List of usage examples for java.util UUID equals
public boolean equals(Object obj)
From source file:org.usergrid.persistence.cassandra.EntityManagerImpl.java
/** * Gets the specified entity.// w w w . ja v a 2s . com * * @param <A> * the generic type * @param applicationId * the application id * @param entityId * the entity id * @param entityType * the entity type * @param entityClass * the entity class * @return entity * @throws Exception * the exception */ public <A extends Entity> A getEntity(UUID entityId, Class<A> entityClass) throws Exception { Object entity_key = key(entityId); Map<String, Object> results = null; // if (entityType == null) { results = deserializeEntityProperties( cass.getAllColumns(cass.getApplicationKeyspace(applicationId), ENTITY_PROPERTIES, entity_key)); // } else { // Set<String> columnNames = Schema.getPropertyNames(entityType); // results = getColumns(getApplicationKeyspace(applicationId), // EntityCF.PROPERTIES, entity_key, columnNames, se, be); // } if (results == null) { logger.warn("getEntity(): No properties found for entity " + entityId + ", probably doesn't exist..."); return null; } UUID id = uuid(results.get(PROPERTY_UUID)); String type = string(results.get(PROPERTY_TYPE)); if (!entityId.equals(id)) { logger.error("Expected entity id " + entityId + ", found " + id, new Throwable()); return null; } A entity = EntityFactory.newEntity(id, type, entityClass); entity.setProperties(results); return entity; }
From source file:com.wasteofplastic.acidisland.commands.IslandCmd.java
/** * Adds a player to a team. The player and the teamleader MAY be the same * //ww w .ja v a 2s .c o m * @param playerUUID * @param teamLeader * @return */ public boolean addPlayertoTeam(final UUID playerUUID, final UUID teamLeader) { // Set the player's team giving the team leader's name and the team's // island // location plugin.getPlayers().setJoinTeam(playerUUID, teamLeader, plugin.getPlayers().getIslandLocation(teamLeader)); // If the player's name and the team leader are NOT the same when this // method is called then set the player's home location to the leader's // home location // if it exists, and if not set to the island location if (!playerUUID.equals(teamLeader)) { // Clear any old home locations plugin.getPlayers().clearHomeLocations(playerUUID); if (plugin.getPlayers().getHomeLocation(teamLeader, 1) != null) { plugin.getPlayers().setHomeLocation(playerUUID, plugin.getPlayers().getHomeLocation(teamLeader)); // plugin.getLogger().info("DEBUG: Setting player's home to the leader's home location"); } else { plugin.getPlayers().setHomeLocation(playerUUID, plugin.getPlayers().getIslandLocation(teamLeader)); // plugin.getLogger().info("DEBUG: Setting player's home to the team island location"); } // If the leader's member list does not contain player then add it if (!plugin.getPlayers().getMembers(teamLeader).contains(playerUUID)) { plugin.getPlayers().addTeamMember(teamLeader, playerUUID); } // If the leader's member list does not contain their own name then // add it if (!plugin.getPlayers().getMembers(teamLeader).contains(teamLeader)) { plugin.getPlayers().addTeamMember(teamLeader, teamLeader); } // Fire event final IslandJoinEvent event = new IslandJoinEvent(plugin, playerUUID, teamLeader); plugin.getServer().getPluginManager().callEvent(event); } return true; }
From source file:com.wasteofplastic.askyblock.commands.IslandCmd.java
/** * Removes a player from a team run by teamleader * //w ww. j a v a 2 s .c o m * @param playerUUID * @param teamLeader */ public void removePlayerFromTeam(final UUID playerUUID, final UUID teamLeader) { // Remove player from the team plugin.getPlayers().removeMember(teamLeader, playerUUID); // If player is online // If player is not the leader of their own team if (!playerUUID.equals(teamLeader)) { plugin.getPlayers().setLeaveTeam(playerUUID); //plugin.getPlayers().setHomeLocation(player, null); plugin.getPlayers().clearHomeLocations(playerUUID); plugin.getPlayers().setIslandLocation(playerUUID, null); plugin.getPlayers().setTeamIslandLocation(playerUUID, null); OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(playerUUID); if (offlinePlayer.isOnline()) { // Check perms if (!((Player) offlinePlayer).hasPermission(Settings.PERMPREFIX + "command.leaveexempt")) { runCommands(Settings.leaveCommands, offlinePlayer); } } else { // If offline, all commands are run, sorry runCommands(Settings.leaveCommands, offlinePlayer); } // Fire event final Collection<Island> islands = plugin.getGrid().getOwnedIslands().get(offlinePlayer.getUniqueId()); islands.forEach((island) -> { final IslandLeaveEvent event = new IslandLeaveEvent(playerUUID, island); plugin.getServer().getPluginManager().callEvent(event); }); } else { // Ex-Leaders keeps their island, but the rest of the team items are // removed plugin.getPlayers().setLeaveTeam(playerUUID); } }
From source file:com.wasteofplastic.askyblock.commands.IslandCmd.java
/** * Adds a player to a team. The player and the teamleader MAY be the same * //from ww w. j a v a 2 s .c om * @param playerUUID * @param teamLeader * @return true if the player is successfully added */ public boolean addPlayertoTeam(final UUID playerUUID, final UUID teamLeader) { // Set the player's team giving the team leader's name and the team's // island // location plugin.getPlayers().setJoinTeam(playerUUID, teamLeader, plugin.getPlayers().getIslandLocation(teamLeader)); // If the player's name and the team leader are NOT the same when this // method is called then set the player's home location to the leader's // home location // if it exists, and if not set to the island location if (!playerUUID.equals(teamLeader)) { // Clear any old home locations plugin.getPlayers().clearHomeLocations(playerUUID); if (plugin.getPlayers().getHomeLocation(teamLeader, 1) != null) { plugin.getPlayers().setHomeLocation(playerUUID, plugin.getPlayers().getHomeLocation(teamLeader)); // plugin.getLogger().info("DEBUG: Setting player's home to the leader's home location"); } else { plugin.getPlayers().setHomeLocation(playerUUID, plugin.getPlayers().getIslandLocation(teamLeader)); // plugin.getLogger().info("DEBUG: Setting player's home to the team island location"); } // If the leader's member list does not contain player then add it if (!plugin.getPlayers().getMembers(teamLeader).contains(playerUUID)) { plugin.getPlayers().addTeamMember(teamLeader, playerUUID); } // If the leader's member list does not contain their own name then // add it if (!plugin.getPlayers().getMembers(teamLeader).contains(teamLeader)) { plugin.getPlayers().addTeamMember(teamLeader, teamLeader); } // Fire event plugin.getGrid().getOwnedIslands().get(playerUUID).forEach((island) -> { final IslandJoinEvent event = new IslandJoinEvent(playerUUID, island); plugin.getServer().getPluginManager().callEvent(event); }); } return true; }
From source file:org.usergrid.persistence.cassandra.EntityManagerImpl.java
/** * Returns true if the property is unique, and the entity can be saved. If it's not unique, false is returned * @param thisEntity/*from w w w . ja v a 2 s. c o m*/ * @param entityType * @param propertyName * @param propertyValue * @return * @throws Exception */ @Metered(group = "core", name = "EntityManager_isPropertyValueUniqueForEntity") public boolean isPropertyValueUniqueForEntity(UUID thisEntity, String entityType, String propertyName, Object propertyValue) throws Exception { if (!getDefaultSchema().isPropertyUnique(entityType, propertyName)) { return true; } if (propertyValue == null) { return true; } String collectionName = defaultCollectionName(entityType); Lock lock = getUniqueUpdateLock(cass.getLockManager(), applicationId, propertyValue, entityType, propertyName); List<HColumn<ByteBuffer, ByteBuffer>> cols = null; try { lock.lock(); Object key = createUniqueIndexKey(collectionName, propertyName, propertyValue); cols = cass.getColumns(cass.getApplicationKeyspace(applicationId), ENTITY_UNIQUE, key, null, null, 2, false); } finally { lock.unlock(); } //No columns at all, it's unique if (cols.size() == 0) { return true; } //shouldn't happen, but it's an error case if (cols.size() > 1) { logger.error( "INDEX CORRUPTION: More than 1 unique value exists for entities in application {} of type {} on property {} with value {}", new Object[] { applicationId, entityType, propertyName, propertyValue }); } /** * Doing this in a loop sucks, but we need to account for possibly having more than 1 entry in the index due to corruption. We need to allow them to update, otherwise * both entities will be unable to update and must be deleted */ for (HColumn<ByteBuffer, ByteBuffer> col : cols) { UUID id = ue.fromByteBuffer(col.getName()); if (thisEntity.equals(id)) { return true; } } return false; }
From source file:com.wasteofplastic.acidisland.commands.IslandCmd.java
@Override public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split) { if (!(sender instanceof Player)) { return false; }//from ww w. j a v a 2 s . c o m final Player player = (Player) sender; // Basic permissions check to even use /island if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.create")) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).islanderrorYouDoNotHavePermission); return true; } /* * Grab data for this player - may be null or empty * playerUUID is the unique ID of the player who issued the command */ final UUID playerUUID = player.getUniqueId(); final UUID teamLeader = plugin.getPlayers().getTeamLeader(playerUUID); List<UUID> teamMembers = new ArrayList<UUID>(); if (teamLeader != null) { teamMembers = plugin.getPlayers().getMembers(teamLeader); } // The target player's UUID UUID targetPlayer = null; // Check if a player has an island or is in a team switch (split.length) { // /island command by itself case 0: // New island if (plugin.getPlayers().getIslandLocation(playerUUID) == null && !plugin.getPlayers().inTeam(playerUUID)) { // Check if the max number of islands is made already if (Settings.maxIslands > 0 && plugin.getGrid().getIslandCount() > Settings.maxIslands) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMaxIslands); return true; } // Create new island for player player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandnew); chooseIsland(player); return true; } else { if (Settings.useControlPanel) { player.performCommand(Settings.ISLANDCOMMAND + " cp"); } else { if (!player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || Settings.allowTeleportWhenFalling || !PlayerEvents.isFalling(playerUUID) || (player.isOp() && !Settings.damageOps)) { // Teleport home plugin.getGrid().homeTeleport(player); if (Settings.islandRemoveMobs) { plugin.getGrid().removeMobs(player.getLocation()); } } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady); } } return true; } case 1: if (split[0].equalsIgnoreCase("teamchat")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.chat")) { // Check if this command is on or not if (!Settings.teamChat) { return false; } // Check if in team if (plugin.getPlayers().inTeam(playerUUID)) { // Check if team members are online boolean online = false; for (UUID teamMember : plugin.getPlayers().getMembers(playerUUID)) { if (!teamMember.equals(playerUUID) && plugin.getServer().getPlayer(teamMember) != null) { online = true; } } if (!online) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeamAround); player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff); plugin.getChatListener().unSetPlayer(playerUUID); return true; } if (plugin.getChatListener().isTeamChat(playerUUID)) { // Toggle player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff); plugin.getChatListener().unSetPlayer(playerUUID); } else { player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOn); plugin.getChatListener().setPlayer(playerUUID); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeam); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); } return true; } if (split[0].equalsIgnoreCase("ban")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { // Just show ban help player.sendMessage(plugin.myLocale(playerUUID).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpBan); } else { player.sendMessage(plugin.myLocale(playerUUID).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("unban") && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { // Just show unban help player.sendMessage(plugin.myLocale(playerUUID).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpUnban); } else { player.sendMessage(plugin.myLocale(playerUUID).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("make")) { //plugin.getLogger().info("DEBUG: /is make called"); if (!pendingNewIslandSelection.contains(playerUUID)) { return false; } pendingNewIslandSelection.remove(playerUUID); Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId()); newIsland(player); if (resettingIsland.contains(playerUUID)) { resettingIsland.remove(playerUUID); resetPlayer(player, oldIsland); } return true; } else if (split[0].equalsIgnoreCase("lang")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) { player.sendMessage("/" + label + " lang <locale>"); player.sendMessage("English"); player.sendMessage("Franais"); player.sendMessage("Deutsch"); player.sendMessage("Espaol"); player.sendMessage("Italiano"); player.sendMessage("? / Korean"); player.sendMessage("Polski"); player.sendMessage("Brasil"); player.sendMessage(" / SimplifiedChinese"); player.sendMessage("etina"); player.sendMessage("Sloven?ina"); player.sendMessage("? / TraditionalChinese"); player.sendMessage("Nederlands"); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("settings")) { // Show what the plugin settings are if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) { try { player.openInventory(plugin.getSettingsPanel().islandGuardPanel(player)); } catch (Exception e) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("lock")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // plugin.getLogger().info("DEBUG: perms ok"); // Find out which island they want to lock Island island = plugin.getGrid().getIsland(playerUUID); if (island == null) { // plugin.getLogger().info("DEBUG: player has no island in grid"); // Player has no island in the grid player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } else { if (!island.isLocked()) { // Remove any visitors for (Player target : plugin.getServer().getOnlinePlayers()) { // See if target is on this player's island, not a mod, no bypass, and not a coop player if (!player.equals(target) && !target.isOp() && !VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect") && (target.getWorld().equals(ASkyBlock.getIslandWorld()) || target.getWorld().equals(ASkyBlock.getNetherWorld())) && plugin.getGrid().isOnIsland(player, target) && !CoopPlay.getInstance() .getCoopPlayers(island.getCenter()).contains(target.getUniqueId())) { // Send them home if (plugin.getPlayers().inTeam(target.getUniqueId()) || plugin.getPlayers().hasIsland(target.getUniqueId())) { plugin.getGrid().homeTeleport(target); } else { // Just move target to spawn if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(player.getWorld().getSpawnLocation()); } } target.sendMessage( ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled); plugin.getLogger().info(player.getName() + " expelled " + target.getName() + " from their island when locking."); // Yes they are player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess .replace("[name]", target.getDisplayName())); } } player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).lockLocking); plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked.replace("[name]", player.getDisplayName())); plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked .replace("[name]", player.getDisplayName())); island.setLocked(true); } else { player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).lockUnlocking); plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked.replace("[name]", player.getDisplayName())); plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked .replace("[name]", player.getDisplayName())); island.setLocked(false); } return true; } } else if (split[0].equalsIgnoreCase("go")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) { // Player has no island player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoIsland); return true; } // Teleport home plugin.getGrid().homeTeleport(player); if (Settings.islandRemoveMobs) { plugin.getGrid().removeMobs(player.getLocation()); } return true; } else if (split[0].equalsIgnoreCase("about")) { player.sendMessage(ChatColor.GOLD + "This plugin is free software: you can redistribute"); player.sendMessage(ChatColor.GOLD + "it and/or modify it under the terms of the GNU"); player.sendMessage(ChatColor.GOLD + "General Public License as published by the Free"); player.sendMessage(ChatColor.GOLD + "Software Foundation, either version 3 of the License,"); player.sendMessage(ChatColor.GOLD + "or (at your option) any later version."); player.sendMessage(ChatColor.GOLD + "This plugin is distributed in the hope that it"); player.sendMessage(ChatColor.GOLD + "will be useful, but WITHOUT ANY WARRANTY; without"); player.sendMessage(ChatColor.GOLD + "even the implied warranty of MERCHANTABILITY or"); player.sendMessage(ChatColor.GOLD + "FITNESS FOR A PARTICULAR PURPOSE. See the"); player.sendMessage(ChatColor.GOLD + "GNU General Public License for more details."); player.sendMessage(ChatColor.GOLD + "You should have received a copy of the GNU"); player.sendMessage(ChatColor.GOLD + "General Public License along with this plugin."); player.sendMessage(ChatColor.GOLD + "If not, see <http://www.gnu.org/licenses/>."); player.sendMessage(ChatColor.GOLD + "Souce code is available on GitHub."); player.sendMessage(ChatColor.GOLD + "(c) 2014 - 2015 by tastybento"); return true; // Spawn enderman // Enderman enderman = (Enderman) // player.getWorld().spawnEntity(player.getLocation().add(new // Vector(5,0,5)), EntityType.ENDERMAN); // enderman.setCustomName("TastyBento's Ghost"); // enderman.setCarriedMaterial(new // MaterialData(Material.GRASS)); } if (split[0].equalsIgnoreCase("controlpanel") || split[0].equalsIgnoreCase("cp")) { // if // (player.getWorld().getName().equalsIgnoreCase(Settings.worldName)) // { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) { player.openInventory(ControlPanel.controlPanel.get(ControlPanel.getDefaultPanelName())); return true; } // } } if (split[0].equalsIgnoreCase("minishop") || split[0].equalsIgnoreCase("ms")) { if (Settings.useEconomy) { // Check island if (plugin.getGrid().getIsland(player.getUniqueId()) == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } if (player.getWorld().equals(ASkyBlock.getIslandWorld()) || player.getWorld().equals(ASkyBlock.getNetherWorld())) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) { player.openInventory(ControlPanel.miniShop); return true; } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld); return true; } } } // /island <command> if (split[0].equalsIgnoreCase("warp")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { player.sendMessage(ChatColor.YELLOW + "/island warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp); return true; } } else if (split[0].equalsIgnoreCase("warps")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { // Step through warp table Collection<UUID> warpList = plugin.getWarpSignsListener().listWarps(); if (warpList.isEmpty()) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } return true; } else { if (Settings.useWarpPanel) { // Try the warp panel player.openInventory(plugin.getWarpPanel().getWarpPanel(0)); } else { Boolean hasWarp = false; String wlist = ""; for (UUID w : warpList) { if (wlist.isEmpty()) { wlist = plugin.getPlayers().getName(w); } else { wlist += ", " + plugin.getPlayers().getName(w); } if (w.equals(playerUUID)) { hasWarp = true; } } player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpswarpsAvailable + ": " + ChatColor.WHITE + wlist); if (!hasWarp && (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp"))) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } } return true; } } } else if (split[0].equalsIgnoreCase("restart") || split[0].equalsIgnoreCase("reset")) { // Check this player has an island if (!plugin.getPlayers().hasIsland(playerUUID)) { // No so just start an island player.performCommand(Settings.ISLANDCOMMAND); return true; } if (plugin.getPlayers().inTeam(playerUUID)) { if (!plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandresetOnlyOwner); } else { player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetMustRemovePlayers); } return true; } // Check if the player has used up all their resets if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandResetNoMore); return true; } if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).resetYouHave .replace("[number]", String.valueOf(plugin.getPlayers().getResetsLeft(playerUUID)))); } if (!onRestartWaitTime(player) || Settings.resetWait == 0 || player.isOp()) { // Kick off the confirmation player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandresetConfirm .replace("[seconds]", String.valueOf(Settings.resetConfirmWait))); if (!confirm.containsKey(playerUUID) || !confirm.get(playerUUID)) { confirm.put(playerUUID, true); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { confirm.put(playerUUID, false); } }, (Settings.resetConfirmWait * 20)); } return true; } else { player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetWait .replace("[time]", String.valueOf(getResetWaitTime(player)))); } return true; } else if (split[0].equalsIgnoreCase("confirm")) { // This is where the actual reset is done if (confirm.containsKey(playerUUID) && confirm.get(playerUUID)) { confirm.remove(playerUUID); // Actually RESET the island player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetPleaseWait); if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandResetNoMore); } if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).resetYouHave.replace( "[number]", String.valueOf(plugin.getPlayers().getResetsLeft(playerUUID)))); } // Show a schematic panel if the player has a choice // Get the schematics that this player is eligible to use List<Schematic> schems = getSchematics(player, false); //plugin.getLogger().info("DEBUG: size of schematics for this player = " + schems.size()); Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId()); if (schems.isEmpty()) { // No schematics - use default island newIsland(player); resetPlayer(player, oldIsland); } else if (schems.size() == 1) { // Hobson's choice newIsland(player, schems.get(0)); resetPlayer(player, oldIsland); } else { // A panel can only be shown if there is >1 viable schematic if (Settings.useSchematicPanel) { pendingNewIslandSelection.add(playerUUID); resettingIsland.add(playerUUID); player.openInventory(plugin.getSchematicsPanel().getPanel(player)); } else { // No panel // Check schematics for specific permission schems = getSchematics(player, true); if (schems.isEmpty()) { newIsland(player); } else if (Settings.chooseIslandRandomly) { // Choose an island randomly from the list newIsland(player, schems.get(random.nextInt(schems.size()))); } else { // Do the first one in the list newIsland(player, schems.get(0)); } resetPlayer(player, oldIsland); } } return true; } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/island restart: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart); return true; } } else if (split[0].equalsIgnoreCase("sethome")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { // Check island if (plugin.getGrid().getIsland(player.getUniqueId()) == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } plugin.getGrid().homeSet(player); return true; } return false; } else if (split[0].equalsIgnoreCase("help")) { player.sendMessage( ChatColor.GREEN + plugin.getName() + " " + plugin.getDescription().getVersion() + " help:"); if (Settings.useControlPanel) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpIsland); } // Dynamic home sizes with permissions int maxHomes = Settings.maxHomes; for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) { maxHomes = Integer .valueOf(perms.getPermission().split(Settings.PERMPREFIX + "island.maxhomes.")[1]); } // Do some sanity checking if (maxHomes < 1) { maxHomes = 1; } } if (maxHomes > 1 && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport); } if (plugin.getGrid() != null && plugin.getGrid().getSpawn() != null) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " spawn: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSpawn); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " controlpanel or cp: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel); } player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " restart: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { if (maxHomes > 1) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome); } } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevel); player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevelPlayer); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " top: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTop); } if (Settings.useEconomy && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " minishop or ms: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMiniShop); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warps: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarps); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " team: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeam); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " invite <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpInvite); player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " leave: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLeave); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " kick <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpKick); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " <accept/reject>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpAcceptReject); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " makeleader <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMakeLeader); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.chat") && plugin.getPlayers().inTeam(playerUUID)) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " teamchat: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).teamChatHelp); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " biomes: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBiome); } // if (!Settings.allowPvP) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " expel <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpExpel); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBan); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnban); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop); player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " uncoop: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnCoop); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lock: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpLock); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " settings: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSettings); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.challenges")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + plugin.myLocale(player.getUniqueId()).islandHelpChallenges); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lang <locale> - select language"); } return true; } else if (split[0].equalsIgnoreCase("biomes")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) { // Only the team leader can do this if (teamLeader != null && !teamLeader.equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).levelerrornotYourIsland); return true; } if (!plugin.getPlayers().hasIsland(playerUUID)) { // Player has no island player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } if (!plugin.getGrid().playerIsOnIsland(player)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland); return true; } // Not allowed in the nether if (plugin.getPlayers().getIslandLocation(playerUUID).getWorld().getEnvironment() .equals(Environment.NETHER)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld); return true; } // player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "[Biomes]"); Inventory inv = plugin.getBiomes().getBiomePanel(player); if (inv != null) { player.openInventory(inv); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("spawn") && plugin.getGrid().getSpawn() != null) { // go to spawn Location l = ASkyBlock.getIslandWorld().getSpawnLocation(); l.add(new Vector(0.5, 0, 0.5)); Island spawn = plugin.getGrid().getSpawn(); if (spawn != null && spawn.getSpawnPoint() != null) { l = spawn.getSpawnPoint(); } player.teleport(l); return true; } else if (split[0].equalsIgnoreCase("top")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) { TopTen.topTenShow(player); return true; } return false; } else if (split[0].equalsIgnoreCase("level")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) { if (!plugin.getPlayers().inTeam(playerUUID) && !plugin.getPlayers().hasIsland(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } else { if (Settings.fastLevelCalc) { calculateIslandLevel(player, playerUUID); return true; } else { // Legacy - forces player to be on island to reduce frivolous calculations if (plugin.getGrid().playerIsOnIsland(player)) { calculateIslandLevel(player, playerUUID); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland); } return true; } } } return false; } else if (split[0].equalsIgnoreCase("invite")) { // Invite label with no name, i.e., /island invite - tells the // player how many more people they can invite if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).invitehelp); // If the player who is doing the inviting has a team if (plugin.getPlayers().inTeam(playerUUID)) { // Check to see if the player is the leader if (teamLeader.equals(playerUUID)) { // Check to see if the team is already full int maxSize = Settings.maxTeamSize; // Dynamic team sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { //plugin.getLogger().info("DEBUG perms: " + perms); if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) { maxSize = Integer.valueOf( perms.getPermission().split(Settings.PERMPREFIX + "team.maxsize.")[1]); } // Do some sanity checking if (maxSize < Settings.maxTeamSize) { maxSize = Settings.maxTeamSize; } } // Account for deprecated permissions. These will be zero on new installs // This avoids these permissions breaking on upgrades if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.vip")) { if (Settings.maxTeamSizeVIP > maxSize) { maxSize = Settings.maxTeamSizeVIP; } } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.vip2")) { if (Settings.maxTeamSizeVIP2 > maxSize) { maxSize = Settings.maxTeamSizeVIP2; } } if (teamMembers.size() < maxSize) { player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite .replace("[number]", String.valueOf(maxSize - teamMembers.size()))); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull); } return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); return true; } return true; } return false; } else if (split[0].equalsIgnoreCase("accept")) { // Accept an invite command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) { // If player is not in a team but has been invited to join // one if (!plugin.getPlayers().inTeam(playerUUID) && inviteList.containsKey(playerUUID)) { // If the invitee has an island of their own if (plugin.getPlayers().hasIsland(playerUUID)) { plugin.getLogger().info( player.getName() + "'s island will be deleted because they joined a party."); plugin.deletePlayerIsland(playerUUID, true); plugin.getLogger().info("Island deleted."); } // Add the player to the team addPlayertoTeam(playerUUID, inviteList.get(playerUUID)); // If the leader who did the invite does not yet have a // team (leader is not in a team yet) if (!plugin.getPlayers().inTeam(inviteList.get(playerUUID))) { // Add the leader to their own team addPlayertoTeam(inviteList.get(playerUUID), inviteList.get(playerUUID)); } setResetWaitTime(player); plugin.getGrid().homeTeleport(player); plugin.resetPlayer(player); // Reset reset limit - note that a player can get around the reset // limit by begging someone to invite them to an island and then leaving plugin.getPlayers().setResetsLeft(playerUUID, Settings.resetLimit); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouHaveJoinedAnIsland); if (Bukkit.getPlayer(inviteList.get(playerUUID)) != null) { Bukkit.getPlayer(inviteList.get(playerUUID)) .sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).invitehasJoinedYourIsland .replace("[name]", player.getName())); } // Remove the invite inviteList.remove(player.getUniqueId()); plugin.getGrid().saveGrid(); return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady); return true; } return false; } else if (split[0].equalsIgnoreCase("reject")) { // Reject /island reject if (inviteList.containsKey(player.getUniqueId())) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).rejectyouHaveRejectedInvitation); // If the player is online still then tell them directly // about the rejection if (Bukkit.getPlayer(inviteList.get(player.getUniqueId())) != null) { Bukkit.getPlayer(inviteList.get(player.getUniqueId())).sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).rejectnameHasRejectedInvite .replace("[name]", player.getName())); } // Remove this player from the global invite list inviteList.remove(player.getUniqueId()); } else { // Someone typed /island reject and had not been invited player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).rejectyouHaveNotBeenInvited); } return true; } else if (split[0].equalsIgnoreCase("leave")) { // Leave team command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) { if (player.getWorld().getName().equalsIgnoreCase(ASkyBlock.getIslandWorld().getName())) { if (plugin.getPlayers().inTeam(playerUUID)) { if (plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveerrorYouAreTheLeader); return true; } // Clear any coop inventories // CoopPlay.getInstance().returnAllInventories(player); // Remove any of the target's coop invitees and grab // their stuff CoopPlay.getInstance().clearMyInvitedCoops(player); CoopPlay.getInstance().clearMyCoops(player); // Log the location that this player left so they // cannot join again before the cool down ends plugin.getPlayers().startInviteCoolDownTimer(playerUUID, plugin.getPlayers().getTeamIslandLocation(teamLeader)); // Remove from team removePlayerFromTeam(playerUUID, teamLeader); // Remove any warps plugin.getWarpSignsListener().removeWarp(playerUUID); player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveyouHaveLeftTheIsland); // Tell the leader if they are online if (plugin.getServer().getPlayer(teamLeader) != null) { plugin.getServer().getPlayer(teamLeader).sendMessage( ChatColor.RED + plugin.myLocale(teamLeader).leavenameHasLeftYourIsland .replace("[name]", player.getName())); } else { // Leave them a message plugin.getMessages().setMessage(teamLeader, ChatColor.RED + plugin.myLocale(teamLeader).leavenameHasLeftYourIsland .replace("[name]", player.getName())); } // Check if the size of the team is now 1 // teamMembers.remove(playerUUID); if (teamMembers.size() < 2) { // plugin.getLogger().info("DEBUG: Party is less than 2 - removing leader from team"); removePlayerFromTeam(teamLeader, teamLeader); } // Clear all player variables and save plugin.resetPlayer(player); if (!player.performCommand(Settings.SPAWNCOMMAND)) { player.teleport(player.getWorld().getSpawnLocation()); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorYouCannotLeaveIsland); return true; } } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorYouMustBeInWorld); } return true; } return false; } else if (split[0].equalsIgnoreCase("team")) { if (plugin.getPlayers().inTeam(playerUUID)) { if (teamLeader.equals(playerUUID)) { int maxSize = Settings.maxTeamSize; // Dynamic team sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) { maxSize = Integer.valueOf( perms.getPermission().split(Settings.PERMPREFIX + "team.maxsize.")[1]); } // Do some sanity checking if (maxSize < Settings.maxTeamSize) { maxSize = Settings.maxTeamSize; } } if (teamMembers.size() < maxSize) { player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite .replace("[number]", String.valueOf(maxSize - teamMembers.size()))); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull); } } player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).teamlistingMembers + ":"); // Display members in the list for (UUID m : plugin.getPlayers().getMembers(teamLeader)) { player.sendMessage(ChatColor.WHITE + plugin.getPlayers().getName(m)); } } else if (inviteList.containsKey(playerUUID)) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitenameHasInvitedYou .replace("[name]", plugin.getPlayers().getName(inviteList.get(playerUUID)))); player.sendMessage(ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitetoAcceptOrReject); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam); } return true; } else { // Incorrect syntax return false; } /* * Commands that have two parameters */ case 2: if (split[0].equalsIgnoreCase("warps")) { if (Settings.useWarpPanel) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { // Step through warp table Set<UUID> warpList = plugin.getWarpSignsListener().listWarps(); if (warpList.isEmpty()) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } return true; } else { // Try the warp panel int panelNum = 0; try { panelNum = Integer.valueOf(split[1]) - 1; } catch (Exception e) { panelNum = 0; } player.openInventory(plugin.getWarpPanel().getWarpPanel(panelNum)); return true; } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); } } else { return false; } } else if (split[0].equalsIgnoreCase("make")) { //plugin.getLogger().info("DEBUG: /is make '" + split[1] + "' called"); if (!pendingNewIslandSelection.contains(playerUUID)) { return false; } pendingNewIslandSelection.remove(playerUUID); // Create a new island using schematic if (!schematics.containsKey(split[1])) { return false; } else { Schematic schematic = schematics.get(split[1]); // Check perm again if (schematic.getPerm().isEmpty() || VaultHelper.checkPerm(player, schematic.getPerm())) { Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId()); newIsland(player, schematic); if (resettingIsland.contains(playerUUID)) { resettingIsland.remove(playerUUID); resetPlayer(player, oldIsland); } return true; } else { return false; } } } else if (split[0].equalsIgnoreCase("lang")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) { if (split[1].equalsIgnoreCase("english")) { plugin.getPlayers().setLocale(playerUUID, "en-US"); } else if (split[1].equalsIgnoreCase("Franais") || split[1].equalsIgnoreCase("Francais")) { plugin.getPlayers().setLocale(playerUUID, "fr-FR"); } else if (split[1].equalsIgnoreCase("Deutsch")) { plugin.getPlayers().setLocale(playerUUID, "de-DE"); } else if (split[1].equalsIgnoreCase("espaol") || split[1].equalsIgnoreCase("espanol")) { plugin.getPlayers().setLocale(playerUUID, "es-ES"); } else if (split[1].equalsIgnoreCase("italiano")) { plugin.getPlayers().setLocale(playerUUID, "it-IT"); } else if (split[1].equalsIgnoreCase("Korean") || split[1].equalsIgnoreCase("?")) { plugin.getPlayers().setLocale(playerUUID, "ko-KR"); } else if (split[1].equalsIgnoreCase("polski")) { plugin.getPlayers().setLocale(playerUUID, "pl-PL"); } else if (split[1].equalsIgnoreCase("Brasil")) { plugin.getPlayers().setLocale(playerUUID, "pt-BR"); } else if (split[1].equalsIgnoreCase("SimplifiedChinese") || split[1].equalsIgnoreCase("")) { plugin.getPlayers().setLocale(playerUUID, "zh-CN"); } else if (split[1].equalsIgnoreCase("etina") || split[1].equalsIgnoreCase("Cestina")) { plugin.getPlayers().setLocale(playerUUID, "cs-CS"); } else if (split[1].equalsIgnoreCase("Sloven?ina") || split[1].equalsIgnoreCase("Slovencina")) { plugin.getPlayers().setLocale(playerUUID, "sk-SK"); } else if (split[1].equalsIgnoreCase("TraditionalChinese") || split[1].equalsIgnoreCase("?")) { plugin.getPlayers().setLocale(playerUUID, "nl-NL"); } else if (split[1].equalsIgnoreCase("Nederlands") || split[1].equalsIgnoreCase("Dutch")) { plugin.getPlayers().setLocale(playerUUID, "nl-NL"); } else { // Typed it in wrong player.sendMessage("/" + label + " lang <locale>"); player.sendMessage("English"); player.sendMessage("Franais"); player.sendMessage("Deutsch"); player.sendMessage("Espaol"); player.sendMessage("Italiano"); player.sendMessage("? / Korean"); player.sendMessage("Polski"); player.sendMessage("Brasil"); player.sendMessage(" / SimplifiedChinese"); player.sendMessage("etina"); player.sendMessage("Sloven?ina"); player.sendMessage("? / TraditionalChinese"); player.sendMessage("Nederlands"); return true; } player.sendMessage("OK!"); return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else // Multi home if (split[0].equalsIgnoreCase("go")) { if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) { // Player has no island player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { int number = 1; try { number = Integer.valueOf(split[1]); //plugin.getLogger().info("DEBUG: number = " + number); if (number < 1) { plugin.getGrid().homeTeleport(player, 1); } else { int maxHomes = Settings.maxHomes; // Dynamic home sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) { maxHomes = Integer.valueOf(perms.getPermission() .split(Settings.PERMPREFIX + "island.maxhomes.")[1]); } // Do some sanity checking if (maxHomes < 1) { maxHomes = 1; } } if (number > maxHomes) { if (maxHomes > 1) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes .replace("[max]", String.valueOf(maxHomes))); } else { plugin.getGrid().homeTeleport(player, 1); } } else { // Teleport home plugin.getGrid().homeTeleport(player, number); } } } catch (Exception e) { // Teleport home plugin.getGrid().homeTeleport(player, 1); } if (Settings.islandRemoveMobs) { plugin.getGrid().removeMobs(player.getLocation()); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("sethome")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { Island island = plugin.getGrid().getIsland(playerUUID); if (island == null) { // plugin.getLogger().info("DEBUG: player has no island in grid"); // Player has no island in the grid player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } int maxHomes = Settings.maxHomes; // Dynamic home sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) { maxHomes = Integer.valueOf( perms.getPermission().split(Settings.PERMPREFIX + "island.maxhomes.")[1]); } } if (maxHomes > 1) { // Check the number given is a number int number = 0; try { number = Integer.valueOf(split[1]); if (number < 1 || number > maxHomes) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes .replace("[max]", String.valueOf(maxHomes))); } else { plugin.getGrid().homeSet(player, number); } } catch (Exception e) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes .replace("[max]", String.valueOf(maxHomes))); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } else if (split[0].equalsIgnoreCase("warp")) { // Warp somewhere command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { final Set<UUID> warpList = plugin.getWarpSignsListener().listWarps(); if (warpList.isEmpty()) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp")) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } else { // Check if this is part of a name UUID foundWarp = null; for (UUID warp : warpList) { if (plugin.getPlayers().getName(warp).toLowerCase() .startsWith(split[1].toLowerCase())) { foundWarp = warp; break; } } if (foundWarp == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist); return true; } else { // Warp exists! final Location warpSpot = plugin.getWarpSignsListener().getWarp(foundWarp); // Check if the warp spot is safe if (warpSpot == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotReadyYet); plugin.getLogger().warning( "Null warp found, owned by " + plugin.getPlayers().getName(foundWarp)); return true; } // Find out if island is locked Island island = plugin.getGrid().getIslandAt(warpSpot); // Check bans if (island != null && plugin.getPlayers().isBanned(island.getOwner(), playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).banBanned .replace("[name]", plugin.getPlayers().getName(island.getOwner()))); if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypasslock")) { return true; } } if (island != null && island.isLocked() && !player.isOp() && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypasslock") && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { // Always inform that the island is locked player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).lockIslandLocked); // Check if this is the owner, team member or coop if (!plugin.getGrid().locationIsAtHome(player, true, warpSpot)) { //plugin.getLogger().info("DEBUG: not at home"); return true; } } boolean pvp = false; if ((warpSpot.getWorld().equals(ASkyBlock.getIslandWorld()) && island.getIgsFlag(Flags.allowPvP)) || (warpSpot.getWorld().equals(ASkyBlock.getNetherWorld()) && island.getIgsFlag(Flags.allowNetherPvP))) { pvp = true; } // Find out which direction the warp is facing Block b = warpSpot.getBlock(); if (b.getType().equals(Material.SIGN_POST) || b.getType().equals(Material.WALL_SIGN)) { Sign sign = (Sign) b.getState(); org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData(); BlockFace directionFacing = s.getFacing(); Location inFront = b.getRelative(directionFacing).getLocation(); Location oneDown = b.getRelative(directionFacing).getRelative(BlockFace.DOWN) .getLocation(); if ((GridManager.isSafeLocation(inFront))) { warpPlayer(player, inFront, foundWarp, directionFacing, pvp); return true; } else if (b.getType().equals(Material.WALL_SIGN) && GridManager.isSafeLocation(oneDown)) { // Try one block down if this is a wall sign warpPlayer(player, oneDown, foundWarp, directionFacing, pvp); return true; } } else { // Warp has been removed player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist); plugin.getWarpSignsListener().removeWarp(warpSpot); return true; } if (!(GridManager.isSafeLocation(warpSpot))) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotSafe); // WALL_SIGN's will always be unsafe if the place in front is obscured. if (b.getType().equals(Material.SIGN_POST)) { plugin.getLogger().warning("Unsafe warp found at " + warpSpot.toString() + " owned by " + plugin.getPlayers().getName(foundWarp)); } return true; } else { final Location actualWarp = new Location(warpSpot.getWorld(), warpSpot.getBlockX() + 0.5D, warpSpot.getBlockY(), warpSpot.getBlockZ() + 0.5D); player.teleport(actualWarp); if (pvp) { player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + plugin.myLocale(player.getUniqueId()).igsPVP + " " + plugin.myLocale(player.getUniqueId()).igsAllowed); player.getWorld().playSound(player.getLocation(), Sound.ARROW_HIT, 1F, 1F); } else { player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1F, 1F); } return true; } } } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return false; } } else if (split[0].equalsIgnoreCase("level")) { // island level <name> command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) { // Find out if the target has an island final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Invited player must be known if (targetPlayerUUID == null) { // plugin.getLogger().info("DEBUG: unknown player"); player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Check if this player has an island or not if (plugin.getPlayers().hasIsland(targetPlayerUUID) || plugin.getPlayers().inTeam(targetPlayerUUID)) { calculateIslandLevel(player, targetPlayerUUID); } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return false; } else if (split[0].equalsIgnoreCase("invite")) { // Team invite a player command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) { // May return null if not known final UUID invitedPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Invited player must be known if (invitedPlayerUUID == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Player must be online if (plugin.getServer().getPlayer(invitedPlayerUUID) == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer); return true; } // Player issuing the command must have an island if (!plugin.getPlayers().hasIsland(player.getUniqueId())) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); return true; } // Player cannot invite themselves if (player.getName().equalsIgnoreCase(split[1])) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouCannotInviteYourself); return true; } // Check if this player can be invited to this island, or // whether they are still on cooldown long time = plugin.getPlayers().getInviteCoolDownTime(invitedPlayerUUID, plugin.getPlayers().getIslandLocation(playerUUID)); if (time > 0 && !player.isOp()) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorCoolDown .replace("[time]", String.valueOf(time))); return true; } // If the player already has a team then check that they are // the leader, etc if (plugin.getPlayers().inTeam(player.getUniqueId())) { // Leader? if (teamLeader.equals(player.getUniqueId())) { // Invited player is free and not in a team if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) { // Player has space in their team int maxSize = Settings.maxTeamSize; // Dynamic team sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) { maxSize = Integer.valueOf(perms.getPermission() .split(Settings.PERMPREFIX + "team.maxsize.")[1]); } // Do some sanity checking if (maxSize < Settings.maxTeamSize) { maxSize = Settings.maxTeamSize; } } if (teamMembers.size() < maxSize) { // If that player already has an invite out // then retract it. // Players can only have one invite out at a // time - interesting if (inviteList.containsValue(playerUUID)) { inviteList.remove(getKeyByValue(inviteList, player.getUniqueId())); player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite); } // Put the invited player (key) onto the // list with inviter (value) // If someone else has invited a player, // then this invite will overwrite the // previous invite! inviteList.put(invitedPlayerUUID, player.getUniqueId()); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo .replace("[name]", split[1])); // Send message to online player Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou .replace("[name]", player.getName())); Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject); if (plugin.getPlayers().hasIsland(invitedPlayerUUID)) { Bukkit.getPlayer(invitedPlayerUUID).sendMessage(ChatColor.RED + plugin .myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull); } } else { player.sendMessage(ChatColor.RED + plugin .myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); } } else { // First-time invite player does not have a team // Check if invitee is in a team or not if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) { // If the inviter already has an invite out, remove // it if (inviteList.containsValue(playerUUID)) { inviteList.remove(getKeyByValue(inviteList, player.getUniqueId())); player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite); } // Place the player and invitee on the invite list inviteList.put(invitedPlayerUUID, player.getUniqueId()); player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo .replace("[name]", split[1])); Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou .replace("[name]", player.getName())); Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject); // Check if the player has an island and warn // accordingly // plugin.getLogger().info("DEBUG: invited player = " // + invitedPlayerUUID.toString()); if (plugin.getPlayers().hasIsland(invitedPlayerUUID)) { // plugin.getLogger().info("DEBUG: invited player has island"); Bukkit.getPlayer(invitedPlayerUUID).sendMessage(ChatColor.RED + plugin.myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam); } } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return false; } } else if (split[0].equalsIgnoreCase("coop")) { // Give a player coop privileges if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { // May return null if not known final UUID invitedPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Invited player must be known if (invitedPlayerUUID == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Player must be online Player newPlayer = plugin.getServer().getPlayer(invitedPlayerUUID); if (newPlayer == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer); return true; } // Player issuing the command must have an island if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); return true; } // Player cannot invite themselves if (player.getName().equalsIgnoreCase(split[1])) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouCannotInviteYourself); return true; } // If target player is already on the team ignore if (plugin.getPlayers().getMembers(playerUUID).contains(invitedPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).coopOnYourTeam); return true; } // Target has to have an island if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) { if (!plugin.getPlayers().hasIsland(invitedPlayerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther); return true; } } // Add target to coop list CoopPlay.getInstance().addCoopPlayer(player, newPlayer); // Tell everyone what happened player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopSuccess .replace("[name]", newPlayer.getDisplayName())); newPlayer.sendMessage(ChatColor.GREEN + plugin.myLocale(newPlayer.getUniqueId()).coopMadeYouCoop .replace("[name]", player.getDisplayName())); return true; } } else if (split[0].equalsIgnoreCase("expel")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to expel final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Player must be known if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotYourself); return true; } // Target must be online Player target = plugin.getServer().getPlayer(targetPlayerUUID); if (target == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer); return true; } // Target cannot be op if (target.isOp() || VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelFail .replace("[name]", target.getDisplayName())); return true; } // Remove them from the coop list boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, target); if (coop) { target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved .replace("[name]", player.getDisplayName())); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess .replace("[name]", target.getDisplayName())); } // See if target is on this player's island if (plugin.getGrid().isOnIsland(player, target)) { // Check to see if this player has an island or is just // helping out if (plugin.getPlayers().inTeam(targetPlayerUUID) || plugin.getPlayers().hasIsland(targetPlayerUUID)) { plugin.getGrid().homeTeleport(target); } else { // Just move target to spawn if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(player.getWorld().getSpawnLocation()); /* * target.sendBlockChange(target.getWorld(). * getSpawnLocation() * ,target.getWorld().getSpawnLocation().getBlock(). * getType() * ,target.getWorld().getSpawnLocation().getBlock(). * getData()); */ } } target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled); plugin.getLogger() .info(player.getName() + " expelled " + target.getName() + " from their island."); // Yes they are player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess .replace("[name]", target.getDisplayName())); } else if (!coop) { // No they're not player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotOnIsland); } return true; } else if (split[0].equalsIgnoreCase("uncoop")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to uncoop final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Player must be known if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself); return true; } // Target must be online Player target = plugin.getServer().getPlayer(targetPlayerUUID); if (target == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer); return true; } // Remove them from the coop list boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, target); if (coop) { target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved .replace("[name]", player.getDisplayName())); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess .replace("[name]", target.getDisplayName())); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).coopNotInCoop .replace("[name]", target.getDisplayName())); } return true; } else if (split[0].equalsIgnoreCase("ban")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to ban final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Player must be known if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself); return true; } // Target cannot be on the same team if (plugin.getPlayers().inTeam(playerUUID) && plugin.getPlayers().inTeam(targetPlayerUUID)) { if (plugin.getPlayers().getTeamLeader(playerUUID) .equals(plugin.getPlayers().getTeamLeader(targetPlayerUUID))) { // Same team! player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotTeamMember); return true; } } // Check that the player is not banned already if (plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).banAlreadyBanned.replace("[name]", split[1])); return true; } // Check online/offline status Player target = plugin.getServer().getPlayer(targetPlayerUUID); // Get offline player OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID); // Target cannot be op if (offlineTarget.isOp()) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banFail .replace("[name]", offlineTarget.getName())); return true; } if (target != null) { // Remove them from the coop list boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, target); if (coop) { target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved .replace("[name]", player.getDisplayName())); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess .replace("[name]", target.getDisplayName())); } // See if target is on this player's island and if so send them away if (plugin.getGrid().isOnIsland(player, target)) { // Check to see if this player has an island or is just // helping out if (plugin.getPlayers().inTeam(targetPlayerUUID) || plugin.getPlayers().hasIsland(targetPlayerUUID)) { plugin.getGrid().homeTeleport(target); } else { // Just move target to spawn if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(player.getWorld().getSpawnLocation()); } } } // Notifications // Target target.sendMessage(ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getDisplayName())); } else { // Offline notification plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getDisplayName())); } // Console plugin.getLogger() .info(player.getName() + " banned " + offlineTarget.getName() + " from their island."); // Player player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess .replace("[name]", offlineTarget.getName())); // Tell team plugin.getMessages().tellTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", offlineTarget.getName())); plugin.getMessages().tellOfflineTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", offlineTarget.getName())); // Ban the sucker plugin.getPlayers().ban(playerUUID, targetPlayerUUID); plugin.getGrid().saveGrid(); return true; } else if (split[0].equalsIgnoreCase("unban")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to unban final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Player must be known if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself); return true; } // Check that the player is actually banned if (!plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotBanned.replace("[name]", split[1])); return true; } // Notifications // Online check Player target = plugin.getServer().getPlayer(targetPlayerUUID); // Target if (target != null) { // Online target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).banLifted .replace("[name]", player.getDisplayName())); } else { plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).banLifted.replace("[name]", player.getDisplayName())); } OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID); // Player player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess .replace("[name]", offlineTarget.getName())); // Console plugin.getLogger() .info(player.getName() + " unbanned " + offlineTarget.getName() + " from their island."); // Tell team plugin.getMessages().tellTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", offlineTarget.getName())); plugin.getMessages().tellOfflineTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", offlineTarget.getName())); // Unban the redeemed one plugin.getPlayers().unBan(playerUUID, targetPlayerUUID); plugin.getGrid().saveGrid(); return true; } else if (split[0].equalsIgnoreCase("kick") || split[0].equalsIgnoreCase("remove")) { // PlayerIsland remove command with a player name, or island kick // command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) { if (!plugin.getPlayers().inTeam(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam); return true; } // Only leaders can kick if (teamLeader != null && !teamLeader.equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorOnlyLeaderCan); return true; } // The main thing to do is check if the player name to kick // is in the list of players in the team. targetPlayer = null; for (UUID member : teamMembers) { if (plugin.getPlayers().getName(member).equalsIgnoreCase(split[1])) { targetPlayer = member; } } if (targetPlayer == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam); return true; } if (teamMembers.contains(targetPlayer)) { // If the player leader tries to kick or remove // themselves if (player.getUniqueId().equals(targetPlayer)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorLeadersCannotLeave); return true; } // If target is online Player target = plugin.getServer().getPlayer(targetPlayer); if (target != null) { // plugin.getLogger().info("DEBUG: player is online"); target.sendMessage(ChatColor.RED + plugin.myLocale(targetPlayer).kicknameRemovedYou .replace("[name]", player.getName())); // Log the location that this player left so they // cannot join again before the cool down ends plugin.getPlayers().startInviteCoolDownTimer(targetPlayer, plugin.getPlayers().getIslandLocation(playerUUID)); // Clear any coop inventories // CoopPlay.getInstance().returnAllInventories(target); // Remove any of the target's coop invitees and // anyone they invited CoopPlay.getInstance().clearMyInvitedCoops(target); CoopPlay.getInstance().clearMyCoops(target); // Clear the player out and throw their stuff at the // leader if (target.getWorld().equals(ASkyBlock.getIslandWorld())) { for (ItemStack i : target.getInventory().getContents()) { if (i != null) { try { player.getWorld().dropItemNaturally(player.getLocation(), i); } catch (Exception e) { } } } for (ItemStack i : target.getEquipment().getArmorContents()) { if (i != null) { try { player.getWorld().dropItemNaturally(player.getLocation(), i); } catch (Exception e) { } } } // plugin.resetPlayer(target); <- no good if // reset inventory is false // Clear their inventory and equipment and set // them as survival target.getInventory().clear(); // Javadocs are // wrong - this // does not // clear armor slots! So... // plugin.getLogger().info("DEBUG: Clearing kicked player's inventory"); target.getInventory().setArmorContents(null); target.getInventory().setHelmet(null); target.getInventory().setChestplate(null); target.getInventory().setLeggings(null); target.getInventory().setBoots(null); target.getEquipment().clear(); if (Settings.resetChallenges) { // Reset the player's challenge status plugin.getPlayers().resetAllChallenges(target.getUniqueId()); } // Reset the island level plugin.getPlayers().setIslandLevel(target.getUniqueId(), 0); plugin.getPlayers().save(target.getUniqueId()); TopTen.topTenAddEntry(playerUUID, 0); // Update the inventory target.updateInventory(); } if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(ASkyBlock.getIslandWorld().getSpawnLocation()); } } else { // Offline // plugin.getLogger().info("DEBUG: player is offline " // + targetPlayer.toString()); // Tell offline player they were kicked plugin.getMessages().setMessage(targetPlayer, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemovedYou .replace("[name]", player.getName())); } // Remove any warps plugin.getWarpSignsListener().removeWarp(targetPlayer); // Tell leader they removed the player player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemoved .replace("[name]", split[1])); removePlayerFromTeam(targetPlayer, teamLeader); teamMembers.remove(targetPlayer); if (teamMembers.size() < 2) { removePlayerFromTeam(player.getUniqueId(), teamLeader); } plugin.getPlayers().save(targetPlayer); } else { plugin.getLogger().warning("Player " + player.getName() + " failed to remove " + plugin.getPlayers().getName(targetPlayer)); player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return false; } } else if (split[0].equalsIgnoreCase("makeleader")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) { targetPlayer = plugin.getPlayers().getUUID(split[1]); if (targetPlayer == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } if (targetPlayer.equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError); return true; } if (!plugin.getPlayers().inTeam(player.getUniqueId())) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorYouMustBeInTeam); return true; } if (plugin.getPlayers().getMembers(player.getUniqueId()).size() > 2) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorRemoveAllPlayersFirst); plugin.getLogger().info(player.getName() + " tried to transfer his island, but failed because >2 people in a team"); return true; } if (plugin.getPlayers().inTeam(player.getUniqueId())) { if (teamLeader.equals(player.getUniqueId())) { if (teamMembers.contains(targetPlayer)) { // Check if online if (plugin.getServer().getPlayer(targetPlayer) != null) { plugin.getServer().getPlayer(targetPlayer).sendMessage(ChatColor.GREEN + plugin.myLocale(targetPlayer).makeLeaderyouAreNowTheOwner); } else { plugin.getMessages().setMessage(targetPlayer, plugin.myLocale(player.getUniqueId()).makeLeaderyouAreNowTheOwner); // .makeLeadererrorPlayerMustBeOnline } player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).makeLeadernameIsNowTheOwner .replace("[name]", plugin.getPlayers().getName(targetPlayer))); // targetPlayer is the new leader // plugin.getLogger().info("DEBUG: " + // plugin.getPlayers().getIslandLevel(teamLeader)); // Remove the target player from the team removePlayerFromTeam(targetPlayer, teamLeader); // Remove the leader from the team removePlayerFromTeam(teamLeader, teamLeader); // plugin.getLogger().info("DEBUG: " + // plugin.getPlayers().getIslandLevel(teamLeader)); // Transfer the data from the old leader to the // new one plugin.getGrid().transferIsland(player.getUniqueId(), targetPlayer); // Create a new team with addPlayertoTeam(player.getUniqueId(), targetPlayer); addPlayertoTeam(targetPlayer, targetPlayer); plugin.getGrid().saveGrid(); return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorThatPlayerIsNotInTeam); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorNotYourIsland); } } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return false; } } else { return false; } } return false; }
From source file:com.wasteofplastic.askyblock.commands.IslandCmd.java
@Override public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split) { if (!(sender instanceof Player)) { sender.sendMessage(plugin.myLocale().errorUseInGame); return false; }//from ww w . j a v a 2 s.co m final Player player = (Player) sender; // Basic permissions check to even use /island if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.create")) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).islanderrorYouDoNotHavePermission); return true; } /* * Grab data for this player - may be null or empty * playerUUID is the unique ID of the player who issued the command */ final UUID playerUUID = player.getUniqueId(); final UUID teamLeader = plugin.getPlayers().getTeamLeader(playerUUID); List<UUID> teamMembers = new ArrayList<UUID>(); if (teamLeader != null) { teamMembers = plugin.getPlayers().getMembers(teamLeader); } // Island name (can have spaces) if (split.length > 1 && split[0].equalsIgnoreCase("name")) { // Naming of island if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID, player.getWorld().getEnvironment())) { String name = split[1]; for (int i = 2; i < split.length; i++) { name = name + " " + split[i]; } if (name.length() < Settings.minNameLength) { player.sendMessage(ChatColor.RED + (plugin.myLocale(player.getUniqueId()).errorTooShort) .replace("[length]", String.valueOf(Settings.minNameLength))); return true; } if (name.length() > Settings.maxNameLength) { player.sendMessage(ChatColor.RED + (plugin.myLocale(player.getUniqueId()).errorTooLong) .replace("[length]", String.valueOf(Settings.maxNameLength))); return true; } plugin.getGrid().setIslandName(playerUUID, ChatColor.translateAlternateColorCodes('&', name)); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).generalSuccess); return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } // The target player's UUID UUID targetPlayer = null; // Check if a player has an island or is in a team switch (split.length) { // /island command by itself case 0: // New island if (plugin.getPlayers().getIslandLocation(playerUUID) == null && !plugin.getPlayers().inTeam(playerUUID)) { // Check if the max number of islands is made already if (Settings.maxIslands > 0 && plugin.getGrid().getIslandCount() > Settings.maxIslands) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMaxIslands); return true; } // Create new island for player System.out.println("Choosing island"); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandnew); chooseIsland(player, Environment.NORMAL); return true; } else { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel") && plugin.getPlayers().getControlPanel(playerUUID)) { player.performCommand(Settings.ISLANDCOMMAND + " cp"); } else { if (!player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || Settings.allowTeleportWhenFalling || !PlayerEvents.isFalling(playerUUID) || (player.isOp() && !Settings.damageOps)) { // Teleport home plugin.getGrid().homeTeleport(player, player.getWorld().getEnvironment()); if (Settings.islandRemoveMobs) { plugin.getGrid().removeMobs(player.getLocation()); } } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady); } } return true; } case 1: if (split[0].equalsIgnoreCase("makenether")) { // New island if (plugin.getPlayers().hasIsland(playerUUID, Environment.NETHER) && !plugin.getPlayers().inTeam(playerUUID)) { // Check if the max number of islands is made already if (Settings.maxIslands > 0 && plugin.getGrid().getIslandCount() > Settings.maxIslands) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMaxIslands); return true; } // Create new island for player System.out.println("Choosing island"); player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandnew); chooseIsland(player, Environment.NETHER); return true; } } if (split[0].equalsIgnoreCase("name")) { // Explain command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID, player.getWorld().getEnvironment())) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " name <name>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpName); return true; } } else if (split[0].equalsIgnoreCase("resetname")) { // Convert name to a UUID if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers() .hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment())) { // Has an island plugin.getGrid().setIslandName(playerUUID, null); sender.sendMessage(plugin.myLocale().generalSuccess); } return true; } if (split[0].equalsIgnoreCase("coop")) { // Explain command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop); return true; } } else if (split[0].equalsIgnoreCase("uncoop")) { // Explain command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " uncoop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnCoop); return true; } } else if (split[0].equalsIgnoreCase("expel")) { // Explain command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " expel <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpExpel); return true; } } else if (split[0].equalsIgnoreCase("teamchat") || split[0].equalsIgnoreCase("tc")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.chat")) { // Check if this command is on or not if (!Settings.teamChat) { player.sendMessage(ChatColor.RED + plugin.myLocale().errorUnknownCommand); return false; } // Check if in team if (plugin.getPlayers().inTeam(playerUUID)) { // Check if team members are online boolean online = false; for (UUID teamMember : plugin.getPlayers().getMembers(playerUUID)) { if (!teamMember.equals(playerUUID) && plugin.getServer().getPlayer(teamMember) != null) { online = true; } } if (!online) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeamAround); player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff); plugin.getChatListener().unSetPlayer(playerUUID); return true; } if (plugin.getChatListener().isTeamChat(playerUUID)) { // Toggle player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff); plugin.getChatListener().unSetPlayer(playerUUID); } else { player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOn); plugin.getChatListener().setPlayer(playerUUID); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeam); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); } return true; } if (split[0].equalsIgnoreCase("ban")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { // Just show ban help player.sendMessage(plugin.myLocale(playerUUID).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpBan); } else { player.sendMessage(plugin.myLocale(playerUUID).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("unban") && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { // Just show unban help player.sendMessage(plugin.myLocale(playerUUID).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpUnban); } else { player.sendMessage(plugin.myLocale(playerUUID).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("make")) { //plugin.getLogger().info("DEBUG: /is make called"); if (!pendingNewIslandSelection.contains(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale().errorUnknownCommand); return false; } pendingNewIslandSelection.remove(playerUUID); Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId(), player.getWorld().getEnvironment()); newIsland(player); if (resettingIsland.contains(playerUUID)) { resettingIsland.remove(playerUUID); resetPlayer(player, oldIsland); } return true; } else if (split[0].equalsIgnoreCase("lang")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) { player.sendMessage("/" + label + " lang <#>"); displayLocales(player); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("settings")) { // Show what the plugin settings are if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) { try { player.openInventory(plugin.getSettingsPanel().islandGuardPanel(player)); } catch (Exception e) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("lock")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // plugin.getLogger().info("DEBUG: perms ok"); // Find out which island they want to lock Island island = plugin.getGrid().getIsland(playerUUID, player.getWorld().getEnvironment()); if (island == null) { // plugin.getLogger().info("DEBUG: player has no island in grid"); // Player has no island in the grid player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } else { if (!island.isLocked()) { // Remove any visitors for (Player target : plugin.getServer().getOnlinePlayers()) { // See if target is on this player's island, not a mod, no bypass, and not a coop player if (!player.equals(target) && !target.isOp() && !VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect") && plugin.getGrid().isOnIsland(player, target) && !CoopPlay.getInstance() .getCoopPlayers(island.getCenter()).contains(target.getUniqueId())) { // Send them home if (plugin.getPlayers().inTeam(target.getUniqueId()) || plugin.getPlayers().hasIsland(target.getUniqueId(), ((Player) sender).getWorld().getEnvironment())) { plugin.getGrid().homeTeleport(target, target.getWorld().getEnvironment()); } else { // Just move target to spawn if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(player.getWorld().getSpawnLocation()); } } target.sendMessage( ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled); plugin.getLogger().info(player.getName() + " expelled " + target.getName() + " from their island when locking."); // Yes they are player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess .replace("[name]", target.getDisplayName())); } } player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).lockLocking); plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked.replace("[name]", player.getDisplayName())); plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked .replace("[name]", player.getDisplayName())); island.setLocked(true); } else { player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).lockUnlocking); plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked.replace("[name]", player.getDisplayName())); plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked .replace("[name]", player.getDisplayName())); island.setLocked(false); } return true; } } else if (split[0].equalsIgnoreCase("go")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } if (!plugin.getPlayers().hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment()) && !plugin.getPlayers().inTeam(playerUUID)) { // Player has no island player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoIsland); return true; } // Teleport home plugin.getGrid().homeTeleport(player, player.getWorld().getEnvironment()); if (Settings.islandRemoveMobs) { plugin.getGrid().removeMobs(player.getLocation()); } return true; } else if (split[0].equalsIgnoreCase("about")) { player.sendMessage(ChatColor.GOLD + "This plugin is free software: you can redistribute"); player.sendMessage(ChatColor.GOLD + "it and/or modify it under the terms of the GNU"); player.sendMessage(ChatColor.GOLD + "General Public License as published by the Free"); player.sendMessage(ChatColor.GOLD + "Software Foundation, either version 3 of the License,"); player.sendMessage(ChatColor.GOLD + "or (at your option) any later version."); player.sendMessage(ChatColor.GOLD + "This plugin is distributed in the hope that it"); player.sendMessage(ChatColor.GOLD + "will be useful, but WITHOUT ANY WARRANTY; without"); player.sendMessage(ChatColor.GOLD + "even the implied warranty of MERCHANTABILITY or"); player.sendMessage(ChatColor.GOLD + "FITNESS FOR A PARTICULAR PURPOSE. See the"); player.sendMessage(ChatColor.GOLD + "GNU General Public License for more details."); player.sendMessage(ChatColor.GOLD + "You should have received a copy of the GNU"); player.sendMessage(ChatColor.GOLD + "General Public License along with this plugin."); player.sendMessage(ChatColor.GOLD + "If not, see <http://www.gnu.org/licenses/>."); player.sendMessage(ChatColor.GOLD + "Souce code is available on GitHub."); player.sendMessage(ChatColor.GOLD + "(c) 2014 - 2015 by tastybento"); return true; // Spawn enderman // Enderman enderman = (Enderman) // player.getWorld().spawnEntity(player.getLocation().add(new // Vector(5,0,5)), EntityType.ENDERMAN); // enderman.setCustomName("TastyBento's Ghost"); // enderman.setCarriedMaterial(new // MaterialData(Material.GRASS)); } if (split[0].equalsIgnoreCase("controlpanel") || split[0].equalsIgnoreCase("cp")) { // if // (player.getWorld().getName().equalsIgnoreCase(Settings.worldName)) // { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) { player.openInventory(ControlPanel.controlPanel.get(ControlPanel.getDefaultPanelName())); return true; } // } } if (split[0].equalsIgnoreCase("minishop") || split[0].equalsIgnoreCase("ms")) { if (Settings.useEconomy && Settings.useMinishop) { // Check island if (plugin.getGrid().getIsland(player.getUniqueId(), player.getWorld().getEnvironment()) == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } if (player.getWorld().equals(ASkyBlock.getIslandWorld()) || player.getWorld().equals(ASkyBlock.getNetherWorld())) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) { player.openInventory(ControlPanel.miniShop); return true; } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld); return true; } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMinishopDisabled); } } // /island <command> if (split[0].equalsIgnoreCase("warp")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { player.sendMessage(ChatColor.YELLOW + "/island warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp); return true; } } else if (split[0].equalsIgnoreCase("warps")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { // Step through warp table Collection<UUID> warpList = plugin.getWarpSignsListener().listWarps(); if (warpList.isEmpty()) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } return true; } else { if (Settings.useWarpPanel) { // Try the warp panel player.openInventory(plugin.getWarpPanel().getWarpPanel(0)); } else { Boolean hasWarp = false; String wlist = ""; for (UUID w : warpList) { if (wlist.isEmpty()) { wlist = plugin.getPlayers().getName(w); } else { wlist += ", " + plugin.getPlayers().getName(w); } if (w.equals(playerUUID)) { hasWarp = true; } } player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpswarpsAvailable + ": " + ChatColor.WHITE + wlist); if (!hasWarp && (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp"))) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } } return true; } } } else if (split[0].equalsIgnoreCase("startnether")) { return tryClaimNew(player, Environment.NETHER); } else if (split[0].equalsIgnoreCase("gonether")) { } else if (split[0].equalsIgnoreCase("restart") || split[0].equalsIgnoreCase("reset")) { return tryClaimNew(player, Environment.NORMAL); } else if (split[0].equalsIgnoreCase("confirm")) { // This is where the actual reset is done if (confirm.containsKey(playerUUID) && confirm.get(playerUUID)) { confirm.remove(playerUUID); // Actually RESET the island player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetPleaseWait); if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandResetNoMore); } if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).resetYouHave.replace( "[number]", String.valueOf(plugin.getPlayers().getResetsLeft(playerUUID)))); } // Show a schematic panel if the player has a choice // Get the schematics that this player is eligible to use List<Schematic> schems = getSchematics(player, false); //plugin.getLogger().info("DEBUG: size of schematics for this player = " + schems.size()); Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId(), player.getWorld().getEnvironment()); if (schems.isEmpty()) { // No schematics - use default island newIsland(player); resetPlayer(player, oldIsland); } else if (schems.size() == 1) { // Hobson's choice newIsland(player, schems.get(0)); resetPlayer(player, oldIsland); } else { // A panel can only be shown if there is >1 viable schematic if (Settings.useSchematicPanel) { pendingNewIslandSelection.add(playerUUID); resettingIsland.add(playerUUID); player.openInventory(plugin.getSchematicsPanel().getPanel(player)); } else { // No panel // Check schematics for specific permission schems = getSchematics(player, true); if (schems.isEmpty()) { newIsland(player); } else if (Settings.chooseIslandRandomly) { // Choose an island randomly from the list newIsland(player, schems.get(random.nextInt(schems.size()))); } else { // Do the first one in the list newIsland(player, schems.get(0)); } resetPlayer(player, oldIsland); } } return true; } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/island restart: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart); return true; } } else if (split[0].equalsIgnoreCase("sethome")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { // Check island if (plugin.getGrid().getIsland(player.getUniqueId(), player.getWorld().getEnvironment()) == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } plugin.getGrid().homeSet(player); return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("help")) { player.sendMessage( ChatColor.GREEN + plugin.getName() + " " + plugin.getDescription().getVersion() + " help:"); if (Settings.useControlPanel) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpIsland); } // Dynamic home sizes with permissions int maxHomes = Settings.maxHomes; for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) { if (perms.getPermission().contains(Settings.PERMPREFIX + "island.maxhomes.*")) { maxHomes = Settings.maxHomes; break; } else { // Get the max value should there be more than one String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.maxhomes."); if (spl.length > 1) { maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (maxHomes < 1) { maxHomes = 1; } } if (maxHomes > 1 && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport); } if (plugin.getGrid() != null && plugin.getGrid().getSpawn() != null) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " spawn: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSpawn); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " controlpanel or cp [on/off]: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel); } player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " restart: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { if (maxHomes > 1) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome); } } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevel); player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevelPlayer); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers() .hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment())) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " name <name>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpName); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " top: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTop); } if (Settings.useEconomy && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " minishop or ms: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMiniShop); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warps: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarps); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " team: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeam); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " invite <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpInvite); player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " leave: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLeave); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " kick <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpKick); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " <accept/reject>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpAcceptReject); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " makeleader <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMakeLeader); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.chat") && plugin.getPlayers().inTeam(playerUUID)) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " teamchat: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).teamChatHelp); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " biomes: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBiome); } // if (!Settings.allowPvP) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " expel <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpExpel); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBan); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnban); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " uncoop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnCoop); player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " listcoops: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpListCoops); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lock: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpLock); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers() .hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment())) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " resetname: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpResetName); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " settings: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSettings); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.challenges")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + plugin.myLocale(player.getUniqueId()).islandHelpChallenges); } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lang <#>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSelectLanguage); } return true; } else if (split[0].equalsIgnoreCase("listcoops")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { Island island = plugin.getGrid().getIsland(playerUUID, player.getWorld().getEnvironment()); boolean none = true; for (UUID uuid : CoopPlay.getInstance().getCoopPlayers(island.getCenter())) { player.sendMessage(ChatColor.GREEN + plugin.getPlayers().getName(uuid)); none = false; } if (none) { player.sendMessage( plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop); } else { player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + plugin.myLocale(playerUUID).coopUseExpel); } return true; } } else if (split[0].equalsIgnoreCase("biomes")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) { // Only the team leader can do this if (teamLeader != null && !teamLeader.equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).levelerrornotYourIsland); return true; } if (!plugin.getPlayers().hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment())) { // Player has no island player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } if (!plugin.getGrid().playerIsOnIsland(player)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland); return true; } // Not allowed in the nether if (plugin.getPlayers().getIslandLocation(playerUUID).getWorld().getEnvironment() .equals(Environment.NETHER)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld); return true; } // player.sendMessage(plugin.myLocale(player.getUniqueId()).helpColor + "[Biomes]"); Inventory inv = plugin.getBiomes().getBiomePanel(player); if (inv != null) { player.openInventory(inv); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("spawn") && plugin.getGrid().getSpawn() != null) { // go to spawn Location l = ASkyBlock.getIslandWorld().getSpawnLocation(); l.add(new Vector(0.5, 0, 0.5)); Island spawn = plugin.getGrid().getSpawn(); if (spawn != null && spawn.getSpawnPoint() != null) { l = spawn.getSpawnPoint(); } player.teleport(l); return true; } else if (split[0].equalsIgnoreCase("top")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) { TopTen.topTenShow(player); return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("level")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) { if (!plugin.getPlayers().inTeam(playerUUID) && !plugin.getPlayers().hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment())) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } else { if (Settings.fastLevelCalc) { calculateIslandLevel(player, playerUUID); return true; } else { // Legacy - forces player to be on island to reduce frivolous calculations if (plugin.getGrid().playerIsOnIsland(player)) { calculateIslandLevel(player, playerUUID); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland); } return true; } } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("invite")) { // Invite label with no name, i.e., /island invite - tells the // player how many more people they can invite if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) { player.sendMessage(plugin.myLocale(player.getUniqueId()).invitehelp); // If the player who is doing the inviting has a team if (plugin.getPlayers().inTeam(playerUUID)) { // Check to see if the player is the leader if (teamLeader.equals(playerUUID)) { // Check to see if the team is already full int maxSize = Settings.maxTeamSize; // Dynamic team sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) { if (perms.getPermission().contains(Settings.PERMPREFIX + "team.maxsize.*")) { maxSize = Settings.maxTeamSize; break; } else { // Get the max value should there be more than one String[] spl = perms.getPermission() .split(Settings.PERMPREFIX + "team.maxsize."); if (spl.length > 1) { maxSize = Math.max(maxSize, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (maxSize < 1) { maxSize = 1; } } // Account for deprecated permissions. These will be zero on new installs // This avoids these permissions breaking on upgrades if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.vip")) { if (Settings.maxTeamSizeVIP > maxSize) { maxSize = Settings.maxTeamSizeVIP; } } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.vip2")) { if (Settings.maxTeamSizeVIP2 > maxSize) { maxSize = Settings.maxTeamSizeVIP2; } } if (teamMembers.size() < maxSize) { player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite .replace("[number]", String.valueOf(maxSize - teamMembers.size()))); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull); } return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); return true; } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("accept")) { // Accept an invite command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) { // If player is not in a team but has been invited to join // one if (!plugin.getPlayers().inTeam(playerUUID) && inviteList.containsKey(playerUUID)) { // If the invitee has an island of their own if (plugin.getPlayers().hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment())) { plugin.getLogger().info( player.getName() + "'s island will be deleted because they joined a party."); plugin.deletePlayerIsland(playerUUID, true, player.getWorld().getEnvironment()); plugin.getLogger().info("Island deleted."); } // Add the player to the team addPlayertoTeam(playerUUID, inviteList.get(playerUUID)); // If the leader who did the invite does not yet have a // team (leader is not in a team yet) if (!plugin.getPlayers().inTeam(inviteList.get(playerUUID))) { // Add the leader to their own team addPlayertoTeam(inviteList.get(playerUUID), inviteList.get(playerUUID)); } setResetWaitTime(player); if (Settings.teamJoinDeathReset) { plugin.getPlayers().setDeaths(player.getUniqueId(), 0); } plugin.getGrid().homeTeleport(player, player.getWorld().getEnvironment()); plugin.resetPlayer(player); if (!player.hasPermission(Settings.PERMPREFIX + "command.newteamexempt")) { //plugin.getLogger().info("DEBUG: Executing new island commands"); runCommands(Settings.teamStartCommands, player); } player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouHaveJoinedAnIsland); if (Bukkit.getPlayer(inviteList.get(playerUUID)) != null) { Bukkit.getPlayer(inviteList.get(playerUUID)) .sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).invitehasJoinedYourIsland .replace("[name]", player.getName())); } // Remove the invite inviteList.remove(player.getUniqueId()); plugin.getGrid().saveGrid(); return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady); return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("reject")) { // Reject /island reject if (inviteList.containsKey(player.getUniqueId())) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).rejectyouHaveRejectedInvitation); // If the player is online still then tell them directly // about the rejection if (Bukkit.getPlayer(inviteList.get(player.getUniqueId())) != null) { Bukkit.getPlayer(inviteList.get(player.getUniqueId())).sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).rejectnameHasRejectedInvite .replace("[name]", player.getName())); } // Remove this player from the global invite list inviteList.remove(player.getUniqueId()); } else { // Someone typed /island reject and had not been invited player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).rejectyouHaveNotBeenInvited); } return true; } else if (split[0].equalsIgnoreCase("leave")) { // Leave team command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) { if (player.getWorld().equals(ASkyBlock.getIslandWorld()) || (Settings.createNether && Settings.newNether && ASkyBlock.getNetherWorld() != null && player.getWorld().equals(ASkyBlock.getNetherWorld()))) { if (plugin.getPlayers().inTeam(playerUUID)) { if (plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveerrorYouAreTheLeader); return true; } // Clear any coop inventories // CoopPlay.getInstance().returnAllInventories(player); // Remove any of the target's coop invitees and grab // their stuff CoopPlay.getInstance().clearMyInvitedCoops(player); CoopPlay.getInstance().clearMyCoops(player); // Log the location that this player left so they // cannot join again before the cool down ends plugin.getPlayers().startInviteCoolDownTimer(playerUUID, plugin.getPlayers().getTeamIslandLocation(teamLeader)); // Remove from team removePlayerFromTeam(playerUUID, teamLeader); // Remove any warps plugin.getWarpSignsListener().removeWarp(playerUUID); player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveyouHaveLeftTheIsland); // Tell the leader if they are online if (plugin.getServer().getPlayer(teamLeader) != null) { plugin.getServer().getPlayer(teamLeader).sendMessage( ChatColor.RED + plugin.myLocale(teamLeader).leavenameHasLeftYourIsland .replace("[name]", player.getName())); } else { // Leave them a message plugin.getMessages().setMessage(teamLeader, ChatColor.RED + plugin.myLocale(teamLeader).leavenameHasLeftYourIsland .replace("[name]", player.getName())); } // Check if the size of the team is now 1 // teamMembers.remove(playerUUID); if (teamMembers.size() < 2) { // plugin.getLogger().info("DEBUG: Party is less than 2 - removing leader from team"); removePlayerFromTeam(teamLeader, teamLeader); } // Clear all player variables and save plugin.resetPlayer(player); if (!player.performCommand(Settings.SPAWNCOMMAND)) { player.teleport(player.getWorld().getSpawnLocation()); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorYouCannotLeaveIsland); return true; } } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorYouMustBeInWorld); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("team")) { if (plugin.getPlayers().inTeam(playerUUID)) { if (teamLeader.equals(playerUUID)) { int maxSize = Settings.maxTeamSize; for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) { if (perms.getPermission().contains(Settings.PERMPREFIX + "team.maxsize.*")) { maxSize = Settings.maxTeamSize; break; } else { // Get the max value should there be more than one String[] spl = perms.getPermission() .split(Settings.PERMPREFIX + "team.maxsize."); if (spl.length > 1) { maxSize = Math.max(maxSize, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (maxSize < 1) { maxSize = 1; } } if (teamMembers.size() < maxSize) { player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite .replace("[number]", String.valueOf(maxSize - teamMembers.size()))); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull); } } player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).teamlistingMembers + ":"); // Display members in the list for (UUID m : plugin.getPlayers().getMembers(teamLeader)) { player.sendMessage(ChatColor.WHITE + plugin.getPlayers().getName(m)); } } else if (inviteList.containsKey(playerUUID)) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitenameHasInvitedYou .replace("[name]", plugin.getPlayers().getName(inviteList.get(playerUUID)))); player.sendMessage(ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitetoAcceptOrReject); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam); } return true; } else { // Incorrect syntax player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand); return true; } /* * Commands that have two parameters */ case 2: if (split[0].equalsIgnoreCase("controlpanel") || split[0].equalsIgnoreCase("cp")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) { if (split[1].equalsIgnoreCase("on")) { plugin.getPlayers().setControlPanel(playerUUID, true); } else if (split[1].equalsIgnoreCase("off")) { plugin.getPlayers().setControlPanel(playerUUID, false); } player.sendMessage(ChatColor.GREEN + plugin.myLocale(playerUUID).generalSuccess); return true; } else { player.sendMessage(plugin.myLocale(playerUUID).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("warps")) { if (Settings.useWarpPanel) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { // Step through warp table Set<UUID> warpList = plugin.getWarpSignsListener().listWarps(); if (warpList.isEmpty()) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } return true; } else { // Try the warp panel int panelNum = 0; try { panelNum = Integer.valueOf(split[1]) - 1; } catch (Exception e) { panelNum = 0; } player.openInventory(plugin.getWarpPanel().getWarpPanel(panelNum)); return true; } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand); return true; } } else if (split[0].equalsIgnoreCase("make")) { //plugin.getLogger().info("DEBUG: /is make '" + split[1] + "' called"); if (!pendingNewIslandSelection.contains(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand); return true; } pendingNewIslandSelection.remove(playerUUID); // Create a new island using schematic if (!schematics.containsKey(split[1])) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand); return true; } else { Schematic schematic = schematics.get(split[1]); // Check perm again if (schematic.getPerm().isEmpty() || VaultHelper.checkPerm(player, schematic.getPerm())) { Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId(), player.getWorld().getEnvironment()); newIsland(player, schematic); if (resettingIsland.contains(playerUUID)) { resettingIsland.remove(playerUUID); resetPlayer(player, oldIsland); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } } else if (split[0].equalsIgnoreCase("lang")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) { if (!NumberUtils.isDigits(split[1])) { player.sendMessage(ChatColor.RED + "/" + label + " lang <#>"); displayLocales(player); return true; } else { try { int index = Integer.valueOf(split[1]); if (index < 1 || index > plugin.getAvailableLocales().size()) { player.sendMessage(ChatColor.RED + "/" + label + " lang <#>"); displayLocales(player); return true; } for (ASLocale locale : plugin.getAvailableLocales().values()) { if (locale.getIndex() == index) { plugin.getPlayers().setLocale(playerUUID, locale.getLocaleName()); player.sendMessage( ChatColor.GREEN + plugin.myLocale(playerUUID).generalSuccess); return true; } } // Not in the list player.sendMessage(ChatColor.RED + "/" + label + " lang <#>"); displayLocales(player); } catch (Exception e) { player.sendMessage(ChatColor.RED + "/" + label + " lang <#>"); displayLocales(player); } } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission); return true; } } else // Multi home if (split[0].equalsIgnoreCase("go")) { if (!plugin.getPlayers().hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment()) && !plugin.getPlayers().inTeam(playerUUID)) { // Player has no island player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { int number = 1; try { number = Integer.valueOf(split[1]); //plugin.getLogger().info("DEBUG: number = " + number); if (number < 1) { plugin.getGrid().homeTeleport(player, 1, player.getWorld().getEnvironment()); } else { // Dynamic home sizes with permissions int maxHomes = Settings.maxHomes; for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) { if (perms.getPermission().contains(Settings.PERMPREFIX + "island.maxhomes.*")) { maxHomes = Settings.maxHomes; break; } else { // Get the max value should there be more than one String[] spl = perms.getPermission() .split(Settings.PERMPREFIX + "island.maxhomes."); if (spl.length > 1) { maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (maxHomes < 1) { maxHomes = 1; } } if (number > maxHomes) { if (maxHomes > 1) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes .replace("[max]", String.valueOf(maxHomes))); } else { plugin.getGrid().homeTeleport(player, 1, player.getWorld().getEnvironment()); } } else { // Teleport home plugin.getGrid().homeTeleport(player, number, player.getWorld().getEnvironment()); } } } catch (Exception e) { // Teleport home plugin.getGrid().homeTeleport(player, 1, player.getWorld().getEnvironment()); } if (Settings.islandRemoveMobs) { plugin.getGrid().removeMobs(player.getLocation()); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } else if (split[0].equalsIgnoreCase("sethome")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) { Island island = plugin.getGrid().getIsland(playerUUID, player.getWorld().getEnvironment()); if (island == null) { // plugin.getLogger().info("DEBUG: player has no island in grid"); // Player has no island in the grid player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); return true; } // Dynamic home sizes with permissions int maxHomes = Settings.maxHomes; for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) { // Get the max value should there be more than one if (perms.getPermission().contains(Settings.PERMPREFIX + "island.maxhomes.*")) { maxHomes = Settings.maxHomes; break; } else { String[] spl = perms.getPermission() .split(Settings.PERMPREFIX + "island.maxhomes."); if (spl.length > 1) { maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (maxHomes < 1) { maxHomes = 1; } } if (maxHomes > 1) { // Check the number given is a number int number = 0; try { number = Integer.valueOf(split[1]); if (number < 1 || number > maxHomes) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes .replace("[max]", String.valueOf(maxHomes))); } else { plugin.getGrid().homeSet(player, number); } } catch (Exception e) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes .replace("[max]", String.valueOf(maxHomes))); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } else if (split[0].equalsIgnoreCase("warp")) { // Warp somewhere command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) { final Set<UUID> warpList = plugin.getWarpSignsListener().listWarps(); if (warpList.isEmpty()) { player.sendMessage( ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet); if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp")) { player.sendMessage(ChatColor.YELLOW + plugin.myLocale().warpswarpTip); } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); } return true; } else { // Check if this is part of a name UUID foundWarp = null; for (UUID warp : warpList) { if (plugin.getPlayers().getName(warp).toLowerCase().equals(split[1].toLowerCase())) { foundWarp = warp; break; } else if (plugin.getPlayers().getName(warp).toLowerCase() .startsWith(split[1].toLowerCase())) { foundWarp = warp; } } if (foundWarp == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist); return true; } else { // Warp exists! final Location warpSpot = plugin.getWarpSignsListener().getWarp(foundWarp); // Check if the warp spot is safe if (warpSpot == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotReadyYet); plugin.getLogger().warning( "Null warp found, owned by " + plugin.getPlayers().getName(foundWarp)); return true; } // Find out if island is locked Island island = plugin.getGrid().getIslandAt(warpSpot); // Check bans if (island != null && plugin.getPlayers().isBanned(island.getOwner(), playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).banBanned .replace("[name]", plugin.getPlayers().getName(island.getOwner()))); if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypasslock")) { return true; } } if (island != null && island.isLocked() && !player.isOp() && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypasslock") && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { // Always inform that the island is locked player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).lockIslandLocked); // Check if this is the owner, team member or coop if (!plugin.getGrid().locationIsAtHome(player, true, warpSpot)) { //plugin.getLogger().info("DEBUG: not at home"); return true; } } boolean pvp = false; if ((warpSpot.getWorld().equals(ASkyBlock.getIslandWorld()) && island.getIgsFlag(Flags.allowPvP)) || (warpSpot.getWorld().equals(ASkyBlock.getNetherWorld()) && island.getIgsFlag(Flags.allowNetherPvP))) { pvp = true; } // Find out which direction the warp is facing Block b = warpSpot.getBlock(); if (b.getType().equals(Material.SIGN_POST) || b.getType().equals(Material.WALL_SIGN)) { Sign sign = (Sign) b.getState(); org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData(); BlockFace directionFacing = s.getFacing(); Location inFront = b.getRelative(directionFacing).getLocation(); Location oneDown = b.getRelative(directionFacing).getRelative(BlockFace.DOWN) .getLocation(); if ((GridManager.isSafeLocation(inFront))) { warpPlayer(player, inFront, foundWarp, directionFacing, pvp); return true; } else if (b.getType().equals(Material.WALL_SIGN) && GridManager.isSafeLocation(oneDown)) { // Try one block down if this is a wall sign warpPlayer(player, oneDown, foundWarp, directionFacing, pvp); return true; } } else { // Warp has been removed player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist); plugin.getWarpSignsListener().removeWarp(warpSpot); return true; } if (!(GridManager.isSafeLocation(warpSpot))) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotSafe); // WALL_SIGN's will always be unsafe if the place in front is obscured. if (b.getType().equals(Material.SIGN_POST)) { plugin.getLogger().warning("Unsafe warp found at " + warpSpot.toString() + " owned by " + plugin.getPlayers().getName(foundWarp)); } return true; } else { final Location actualWarp = new Location(warpSpot.getWorld(), warpSpot.getBlockX() + 0.5D, warpSpot.getBlockY(), warpSpot.getBlockZ() + 0.5D); player.teleport(actualWarp); if (pvp) { player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + plugin.myLocale(player.getUniqueId()).igsPVP + " " + plugin.myLocale(player.getUniqueId()).igsAllowed); if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) { player.getWorld().playSound(player.getLocation(), Sound.valueOf("ARROW_HIT"), 1F, 1F); } else { player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F); } } else { if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) { player.getWorld().playSound(player.getLocation(), Sound.valueOf("BAT_TAKEOFF"), 1F, 1F); } else { player.getWorld().playSound(player.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F); } } return true; } } } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("level")) { // island level <name> command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) { // Find out if the target has an island final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Invited player must be known if (targetPlayerUUID == null) { // plugin.getLogger().info("DEBUG: unknown player"); player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Check if this player has an island or not if (plugin.getPlayers().hasIsland(targetPlayerUUID, ((Player) sender).getWorld().getEnvironment()) || plugin.getPlayers().inTeam(targetPlayerUUID)) { calculateIslandLevel(player, targetPlayerUUID); } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("invite")) { // Team invite a player command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) { // Only online players can be invited Player invitedPlayer = plugin.getServer().getPlayer(split[1]); if (invitedPlayer == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer); return true; } UUID invitedPlayerUUID = invitedPlayer.getUniqueId(); // Player issuing the command must have an island if (!plugin.getPlayers().hasIsland(player.getUniqueId(), ((Player) sender).getWorld().getEnvironment())) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); return true; } // Player cannot invite themselves if (player.getName().equalsIgnoreCase(split[1])) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouCannotInviteYourself); return true; } // Check if this player can be invited to this island, or // whether they are still on cooldown long time = plugin.getPlayers().getInviteCoolDownTime(invitedPlayerUUID, plugin.getPlayers().getIslandLocation(playerUUID)); if (time > 0 && !player.isOp()) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorCoolDown .replace("[time]", String.valueOf(time))); return true; } // If the player already has a team then check that they are // the leader, etc if (plugin.getPlayers().inTeam(player.getUniqueId())) { // Leader? if (teamLeader.equals(player.getUniqueId())) { // Invited player is free and not in a team if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) { // Player has space in their team int maxSize = Settings.maxTeamSize; // Dynamic team sizes with permissions for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) { if (perms.getPermission() .contains(Settings.PERMPREFIX + "team.maxsize.*")) { maxSize = Settings.maxTeamSize; break; } else { // Get the max value should there be more than one String[] spl = perms.getPermission() .split(Settings.PERMPREFIX + "team.maxsize."); if (spl.length > 1) { maxSize = Math.max(maxSize, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (maxSize < 1) { maxSize = 1; } } if (teamMembers.size() < maxSize) { // If that player already has an invite out // then retract it. // Players can only have one invite out at a // time - interesting if (inviteList.containsValue(playerUUID)) { inviteList.remove(getKeyByValue(inviteList, player.getUniqueId())); player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite); } // Put the invited player (key) onto the // list with inviter (value) // If someone else has invited a player, // then this invite will overwrite the // previous invite! inviteList.put(invitedPlayerUUID, player.getUniqueId()); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo .replace("[name]", split[1])); // Send message to online player Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou .replace("[name]", player.getName())); Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject); if (plugin.getPlayers().hasIsland(invitedPlayerUUID, ((Player) sender).getWorld().getEnvironment())) { Bukkit.getPlayer(invitedPlayerUUID).sendMessage(ChatColor.RED + plugin .myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull); } } else { player.sendMessage(ChatColor.RED + plugin .myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); } } else { // First-time invite player does not have a team // Check if invitee is in a team or not if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) { // If the inviter already has an invite out, remove // it if (inviteList.containsValue(playerUUID)) { inviteList.remove(getKeyByValue(inviteList, player.getUniqueId())); player.sendMessage(ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite); } // Place the player and invitee on the invite list inviteList.put(invitedPlayerUUID, player.getUniqueId()); player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo .replace("[name]", split[1])); Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou .replace("[name]", player.getName())); Bukkit.getPlayer(invitedPlayerUUID) .sendMessage(ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject); // Check if the player has an island and warn // accordingly // plugin.getLogger().info("DEBUG: invited player = " // + invitedPlayerUUID.toString()); if (plugin.getPlayers().hasIsland(invitedPlayerUUID, ((Player) sender).getWorld().getEnvironment())) { // plugin.getLogger().info("DEBUG: invited player has island"); Bukkit.getPlayer(invitedPlayerUUID).sendMessage(ChatColor.RED + plugin.myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland); } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam); } } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("coop")) { // Give a player coop privileges if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Only online players can be cooped Player target = plugin.getServer().getPlayer(split[1]); if (target == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer); return true; } UUID targetPlayerUUID = target.getUniqueId(); // Player issuing the command must have an island if (!plugin.getPlayers().hasIsland(playerUUID, ((Player) sender).getWorld().getEnvironment()) && !plugin.getPlayers().inTeam(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite); return true; } // Player cannot invite themselves if (playerUUID.equals(targetPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouCannotInviteYourself); return true; } // If target player is already on the team ignore if (plugin.getPlayers().getMembers(playerUUID).contains(targetPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).coopOnYourTeam); return true; } // Target has to have an island if (!plugin.getPlayers().inTeam(targetPlayerUUID)) { if (!plugin.getPlayers().hasIsland(targetPlayerUUID, ((Player) sender).getWorld().getEnvironment())) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther); return true; } } // Add target to coop list CoopPlay.getInstance().addCoopPlayer(player, target); // Tell everyone what happened player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopSuccess .replace("[name]", target.getDisplayName())); target.sendMessage(ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).coopMadeYouCoop .replace("[name]", player.getDisplayName())); return true; } else if (split[0].equalsIgnoreCase("expel")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to expel UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotYourself); return true; } // Target cannot be op Player target = plugin.getServer().getPlayer(targetPlayerUUID); if (target != null) { if (target.isOp() || VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect") || VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassexpel")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelFail .replace("[name]", target.getDisplayName())); return true; } } // Remove them from the coop list boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, targetPlayerUUID); if (coop) { if (target != null) { target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved .replace("[name]", player.getDisplayName())); } else { plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).coopRemoved.replace("[name]", player.getDisplayName())); } player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess .replace("[name]", plugin.getPlayers().getName(targetPlayerUUID))); } // See if target is on this player's island if (target != null && plugin.getGrid().isOnIsland(player, target)) { // Check to see if this player has an island or is just // helping out if (plugin.getPlayers().inTeam(targetPlayerUUID) || plugin.getPlayers() .hasIsland(targetPlayerUUID, ((Player) sender).getWorld().getEnvironment())) { plugin.getGrid().homeTeleport(target, target.getWorld().getEnvironment()); } else { // Just move target to spawn if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(player.getWorld().getSpawnLocation()); /* * target.sendBlockChange(target.getWorld(). * getSpawnLocation() * ,target.getWorld().getSpawnLocation().getBlock(). * getType() * ,target.getWorld().getSpawnLocation().getBlock(). * getData()); */ } } target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled); plugin.getLogger() .info(player.getName() + " expelled " + target.getName() + " from their island."); // Yes they are player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess .replace("[name]", target.getDisplayName())); } else if (!coop) { // No they're not player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotOnIsland); } return true; } else if (split[0].equalsIgnoreCase("uncoop")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to uncoop UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotYourself); return true; } OfflinePlayer target = plugin.getServer().getOfflinePlayer(targetPlayerUUID); // Remove them from the coop list boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, targetPlayerUUID); if (coop) { if (target != null && target.isOnline()) { target.getPlayer() .sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved .replace("[name]", player.getDisplayName())); } else { plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).coopRemoved.replace("[name]", player.getDisplayName())); } player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess .replace("[name]", plugin.getPlayers().getName(targetPlayerUUID))); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).coopNotInCoop .replace("[name]", plugin.getPlayers().getName(targetPlayerUUID))); } return true; } else if (split[0].equalsIgnoreCase("ban")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to ban final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Player must be known if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself); return true; } // Target cannot be on the same team if (plugin.getPlayers().inTeam(playerUUID) && plugin.getPlayers().inTeam(targetPlayerUUID)) { if (plugin.getPlayers().getTeamLeader(playerUUID) .equals(plugin.getPlayers().getTeamLeader(targetPlayerUUID))) { // Same team! player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotTeamMember); return true; } } // Check that the player is not banned already if (plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).banAlreadyBanned.replace("[name]", split[1])); return true; } // Check online/offline status Player target = plugin.getServer().getPlayer(targetPlayerUUID); // Get offline player OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID); // Target cannot be op if (offlineTarget.isOp()) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banFail.replace("[name]", split[1])); return true; } if (target != null) { // Remove them from the coop list boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, target); if (coop) { target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved .replace("[name]", player.getDisplayName())); player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess .replace("[name]", target.getDisplayName())); } // See if target is on this player's island and if so send them away if (plugin.getGrid().isOnIsland(player, target)) { // Check to see if this player has an island or is just // helping out if (plugin.getPlayers().inTeam(targetPlayerUUID) || plugin.getPlayers() .hasIsland(targetPlayerUUID, ((Player) sender).getWorld().getEnvironment())) { plugin.getGrid().homeTeleport(target, target.getWorld().getEnvironment()); } else { // Just move target to spawn if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(player.getWorld().getSpawnLocation()); } } } // Notifications // Target target.sendMessage(ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getDisplayName())); } else { // Offline notification plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getDisplayName())); } // Console plugin.getLogger().info(player.getName() + " banned " + split[1] + " from their island."); // Player player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", split[1])); // Tell team plugin.getMessages().tellTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", split[1])); plugin.getMessages().tellOfflineTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", split[1])); // Ban the sucker plugin.getPlayers().ban(playerUUID, targetPlayerUUID); plugin.getGrid().saveGrid(); return true; } else if (split[0].equalsIgnoreCase("unban")) { if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } // Find out who they want to unban final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]); // Player must be known if (targetPlayerUUID == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } // Target should not be themselves if (targetPlayerUUID.equals(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself); return true; } // Check that the player is actually banned if (!plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotBanned.replace("[name]", split[1])); return true; } // Notifications // Online check Player target = plugin.getServer().getPlayer(targetPlayerUUID); // Target if (target != null) { // Online target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).banLifted .replace("[name]", player.getDisplayName())); } else { plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).banLifted.replace("[name]", player.getDisplayName())); } //OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID); // Player player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", split[1])); // Console plugin.getLogger().info(player.getName() + " unbanned " + split[1] + " from their island."); // Tell team plugin.getMessages().tellTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", split[1])); plugin.getMessages().tellOfflineTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", split[1])); // Unban the redeemed one plugin.getPlayers().unBan(playerUUID, targetPlayerUUID); plugin.getGrid().saveGrid(); return true; } else if (split[0].equalsIgnoreCase("kick") || split[0].equalsIgnoreCase("remove")) { // PlayerIsland remove command with a player name, or island kick // command if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) { if (!plugin.getPlayers().inTeam(playerUUID)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam); return true; } // Only leaders can kick if (teamLeader != null && !teamLeader.equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorOnlyLeaderCan); return true; } // The main thing to do is check if the player name to kick // is in the list of players in the team. targetPlayer = null; for (UUID member : teamMembers) { if (plugin.getPlayers().getName(member).equalsIgnoreCase(split[1])) { targetPlayer = member; } } if (targetPlayer == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam); return true; } if (teamMembers.contains(targetPlayer)) { // If the player leader tries to kick or remove // themselves if (player.getUniqueId().equals(targetPlayer)) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorLeadersCannotLeave); return true; } // If target is online Player target = plugin.getServer().getPlayer(targetPlayer); if (target != null) { // plugin.getLogger().info("DEBUG: player is online"); target.sendMessage(ChatColor.RED + plugin.myLocale(targetPlayer).kicknameRemovedYou .replace("[name]", player.getName())); // Log the location that this player left so they // cannot join again before the cool down ends plugin.getPlayers().startInviteCoolDownTimer(targetPlayer, plugin.getPlayers().getIslandLocation(playerUUID)); // Clear any coop inventories // CoopPlay.getInstance().returnAllInventories(target); // Remove any of the target's coop invitees and // anyone they invited CoopPlay.getInstance().clearMyInvitedCoops(target); CoopPlay.getInstance().clearMyCoops(target); // Clear the player out and throw their stuff at the // leader if (target.getWorld().equals(ASkyBlock.getIslandWorld())) { for (ItemStack i : target.getInventory().getContents()) { if (i != null) { try { // Fire an event to see if this item should be dropped or not // Some plugins may not want items to be dropped Item drop = player.getWorld().dropItemNaturally(player.getLocation(), i); PlayerDropItemEvent event = new PlayerDropItemEvent(target, drop); plugin.getServer().getPluginManager().callEvent(event); } catch (Exception e) { } } } // plugin.resetPlayer(target); <- no good if // reset inventory is false // Clear their inventory and equipment and set // them as survival target.getInventory().clear(); // Javadocs are // wrong - this // does not // clear armor slots! So... // plugin.getLogger().info("DEBUG: Clearing kicked player's inventory"); target.getInventory().setArmorContents(null); target.getInventory().setHelmet(null); target.getInventory().setChestplate(null); target.getInventory().setLeggings(null); target.getInventory().setBoots(null); target.getEquipment().clear(); if (Settings.resetChallenges) { // Reset the player's challenge status plugin.getPlayers().resetAllChallenges(target.getUniqueId(), false); } // Reset the island level plugin.getPlayers().setIslandLevel(target.getUniqueId(), 0); plugin.getPlayers().save(target.getUniqueId()); TopTen.topTenAddEntry(playerUUID, 0); // Update the inventory target.updateInventory(); } if (!target.performCommand(Settings.SPAWNCOMMAND)) { target.teleport(ASkyBlock.getIslandWorld().getSpawnLocation()); } } else { // Offline // plugin.getLogger().info("DEBUG: player is offline " // + targetPlayer.toString()); // Tell offline player they were kicked plugin.getMessages().setMessage(targetPlayer, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemovedYou .replace("[name]", player.getName())); } // Remove any warps plugin.getWarpSignsListener().removeWarp(targetPlayer); // Tell leader they removed the player player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemoved .replace("[name]", split[1])); removePlayerFromTeam(targetPlayer, teamLeader); teamMembers.remove(targetPlayer); if (teamMembers.size() < 2) { removePlayerFromTeam(player.getUniqueId(), teamLeader); } plugin.getPlayers().save(targetPlayer); } else { plugin.getLogger().warning("Player " + player.getName() + " failed to remove " + plugin.getPlayers().getName(targetPlayer)); player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else if (split[0].equalsIgnoreCase("makeleader")) { if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) { targetPlayer = plugin.getPlayers().getUUID(split[1]); if (targetPlayer == null) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer); return true; } if (targetPlayer.equals(playerUUID)) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError); return true; } if (!plugin.getPlayers().inTeam(player.getUniqueId())) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorYouMustBeInTeam); return true; } if (plugin.getPlayers().getMembers(player.getUniqueId()).size() > 2) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorRemoveAllPlayersFirst); plugin.getLogger().info(player.getName() + " tried to transfer his island, but failed because >2 people in a team"); return true; } if (plugin.getPlayers().inTeam(player.getUniqueId())) { if (teamLeader.equals(player.getUniqueId())) { if (teamMembers.contains(targetPlayer)) { // Check if online if (plugin.getServer().getPlayer(targetPlayer) != null) { plugin.getServer().getPlayer(targetPlayer).sendMessage(ChatColor.GREEN + plugin.myLocale(targetPlayer).makeLeaderyouAreNowTheOwner); } else { plugin.getMessages().setMessage(targetPlayer, plugin.myLocale(player.getUniqueId()).makeLeaderyouAreNowTheOwner); // .makeLeadererrorPlayerMustBeOnline } player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).makeLeadernameIsNowTheOwner .replace("[name]", plugin.getPlayers().getName(targetPlayer))); // targetPlayer is the new leader // plugin.getLogger().info("DEBUG: " + // plugin.getPlayers().getIslandLevel(teamLeader)); // Remove the target player from the team removePlayerFromTeam(targetPlayer, teamLeader); // Remove the leader from the team removePlayerFromTeam(teamLeader, teamLeader); // plugin.getLogger().info("DEBUG: " + // plugin.getPlayers().getIslandLevel(teamLeader)); // Transfer the data from the old leader to the // new one plugin.getGrid().transferIsland(player.getUniqueId(), targetPlayer, ((Player) sender).getWorld().getEnvironment()); // Create a new team with addPlayertoTeam(player.getUniqueId(), targetPlayer); addPlayertoTeam(targetPlayer, targetPlayer); plugin.getGrid().saveGrid(); return true; } player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorThatPlayerIsNotInTeam); } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorNotYourIsland); } } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError); } return true; } else { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); return true; } } else { player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand); return true; } break; } player.sendMessage(ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand); return true; }
From source file:tds.dll.mssql.StudentDLL.java
/** * Integrity check: Make sure that testee opportunity attributes match those * in table TestOpportunity Unlike GetItems and InsertItems, there is no * provision for suppressing the test status. * //from w ww . j a v a 2 s .co m * @note Related to ValidateProctorSession_FN and _ValidateTesteeAccessProc_SP * * @param SQLConnection * the database connection * @param testopp * the test opportunity UUID * @param session * the session UUID * @param browserID * the browser UUID * * @return String containing status message if error or null if ok. * * @throws ReturnStatusException */ public String _ValidateItemsAccess_FN(SQLConnection connection, UUID testopp, UUID session, UUID browserID) throws ReturnStatusException { Date now = _dateUtil.getDateWRetStatus(connection); UUID sessionKey = null; UUID browserKey = null; String status = null; final String query1 = "SELECT _fk_Session, _fk_browser, status from TestOpportunity where _Key = ${testopp} "; // With_(NoLock) SqlParametersMaps params1 = (new SqlParametersMaps()).put("testopp", testopp); SingleDataResultSet result1 = executeStatement(connection, query1, params1, true).getResultSets().next(); DbResultRecord record1 = result1.getCount() > 0 ? result1.getRecords().next() : null; if (record1 != null) { sessionKey = record1.<UUID>get("_fk_Session"); browserKey = record1.<UUID>get("_fk_browser"); status = record1.<String>get("status"); } if ((sessionKey == null) || (session == null) || (!sessionKey.equals(session))) { return "The session keys do not match; please consult your test administrator"; } String sessionStatus = null; Date dateBegin = null; Date dateEnd = null; final String query2 = "select [status], DateBegin, DateEnd from Session where _Key = ${session} "; // With_(NoLock) SqlParametersMaps params2 = (new SqlParametersMaps()).put("session", session); SingleDataResultSet result2 = executeStatement(connection, query2, params2, true).getResultSets().next(); DbResultRecord record2 = result2.getCount() > 0 ? result2.getRecords().next() : null; if (record2 != null) { sessionStatus = record2.<String>get("status"); dateBegin = record2.<Date>get("DateBegin"); dateEnd = record2.<Date>get("DateEnd"); } Date dateBeginAdj = adjustDateMinutes(dateBegin, -5); if (DbComparator.notEqual(sessionStatus, "open") || DbComparator.lessThan(now, dateBeginAdj) || DbComparator.greaterThan(now, dateEnd)) { return "The session is not available for testing, please check with your test administrator."; } if (DbComparator.notEqual(browserKey, browserID)) { return "Access violation: System access denied"; } if ((!"started".equals(status)) && (!"review".equals(status))) { return "The test opportunity has been paused"; } return null; }
From source file:tds.dll.mysql.StudentDLL.java
/** * Integrity check: Make sure that testee opportunity attributes match those * in table testopportunity Unlike GetItems and InsertItems, there is no * provision for suppressing the test status. * //from w w w . j a v a2 s .co m * @note Related to ValidateProctorSession_FN and _ValidateTesteeAccessProc_SP * * @param SQLConnection * the database connection * @param testopp * the test opportunity UUID * @param session * the session UUID * @param browserID * the browser UUID * * @return String containing status message if error or null if ok. * * @throws ReturnStatusException */ public String _ValidateItemsAccess_FN(SQLConnection connection, UUID testopp, UUID session, UUID browserID) throws ReturnStatusException { Date now = _dateUtil.getDateWRetStatus(connection); UUID sessionKey = null; UUID browserKey = null; String status = null; final String query1 = "SELECT _fk_Session, _fk_browser, status from testopportunity where _Key = ${testopp} "; // With_(NoLock) SqlParametersMaps params1 = (new SqlParametersMaps()).put("testopp", testopp); SingleDataResultSet result1 = executeStatement(connection, query1, params1, true).getResultSets().next(); DbResultRecord record1 = result1.getCount() > 0 ? result1.getRecords().next() : null; if (record1 != null) { sessionKey = record1.<UUID>get("_fk_Session"); browserKey = record1.<UUID>get("_fk_browser"); status = record1.<String>get("status"); } if ((sessionKey == null) || (session == null) || (!sessionKey.equals(session))) { return "The session keys do not match; please consult your test administrator"; } String sessionStatus = null; Date dateBegin = null; Date dateEnd = null; final String query2 = "select status, DateBegin, DateEnd from session where _Key = ${session} "; // With_(NoLock) SqlParametersMaps params2 = (new SqlParametersMaps()).put("session", session); SingleDataResultSet result2 = executeStatement(connection, query2, params2, true).getResultSets().next(); DbResultRecord record2 = result2.getCount() > 0 ? result2.getRecords().next() : null; if (record2 != null) { sessionStatus = record2.<String>get("status"); dateBegin = record2.<Date>get("DateBegin"); dateEnd = record2.<Date>get("DateEnd"); } Date dateBeginAdj = _commonDll.adjustDateMinutes(dateBegin, -5); if (DbComparator.notEqual(sessionStatus, "open") || DbComparator.lessThan(now, dateBeginAdj) || DbComparator.greaterThan(now, dateEnd)) { return "The session is not available for testing, please check with your test administrator."; } if (DbComparator.notEqual(browserKey, browserID)) { return "Access violation: System access denied"; } if ((!"started".equals(status)) && (!"review".equals(status))) { return "The test opportunity has been paused"; } return null; }