Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void playerInteract(PlayerInteractEvent event)
- {
- Player player = event.getPlayer();
- Action action = event.getAction();
- // 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
- Block block = event.getClickedBlock();
- 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.
- {
- Sign sign = (Sign) event.getClickedBlock().getState();
- String line1 = sign.getLine(1);
- if (line1.contains("[JoinGame]") && Main.plugin.Players.size() < Main.maxPlayers && Main.isWorldGenerated == true)
- {
- if (Main.plugin.InGameQueue.containsKey(player))
- {
- player.sendMessage(ReferenceStrings.errorJoin1);
- }
- else if (Main.GameStarted == false)
- {
- if (Main.plugin.Players.size() > 10)
- {
- Teleport.VotingAndToolSelection(player);
- Main.plugin.InGameQueue.put(player, null);
- Main.plugin.Players.put(player, null);
- Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "[MobAPA] " + ChatColor.GREEN + player.getName() + " has joined the Game. " + Main.plugin.Players.size() + "/" + Main.maxPlayers + " Joined");
- }
- else
- {
- Teleport.VotingAndToolSelection(player);
- Main.plugin.InGameQueue.put(player, null);
- Main.plugin.Players.put(player, null);
- 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");
- System.out.println(Main.plugin.Players.size());
- if (Main.plugin.Players.size() == 10)
- {
- CountDown.StartCountDownTimer(player);
- }
- }
- }
- else if (Main.GameStarted == true)
- {
- player.sendMessage(ReferenceStrings.errorJoin2);
- }
- }
- else
- {
- if (Main.isWorldGenerated == false)
- {
- player.sendMessage(ReferenceStrings.worldIsNotGenerated);
- }
- else
- {
- player.sendMessage(ReferenceStrings.errorJoin3);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement