@EventHandler public void onPlayerPlaceBlock(BlockPlaceEvent e) { int id = gm.getPlayerGameId(e.getPlayer()); if (id != -1) { if (gm.getGame(id).getState() == State.INGAME) gm.getPlayerClass(e.getPlayer()).PlayerPlaceBlock(e.getBlock()); } }
@EventHandler public void onMove(PlayerMoveEvent e) { Player p = e.getPlayer(); int id = gm.getPlayerGameId(p); if (id != -1) { Game g = gm.getGame(id); if (g.getState() == Game.State.INGAME) g.getPlayerClass(p).PlayerMove(); } }
@EventHandler public void onEntityDeath(EntityShootBowEvent e) { if (e.getEntity() instanceof Player) { Player p = (Player) e.getEntity(); int game = GameManager.getInstance().getPlayerGameId(p); if (game != -1) { gm.getGame(game).getPlayerClass(p).PlayerShootArrow(e.getProjectile()); } } }
@EventHandler public void onEntityDamaged(EntityDamageEvent e) { if (e.getEntity() instanceof Player) { Player p = (Player) e.getEntity(); int game = GameManager.getInstance().getPlayerGameId(p); if (game != -1) { Game g = gm.getGame(game); if (g.getState() == Game.State.INGAME) { g.getPlayerClass(p).PlayerDamaged(); } } } }
@EventHandler public void onEntityDeath(PlayerDeathEvent e) { if (e.getEntity() instanceof Player) { Player p = (Player) e.getEntity(); int id = gm.getPlayerGameId(p); if (id != -1) { gm.getPlayerClass(p).PlayerDeath(); gm.getGame(id).killPlayer(p, e.getDeathMessage()); e.setDeathMessage(null); } } }
@EventHandler public void onInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); int id = gm.getPlayerGameId(p); if (id != -1) { Game g = gm.getGame(id); if (g.getState() == Game.State.INGAME) { if (e.getPlayer().getItemInHand().getType() == Material.DIAMOND_AXE) { g.getPlayerClass(p).Smash(); } else { g.getPlayerClass(p).PlayerInteract(e.getAction()); } } // e.setCancelled(true); } }