Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package world;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Worlds extends JavaPlugin implements Listener{
- public void onEnable(){
- getServer().getPluginManager().registerEvents(this, this);
- }
- public void onDisable(){
- }
- private void World(Player player){
- Inventory Worlds = Bukkit.createInventory(null,9, ChatColor.DARK_PURPLE
- + "World Selector");
- //###################### WORLD 1 ##########################
- ItemStack World1 = new ItemStack(Material.GRASS);
- ItemMeta world1Meta = World1.getItemMeta();
- world1Meta.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "Normal World");
- World1.setItemMeta(world1Meta);
- //#########################################################
- //###################### WORLD 2 ##########################
- ItemStack World2 = new ItemStack(Material.ENDER_STONE);
- ItemMeta world2Meta = World2.getItemMeta();
- world2Meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + "End World");
- World2.setItemMeta(world2Meta);
- //#########################################################
- //###################### WORLD 3 ##########################
- ItemStack World3 = new ItemStack(Material.NETHERRACK);
- ItemMeta world3Meta = World3.getItemMeta();
- world3Meta.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Nether World");
- World3.setItemMeta(world3Meta);
- //#########################################################
- //###################### WORLD 4 ##########################
- ItemStack World4 = new ItemStack(Material.DIAMOND_BLOCK);
- ItemMeta world4Meta = World4.getItemMeta();
- world4Meta.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Freebuild World");
- World4.setItemMeta(world4Meta);
- //#########################################################
- //###################### WORLD 5 ##########################
- ItemStack World5 = new ItemStack(Material.BARRIER);
- ItemMeta world5Meta = World5.getItemMeta();
- world5Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
- World5.setItemMeta(world5Meta);
- //#########################################################
- //###################### WORLD 6 ##########################
- ItemStack World6 = new ItemStack(Material.BARRIER);
- ItemMeta world6Meta = World6.getItemMeta();
- world6Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
- World6.setItemMeta(world6Meta);
- //#########################################################
- //###################### WORLD 7 ##########################
- ItemStack World7 = new ItemStack(Material.BARRIER);
- ItemMeta world7Meta = World7.getItemMeta();
- world7Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
- World7.setItemMeta(world7Meta);
- //#########################################################
- //###################### WORLD 8 ##########################
- ItemStack World8 = new ItemStack(Material.BARRIER);
- ItemMeta world8Meta = World8.getItemMeta();
- world8Meta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Coming Soon...");
- World8.setItemMeta(world8Meta);
- //#########################################################
- //###################### CLOSE BUTTON ##########################
- ItemStack Close = new ItemStack(Material.REDSTONE_BLOCK);
- ItemMeta CloseMeta = Close.getItemMeta();
- CloseMeta.setDisplayName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Close");
- Close.setItemMeta(CloseMeta);
- //#########################################################
- Worlds.setItem(0, World1);
- Worlds.setItem(1, World2);
- Worlds.setItem(2, World3);
- Worlds.setItem(3, World4);
- Worlds.setItem(4, World5);
- Worlds.setItem(5, World6);
- Worlds.setItem(6, World7);
- Worlds.setItem(7, World8);
- Worlds.setItem(8, Close);
- player.openInventory(Worlds);
- }
- @EventHandler
- public boolean onWorld(CommandSender sender, Command cmd, String commandLabel, String args[]) {
- Player p = (Player) sender;
- if(commandLabel.equalsIgnoreCase("worlds") && args.length == 0 && p.hasPermission("worlds.change")){
- World(p);
- return true;
- }
- return false;
- }
- @EventHandler
- public void worldSelected(InventoryClickEvent event){
- if (!ChatColor.stripColor(event.getInventory().getName())
- .equalsIgnoreCase("World Selector")){
- return;
- }
- Player player = (Player) event.getWhoClicked();
- event.setCancelled(true);
- if (event.getCurrentItem() == null
- || event.getCurrentItem().getType() == Material.AIR
- || !event.getCurrentItem().hasItemMeta()){
- player.closeInventory();
- return;
- }
- switch (event.getCurrentItem().getType()){
- case GRASS:
- player.closeInventory();
- player.chat("/warp normal");
- player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
- ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
- break;
- case ENDER_STONE:
- player.closeInventory();
- player.chat("/warp end");
- player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
- ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
- break;
- case NETHERRACK:
- player.closeInventory();
- player.chat("/warp nether");
- player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
- ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
- break;
- case DIAMOND_BLOCK:
- player.closeInventory();
- player.chat("/warp freebuild");
- player.sendMessage(String.format("%sTo claim a plot in this world type %s/plot auto %sor use the %splot finder!" ,
- ChatColor.GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.RED));
- break;
- case BARRIER:
- player.closeInventory();
- player.sendMessage(String.format("%sComing Soon....", ChatColor.GRAY));
- break;
- case REDSTONE_BLOCK:
- player.closeInventory();
- break;
- default:
- player.closeInventory();
- break;
- }
- }
- @EventHandler
- public void onclick(PlayerInteractEvent event){
- Action a = event.getAction();
- ItemStack Worl = event.getItem();
- if (a == Action.PHYSICAL || Worl ==null || Worl.getType()== Material.AIR){
- return;
- }
- if (Worl.getType()==Material.NETHER_STAR){
- World(event.getPlayer());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment