skela

Untitled

Dec 17th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.88 KB | None | 0 0
  1. package world;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.block.Action;
  12. import org.bukkit.event.inventory.InventoryClickEvent;
  13. import org.bukkit.event.player.PlayerInteractEvent;
  14. import org.bukkit.inventory.Inventory;
  15. import org.bukkit.inventory.ItemStack;
  16. import org.bukkit.inventory.meta.ItemMeta;
  17. import org.bukkit.plugin.java.JavaPlugin;
  18.  
  19. public class Worlds extends JavaPlugin implements Listener{
  20. public void onEnable(){
  21. getServer().getPluginManager().registerEvents(this, this);
  22. }
  23. public void onDisable(){
  24.  
  25. }
  26.  
  27. private void World(Player player){
  28. Inventory Worlds = Bukkit.createInventory(null,9, ChatColor.DARK_PURPLE
  29. + "World Selector");
  30. //###################### WORLD 1 ##########################
  31. ItemStack World1 = new ItemStack(Material.GRASS);
  32. ItemMeta world1Meta = World1.getItemMeta();
  33. world1Meta.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "Normal World");
  34. World1.setItemMeta(world1Meta);
  35. //#########################################################
  36. //###################### WORLD 2 ##########################
  37. ItemStack World2 = new ItemStack(Material.ENDER_STONE);
  38. ItemMeta world2Meta = World2.getItemMeta();
  39. world2Meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + "End World");
  40. World2.setItemMeta(world2Meta);
  41. //#########################################################
  42. //###################### WORLD 3 ##########################
  43. ItemStack World3 = new ItemStack(Material.NETHERRACK);
  44. ItemMeta world3Meta = World3.getItemMeta();
  45. world3Meta.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Nether World");
  46. World3.setItemMeta(world3Meta);
  47. //#########################################################
  48. //###################### WORLD 4 ##########################
  49. ItemStack World4 = new ItemStack(Material.DIAMOND_BLOCK);
  50. ItemMeta world4Meta = World4.getItemMeta();
  51. world4Meta.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Freebuild World");
  52. World4.setItemMeta(world4Meta);
  53. //#########################################################
  54. //###################### WORLD 5 ##########################
  55. ItemStack World5 = new ItemStack(Material.BARRIER);
  56. ItemMeta world5Meta = World5.getItemMeta();
  57. world5Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
  58. World5.setItemMeta(world5Meta);
  59. //#########################################################
  60. //###################### WORLD 6 ##########################
  61. ItemStack World6 = new ItemStack(Material.BARRIER);
  62. ItemMeta world6Meta = World6.getItemMeta();
  63. world6Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
  64. World6.setItemMeta(world6Meta);
  65. //#########################################################
  66. //###################### WORLD 7 ##########################
  67. ItemStack World7 = new ItemStack(Material.BARRIER);
  68. ItemMeta world7Meta = World7.getItemMeta();
  69. world7Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
  70. World7.setItemMeta(world7Meta);
  71. //#########################################################
  72. //###################### WORLD 8 ##########################
  73. ItemStack World8 = new ItemStack(Material.BARRIER);
  74. ItemMeta world8Meta = World8.getItemMeta();
  75. world8Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
  76. World8.setItemMeta(world8Meta);
  77. //#########################################################
  78. //###################### CLOSE BUTTON ##########################
  79. ItemStack Close = new ItemStack(Material.REDSTONE_BLOCK);
  80. ItemMeta CloseMeta = Close.getItemMeta();
  81. CloseMeta.setDisplayName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Close");
  82. Close.setItemMeta(CloseMeta);
  83. //#########################################################
  84. Worlds.setItem(0, World1);
  85. Worlds.setItem(1, World2);
  86. Worlds.setItem(2, World3);
  87. Worlds.setItem(3, World4);
  88. Worlds.setItem(4, World5);
  89. Worlds.setItem(5, World6);
  90. Worlds.setItem(6, World7);
  91. Worlds.setItem(7, World8);
  92. Worlds.setItem(8, Close);
  93. player.openInventory(Worlds);
  94. }
  95.  
  96. @EventHandler
  97. public boolean onWorld(CommandSender sender, Command cmd, String commandLabel, String args[]) {
  98. Player p = (Player) sender;
  99. if(commandLabel.equalsIgnoreCase("worlds") && args.length == 0 && p.hasPermission("worlds.change")){
  100. World(p);
  101. return true;
  102. }
  103. return false;
  104. }
  105.  
  106.  
  107. @EventHandler
  108. public void worldSelected(InventoryClickEvent event){
  109.  
  110. if (!ChatColor.stripColor(event.getInventory().getName())
  111. .equalsIgnoreCase("World Selector")){
  112. return;
  113. }
  114. Player player = (Player) event.getWhoClicked();
  115. event.setCancelled(true);
  116.  
  117. if (event.getCurrentItem() == null
  118. || event.getCurrentItem().getType() == Material.AIR
  119. || !event.getCurrentItem().hasItemMeta()){
  120. player.closeInventory();
  121. return;
  122. }
  123.  
  124. switch (event.getCurrentItem().getType()){
  125. case GRASS:
  126. player.closeInventory();
  127. player.chat("/warp normal");
  128. player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
  129. ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
  130. break;
  131. case ENDER_STONE:
  132. player.closeInventory();
  133. player.chat("/warp end");
  134. player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
  135. ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
  136. break;
  137. case NETHERRACK:
  138. player.closeInventory();
  139. player.chat("/warp nether");
  140. player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
  141. ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
  142. break;
  143. case DIAMOND_BLOCK:
  144. player.closeInventory();
  145. player.chat("/warp freebuild");
  146. player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
  147. ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
  148. break;
  149. case BARRIER:
  150. player.closeInventory();
  151. player.sendMessage(String.format("%sComing Soon....", ChatColor.GRAY));
  152. break;
  153. case REDSTONE_BLOCK:
  154. player.closeInventory();
  155. break;
  156. default:
  157. player.closeInventory();
  158. break;
  159. }
  160.  
  161. }
  162.  
  163. @EventHandler
  164. public void onclick(PlayerInteractEvent event){
  165. Action a = event.getAction();
  166. ItemStack Worl = event.getItem();
  167.  
  168. if (a == Action.PHYSICAL || Worl ==null || Worl.getType()== Material.AIR){
  169. return;
  170. }
  171. if (Worl.getType()==Material.NETHER_STAR){
  172. World(event.getPlayer());
  173. }
  174. }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment