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();
- if(block != null)
- {
- if(action == Action.LEFT_CLICK_AIR)
- {
- event.setCancelled(true);
- }
- if(action == Action.LEFT_CLICK_BLOCK)
- {
- event.setCancelled(true);
- }
- if(action == Action.RIGHT_CLICK_AIR)
- {
- event.setCancelled(true);
- }
- if(action == Action.RIGHT_CLICK_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);
- }
- }
- }
- }
- else
- {
- event.setCancelled(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement