@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { TregminePlayer player = plugin.getPlayer(event.getPlayer()); if (player == null) { event.getPlayer().kickPlayer("Something went wrong"); Tregmine.LOGGER.info(event.getPlayer().getName() + " was not found " + "in players map."); return; } if (!player.hasFlag(TregminePlayer.Flags.HIDDEN_LOCATION)) { if (player.getCountry() != null) { plugin .getServer() .broadcastMessage( ChatColor.DARK_AQUA + "Welcome " + player.getChatName() + ChatColor.DARK_AQUA + " from " + player.getCountry() + "!"); } else { plugin .getServer() .broadcastMessage(ChatColor.DARK_AQUA + "Welcome " + player.getChatName()); } } String aliasList = null; try (IContext ctx = plugin.createContext()) { ILogDAO logDAO = ctx.getLogDAO(); Set<String> aliases = logDAO.getAliases(player); StringBuilder buffer = new StringBuilder(); String delim = ""; for (String name : aliases) { buffer.append(delim); buffer.append(name); delim = ", "; } aliasList = buffer.toString(); if (aliases.size() > 1) { Tregmine.LOGGER.info("Aliases: " + aliasList); for (TregminePlayer current : plugin.getOnlinePlayers()) { if (!current.getRank().canSeeAliases()) { continue; } if (player.hasFlag(TregminePlayer.Flags.HIDDEN_LOCATION)) { continue; } current.sendMessage(ChatColor.YELLOW + "This player have also used names: " + aliasList); } } } catch (DAOException e) { throw new RuntimeException(e); } }
@EventHandler public void onRotate(PlayerInteractEntityEvent event) { if (!(event .getRightClicked() .getType() .equals(EntityType.ITEM_FRAME))) { // Before we do anything lets check were interacting with // ItemFrames return; } TregminePlayer player = plugin.getPlayer(event.getPlayer()); if (player.getRank().canModifyZones()) { // Lets people with "canModifyZones" return; } ZoneWorld world = plugin.getWorld(player.getWorld()); Entity entity = event.getRightClicked(); Location location = entity.getLocation(); Point pos = new Point(location.getBlockX(), location.getBlockZ()); Zone zone = world.findZone(pos); Zone.Permission perm = zone.getUser(player); Lot lot = world.findLot(pos); if (perm != null && perm == Zone.Permission.Banned) { // Eliminate banned from zone event.setCancelled(true); player.sendMessage( ChatColor.RED + "[" + zone.getName() + "] " + "You are banned from " + zone.getName() + "."); } if (zone != null && lot == null) { // If Zone but not Lot if (perm == Zone.Permission.Allowed || perm == Zone.Permission.Maker || perm == Zone.Permission.Owner) { // Checks if player is Allowed/Maker/Owner return; } if (zone.getDestroyDefault()) { // If people can destroy, Then we will let them rotate. return; } // If still at this point then they are not allowed to rotate item frames so BURN THEM ALIVE!! player.setFireTicks(50); event.setCancelled(true); player.sendMessage( ChatColor.RED + "[" + zone.getName() + "] " + "You are not allowed to rotate item frames in " + zone.getName() + "."); return; } else if (zone != null && lot != null) { // If lot in a zone if (perm == Zone.Permission.Owner && zone.isCommunist()) { // Zone owners can modify lots in communist zones return; } if (lot.isOwner(player)) { // Lot owners can always modify lots return; } // If still at this point then they are not allowed to rotate item frames so BURN THEM ALIVE!! player.setFireTicks(50); event.setCancelled(true); player.sendMessage( ChatColor.RED + "[" + zone.getName() + "] " + "You are not allowed to rotate item frames in " + zone.getName() + "."); return; } else { // No Zone (obviously No Lot) so just end. return; } }
@Override public void queryGameState(Tregmine tregmine) { Server server = tregmine.getServer(); version = server.getName() + " " + server.getVersion(); }