@EventHandler(priority = EventPriority.MONITOR) public void onDeath(PlayerDeathEvent e) { final Player ent = (Player) e.getEntity(); Player killer = (Player) e.getEntity().getKiller(); if (ArenaManager.getInstance().getPlayerArena(e.getEntity()) != null) { Arena a = ArenaManager.getInstance() .getArena(ArenaManager.getInstance().getPlayerArena(e.getEntity())); e.getDrops().clear(); e.setDeathMessage(null); e.setDroppedExp(0); if (a.getArenaState() != ArenaState.STARTED) { return; } a.removeLevel(ent); // TODO: Death message. e.setDeathMessage( UGunGame.getInstance().prefix + "§e" + ent.getName() + " killed by " + killer.getName()); MessageManager.good(killer, "You got §6" + a.getCfg().getInt("arena.money.add") + " §aUGP!"); MessageManager.bad(ent, "You lost §6" + a.getCfg().getInt("arena.money.remove") + " §cUGP!"); ScoreboardStats.addMoney(a, killer); ScoreboardStats.removeMoney(a, ent); ScoreboardStats.createScoreboard(killer); ScoreboardStats.createScoreboard(ent); } if (killer == null) { return; } if (ArenaManager.getInstance().getPlayerArena(killer) != null) { Arena a = ArenaManager.getInstance().getArena(ArenaManager.getInstance().getPlayerArena(killer)); if (a.getArenaState() != ArenaState.STARTED) { return; } killer.getInventory().clear(); killer.getInventory().setArmorContents(null); a.addLevel(killer); } }
@Override public void onCommand(Player p, String[] args) { if (!p.hasPermission("ugungame.setspawn")) { MessageManager.bad(p, "You dont have the permission to do this!"); return; } if (args.length < 2) { MessageManager.bad(p, usage + "setspawn <arena> <mapid(1|2)>"); return; } if (!ArenaManager.getInstance().isExist(args[0])) { MessageManager.bad(p, "§cThe arena §6" + args[0] + " §cdoes not exist!"); return; } Arena a = ArenaManager.getInstance().getArena(args[0]); if (args[1].equalsIgnoreCase("1")) { a.getCfg().set("locations.spawns.spawn.map1.world", p.getLocation().getWorld().getName()); a.getCfg().set("locations.spawns.spawn.map1.x", Double.valueOf(p.getLocation().getX())); a.getCfg().set("locations.spawns.spawn.map1.y", Double.valueOf(p.getLocation().getY())); a.getCfg().set("locations.spawns.spawn.map1.z", Double.valueOf(p.getLocation().getZ())); a.getCfg().set("locations.spawns.spawn.map1.yaw", Float.valueOf(p.getLocation().getYaw())); a.getCfg() .set("locations.spawns.spawn.map1.pitch", Float.valueOf(p.getLocation().getPitch())); try { a.getCfg().save(a.getFile()); MessageManager.good( p, "The spawn for arena §6" + a.getName() + " §aand for the map §61 §ahas been set!"); } catch (IOException e) { e.printStackTrace(); } } else if (args[1].equalsIgnoreCase("2")) { a.getCfg().set("locations.spawns.spawn.map2.world", p.getLocation().getWorld().getName()); a.getCfg().set("locations.spawns.spawn.map2.x", Double.valueOf(p.getLocation().getX())); a.getCfg().set("locations.spawns.spawn.map2.y", Double.valueOf(p.getLocation().getY())); a.getCfg().set("locations.spawns.spawn.map2.z", Double.valueOf(p.getLocation().getZ())); a.getCfg().set("locations.spawns.spawn.map2.yaw", Float.valueOf(p.getLocation().getYaw())); a.getCfg() .set("locations.spawns.spawn.map2.pitch", Float.valueOf(p.getLocation().getPitch())); try { a.getCfg().save(a.getFile()); MessageManager.good( p, "The spawn for arena §6" + a.getName() + " §aand for the map §62 §ahas been set!"); } catch (IOException e) { e.printStackTrace(); } } }