Advertisement
Guest User

Untitled

a guest
Jun 8th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.53 KB | None | 0 0
  1. package me.jonah.Minigames;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.logging.Logger;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.Location;
  10. import org.bukkit.Material;
  11. import org.bukkit.block.Sign;
  12. import org.bukkit.command.Command;
  13. import org.bukkit.command.CommandSender;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.event.EventHandler;
  16. import org.bukkit.event.Listener;
  17. import org.bukkit.event.block.Action;
  18. import org.bukkit.event.block.BlockPlaceEvent;
  19. import org.bukkit.event.inventory.InventoryClickEvent;
  20. import org.bukkit.event.player.PlayerInteractEvent;
  21. import org.bukkit.event.player.PlayerJoinEvent;
  22. import org.bukkit.inventory.Inventory;
  23. import org.bukkit.inventory.ItemStack;
  24. import org.bukkit.inventory.meta.ItemMeta;
  25. import org.bukkit.plugin.java.JavaPlugin;
  26. import org.bukkit.scoreboard.Scoreboard;
  27. import org.bukkit.scoreboard.ScoreboardManager;
  28. import org.bukkit.scoreboard.Team;
  29.  
  30. public class MiniGamesPaintball extends JavaPlugin implements Listener{
  31.  
  32.     Logger l = Bukkit.getLogger();
  33.     ScoreboardManager manager;
  34.     Scoreboard board;
  35.     Team flame,flame2,flame3;
  36.     Team ice,ice2,ice3;
  37.  
  38.     @Override
  39.     public void onEnable(){
  40.         l.info("Minigames Paintball is being enabled!");
  41.         getConfig();
  42.         getConfig().options().copyDefaults(true);
  43.         saveConfig();
  44.         manager = Bukkit.getScoreboardManager();
  45.         board = manager.getNewScoreboard();
  46.         ice = board.registerNewTeam("Ice Team");
  47.         flame = board.registerNewTeam("Flame Team");
  48.         ice2 = board.registerNewTeam("Ice Team 2");
  49.         flame2 = board.registerNewTeam("Flame Team 2");
  50.         ice3 = board.registerNewTeam("Ice Team 3");
  51.         flame3 = board.registerNewTeam("Flame Team 3");
  52.         ice.setPrefix(ChatColor.AQUA+"");
  53.         flame.setPrefix(ChatColor.RED+"");
  54.         ice2.setPrefix(ChatColor.AQUA+"");
  55.         flame2.setPrefix(ChatColor.RED+"");
  56.         ice3.setPrefix(ChatColor.AQUA+"");
  57.         flame3.setPrefix(ChatColor.RED+"");
  58.         this.getServer().getPluginManager().registerEvents(this,this);
  59.     }
  60.  
  61.     @Override
  62.     public void onDisable(){
  63.         l.info("Minigames Paintball is being disabled!");
  64.     }
  65.  
  66.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  67.         Player p = (Player) sender;
  68.         if (p.isOp()){
  69.             if ((label.equalsIgnoreCase("createpbarena"))&&(args.length == 1)){
  70.                 if (getConfig().contains("paintball" + args[0])){
  71.                     p.sendMessage("This arena already exists");
  72.                 }
  73.                 else
  74.                 {
  75.                     getConfig().createSection("paintball" + args[0]);
  76.                     getConfig().createSection("paintball" + args[0] + ".lobby");
  77.                     getConfig().createSection("paintball" + args[0] + ".lobby.world");
  78.                     getConfig().createSection("paintball" + args[0] + ".lobby.x");
  79.                     getConfig().createSection("paintball" + args[0] + ".lobby.y");
  80.                     getConfig().createSection("paintball" + args[0] + ".lobby.z");
  81.                     getConfig().createSection("paintball" + args[0] + ".flame");
  82.                     getConfig().createSection("paintball" + args[0] + ".flame.world");
  83.                     getConfig().createSection("paintball" + args[0] + ".flame.x");
  84.                     getConfig().createSection("paintball" + args[0] + ".flame.y");
  85.                     getConfig().createSection("paintball" + args[0] + ".flame.z");
  86.                     getConfig().createSection("paintball" + args[0] + ".ice.world");
  87.                     getConfig().createSection("paintball" + args[0] + ".ice.x");
  88.                     getConfig().createSection("paintball" + args[0] + ".ice.y");
  89.                     getConfig().createSection("paintball" + args[0] + ".ice.z");
  90.                     saveConfig();
  91.                     p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " created.");
  92.                 }
  93.             }
  94.             if ((label.equalsIgnoreCase("setpblobby"))&&(args.length == 1)){
  95.                 Location l = p.getLocation();
  96.                 getConfig().set("paintball" + args[0] + ".lobby.world", l.getWorld().getName());
  97.                 getConfig().set("paintball" + args[0] + ".lobby.x", l.getX());
  98.                 getConfig().set("paintball" + args[0] + ".lobby.y", l.getY());
  99.                 getConfig().set("paintball" + args[0] + ".lobby.z", l.getZ());
  100.                 saveConfig();
  101.                 l = null;
  102.                 p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " lobby set.");
  103.             }
  104.             if ((label.equalsIgnoreCase("gotopblobby"))&&(args.length == 1)){
  105.                 Location lobby = p.getLocation();
  106.                 String worldname = getConfig().getString("paintball" + args[0] + ".lobby.world");
  107.                 lobby.setWorld(Bukkit.getServer().getWorld(worldname));
  108.                 lobby.setX(getConfig().getDouble("paintball" + args[0] + ".lobby.x"));
  109.                 lobby.setY(getConfig().getDouble("paintball" + args[0] + ".lobby.y"));
  110.                 lobby.setZ(getConfig().getDouble("paintball" + args[0] + ".lobby.z"));
  111.                 p.teleport(lobby);
  112.                 saveConfig();
  113.                 lobby = null;
  114.                 p.sendMessage(ChatColor.AQUA + "Teleported to paintball lobby " + args[0]);
  115.             }
  116.             if (label.equalsIgnoreCase("setpbflame")){
  117.                 Location flame = p.getLocation();
  118.                 getConfig().set("paintball" + args[0] + ".flame.world", flame.getWorld().getName());
  119.                 getConfig().set("paintball" + args[0] + ".flame.x", flame.getX());
  120.                 getConfig().set("paintball" + args[0] + ".flame.y", flame.getY());
  121.                 getConfig().set("paintball" + args[0] + ".flame.z", flame.getZ());
  122.                 saveConfig();
  123.                 flame = null;
  124.                 p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " Flame set.");
  125.             }
  126.             if ((label.equalsIgnoreCase("gotopbflame"))&&(args.length == 1)){
  127.                 Location flame = p.getLocation();
  128.                 String worldname = getConfig().getString("paintball" + args[0] + ".flame.world");
  129.                 flame.setWorld(Bukkit.getServer().getWorld(worldname));
  130.                 flame.setX(getConfig().getDouble("paintball" + args[0] + ".flame.x"));
  131.                 flame.setY(getConfig().getDouble("paintball" + args[0] + ".flame.y"));
  132.                 flame.setZ(getConfig().getDouble("paintball" + args[0] + ".flame.z"));
  133.                 p.teleport(flame);
  134.                 saveConfig();
  135.                 flame = null;
  136.                 p.sendMessage(ChatColor.AQUA + "Teleported to paintball Flame " + args[0]);
  137.             }
  138.             if (label.equalsIgnoreCase("setpbice")){
  139.                 Location ice = p.getLocation();
  140.                 getConfig().set("paintball" + args[0] + ".ice.world", ice.getWorld().getName());
  141.                 getConfig().set("paintball" + args[0] + ".ice.x", ice.getX());
  142.                 getConfig().set("paintball" + args[0] + ".ice.y", ice.getY());
  143.                 getConfig().set("paintball" + args[0] + ".ice.z", ice.getZ());
  144.                 saveConfig();
  145.                 ice = null;
  146.                 p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " Ice set.");
  147.             }
  148.             if ((label.equalsIgnoreCase("gotopbice"))&&(args.length == 1)){
  149.                 Location ice = p.getLocation();
  150.                 String worldname = getConfig().getString("paintball" + args[0] + ".ice.world");
  151.                 ice.setWorld(Bukkit.getServer().getWorld(worldname));
  152.                 ice.setX(getConfig().getDouble("paintball" + args[0] + ".ice.x"));
  153.                 ice.setY(getConfig().getDouble("paintball" + args[0] + ".ice.y"));
  154.                 ice.setZ(getConfig().getDouble("paintball" + args[0] + ".ice.z"));
  155.                 p.teleport(ice);
  156.                 saveConfig();
  157.                 ice = null;
  158.                 p.sendMessage(ChatColor.AQUA + "Teleported to paintball Ice " + args[0]);
  159.             }
  160.             if (label.equalsIgnoreCase("mgpbreload")){
  161.                 reloadConfig();
  162.                 saveConfig();
  163.             }
  164.             if (label.equalsIgnoreCase("openlast")){
  165.                 openGUIpb(p);
  166.             }
  167.         }
  168.         return true;
  169.  
  170.     }
  171.     public void startpb(){
  172.  
  173.     }
  174.  
  175.     @SuppressWarnings("deprecation")
  176.     @EventHandler
  177.     public void onPlayerInteract(PlayerInteractEvent event) {
  178.         Player p = event.getPlayer();
  179.         if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
  180.             if(event.getClickedBlock().getType().getId() ==63 || event.getClickedBlock().getType().getId() == 68) {
  181.                 Sign sign = (Sign) event.getClickedBlock().getState();
  182.                 if (sign.getLine(0).contains("[Paintball]")){
  183.                     Location lobby = p.getLocation();
  184.                     String worldname = getConfig().getString("paintball1.lobby.world");
  185.                     lobby.setWorld(Bukkit.getServer().getWorld(worldname));
  186.                     lobby.setX(getConfig().getDouble("paintball" + sign.getLine(1) + ".lobby.x"));
  187.                     lobby.setY(getConfig().getDouble("paintball" + sign.getLine(1) + ".lobby.y"));
  188.                     lobby.setZ(getConfig().getDouble("paintball" + sign.getLine(1) + ".lobby.z"));
  189.                     p.teleport(lobby);
  190.                     saveConfig();
  191.                     lobby = null;
  192.                     p.sendMessage(ChatColor.AQUA + "Teleported to paintball lobby " + sign.getLine(1));
  193.                 }
  194.             }
  195.         }
  196.         if (event.getAction() == Action.PHYSICAL || event.getItem() == null || event.getItem().getType() == Material.AIR){
  197.             return;
  198.         }
  199.         if (event.getItem().getType() == Material.COMPASS){
  200.             openGUI(p);
  201.         }
  202.  
  203.     }
  204.  
  205.     @EventHandler
  206.     public void onPlayerJoin(PlayerJoinEvent event){
  207.         Player p = event.getPlayer();
  208.         p.sendMessage("Yo");
  209.     }
  210.  
  211.     @SuppressWarnings("deprecation")
  212.     @EventHandler
  213.     public void onBlockPlaceEvent(BlockPlaceEvent e) {
  214.         Player p = e.getPlayer();
  215.         if (e.getBlockPlaced().getType().getId() ==63 || e.getBlockPlaced().getType().getId() == 68) {
  216.             p.sendMessage("You placed a sign");
  217.         }
  218.  
  219.     }
  220.  
  221.     public void openGUI(Player p){
  222.         Inventory inv = Bukkit.createInventory(null,9,"Game Selector");
  223.         ItemStack pbservers = new ItemStack(Material.SNOW_BALL);
  224.         ItemMeta pbserversMeta = pbservers.getItemMeta();
  225.         pbserversMeta.setDisplayName(ChatColor.RED + "Paintball");
  226.         pbservers.setItemMeta(pbserversMeta);
  227.         inv.setItem(3, pbservers);
  228.         p.openInventory(inv);      
  229.     }
  230.    
  231.     public void openGUIpb(Player p){
  232.         Inventory inv1 = Bukkit.createInventory(null,9,"Paintball Servers");
  233.         ItemStack pbserver1 = new ItemStack(Material.EYE_OF_ENDER);
  234.         ItemMeta pbserver1Meta = pbserver1.getItemMeta();
  235.         pbserver1Meta.setDisplayName(ChatColor.AQUA + "Server 1");
  236.         List<String> pbserver1List = new ArrayList<String>();
  237.         pbserver1List.add(ChatColor.GRAY + "Players: " + ChatColor.GREEN + (ice.getSize() + flame.getSize()) + "/16");
  238.         pbserver1Meta.setLore(pbserver1List);
  239.         pbserver1.setItemMeta(pbserver1Meta);
  240.         inv1.setItem(0, pbserver1);
  241.         p.closeInventory();
  242.         p.sendMessage("YOYOYO");
  243.         p.openInventory(inv1);
  244.     }
  245.  
  246.     @EventHandler
  247.     public void onInventoryClick(InventoryClickEvent event){
  248.             Player p = (Player) event.getWhoClicked();
  249.             p.sendMessage("test");
  250.             if (event.getCurrentItem().getType() == Material.SNOW_BALL){
  251.                 p.sendMessage("Hey!");
  252.                 openGUIpb(p);
  253.             }
  254.             if (event.getCurrentItem().getType() == Material.EYE_OF_ENDER){
  255.                 Location lobby = p.getLocation();
  256.                 String worldname = getConfig().getString("paintball1.lobby.world");
  257.                 lobby.setWorld(Bukkit.getServer().getWorld(worldname));
  258.                 lobby.setX(getConfig().getDouble("paintball1.lobby.x"));
  259.                 lobby.setY(getConfig().getDouble("paintball1.lobby.y"));
  260.                 lobby.setZ(getConfig().getDouble("paintball1.lobby.z"));
  261.                 p.teleport(lobby);
  262.                 saveConfig();
  263.                 lobby = null;
  264.                 p.sendMessage(ChatColor.AQUA + "Teleported to paintball lobby 1");
  265.  
  266.             }
  267.     }
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement