Advertisement
GamersMods

Untitled

Jul 31st, 2013
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 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(); // <-- Here you get the type of the block, if the block is null, a NPE will be thrown. Commented it out
  7. Block block = event.getClickedBlock();
  8. if (action == Action.RIGHT_CLICK_BLOCK) // The code in the if clause will only run if the player makes a right click on a block.
  9. {
  10. Sign sign = (Sign) event.getClickedBlock().getState();
  11. String line1 = sign.getLine(1);
  12.  
  13. if (line1.contains("[JoinGame]") && Main.plugin.Players.size() < Main.maxPlayers && Main.isWorldGenerated == true)
  14. {
  15. if (Main.plugin.InGameQueue.containsKey(player))
  16. {
  17. player.sendMessage(ReferenceStrings.errorJoin1);
  18. }
  19. else if (Main.GameStarted == false)
  20. {
  21. if (Main.plugin.Players.size() > 10)
  22. {
  23. Teleport.VotingAndToolSelection(player);
  24. Main.plugin.InGameQueue.put(player, null);
  25. Main.plugin.Players.put(player, null);
  26. Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "[MobAPA] " + ChatColor.GREEN + player.getName() + " has joined the Game. " + Main.plugin.Players.size() + "/" + Main.maxPlayers + " Joined");
  27. }
  28. else
  29. {
  30. Teleport.VotingAndToolSelection(player);
  31. Main.plugin.InGameQueue.put(player, null);
  32. Main.plugin.Players.put(player, null);
  33. 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");
  34. System.out.println(Main.plugin.Players.size());
  35. if (Main.plugin.Players.size() == 10)
  36. {
  37. CountDown.StartCountDownTimer(player);
  38. }
  39. }
  40. }
  41. else if (Main.GameStarted == true)
  42. {
  43. player.sendMessage(ReferenceStrings.errorJoin2);
  44. }
  45. }
  46. else
  47. {
  48. if (Main.isWorldGenerated == false)
  49. {
  50. player.sendMessage(ReferenceStrings.worldIsNotGenerated);
  51. }
  52. else
  53. {
  54. player.sendMessage(ReferenceStrings.errorJoin3);
  55. }
  56. }
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement