Advertisement
Guest User

Main.java

a guest
Aug 9th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. package me.PirateBattle;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Effect;
  9. import org.bukkit.Location;
  10. import org.bukkit.Material;
  11. import org.bukkit.entity.Item;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.EventHandler;
  14. import org.bukkit.event.Listener;
  15. import org.bukkit.event.block.Action;
  16. import org.bukkit.event.player.PlayerDropItemEvent;
  17. import org.bukkit.event.player.PlayerInteractEvent;
  18. import org.bukkit.event.player.PlayerJoinEvent;
  19. import org.bukkit.event.player.PlayerQuitEvent;
  20. import org.bukkit.inventory.ItemStack;
  21. import org.bukkit.inventory.meta.LeatherArmorMeta;
  22. import org.bukkit.plugin.PluginManager;
  23. import org.bukkit.plugin.java.JavaPlugin;
  24.  
  25.  
  26.  
  27.  
  28. public class Main extends JavaPlugin implements Listener{
  29.  
  30. PluginManager pm = this.getServer().getPluginManager();
  31. HashMap<Player, ArrayList<Player>> Lobby = new HashMap<Player, ArrayList<Player>>();
  32. HashMap<Player, ArrayList<Player>> Game = new HashMap<Player, ArrayList<Player>>();
  33. HashMap<Player, ArrayList<Player>> G = new HashMap<Player, ArrayList<Player>>();
  34. HashMap<Player, ArrayList<Player>> R = new HashMap<Player, ArrayList<Player>>();
  35.  
  36. @Override
  37. public void onEnable(){
  38. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  39. }
  40.  
  41. @Override
  42. public void onDisable(){
  43. }
  44.  
  45. ItemStack item = new ItemStack(Material.LEATHER_HELMET);
  46. LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
  47. meta.setColor(Color.GREEN);
  48. item.setItemMeta(meta);
  49.  
  50. @EventHandler
  51. public void ItemDrop(PlayerDropItemEvent e){
  52. Player p = e.getPlayer();
  53. if(!p.hasPermission("pb.drop")){
  54. e.setCancelled(true);
  55. }
  56. }
  57.  
  58.  
  59.  
  60. @EventHandler
  61. public void Quit(PlayerQuitEvent e){
  62. Player p = e.getPlayer();
  63. Lobby.remove(p);
  64. Game.remove(p);
  65. G.remove(p);
  66. R.remove(p);
  67. }
  68.  
  69. @EventHandler
  70. public void onPlayerInteract(PlayerInteractEvent e) {
  71. Player p = e.getPlayer();
  72. if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
  73.  
  74. }
  75. }
  76.  
  77. @EventHandler
  78. public void Join(PlayerJoinEvent e){
  79. Player p = e.getPlayer();
  80. p.getInventory().clear();
  81. Location SpawnLoc = new Location (p.getWorld(),285.5,104,1306);
  82. p.teleport(SpawnLoc);
  83. p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 3);
  84. if(Game.size() == 0){
  85. if(!Lobby.containsKey(p.getName())){
  86. Lobby.put(p, null);
  87. p.sendMessage(ChatColor.GRAY + "---------------" + ChatColor.GREEN + "[PirateBattle]" + ChatColor.GRAY + "---------------");
  88. p.sendMessage(ChatColor.GRAY + "Welcome to the PirateBattle Lobby!");
  89. p.sendMessage(ChatColor.GRAY + "There are currently " + ChatColor.GREEN + Lobby.size() + ChatColor.GRAY + " player in the Lobby");
  90. p.sendMessage(ChatColor.GRAY + "There are minimal " + ChatColor.GREEN + "4 " + ChatColor.GRAY + "players required to start the game.");
  91. if(G.size() <= R.size()){
  92. G.put(p, null);
  93. p.sendMessage(ChatColor.GRAY + "You have joined the " + ChatColor.GREEN + "Green " + ChatColor.GRAY + "team.");
  94. ItemStack redwool = new ItemStack( Material.WOOL, 1, (byte)13 );
  95. p.getInventory().addItem( redwool );
  96. }else{
  97. R.put(p, null);
  98. p.sendMessage(ChatColor.GRAY + "You have joined the " + ChatColor.RED + "Red " + ChatColor.GRAY + "team.");
  99. ItemStack redwool = new ItemStack( Material.WOOL, 1, (byte)14 );
  100. p.getInventory().addItem( redwool );
  101. }
  102. }
  103. }else{
  104. p.sendMessage(ChatColor.GRAY + "---------------" + ChatColor.GREEN + "[PirateBattle]" + ChatColor.GRAY + "---------------");
  105. p.sendMessage(ChatColor.GRAY + "There's a game yet in progress.");
  106. p.sendMessage(ChatColor.GRAY + "You can wait in the lobby, until the game has ended.");
  107. p.sendMessage(ChatColor.GRAY + "There are " + ChatColor.GREEN + Game.size() + ChatColor.GRAY + " players alive.");
  108. }
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement