Hello! I am creating a mini game plugin for a server and I need help, despretly. This is my code: Code: @EventHandler public void clickSign(PlayerInteractEvent e){ Player p = e.getPlayer(); //working ^^ if(e.getAction() == Action.RIGHT_CLICK_BLOCK){ if(e.getClickedBlock().getType() == Material.SIGN_POST){ if(Game.isFull()){ p.sendMessage(ChatColor.RED + "[Pirate Ship Battle] " + ChatColor.RED + "Game is currently full."); }else{ p.sendMessage(ChatColor.RED + "[Pirate Ship Battle] " + ChatColor.GREEN + "Game is open, adding you too game!"); Game.plist.add(p); if(Game.plist.size() >= 2){ Game.startGame(); } } } } } //not working @EventHandler public void diamond(BlockBreakEvent e){ if(e.getBlock().getType() == Material.DIAMOND_BLOCK){ Game.endGame(); } } No errors in console.
@frogman6102 To start you need to explain a bit more on what is suppose to happen. I would guess your Game.endGame() method doesn't outprint or do whatever you expect it to do. That is the correct code to check if the block broken was a diamond block. Mind putting your endGame() method?
Oh yes, sorry about that. Code: public static void endGame(){ plist.get(0).sendMessage(ChatColor.RED + "[Pirate Ship Battle] Game Over..."); plist.get(1).sendMessage(ChatColor.RED + "[Pirate Ship Battle] Game Over..."); plist.get(0).getServer().dispatchCommand(plist.get(0), "spawn"); plist.get(1).getServer().dispatchCommand(plist.get(1), "spawn"); plist.remove(0); plist.remove(1); } @97WaterPolo ^^
If there are always only two players, you can use that. However, if there can be more/less, use this: Code: public static void endGame() { for(Player p : plist) { p.sendMessage(ChatColor.RED + "[Pirate Ship Battle] Game Over..."); p.getServer().dispatchCommand(p, "spawn"); plist.remove(p); } }