Advertisement
GamersMods

Player Interact Event Error

Jul 30th, 2013
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.30 KB | None | 0 0
  1. @EventHandler
  2.     public void playerInteract(PlayerInteractEvent event)
  3.     {
  4.         Player player = event.getPlayer();
  5.         Action action = event.getAction();
  6.         Material block = event.getClickedBlock().getType();
  7.         if(block != null)
  8.         {
  9.             if(action == Action.LEFT_CLICK_AIR)
  10.             {
  11.                 event.setCancelled(true);
  12.             }
  13.             if(action == Action.LEFT_CLICK_BLOCK)
  14.             {
  15.                 event.setCancelled(true);
  16.             }
  17.             if(action == Action.RIGHT_CLICK_AIR)
  18.             {
  19.                 event.setCancelled(true);
  20.             }
  21.             if(action == Action.RIGHT_CLICK_BLOCK)
  22.             {
  23.                 Sign sign = (Sign)event.getClickedBlock().getState();
  24.                 String line1 = sign.getLine(1);
  25.                
  26.                 if(line1.contains("[JoinGame]") && Main.plugin.Players.size() < Main.maxPlayers && Main.isWorldGenerated == true)
  27.                 {
  28.                     if(Main.plugin.InGameQueue.containsKey(player))
  29.                     {
  30.                         player.sendMessage(ReferenceStrings.errorJoin1);
  31.                     }
  32.                     else if(Main.GameStarted == false)
  33.                     {
  34.                         if(Main.plugin.Players.size() > 10)
  35.                         {
  36.                             Teleport.VotingAndToolSelection(player);
  37.                             Main.plugin.InGameQueue.put(player, null);
  38.                             Main.plugin.Players.put(player, null);
  39.                             Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "[MobAPA] " + ChatColor.GREEN + player.getName() + " has joined the Game. " + Main.plugin.Players.size() + "/" + Main.maxPlayers + " Joined");
  40.                         }
  41.                         else
  42.                         {
  43.                             Teleport.VotingAndToolSelection(player);
  44.                             Main.plugin.InGameQueue.put(player, null);
  45.                             Main.plugin.Players.put(player, null);
  46.                             Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "[MobAPA] " + ChatColor.GREEN + player.getName() + " has joined the Game. We need 10 players to start! There are currently: " + Main.plugin.Players.size() + "/" + Main.maxPlayers + " Joined");
  47.                             System.out.println(Main.plugin.Players.size());
  48.                             if(Main.plugin.Players.size() == 10)
  49.                             {
  50.                                 CountDown.StartCountDownTimer(player);
  51.                             }  
  52.                         }
  53.                     }
  54.                     else if(Main.GameStarted == true)
  55.                     {
  56.                         player.sendMessage(ReferenceStrings.errorJoin2);
  57.                     }
  58.                 }
  59.                 else
  60.                 {
  61.                     if(Main.isWorldGenerated == false)
  62.                     {
  63.                         player.sendMessage(ReferenceStrings.worldIsNotGenerated);
  64.                     }
  65.                     else
  66.                     {
  67.                         player.sendMessage(ReferenceStrings.errorJoin3);   
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.         else
  73.         {
  74.             event.setCancelled(true);
  75.         }
  76.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement