Search in sources :

Example 1 with Schematic

use of com.wasteofplastic.askyblock.schematics.Schematic in project askyblock by tastybento.

the class NetherPortals method onPlayerPortal.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (DEBUG)
        plugin.getLogger().info("Player portal event - reason =" + event.getCause());
    UUID playerUUID = event.getPlayer().getUniqueId();
    // If the nether is disabled then quit immediately
    if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Disabled nether: Settings create nether = " + Settings.createNether + " " + (ASkyBlock.getNetherWorld() == null ? "Nether world is null" : "Nether world is not null"));
        return;
    }
    Location currentLocation = event.getFrom().clone();
    String currentWorld = currentLocation.getWorld().getName();
    if (!currentWorld.equalsIgnoreCase(Settings.worldName) && !currentWorld.equalsIgnoreCase(Settings.worldName + "_nether") && !currentWorld.equalsIgnoreCase(Settings.worldName + "_the_end")) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: not island world");
        return;
    }
    // Check if player has permission
    Island island = plugin.getGrid().getIslandAt(currentLocation);
    if ((island == null && !Settings.defaultWorldSettings.get(SettingsFlag.PORTAL)) || (island != null && !(island.getIgsFlag(SettingsFlag.PORTAL) || island.getMembers().contains(event.getPlayer().getUniqueId())))) {
        // Portals use is not allowed
        if (!event.getPlayer().isOp() && !VaultHelper.checkPerm(event.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
            Util.sendMessage(event.getPlayer(), ChatColor.RED + plugin.myLocale(event.getPlayer().getUniqueId()).islandProtected);
            event.setCancelled(true);
            return;
        }
    }
    // Determine what portal it is
    switch(event.getCause()) {
        case END_PORTAL:
            // Same action for all worlds except the end itself
            if (!event.getFrom().getWorld().getEnvironment().equals(Environment.THE_END)) {
                if (plugin.getServer().getWorld(Settings.worldName + "_the_end") != null) {
                    // The end exists
                    event.setCancelled(true);
                    Location end_place = plugin.getServer().getWorld(Settings.worldName + "_the_end").getSpawnLocation();
                    if (GridManager.isSafeLocation(end_place)) {
                        event.getPlayer().teleport(end_place);
                        // end_place.getBlock().getType(),end_place.getBlock().getData());
                        return;
                    } else {
                        Util.sendMessage(event.getPlayer(), ChatColor.RED + plugin.myLocale(event.getPlayer().getUniqueId()).warpserrorNotSafe);
                        plugin.getGrid().homeTeleport(event.getPlayer());
                        return;
                    }
                }
            } else {
                event.setCancelled(true);
                plugin.getGrid().homeTeleport(event.getPlayer());
            }
            break;
        case NETHER_PORTAL:
            // Get the home world of this player
            World homeWorld = ASkyBlock.getIslandWorld();
            Location home = plugin.getPlayers().getHomeLocation(event.getPlayer().getUniqueId());
            if (home != null) {
                homeWorld = home.getWorld();
            }
            if (!Settings.newNether) {
                // Legacy action
                if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
                    // Going to Nether
                    if (homeWorld.getEnvironment().equals(Environment.NORMAL)) {
                        // Home world is over world
                        event.setTo(ASkyBlock.getNetherWorld().getSpawnLocation());
                        event.useTravelAgent(true);
                    } else {
                        // Home world is nether - going home
                        event.useTravelAgent(false);
                        Location dest = plugin.getGrid().getSafeHomeLocation(playerUUID, 1);
                        if (dest != null) {
                            event.setTo(dest);
                        } else {
                            event.setCancelled(true);
                            new SafeTeleportBuilder(plugin).entity(event.getPlayer()).location(plugin.getPlayers().getIslandLocation(playerUUID)).portal().homeNumber(1).build();
                        }
                    }
                } else {
                    // Going to Over world
                    if (homeWorld.getEnvironment().equals(Environment.NORMAL)) {
                        // Home world is over world
                        event.useTravelAgent(false);
                        Location dest = plugin.getGrid().getSafeHomeLocation(playerUUID, 1);
                        if (dest != null) {
                            event.setTo(dest);
                            // Fire entry event
                            Island islandTo = plugin.getGrid().getIslandAt(dest);
                            final IslandEnterEvent event2 = new IslandEnterEvent(event.getPlayer().getUniqueId(), islandTo, dest);
                            plugin.getServer().getPluginManager().callEvent(event2);
                        } else {
                            event.setCancelled(true);
                            new SafeTeleportBuilder(plugin).entity(event.getPlayer()).location(plugin.getPlayers().getIslandLocation(playerUUID)).portal().homeNumber(1).build();
                            // Fire entry event
                            Island islandTo = plugin.getGrid().getIslandAt(plugin.getPlayers().getIslandLocation(playerUUID));
                            final IslandEnterEvent event2 = new IslandEnterEvent(event.getPlayer().getUniqueId(), islandTo, plugin.getPlayers().getIslandLocation(playerUUID));
                            plugin.getServer().getPluginManager().callEvent(event2);
                        }
                    } else {
                        // Home world is nether
                        event.setTo(ASkyBlock.getIslandWorld().getSpawnLocation());
                        event.useTravelAgent(true);
                    }
                }
            } else {
                // Get location of the island where the player is at
                if (island == null) {
                    event.setCancelled(true);
                    return;
                }
                // Can go both ways now
                Location overworldIsland = island.getCenter().toVector().toLocation(ASkyBlock.getIslandWorld());
                Location netherIsland = island.getCenter().toVector().toLocation(ASkyBlock.getNetherWorld());
                // Location dest = event.getFrom().toVector().toLocation(ASkyBlock.getIslandWorld());
                if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
                    // Check that there is a nether island there. Due to legacy reasons it may not exist
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: island center = " + island.getCenter());
                    if (netherIsland.getBlock().getType() != Material.BEDROCK) {
                        // Check to see if there is anything there
                        if (plugin.getGrid().bigScan(netherIsland, 20) == null) {
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: big scan is null");
                            plugin.getLogger().warning("Creating nether island for " + event.getPlayer().getName() + " using default nether schematic");
                            Schematic nether = IslandCmd.getSchematics().get("nether");
                            if (nether != null) {
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: pasting at " + island.getCenter().toVector());
                                plugin.getIslandCmd().pasteSchematic(nether, netherIsland, event.getPlayer(), PasteReason.PARTNER);
                                if (nether.isPlayerSpawn()) {
                                    // Set partner home
                                    plugin.getPlayers().setHomeLocation(event.getPlayer().getUniqueId(), nether.getPlayerSpawn(netherIsland), -2);
                                }
                            } else {
                                plugin.getLogger().severe("Cannot teleport player to nether because there is no nether schematic");
                                event.setCancelled(true);
                                Util.sendMessage(event.getPlayer(), ChatColor.RED + plugin.myLocale(event.getPlayer().getUniqueId()).warpserrorNotSafe);
                                return;
                            }
                        }
                    }
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: Teleporting to " + event.getFrom().toVector().toLocation(ASkyBlock.getNetherWorld()));
                    event.setCancelled(true);
                    // Teleport using the new safeSpot teleport
                    new SafeTeleportBuilder(plugin).entity(event.getPlayer()).location(netherIsland).portal().build();
                    return;
                }
                // Going to the over world - if there isn't an island, do nothing
                event.setCancelled(true);
                // Teleport using the new safeSpot teleport
                new SafeTeleportBuilder(plugin).entity(event.getPlayer()).location(overworldIsland).portal().build();
            }
            break;
        default:
            break;
    }
}
Also used : IslandEnterEvent(com.wasteofplastic.askyblock.events.IslandEnterEvent) SafeTeleportBuilder(com.wasteofplastic.askyblock.util.teleport.SafeTeleportBuilder) UUID(java.util.UUID) World(org.bukkit.World) Island(com.wasteofplastic.askyblock.Island) Schematic(com.wasteofplastic.askyblock.schematics.Schematic) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Schematic

use of com.wasteofplastic.askyblock.schematics.Schematic in project askyblock by tastybento.

the class IslandCmd method onCommand.

/*
     * (non-Javadoc)
     * @see
     * org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender
     * , org.bukkit.command.Command, java.lang.String, java.lang.String[])
     */
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split) {
    if (!(sender instanceof Player)) {
        Util.sendMessage(sender, plugin.myLocale().errorUseInGame);
        return false;
    }
    final Player player = (Player) sender;
    // Basic permissions check to even use /island
    if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.create")) {
        Util.sendMessage(player, 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();
    if (playerUUID == null) {
        plugin.getLogger().severe("Player " + sender.getName() + " has a null UUID - this should never happen!");
        Util.sendMessage(sender, ChatColor.RED + plugin.myLocale().errorCommandNotReady + " (No UUID)");
        return true;
    }
    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)) {
            String name = split[1];
            for (int i = 2; i < split.length; i++) {
                name = name + " " + split[i];
            }
            if (name.length() < Settings.minNameLength) {
                Util.sendMessage(player, ChatColor.RED + (plugin.myLocale(player.getUniqueId()).errorTooShort).replace("[length]", String.valueOf(Settings.minNameLength)));
                return true;
            }
            if (name.length() > Settings.maxNameLength) {
                Util.sendMessage(player, ChatColor.RED + (plugin.myLocale(player.getUniqueId()).errorTooLong).replace("[length]", String.valueOf(Settings.maxNameLength)));
                return true;
            }
            plugin.getGrid().setIslandName(playerUUID, ChatColor.translateAlternateColorCodes('&', name));
            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).generalSuccess);
            return true;
        } else {
            Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMaxIslands);
                    return true;
                }
                // Check if player has resets left
                if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandResetNoMore);
                    return true;
                }
                // Create new island for player
                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandnew);
                chooseIsland(player);
                return true;
            } else {
                // Check if this should open the Control Panel or not
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel") && plugin.getPlayers().getControlPanel(playerUUID)) {
                    Util.runCommand(player, Settings.ISLANDCOMMAND + " cp");
                } else {
                    // Check permission
                    if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                        return true;
                    }
                    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 {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    }
                }
                return true;
            }
        case 1:
            if (split[0].equalsIgnoreCase("value")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.value")) {
                    // Check they are on their island
                    if (!plugin.getGrid().playerIsOnIsland(player)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNotOnIsland);
                        return true;
                    }
                    ItemStack item = player.getItemInHand();
                    double multiplier = 1;
                    if (item != null && item.getType().isBlock()) {
                        // Get permission multiplier
                        for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                            if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.multiplier.")) {
                                String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.multiplier.");
                                // Get the max value should there be more than one
                                if (spl.length > 1) {
                                    if (!NumberUtils.isDigits(spl[1])) {
                                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                    } else {
                                        multiplier = Math.max(multiplier, Integer.valueOf(spl[1]));
                                    }
                                }
                            }
                            // Do some sanity checking
                            if (multiplier < 1) {
                                multiplier = 1;
                            }
                        }
                        // Player height
                        if (player.getLocation().getBlockY() < Settings.seaHeight) {
                            multiplier *= Settings.underWaterMultiplier;
                        }
                        // Get the value. Try the specific item
                        int value = 0;
                        if (Settings.blockValues.containsKey(item.getData())) {
                            value = (int) ((double) Settings.blockValues.get(item.getData()) * multiplier);
                        } else if (Settings.blockValues.containsKey(new MaterialData(item.getType()))) {
                            value = (int) ((double) Settings.blockValues.get(new MaterialData(item.getType())) * multiplier);
                        }
                        if (value > 0) {
                            // [name] placed here may be worth [value]
                            Util.sendMessage(player, ChatColor.GREEN + (plugin.myLocale(player.getUniqueId()).islandblockValue.replace("[name]", Util.prettifyText(item.getType().name())).replace("[value]", String.valueOf(value))));
                        } else {
                            // [name] is worthless
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandblockWorthless.replace("[name]", Util.prettifyText(item.getType().name())));
                        }
                    } else {
                        // That is not a block
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNotABlock);
                    }
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("name")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID)) {
                    Util.sendMessage(player, 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)) {
                    // Has an island
                    plugin.getGrid().setIslandName(playerUUID, null);
                    Util.sendMessage(sender, plugin.myLocale().generalSuccess);
                }
                return true;
            }
            if (split[0].equalsIgnoreCase("coop")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, 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")) {
                    Util.sendMessage(player, 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")) {
                    Util.sendMessage(player, 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) {
                        Util.sendMessage(player, 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) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeamAround);
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff);
                            plugin.getChatListener().unSetPlayer(playerUUID);
                            return true;
                        }
                        if (plugin.getChatListener().isTeamChat(playerUUID)) {
                            // Toggle
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff);
                            plugin.getChatListener().unSetPlayer(playerUUID);
                        } else {
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOn);
                            plugin.getChatListener().setPlayer(playerUUID);
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeam);
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            }
            if (split[0].equalsIgnoreCase("banlist")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    // Show banned players
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).adminInfoBannedPlayers + ":");
                    List<UUID> bannedList = plugin.getPlayers().getBanList(playerUUID);
                    if (bannedList.isEmpty()) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).banNone);
                    } else {
                        for (UUID bannedPlayers : bannedList) {
                            Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + plugin.getPlayers().getName(bannedPlayers));
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("ban")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    // Just show ban help
                    Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpBan);
                } else {
                    Util.sendMessage(player, 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
                    Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpUnban);
                } else {
                    Util.sendMessage(player, plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("make")) {
                // plugin.getLogger().info("DEBUG: /is make called");
                if (!pendingNewIslandSelection.contains(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale().errorUnknownCommand);
                    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")) {
                    Util.sendMessage(player, "/" + label + " lang <#>");
                    displayLocales(player);
                } else {
                    Util.sendMessage(player, 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) {
                        if (DEBUG)
                            e.printStackTrace();
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("lock")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) {
                    Util.sendMessage(player, 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
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                    return true;
                } else {
                    if (!island.isLocked()) {
                        // Remove any visitors
                        for (Player target : plugin.getServer().getOnlinePlayers()) {
                            if (target == null || target.hasMetadata("NPC") || target.isOp() || player.equals(target) || VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect"))
                                continue;
                            // See if target is on this player's island and not a coop player
                            if (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());
                                    }
                                }
                                Util.sendMessage(target, ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled);
                                plugin.getLogger().info(player.getName() + " expelled " + target.getName() + " from their island when locking.");
                                // Yes they are
                                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess.replace("[name]", target.getName()));
                            }
                        }
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).lockLocking);
                        plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked.replace("[name]", player.getName()));
                        plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked.replace("[name]", player.getName()));
                        island.setLocked(true);
                    } else {
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).lockUnlocking);
                        plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked.replace("[name]", player.getName()));
                        plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked.replace("[name]", player.getName()));
                        island.setLocked(false);
                    }
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("go")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) {
                    // Player has no island
                    Util.sendMessage(player, 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")) {
                Util.sendMessage(player, ChatColor.GOLD + "About " + ChatColor.GREEN + plugin.getDescription().getName() + ChatColor.GOLD + " v" + ChatColor.AQUA + plugin.getDescription().getVersion() + ChatColor.GOLD + ":");
                Util.sendMessage(player, ChatColor.GOLD + "This plugin is free software: you can redistribute");
                Util.sendMessage(player, ChatColor.GOLD + "it and/or modify it under the terms of the GNU");
                Util.sendMessage(player, ChatColor.GOLD + "General Public License as published by the Free");
                Util.sendMessage(player, ChatColor.GOLD + "Software Foundation, either version 3 of the License,");
                Util.sendMessage(player, ChatColor.GOLD + "or (at your option) any later version.");
                Util.sendMessage(player, ChatColor.GOLD + "This plugin is distributed in the hope that it");
                Util.sendMessage(player, ChatColor.GOLD + "will be useful, but WITHOUT ANY WARRANTY; without");
                Util.sendMessage(player, ChatColor.GOLD + "even the implied warranty of MERCHANTABILITY or");
                Util.sendMessage(player, ChatColor.GOLD + "FITNESS FOR A PARTICULAR PURPOSE. See the");
                Util.sendMessage(player, ChatColor.GOLD + "GNU General Public License for more details.");
                Util.sendMessage(player, ChatColor.GOLD + "You should have received a copy of the GNU");
                Util.sendMessage(player, ChatColor.GOLD + "General Public License along with this plugin.");
                Util.sendMessage(player, ChatColor.GOLD + "If not, see <http://www.gnu.org/licenses/>.");
                Util.sendMessage(player, ChatColor.GOLD + "Source code is available on GitHub.");
                Util.sendMessage(player, ChatColor.GOLD + "(c) 2014 - 2018 by tastybento, Poslovitch");
                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 (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) {
                    if (ControlPanel.controlPanel.containsKey(ControlPanel.getDefaultPanelName())) {
                        player.openInventory(ControlPanel.controlPanel.get(ControlPanel.getDefaultPanelName()));
                        return true;
                    } else {
                        Util.sendMessage(player, plugin.myLocale(playerUUID).errorCommandNotReady);
                        plugin.getLogger().severe("There is a problem with the controlpanel.yml file - it is probably corrupted. Delete it and let it be regenerated.");
                        return true;
                    }
                }
            }
            if (split[0].equalsIgnoreCase("minishop") || split[0].equalsIgnoreCase("ms")) {
                if (Settings.useEconomy && Settings.useMinishop) {
                    // Check island
                    if (plugin.getGrid().getIsland(player.getUniqueId()) == null) {
                        Util.sendMessage(player, 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")) {
                            if (ControlPanel.miniShop != null) {
                                player.openInventory(ControlPanel.miniShop);
                            } else {
                                Util.sendMessage(player, plugin.myLocale(playerUUID).errorCommandNotReady);
                                plugin.getLogger().severe("Player tried to open the minishop, but it does not exist. Look for errors in the console about the minishop loading.");
                            }
                            return true;
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld);
                        return true;
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMinishopDisabled);
                    return true;
                }
            }
            // /island <command>
            if (split[0].equalsIgnoreCase("warp")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                    Util.sendMessage(player, 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()) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet);
                        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) {
                            Util.sendMessage(player, 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 (w == null)
                                    continue;
                                if (wlist.isEmpty()) {
                                    wlist = plugin.getPlayers().getName(w);
                                } else {
                                    wlist += ", " + plugin.getPlayers().getName(w);
                                }
                                if (w.equals(playerUUID)) {
                                    hasWarp = true;
                                }
                            }
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpswarpsAvailable + ": " + ChatColor.WHITE + wlist);
                            if (!hasWarp && (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp"))) {
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale().warpswarpTip);
                            }
                        }
                        return true;
                    }
                }
            } else if (split[0].equalsIgnoreCase("restart") || split[0].equalsIgnoreCase("reset")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.reset")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Check this player has an island
                if (!plugin.getPlayers().hasIsland(playerUUID)) {
                    // No so just start an island
                    Util.runCommand(player, Settings.ISLANDCOMMAND);
                    return true;
                }
                if (plugin.getPlayers().inTeam(playerUUID)) {
                    if (!plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandresetOnlyOwner);
                    } else {
                        Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandResetNoMore);
                    return true;
                }
                if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) {
                    Util.sendMessage(player, 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
                    Util.sendMessage(player, 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 {
                    Util.sendMessage(player, 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
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetPleaseWait);
                    if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandResetNoMore);
                    }
                    if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) {
                        Util.sendMessage(player, 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 {
                    Util.sendMessage(player, 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) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    plugin.getGrid().homeSet(player);
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("help")) {
                Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + plugin.myLocale(player.getUniqueId()).helpHeader.replace("[plugin]", plugin.getDescription().getName()).replace("[version]", plugin.getDescription().getVersion()));
                if (Settings.useControlPanel) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel);
                } else {
                    Util.sendMessage(player, 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().startsWith(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) {
                                // Check that it is a number
                                if (!NumberUtils.isDigits(spl[1])) {
                                    plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                } else {
                                    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.go")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport);
                } else if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport);
                }
                if (plugin.getGrid() != null && plugin.getGrid().getSpawn() != null && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.spawn")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " spawn: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSpawn);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " controlpanel or cp [on/off]: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.reset")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " reset: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) {
                    if (maxHomes > 1) {
                        Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome);
                    } else {
                        Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome);
                    }
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevel);
                    Util.sendMessage(player, 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)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " name <name>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpName);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " top: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTop);
                }
                if (Settings.useEconomy && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " minishop or ms: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMiniShop);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.value")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " value: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpValue);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warps: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarps);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " team: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeam);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " invite <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpInvite);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " leave: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLeave);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " kick <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpKick);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " <accept/reject>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpAcceptReject);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) {
                    Util.sendMessage(player, 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)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " teamchat: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).teamChatHelp);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) {
                    Util.sendMessage(player, 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")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " expel <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpExpel);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBan);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " banlist <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBanList);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnban);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " uncoop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnCoop);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " listcoops: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpListCoops);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) {
                    Util.sendMessage(player, 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)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " resetname: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpResetName);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " settings: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSettings);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.challenges")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + plugin.myLocale(player.getUniqueId()).islandHelpChallenges);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lang <#>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSelectLanguage);
                }
                /*
                if (player.getInventory().getItemInMainHand() != null) {
                    net.minecraft.server.v1_11_R1.ItemStack stack = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
                    NBTTagCompound tagCompound = stack.getTag();
                    Bukkit.getLogger().info("DEBUG: tag = " + tagCompound);
                }
                 */
                return true;
            } else if (split[0].equalsIgnoreCase("listcoops")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    if (!plugin.getPlayers().hasIsland(playerUUID)) {
                        // Player has no island
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    Island island = plugin.getGrid().getIsland(playerUUID);
                    boolean none = true;
                    for (UUID uuid : CoopPlay.getInstance().getCoopPlayers(island.getCenter())) {
                        Util.sendMessage(player, ChatColor.GREEN + plugin.getPlayers().getName(uuid));
                        none = false;
                    }
                    if (none) {
                        Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop);
                    } else {
                        Util.sendMessage(player, plugin.myLocale(playerUUID).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)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).levelerrornotYourIsland);
                        return true;
                    }
                    if (!plugin.getPlayers().hasIsland(playerUUID)) {
                        // Player has no island
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    if (!plugin.getGrid().playerIsOnIsland(player)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland);
                        return true;
                    }
                    // Not allowed in the nether
                    if (plugin.getPlayers().getIslandLocation(playerUUID).getWorld().getEnvironment().equals(Environment.NETHER)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld);
                        return true;
                    }
                    // Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "[Biomes]");
                    Inventory inv = plugin.getBiomes().getBiomePanel(player);
                    if (inv != null) {
                        player.openInventory(inv);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("spawn") && plugin.getGrid().getSpawn() != null) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.spawn")) {
                    // 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);
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("top")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) {
                    plugin.getTopTen().topTenShow(player);
                    return true;
                } else {
                    Util.sendMessage(player, 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)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    } else {
                        if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "intopten")) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).topTenerrorExcluded.replace("[perm]", Settings.PERMPREFIX + "intopten"));
                        }
                        calculateIslandLevel(player, playerUUID);
                        return true;
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("invite")) {
                // player how many more people they can invite
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) {
                    Util.sendMessage(player, 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) {
                                            if (!NumberUtils.isDigits(spl[1])) {
                                                plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                            } else {
                                                maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
                                            }
                                        }
                                    }
                                }
                                // Do some sanity checking
                                if (maxSize < 1) {
                                    maxSize = 1;
                                }
                            }
                            if (teamMembers.size() < maxSize) {
                                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite.replace("[number]", String.valueOf(maxSize - teamMembers.size())));
                            } else {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull);
                            }
                            return true;
                        }
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                        return true;
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("coopaccept")) {
                // Accept an invite command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    if (coopInviteList.containsKey(playerUUID)) {
                        // Check if inviter is online
                        Player inviter = plugin.getServer().getPlayer(coopInviteList.get(playerUUID));
                        if (inviter == null || !inviter.isOnline()) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer);
                            coopInviteList.remove(playerUUID);
                            return true;
                        }
                        if (CoopPlay.getInstance().addCoopPlayer(inviter, player)) {
                            // Tell everyone what happened
                            Util.sendMessage(inviter, ChatColor.GREEN + plugin.myLocale(inviter.getUniqueId()).coopSuccess.replace("[name]", player.getName()));
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).coopMadeYouCoop.replace("[name]", inviter.getName()));
                        // TODO: Give perms if the player is on the coop island
                        }
                        setResetWaitTime(player);
                        // Remove the invite
                        coopInviteList.remove(playerUUID);
                        return true;
                    }
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    return true;
                } else {
                    Util.sendMessage(player, 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")) {
                    // 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));
                        // 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);
                        plugin.resetPlayer(player);
                        if (!player.hasPermission(Settings.PERMPREFIX + "command.newteamexempt")) {
                            // plugin.getLogger().info("DEBUG: Executing new island commands");
                            runCommands(Settings.teamStartCommands, player);
                        }
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).inviteyouHaveJoinedAnIsland);
                        if (plugin.getServer().getPlayer(inviteList.get(playerUUID)) != null) {
                            Util.sendMessage(plugin.getServer().getPlayer(inviteList.get(playerUUID)), ChatColor.GREEN + plugin.myLocale(inviteList.get(playerUUID)).invitehasJoinedYourIsland.replace("[name]", player.getName()));
                        }
                        // Remove the invite
                        inviteList.remove(player.getUniqueId());
                        plugin.getGrid().saveGrid();
                        return true;
                    }
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("coopreject")) {
                // Reject /island coopreject
                if (coopInviteList.containsKey(playerUUID)) {
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(playerUUID).rejectyouHaveRejectedInvitation);
                    // about the rejection
                    if (Bukkit.getPlayer(inviteList.get(playerUUID)) != null) {
                        Util.sendMessage(Bukkit.getPlayer(inviteList.get(playerUUID)), ChatColor.RED + plugin.myLocale(inviteList.get(playerUUID)).rejectnameHasRejectedInvite.replace("[name]", player.getName()));
                    }
                    // Remove this player from the global invite list
                    coopInviteList.remove(playerUUID);
                } else {
                    // Someone typed /island coopreject and had not been invited
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).rejectyouHaveNotBeenInvited);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("reject")) {
                // Reject /island reject
                if (inviteList.containsKey(player.getUniqueId())) {
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(playerUUID).rejectyouHaveRejectedInvitation);
                    // about the rejection
                    if (Bukkit.getPlayer(inviteList.get(player.getUniqueId())) != null) {
                        Util.sendMessage(Bukkit.getPlayer(inviteList.get(playerUUID)), ChatColor.RED + plugin.myLocale(inviteList.get(playerUUID)).rejectnameHasRejectedInvite.replace("[name]", player.getName()));
                    }
                    // Remove this player from the global invite list
                    inviteList.remove(playerUUID);
                } else {
                    // Someone typed /island reject and had not been invited
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).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) != null && plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) {
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveerrorYouAreTheLeader);
                                return true;
                            }
                            // Check for confirmation
                            if (!leavingPlayers.contains(playerUUID)) {
                                leavingPlayers.add(playerUUID);
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveWarning);
                                new BukkitRunnable() {

                                    @Override
                                    public void run() {
                                        // If the player is still on the list, remove them and cancel the leave
                                        if (leavingPlayers.contains(playerUUID)) {
                                            leavingPlayers.remove(playerUUID);
                                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveCanceled);
                                        }
                                    }
                                }.runTaskLater(plugin, Settings.resetConfirmWait * 20L);
                                return true;
                            }
                            // Remove from confirmation list
                            leavingPlayers.remove(playerUUID);
                            // Remove from team
                            if (!removePlayerFromTeam(playerUUID, teamLeader)) {
                                // If this is canceled, fail silently
                                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 any warps
                            plugin.getWarpSignsListener().removeWarp(playerUUID);
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveyouHaveLeftTheIsland);
                            // Tell the leader if they are online
                            if (plugin.getServer().getPlayer(teamLeader) != null) {
                                Player leader = plugin.getServer().getPlayer(teamLeader);
                                Util.sendMessage(leader, 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()));
                            }
                            // teamMembers.remove(playerUUID);
                            if (teamMembers.size() < 2) {
                                // plugin.getLogger().info("DEBUG: Party is less than 2 - removing leader from team");
                                if (!removePlayerFromTeam(teamLeader, teamLeader)) {
                                    // If this is canceled, return silently.
                                    return true;
                                }
                            }
                            // Clear all player variables and save
                            plugin.resetPlayer(player);
                            if (!player.performCommand(Settings.SPAWNCOMMAND)) {
                                player.teleport(player.getWorld().getSpawnLocation());
                            }
                            return true;
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).leaveerrorYouCannotLeaveIsland);
                            return true;
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).leaveerrorYouMustBeInWorld);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, 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) {
                                        if (!NumberUtils.isDigits(spl[1])) {
                                            plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                        } else {
                                            maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
                                        }
                                    }
                                }
                            }
                            // Do some sanity checking
                            if (maxSize < 1) {
                                maxSize = 1;
                            }
                        }
                        if (teamMembers.size() < maxSize) {
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite.replace("[number]", String.valueOf(maxSize - teamMembers.size())));
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull);
                        }
                    }
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).teamlistingMembers + ":");
                    // Display members in the list
                    for (UUID m : plugin.getPlayers().getMembers(teamLeader)) {
                        Util.sendMessage(player, ChatColor.WHITE + plugin.getPlayers().getName(m));
                    }
                } else if (inviteList.containsKey(playerUUID)) {
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitenameHasInvitedYou.replace("[name]", plugin.getPlayers().getName(inviteList.get(playerUUID))));
                    Util.sendMessage(player, ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitetoAcceptOrReject);
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam);
                }
                return true;
            } else {
                // Incorrect syntax
                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                return true;
            }
            break;
        /*
             * 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);
                    }
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).generalSuccess);
                    return true;
                } else {
                    Util.sendMessage(player, 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()) {
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet);
                            if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) {
                                Util.sendMessage(player, 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 {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    }
                } else {
                    Util.sendMessage(player, 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)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                    return true;
                }
                pendingNewIslandSelection.remove(playerUUID);
                // Create a new island using schematic
                if (!schematics.containsKey(split[1])) {
                    Util.sendMessage(player, 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());
                        newIsland(player, schematic);
                        if (resettingIsland.contains(playerUUID)) {
                            resettingIsland.remove(playerUUID);
                            resetPlayer(player, oldIsland);
                        }
                        return true;
                    } else {
                        Util.sendMessage(player, 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])) {
                        Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                        displayLocales(player);
                        return true;
                    } else {
                        try {
                            int index = Integer.valueOf(split[1]);
                            if (index < 1 || index > plugin.getAvailableLocales().size()) {
                                Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                                displayLocales(player);
                                return true;
                            }
                            for (ASLocale locale : plugin.getAvailableLocales().values()) {
                                if (locale.getIndex() == index) {
                                    plugin.getPlayers().setLocale(playerUUID, locale.getLocaleName());
                                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).generalSuccess);
                                    return true;
                                }
                            }
                            // Not in the list
                            Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                            displayLocales(player);
                        } catch (Exception e) {
                            Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                            displayLocales(player);
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, 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
                    Util.sendMessage(player, 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 {
                            // 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) {
                                            if (!NumberUtils.isDigits(spl[1])) {
                                                plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                            } else {
                                                maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1]));
                                            }
                                        }
                                    }
                                }
                                // Do some sanity checking
                                if (maxHomes < 1) {
                                    maxHomes = 1;
                                }
                            }
                            if (number > maxHomes) {
                                if (maxHomes > 1) {
                                    Util.sendMessage(player, 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 {
                    Util.sendMessage(player, 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
                        Util.sendMessage(player, 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) {
                                    if (!NumberUtils.isDigits(spl[1])) {
                                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                    } else {
                                        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) {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes.replace("[max]", String.valueOf(maxHomes)));
                            } else {
                                plugin.getGrid().homeSet(player, number);
                            }
                        } catch (Exception e) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes.replace("[max]", String.valueOf(maxHomes)));
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    }
                    return true;
                }
                Util.sendMessage(player, 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()) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet);
                        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp")) {
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale().warpswarpTip);
                        } else {
                            Util.sendMessage(player, 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 (warp == null)
                                continue;
                            if (plugin.getPlayers().getName(warp) != null) {
                                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) {
                            Util.sendMessage(player, 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) {
                                Util.sendMessage(player, 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)) {
                                Util.sendMessage(player, 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
                                Util.sendMessage(player, 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 (island != null && ((warpSpot.getWorld().equals(ASkyBlock.getIslandWorld()) && island.getIgsFlag(SettingsFlag.PVP)) || (warpSpot.getWorld().equals(ASkyBlock.getNetherWorld()) && island.getIgsFlag(SettingsFlag.NETHER_PVP)))) {
                                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
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist);
                                plugin.getWarpSignsListener().removeWarp(warpSpot);
                                return true;
                            }
                            if (!(GridManager.isSafeLocation(warpSpot))) {
                                Util.sendMessage(player, 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) {
                                    Util.sendMessage(player, ChatColor.BOLD + "" + ChatColor.RED + plugin.myLocale(player.getUniqueId()).igs.get(SettingsFlag.PVP) + " " + 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 {
                    Util.sendMessage(player, 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");
                        Util.sendMessage(player, 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 {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, 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) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer);
                        return true;
                    }
                    final UUID invitedPlayerUUID = invitedPlayer.getUniqueId();
                    // Player issuing the command must have an island
                    if (!plugin.getPlayers().hasIsland(player.getUniqueId())) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                        return true;
                    }
                    // Player cannot invite themselves
                    if (player.getUniqueId().equals(invitedPlayer.getUniqueId())) {
                        Util.sendMessage(player, 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()) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorCoolDown.replace("[time]", String.valueOf(time)));
                        return true;
                    }
                    // 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) {
                                                if (!NumberUtils.isDigits(spl[1])) {
                                                    plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                                } else {
                                                    maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
                                                }
                                            }
                                        }
                                    }
                                    // Do some sanity checking
                                    if (maxSize < 1) {
                                        maxSize = 1;
                                    }
                                }
                                if (teamMembers.size() < maxSize) {
                                    // time - interesting
                                    if (inviteList.containsValue(playerUUID)) {
                                        inviteList.remove(getKeyByValue(inviteList, player.getUniqueId()));
                                        Util.sendMessage(player, 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());
                                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo.replace("[name]", invitedPlayer.getName()));
                                    // Send message to online player
                                    Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou.replace("[name]", player.getName()));
                                    Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject);
                                    if (plugin.getPlayers().hasIsland(invitedPlayerUUID)) {
                                        Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.RED + plugin.myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland);
                                    }
                                    // Start timeout on invite
                                    if (Settings.inviteTimeout > 0) {
                                        plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

                                            @Override
                                            public void run() {
                                                if (inviteList.containsKey(invitedPlayerUUID) && inviteList.get(invitedPlayerUUID).equals(playerUUID)) {
                                                    inviteList.remove(invitedPlayerUUID);
                                                    if (plugin.getServer().getPlayer(playerUUID) != null) {
                                                        Util.sendMessage(plugin.getServer().getPlayer(playerUUID), ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                                    }
                                                    if (plugin.getServer().getPlayer(invitedPlayerUUID) != null) {
                                                        Util.sendMessage(plugin.getServer().getPlayer(invitedPlayerUUID), ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                                    }
                                                }
                                            }
                                        }, Settings.inviteTimeout);
                                    }
                                } else {
                                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull);
                                }
                            } else {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam);
                            }
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                        }
                    } else {
                        // Check if invitee is in a team or not
                        if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) {
                            // it
                            if (inviteList.containsValue(playerUUID)) {
                                inviteList.remove(getKeyByValue(inviteList, player.getUniqueId()));
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                            }
                            // Place the player and invitee on the invite list
                            inviteList.put(invitedPlayerUUID, player.getUniqueId());
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo.replace("[name]", invitedPlayer.getName()));
                            Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou.replace("[name]", player.getName()));
                            Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject);
                            // + invitedPlayerUUID.toString());
                            if (plugin.getPlayers().hasIsland(invitedPlayerUUID)) {
                                // plugin.getLogger().info("DEBUG: invited player has island");
                                Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.RED + plugin.myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland);
                            }
                            // Start timeout on invite
                            if (Settings.inviteTimeout > 0) {
                                plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

                                    @Override
                                    public void run() {
                                        if (inviteList.containsKey(invitedPlayerUUID) && inviteList.get(invitedPlayerUUID).equals(playerUUID)) {
                                            inviteList.remove(invitedPlayerUUID);
                                            if (plugin.getServer().getPlayer(playerUUID) != null) {
                                                Util.sendMessage(plugin.getServer().getPlayer(playerUUID), ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                            }
                                            if (plugin.getServer().getPlayer(invitedPlayerUUID) != null) {
                                                Util.sendMessage(plugin.getServer().getPlayer(invitedPlayerUUID), ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                            }
                                        }
                                    }
                                }, Settings.inviteTimeout);
                            }
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam);
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, 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")) {
                    Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer);
                    return true;
                }
                final UUID targetPlayerUUID = target.getUniqueId();
                // Player issuing the command must have an island
                if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                    return true;
                }
                // Player cannot invite themselves
                if (playerUUID.equals(targetPlayerUUID)) {
                    Util.sendMessage(player, 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)) {
                    Util.sendMessage(player, 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)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther);
                        return true;
                    }
                }
                // Check if this player can be invited to this island, or
                // whether they are still on cooldown
                long time = plugin.getPlayers().getInviteCoolDownTime(targetPlayerUUID, plugin.getPlayers().getIslandLocation(playerUUID));
                if (time > 0 && !player.isOp()) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorCoolDown.replace("[time]", String.valueOf(time)));
                    return true;
                }
                // Send out coop invite
                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo.replace("[name]", target.getName()));
                Util.sendMessage(target, ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).coopHasInvited.replace("[name]", player.getName()));
                Util.sendMessage(target, ChatColor.GREEN + Settings.ISLANDCOMMAND + " coopaccept/coopreject " + plugin.myLocale(targetPlayerUUID).invitetoAcceptOrReject);
                coopInviteList.put(targetPlayerUUID, playerUUID);
                if (Settings.inviteTimeout > 0) {
                    plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

                        @Override
                        public void run() {
                            if (coopInviteList.containsKey(targetPlayerUUID) && coopInviteList.get(targetPlayerUUID).equals(playerUUID)) {
                                coopInviteList.remove(targetPlayerUUID);
                                if (plugin.getServer().getPlayer(playerUUID) != null) {
                                    Util.sendMessage(plugin.getServer().getPlayer(playerUUID), ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                }
                                if (plugin.getServer().getPlayer(targetPlayerUUID) != null) {
                                    Util.sendMessage(plugin.getServer().getPlayer(targetPlayerUUID), ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                }
                            }
                        }
                    }, Settings.inviteTimeout);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("expel")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) {
                    Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, 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")) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelFail.replace("[name]", target.getName()));
                        return true;
                    }
                }
                // Remove them from the coop list
                boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, targetPlayerUUID);
                if (coop) {
                    if (target != null) {
                        Util.sendMessage(target, ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved.replace("[name]", player.getName()));
                    } else {
                        plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).coopRemoved.replace("[name]", player.getName()));
                    }
                    Util.sendMessage(player, 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)) {
                    // 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());
                                         */
                        }
                    }
                    Util.sendMessage(target, ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled);
                    plugin.getLogger().info(player.getName() + " expelled " + target.getName() + " from their island.");
                    // Yes they are
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess.replace("[name]", target.getName()));
                } else if (!coop) {
                    // No they're not
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotOnIsland);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("uncoop")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, 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()) {
                        Util.sendMessage(target.getPlayer(), ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved.replace("[name]", player.getName()));
                    } else {
                        plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).coopRemoved.replace("[name]", player.getName()));
                    }
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess.replace("[name]", plugin.getPlayers().getName(targetPlayerUUID)));
                } else {
                    Util.sendMessage(player, 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")) {
                    Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, 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!
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotTeamMember);
                        return true;
                    }
                }
                // Check that the player is not banned already
                if (plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) {
                    Util.sendMessage(player, 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()) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banFail.replace("[name]", split[1]));
                    return true;
                }
                if (target != null) {
                    // Do not ban players with the mod.noban permission
                    if (VaultHelper.checkPerm(target, Settings.PERMPREFIX + "admin.noban")) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banFail.replace("[name]", split[1]));
                        return true;
                    }
                    // Remove them from the coop list
                    boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, target);
                    if (coop) {
                        Util.sendMessage(target, ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved.replace("[name]", player.getName()));
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess.replace("[name]", target.getName()));
                    }
                    // See if target is on this player's island and if so send them away
                    if (plugin.getGrid().isOnIsland(player, target)) {
                        // 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
                    Util.sendMessage(target, ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getName()));
                } else {
                    // Offline notification
                    plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getName()));
                }
                // Console
                plugin.getLogger().info(player.getName() + " banned " + split[1] + " from their island.");
                // Player
                Util.sendMessage(player, 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")) {
                    Util.sendMessage(player, 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) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself);
                    return true;
                }
                // Check that the player is actually banned
                if (!plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) {
                    Util.sendMessage(player, 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
                    Util.sendMessage(target, ChatColor.RED + plugin.myLocale(target.getUniqueId()).banLifted.replace("[name]", player.getName()));
                } else {
                    plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).banLifted.replace("[name]", player.getName()));
                }
                // OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID);
                // Player
                Util.sendMessage(player, 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")) {
                // command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) {
                    if (!plugin.getPlayers().inTeam(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam);
                        return true;
                    }
                    // Only leaders can kick
                    if (teamLeader != null && !teamLeader.equals(playerUUID)) {
                        Util.sendMessage(player, 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) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam);
                        return true;
                    }
                    if (teamMembers.contains(targetPlayer)) {
                        // themselves
                        if (player.getUniqueId().equals(targetPlayer)) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorLeadersCannotLeave);
                            return true;
                        }
                        // Try to kick player
                        if (!removePlayerFromTeam(targetPlayer, teamLeader)) {
                            // If this is canceled, fail silently
                            return true;
                        }
                        // 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));
                        if (Settings.resetChallenges) {
                            // Reset the player's challenge status
                            plugin.getPlayers().resetAllChallenges(targetPlayer, false);
                        }
                        // Reset the island level
                        plugin.getPlayers().setIslandLevel(targetPlayer, 0);
                        plugin.getTopTen().topTenAddEntry(playerUUID, 0);
                        // If target is online
                        Player target = plugin.getServer().getPlayer(targetPlayer);
                        if (target != null) {
                            // plugin.getLogger().info("DEBUG: player is online");
                            Util.sendMessage(target, ChatColor.RED + plugin.myLocale(targetPlayer).kicknameRemovedYou.replace("[name]", player.getName()));
                            // 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);
                            // leader
                            if (target.getWorld().equals(ASkyBlock.getIslandWorld())) {
                                if (!Settings.kickedKeepInv) {
                                    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
                                    // Javadocs are
                                    target.getInventory().clear();
                                    // 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();
                                    // Update the inventory
                                    target.updateInventory();
                                }
                            }
                            if (!target.performCommand(Settings.SPAWNCOMMAND)) {
                                target.teleport(ASkyBlock.getIslandWorld().getSpawnLocation());
                            }
                        } else {
                            // Offline
                            if (DEBUG)
                                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
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemoved.replace("[name]", split[1]));
                        // removePlayerFromTeam(targetPlayer, teamLeader);
                        teamMembers.remove(targetPlayer);
                        if (teamMembers.size() < 2) {
                            if (!removePlayerFromTeam(player.getUniqueId(), teamLeader)) {
                                // If cancelled, return silently
                                return true;
                            }
                        }
                        plugin.getPlayers().save(targetPlayer);
                    } else {
                        plugin.getLogger().warning("Player " + player.getName() + " failed to remove " + plugin.getPlayers().getName(targetPlayer));
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, 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) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                        return true;
                    }
                    if (targetPlayer.equals(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError);
                        return true;
                    }
                    if (!plugin.getPlayers().inTeam(player.getUniqueId())) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorYouMustBeInTeam);
                        return true;
                    }
                    if (plugin.getPlayers().getMembers(player.getUniqueId()).size() > 2) {
                        Util.sendMessage(player, 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)) {
                                // Remove the target player from the team
                                if (!removePlayerFromTeam(targetPlayer, teamLeader, true)) {
                                    // If cancelled, return silently
                                    return true;
                                }
                                // Remove the leader from the team
                                if (!removePlayerFromTeam(teamLeader, teamLeader, true)) {
                                    // If cancelled, return silently
                                    return true;
                                }
                                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).makeLeadernameIsNowTheOwner.replace("[name]", plugin.getPlayers().getName(targetPlayer)));
                                // 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);
                                // Check if online
                                Player target = plugin.getServer().getPlayer(targetPlayer);
                                if (target == null) {
                                    plugin.getMessages().setMessage(targetPlayer, plugin.myLocale(player.getUniqueId()).makeLeaderyouAreNowTheOwner);
                                } else {
                                    // Online
                                    Util.sendMessage(plugin.getServer().getPlayer(targetPlayer), ChatColor.GREEN + plugin.myLocale(targetPlayer).makeLeaderyouAreNowTheOwner);
                                    // Check if new leader has a lower range permission than the island size
                                    boolean hasARangePerm = false;
                                    int range = Settings.islandProtectionRange;
                                    // Check for zero protection range
                                    Island islandByOwner = plugin.getGrid().getIsland(targetPlayer);
                                    if (islandByOwner.getProtectionSize() == 0) {
                                        plugin.getLogger().warning("Player " + player.getName() + "'s island had a protection range of 0. Setting to default " + range);
                                        islandByOwner.setProtectionSize(range);
                                    }
                                    for (PermissionAttachmentInfo perms : target.getEffectivePermissions()) {
                                        if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.range.")) {
                                            if (perms.getPermission().contains(Settings.PERMPREFIX + "island.range.*")) {
                                                // Ignore
                                                break;
                                            } else {
                                                String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.range.");
                                                if (spl.length > 1) {
                                                    if (!NumberUtils.isDigits(spl[1])) {
                                                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                                    } else {
                                                        hasARangePerm = true;
                                                        range = Math.max(range, Integer.valueOf(spl[1]));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // Only set the island range if the player has a perm to override the default
                                    if (hasARangePerm) {
                                        // Do some sanity checking
                                        if (range % 2 != 0) {
                                            range--;
                                        }
                                        // Range can go up or down
                                        if (range != islandByOwner.getProtectionSize()) {
                                            Util.sendMessage(player, ChatColor.GOLD + plugin.myLocale(targetPlayer).adminSetRangeUpdated.replace("[number]", String.valueOf(range)));
                                            Util.sendMessage(target, ChatColor.GOLD + plugin.myLocale(targetPlayer).adminSetRangeUpdated.replace("[number]", String.valueOf(range)));
                                            plugin.getLogger().info("Makeleader: Island protection range changed from " + islandByOwner.getProtectionSize() + " to " + range + " for " + player.getName() + " due to permission.");
                                        }
                                        islandByOwner.setProtectionSize(range);
                                    }
                                }
                                plugin.getGrid().saveGrid();
                                return true;
                            }
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorThatPlayerIsNotInTeam);
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorNotYourIsland);
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else {
                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                return true;
            }
            break;
    }
    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
    return true;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) BlockFace(org.bukkit.block.BlockFace) ArrayList(java.util.ArrayList) PlayerDropItemEvent(org.bukkit.event.player.PlayerDropItemEvent) Item(org.bukkit.entity.Item) OfflinePlayer(org.bukkit.OfflinePlayer) List(java.util.List) ArrayList(java.util.ArrayList) PermissionAttachmentInfo(org.bukkit.permissions.PermissionAttachmentInfo) UUID(java.util.UUID) Vector(org.bukkit.util.Vector) ASLocale(com.wasteofplastic.askyblock.ASLocale) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Island(com.wasteofplastic.askyblock.Island) IOException(java.io.IOException) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Collection(java.util.Collection) Block(org.bukkit.block.Block) ASkyBlock(com.wasteofplastic.askyblock.ASkyBlock) Sign(org.bukkit.block.Sign) MaterialData(org.bukkit.material.MaterialData) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) Schematic(com.wasteofplastic.askyblock.schematics.Schematic) Location(org.bukkit.Location)

Example 3 with Schematic

use of com.wasteofplastic.askyblock.schematics.Schematic in project askyblock by tastybento.

the class IslandCmd method loadSchematics.

/**
 * Loads schematics from the config.yml file. If the default
 * island is not included, it will be made up
 */
public void loadSchematics() {
    // Check if there is a schematic folder and make it if it does not exist
    File schematicFolder = new File(plugin.getDataFolder(), "schematics");
    if (!schematicFolder.exists()) {
        schematicFolder.mkdir();
    }
    // Clear the schematic list that is kept in memory
    schematics.clear();
    // Load the default schematic if it exists
    // Set up the default schematic
    File schematicFile = new File(schematicFolder, "island.schematic");
    File netherFile = new File(schematicFolder, "nether.schematic");
    if (!schematicFile.exists()) {
        // Only copy if the default exists
        if (plugin.getResource("schematics/island.schematic") != null) {
            plugin.getLogger().info("Default schematic does not exist, saving it...");
            plugin.saveResource("schematics/island.schematic", false);
            // Add it to schematics
            try {
                schematics.put("default", new Schematic(plugin, schematicFile));
            } catch (IOException e) {
                plugin.getLogger().severe("Could not load default schematic!");
                e.printStackTrace();
            }
        // If this is repeated later due to the schematic config, fine, it will only add info
        } else {
            // No islands.schematic in the jar, so just make the default using
            // built-in island generation
            schematics.put("default", new Schematic(plugin));
        }
        plugin.getLogger().info("Loaded default nether schematic");
    } else {
        // It exists, so load it
        try {
            schematics.put("default", new Schematic(plugin, schematicFile));
            plugin.getLogger().info("Loaded default island schematic.");
        } catch (IOException e) {
            plugin.getLogger().severe("Could not load default schematic!");
            e.printStackTrace();
        }
    }
    // Add the nether default too
    if (!netherFile.exists()) {
        if (plugin.getResource("schematics/nether.schematic") != null) {
            plugin.saveResource("schematics/nether.schematic", false);
            // Add it to schematics
            try {
                Schematic netherIsland = new Schematic(plugin, netherFile);
                netherIsland.setVisible(false);
                schematics.put("nether", netherIsland);
                plugin.getLogger().info("Loaded default nether schematic.");
            } catch (IOException e) {
                plugin.getLogger().severe("Could not load default nether schematic!");
                e.printStackTrace();
            }
        } else {
            plugin.getLogger().severe("Could not find default nether schematic!");
        }
    } else {
        // It exists, so load it
        try {
            Schematic netherIsland = new Schematic(plugin, netherFile);
            netherIsland.setVisible(false);
            schematics.put("nether", netherIsland);
            plugin.getLogger().info("Loaded default nether schematic.");
        } catch (IOException e) {
            plugin.getLogger().severe("Could not load default nether schematic!");
            e.printStackTrace();
        }
    }
    // Set up some basic settings just in case the schematics section is missing
    if (schematics.containsKey("default")) {
        schematics.get("default").setIcon(Material.GRASS);
        schematics.get("default").setOrder(1);
        schematics.get("default").setName("The Original");
        schematics.get("default").setDescription("");
        schematics.get("default").setPartnerName("nether");
        schematics.get("default").setBiome(Settings.defaultBiome);
        schematics.get("default").setIcon(Material.GRASS);
        if (Settings.chestItems.length == 0) {
            schematics.get("default").setUseDefaultChest(false);
        } else {
            schematics.get("default").setUseDefaultChest(true);
        }
    }
    if (schematics.containsKey("nether")) {
        schematics.get("nether").setName("NetherBlock Island");
        schematics.get("nether").setDescription("Nether Island");
        schematics.get("nether").setPartnerName("default");
        schematics.get("nether").setBiome(Biome.HELL);
        schematics.get("nether").setIcon(Material.NETHERRACK);
        schematics.get("nether").setVisible(false);
        schematics.get("nether").setPasteEntities(true);
        if (Settings.chestItems.length == 0) {
            schematics.get("nether").setUseDefaultChest(false);
        }
    }
    // Load the schematics from config.yml
    ConfigurationSection schemSection = plugin.getConfig().getConfigurationSection("schematicsection");
    if (plugin.getConfig().contains("schematicsection")) {
        Settings.useSchematicPanel = schemSection.getBoolean("useschematicspanel", false);
        Settings.chooseIslandRandomly = schemSection.getBoolean("chooseislandrandomly", false);
        ConfigurationSection schematicsSection = schemSection.getConfigurationSection("schematics");
        // Section exists, so go through the various sections
        for (String key : schematicsSection.getKeys(false)) {
            try {
                Schematic newSchem = null;
                // Check the file exists
                // plugin.getLogger().info("DEBUG: schematics." + key + ".filename" );
                String filename = schemSection.getString("schematics." + key + ".filename", "");
                if (!filename.isEmpty()) {
                    // plugin.getLogger().info("DEBUG: filename = " + filename);
                    // Check if this file exists or if it is in the jar
                    schematicFile = new File(schematicFolder, filename);
                    // See if the file exists
                    if (schematicFile.exists()) {
                        newSchem = new Schematic(plugin, schematicFile);
                    } else if (plugin.getResource("schematics/" + filename) != null) {
                        plugin.saveResource("schematics/" + filename, false);
                        newSchem = new Schematic(plugin, schematicFile);
                    }
                } else {
                    // plugin.getLogger().info("DEBUG: filename is empty");
                    if (key.equalsIgnoreCase("default")) {
                        // Øplugin.getLogger().info("DEBUG: key is default, so use this one");
                        newSchem = schematics.get("default");
                    } else {
                        plugin.getLogger().severe("Schematic " + key + " does not have a filename. Skipping!");
                    }
                }
                if (newSchem != null) {
                    // Set the heading
                    newSchem.setHeading(key);
                    // Order
                    newSchem.setOrder(schemSection.getInt("schematics." + key + ".order", 0));
                    // Icon
                    try {
                        Material icon;
                        String iconString = schemSection.getString("schematics." + key + ".icon", "MAP").toUpperCase();
                        // Support damage values
                        String[] split = iconString.split(":");
                        if (StringUtils.isNumeric(split[0])) {
                            icon = Material.getMaterial(Integer.parseInt(split[0]));
                            if (icon == null) {
                                icon = Material.MAP;
                                plugin.getLogger().severe("Schematic's icon could not be found. Try using quotes like '17:2'");
                            }
                        } else {
                            icon = Material.valueOf(split[0]);
                        }
                        int damage = 0;
                        if (split.length == 2) {
                            if (StringUtils.isNumeric(split[1])) {
                                damage = Integer.parseInt(split[1]);
                            }
                        }
                        newSchem.setIcon(icon, damage);
                    } catch (Exception e) {
                        // e.printStackTrace();
                        newSchem.setIcon(Material.MAP);
                    }
                    // Friendly name
                    String name = ChatColor.translateAlternateColorCodes('&', schemSection.getString("schematics." + key + ".name", ""));
                    newSchem.setName(name);
                    // Rating - Rating is not used right now
                    int rating = schemSection.getInt("schematics." + key + ".rating", 50);
                    if (rating < 1) {
                        rating = 1;
                    } else if (rating > 100) {
                        rating = 100;
                    }
                    newSchem.setRating(rating);
                    // Cost
                    double cost = schemSection.getDouble("schematics." + key + ".cost", 0D);
                    if (cost < 0) {
                        cost = 0;
                    }
                    newSchem.setCost(cost);
                    // Description
                    String description = ChatColor.translateAlternateColorCodes('&', schemSection.getString("schematics." + key + ".description", ""));
                    description = description.replace("[rating]", String.valueOf(rating));
                    if (Settings.useEconomy) {
                        description = description.replace("[cost]", String.valueOf(cost));
                    }
                    newSchem.setDescription(description);
                    // Permission
                    String perm = schemSection.getString("schematics." + key + ".permission", "");
                    newSchem.setPerm(perm);
                    // Use default chest
                    newSchem.setUseDefaultChest(schemSection.getBoolean("schematics." + key + ".useDefaultChest", true));
                    // Biomes - overrides default if it exists
                    String biomeString = schemSection.getString("schematics." + key + ".biome", Settings.defaultBiome.toString());
                    Biome biome = null;
                    try {
                        biome = Biome.valueOf(biomeString);
                        newSchem.setBiome(biome);
                    } catch (Exception e) {
                        plugin.getLogger().severe("Could not parse biome " + biomeString + " using default instead.");
                    }
                    // Use physics - overrides default if it exists
                    newSchem.setUsePhysics(schemSection.getBoolean("schematics." + key + ".usephysics", Settings.usePhysics));
                    // Paste Entities or not
                    newSchem.setPasteEntities(schemSection.getBoolean("schematics." + key + ".pasteentities", false));
                    // Paste air or not. Default is false - huge performance savings!
                    // newSchem.setPasteAir(schemSection.getBoolean("schematics." + key + ".pasteair",false));
                    // Visible in GUI or not
                    newSchem.setVisible(schemSection.getBoolean("schematics." + key + ".show", true));
                    // Partner schematic
                    if (biome != null && biome.equals(Biome.HELL)) {
                        // Default for nether biomes is the default overworld island
                        newSchem.setPartnerName(schemSection.getString("schematics." + key + ".partnerSchematic", "default"));
                    } else {
                        // Default for overworld biomes is nether island
                        newSchem.setPartnerName(schemSection.getString("schematics." + key + ".partnerSchematic", "nether"));
                    }
                    // Island companion
                    List<String> companion = schemSection.getStringList("schematics." + key + ".companion");
                    List<EntityType> companionTypes = new ArrayList<EntityType>();
                    if (!companion.isEmpty()) {
                        for (String companionType : companion) {
                            companionType = companionType.toUpperCase();
                            if (companionType.equalsIgnoreCase("NOTHING")) {
                                companionTypes.add(null);
                            } else {
                                try {
                                    EntityType type = EntityType.valueOf(companionType);
                                    companionTypes.add(type);
                                } catch (Exception e) {
                                    plugin.getLogger().warning("Island companion is not recognized in schematic '" + name + "'.");
                                }
                            }
                        }
                        newSchem.setIslandCompanion(companionTypes);
                    }
                    // Companion names
                    List<String> companionNames = schemSection.getStringList("schematics." + key + ".companionnames");
                    if (!companionNames.isEmpty()) {
                        List<String> names = new ArrayList<String>();
                        for (String companionName : companionNames) {
                            names.add(ChatColor.translateAlternateColorCodes('&', companionName));
                        }
                        newSchem.setCompanionNames(names);
                    }
                    // Get chest items
                    final List<String> chestItems = schemSection.getStringList("schematics." + key + ".chestItems");
                    if (!chestItems.isEmpty()) {
                        ItemStack[] tempChest = new ItemStack[chestItems.size()];
                        int i = 0;
                        for (String chestItemString : chestItems) {
                            // plugin.getLogger().info("DEBUG: chest item = " + chestItemString);
                            try {
                                String[] amountdata = chestItemString.split(":");
                                if (amountdata[0].equals("POTION")) {
                                    if (amountdata.length == 3) {
                                        Potion chestPotion = new Potion(PotionType.valueOf(amountdata[1]));
                                        tempChest[i++] = chestPotion.toItemStack(Integer.parseInt(amountdata[2]));
                                    } else if (amountdata.length == 4) {
                                        // Extended or splash potions
                                        if (amountdata[2].equals("EXTENDED")) {
                                            Potion chestPotion = new Potion(PotionType.valueOf(amountdata[1])).extend();
                                            tempChest[i++] = chestPotion.toItemStack(Integer.parseInt(amountdata[3]));
                                        } else if (amountdata[2].equals("SPLASH")) {
                                            Potion chestPotion = new Potion(PotionType.valueOf(amountdata[1])).splash();
                                            tempChest[i++] = chestPotion.toItemStack(Integer.parseInt(amountdata[3]));
                                        } else if (amountdata[2].equals("EXTENDEDSPLASH")) {
                                            Potion chestPotion = new Potion(PotionType.valueOf(amountdata[1])).extend().splash();
                                            tempChest[i++] = chestPotion.toItemStack(Integer.parseInt(amountdata[3]));
                                        }
                                    }
                                } else {
                                    Material mat;
                                    if (StringUtils.isNumeric(amountdata[0])) {
                                        mat = Material.getMaterial(Integer.parseInt(amountdata[0]));
                                    } else {
                                        mat = Material.getMaterial(amountdata[0].toUpperCase());
                                    }
                                    if (amountdata.length == 2) {
                                        tempChest[i++] = new ItemStack(mat, Integer.parseInt(amountdata[1]));
                                    } else if (amountdata.length == 3) {
                                        tempChest[i++] = new ItemStack(mat, Integer.parseInt(amountdata[2]), Short.parseShort(amountdata[1]));
                                    }
                                }
                            } catch (java.lang.IllegalArgumentException ex) {
                                plugin.getLogger().severe("Problem loading chest item for schematic '" + name + "' so skipping it: " + chestItemString);
                                plugin.getLogger().severe("Error is : " + ex.getMessage());
                                plugin.getLogger().info("Potential potion types are: ");
                                for (PotionType c : PotionType.values()) plugin.getLogger().info(c.name());
                            } catch (Exception e) {
                                plugin.getLogger().severe("Problem loading chest item for schematic '" + name + "' so skipping it: " + chestItemString);
                                plugin.getLogger().info("Potential material types are: ");
                                for (Material c : Material.values()) plugin.getLogger().info(c.name());
                            // e.printStackTrace();
                            }
                        }
                        // Store it
                        newSchem.setDefaultChestItems(tempChest);
                    }
                    // Player spawn block
                    String spawnBlock = schemSection.getString("schematics." + key + ".spawnblock");
                    if (spawnBlock != null) {
                        // Check to see if this block is a valid material
                        try {
                            Material playerSpawnBlock;
                            if (StringUtils.isNumeric(spawnBlock)) {
                                playerSpawnBlock = Material.getMaterial(Integer.parseInt(spawnBlock));
                            } else {
                                playerSpawnBlock = Material.valueOf(spawnBlock.toUpperCase());
                            }
                            if (newSchem.setPlayerSpawnBlock(playerSpawnBlock)) {
                                plugin.getLogger().info("Player will spawn at the " + playerSpawnBlock.toString());
                            } else {
                                plugin.getLogger().severe("Problem with schematic '" + name + "'. Spawn block '" + spawnBlock + "' not found in schematic or there is more than one. Skipping...");
                            }
                        } catch (Exception e) {
                            plugin.getLogger().severe("Problem with schematic '" + name + "'. Spawn block '" + spawnBlock + "' is unknown. Skipping...");
                        }
                    } else {
                    // plugin.getLogger().info("No spawn block found");
                    }
                    // Level handicap
                    newSchem.setLevelHandicap(schemSection.getInt("schematics." + key + ".levelHandicap", 0));
                    // Store it
                    schematics.put(key, newSchem);
                    if (perm.isEmpty()) {
                        perm = "all players";
                    } else {
                        perm = "player with " + perm + " permission";
                    }
                    plugin.getLogger().info("Loading schematic " + name + " (" + filename + ") for " + perm + ", order " + newSchem.getOrder());
                } else {
                    plugin.getLogger().warning("Could not find " + filename + " in the schematics folder! Skipping...");
                }
            } catch (IOException e) {
                plugin.getLogger().info("Error loading schematic in section " + key + ". Skipping...");
            }
        }
        if (schematics.isEmpty()) {
            tip();
        }
    }
}
Also used : Potion(org.bukkit.potion.Potion) ArrayList(java.util.ArrayList) Material(org.bukkit.Material) IOException(java.io.IOException) IOException(java.io.IOException) EntityType(org.bukkit.entity.EntityType) Biome(org.bukkit.block.Biome) PotionType(org.bukkit.potion.PotionType) ItemStack(org.bukkit.inventory.ItemStack) File(java.io.File) Schematic(com.wasteofplastic.askyblock.schematics.Schematic) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 4 with Schematic

use of com.wasteofplastic.askyblock.schematics.Schematic in project askyblock by tastybento.

the class IslandCmd method getSchematics.

/**
 * List schematics this player can access. If @param ignoreNoPermission is true, then only
 * schematics with a specific permission set will be checked. I.e., no common schematics will
 * be returned (including the default one).
 * @param player
 * @param ignoreNoPermission
 * @return List of schematics this player can use based on their permission level
 */
public List<Schematic> getSchematics(Player player, boolean ignoreNoPermission) {
    List<Schematic> result = new ArrayList<Schematic>();
    // Bukkit.getLogger().info("DEBUG: Checking schematics for " + player.getName());
    for (Schematic schematic : schematics.values()) {
        // Bukkit.getLogger().info("DEBUG: perm is " + schematic.getPerm());
        if ((!ignoreNoPermission && schematic.getPerm().isEmpty()) || VaultHelper.checkPerm(player, schematic.getPerm())) {
            // Only add if it's visible
            if (schematic.isVisible()) {
                // Check if it's a nether island, but the nether is not enables
                if (schematic.getBiome().equals(Biome.HELL)) {
                    if (Settings.createNether && Settings.newNether && ASkyBlock.getNetherWorld() != null) {
                        result.add(schematic);
                    }
                } else {
                    result.add(schematic);
                }
            }
        }
    }
    // Sort according to order
    Collections.sort(result, new Comparator<Schematic>() {

        @Override
        public int compare(Schematic o1, Schematic o2) {
            return ((o2.getOrder() < o1.getOrder()) ? 1 : -1);
        }
    });
    return result;
}
Also used : ArrayList(java.util.ArrayList) Schematic(com.wasteofplastic.askyblock.schematics.Schematic)

Example 5 with Schematic

use of com.wasteofplastic.askyblock.schematics.Schematic in project askyblock by tastybento.

the class SchematicsPanel method getPanel.

/**
 * Returns a customized panel of available Schematics for the player
 *
 * @param player
 * @return custom Inventory object or null if there are no valid schematics for this player
 */
public Inventory getPanel(Player player) {
    // Go through the available schematics for this player
    int slot = 0;
    List<SPItem> items = new ArrayList<SPItem>();
    List<Schematic> availableSchems = plugin.getIslandCmd().getSchematics(player, false);
    // Generate additional available schematics
    for (Schematic schematic : availableSchems) {
        if (schematic.isVisible()) {
            items.add(new SPItem(schematic, slot++));
        }
    }
    // Now create the inventory panel
    if (items.size() > 0) {
        // Save the items for later retrieval when the player clicks on them
        schematicItems.put(player.getUniqueId(), items);
        // Make sure size is a multiple of 9
        int size = items.size() + 8;
        size -= (size % 9);
        Inventory newPanel = Bukkit.createInventory(null, size, plugin.myLocale(player.getUniqueId()).schematicsTitle);
        // Fill the inventory and return
        for (SPItem i : items) {
            newPanel.setItem(i.getSlot(), i.getItem());
        }
        return newPanel;
    } else {
        Util.sendMessage(player, ChatColor.RED + plugin.myLocale().errorCommandNotReady);
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) Schematic(com.wasteofplastic.askyblock.schematics.Schematic) Inventory(org.bukkit.inventory.Inventory)

Aggregations

Schematic (com.wasteofplastic.askyblock.schematics.Schematic)5 ArrayList (java.util.ArrayList)4 Island (com.wasteofplastic.askyblock.Island)2 IOException (java.io.IOException)2 UUID (java.util.UUID)2 Location (org.bukkit.Location)2 Inventory (org.bukkit.inventory.Inventory)2 ItemStack (org.bukkit.inventory.ItemStack)2 ASLocale (com.wasteofplastic.askyblock.ASLocale)1 ASkyBlock (com.wasteofplastic.askyblock.ASkyBlock)1 IslandEnterEvent (com.wasteofplastic.askyblock.events.IslandEnterEvent)1 SafeTeleportBuilder (com.wasteofplastic.askyblock.util.teleport.SafeTeleportBuilder)1 File (java.io.File)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Material (org.bukkit.Material)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 World (org.bukkit.World)1