public void onPlayerJoin(PlayerJoinEvent event) { myPlayer player = new myPlayer(this.parent, event.getPlayer(), event.getPlayer().getName()); if (this.parent.universe.nations.matches("true")) { // Area Coordinate = round down ( ( position / areasize ) + 0.9375 ) int xchunkloc = this.parent.universe.getZoneCoord(event.getPlayer().getLocation().getX()); int zchunkloc = this.parent.universe.getZoneCoord(event.getPlayer().getLocation().getZ()); // event.getPlayer().sendMessage(xchunkloc+":"+zchunkloc); // new position! int x = xchunkloc; int z = zchunkloc; myZone zone = this.parent.universe.getZoneFromLoc(x, z, event.getPlayer().getWorld()); if (zone != null) { this.parent.universe.setPlayerLastChunkX(event.getPlayer(), xchunkloc); this.parent.universe.setPlayerLastChunkZ(event.getPlayer(), zchunkloc); this.parent.universe.setPlayerLastChunkName(event.getPlayer(), zone.name); } else { // dont provide them info, just update them this.parent.universe.setPlayerLastChunkX(event.getPlayer(), xchunkloc); this.parent.universe.setPlayerLastChunkZ(event.getPlayer(), zchunkloc); this.parent.universe.setPlayerLastChunkName(event.getPlayer(), "Unknown Zone"); } event .getPlayer() .sendMessage( ChatColor.LIGHT_PURPLE + "This server runs " + ChatColor.YELLOW + "NPCX" + ChatColor.LIGHT_PURPLE + " with Civilizations enabled!"); event .getPlayer() .sendMessage( ChatColor.LIGHT_PURPLE + "To claim your own piece of paradise use /civ buy!"); } int count = 0; for (myPlayer p : this.parent.universe.players.values()) { if (p.name.equals(event.getPlayer().getName())) { // attach them p.player = event.getPlayer(); count++; } } if (count == 0) { // System.out.println("npcx : added new player ("+ event.getPlayer().getName()+")"); parent.universe.players.put(player.player.getName(), player); } }
public void onPlayerQuit(PlayerQuitEvent event) { for (myPlayer player : parent.universe.players.values()) { if (player.player == event.getPlayer()) { player.dead = true; this.parent.informNpcDeadPlayer(event.getPlayer()); // System.out.println("npcx : removed player ("+ player.player.getName()+")"); // not needed // parent.universe.players.remove(player); } } }