Search in sources :

Example 1 with MagicWarp

use of com.elmakers.mine.bukkit.warp.MagicWarp in project MagicPlugin by elBukkit.

the class RecallAction method perform.

@Override
public SpellResult perform(CastContext context) {
    if (pendingTeleport != null) {
        return doTeleport();
    }
    if (isActive) {
        if (context.getMage().getActiveGUI() != this) {
            if (context.getTargetLocation() == null) {
                isActive = false;
                return SpellResult.NO_TARGET;
            }
            if (delayExpiration > 0 && System.currentTimeMillis() < delayExpiration) {
                return SpellResult.PENDING;
            }
            if (delayExpiration == 0 && delay > 0) {
                context.playEffects("wait");
                delayExpiration = System.currentTimeMillis() + delay;
                return SpellResult.PENDING;
            }
            isActive = false;
            if (teleport) {
                return doTeleport();
            }
            return SpellResult.CAST;
        }
        return SpellResult.PENDING;
    }
    this.context = context;
    enabledTypes.clear();
    options.clear();
    Mage mage = context.getMage();
    MageController controller = context.getController();
    Player player = mage.getPlayer();
    if (player == null) {
        return SpellResult.PLAYER_REQUIRED;
    }
    Set<String> unlockedWarps = new HashSet<>();
    ConfigurationSection mageData = mage.getData();
    String unlockedString = mageData.getString(unlockKey);
    if (unlockedString != null && !unlockedString.isEmpty()) {
        unlockedWarps.addAll(Arrays.asList(StringUtils.split(unlockedString, ',')));
    }
    Set<String> friends = new HashSet<>();
    String friendString = mageData.getString(friendKey);
    if (friendString != null && !friendString.isEmpty()) {
        friends.addAll(Arrays.asList(StringUtils.split(friendString, ',')));
    }
    ConfigurationSection warpConfig = null;
    if (parameters.contains("warps")) {
        warpConfig = ConfigurationUtils.getConfigurationSection(parameters, "warps");
    }
    if (parameters.getBoolean("allow_magic_warps", true) && controller instanceof MagicController) {
        String group = parameters.getString("group", null);
        MagicController magic = (MagicController) controller;
        Collection<MagicWarp> warps = magic.getWarps().getMagicWarps();
        if (!warps.isEmpty() && warpConfig == null) {
            warpConfig = ConfigurationUtils.newConfigurationSection();
        }
        for (MagicWarp warp : warps) {
            String icon = warp.getIcon();
            if (icon == null || icon.isEmpty())
                continue;
            String warpGroup = warp.getGroup();
            if (group != null && !group.isEmpty() && warpGroup != null && !warpGroup.isEmpty() && !warpGroup.equalsIgnoreCase(group))
                continue;
            ConfigurationSection magicWarpConfig = ConfigurationUtils.newConfigurationSection();
            magicWarpConfig.set("name", warp.getName());
            magicWarpConfig.set("icon", icon);
            magicWarpConfig.set("description", warp.getDescription());
            magicWarpConfig.set("locked", warp.isLocked());
            warpConfig.set(warp.getKey(), magicWarpConfig);
        }
    }
    ConfigurationSection commandConfig = null;
    if (parameters.contains("commands")) {
        commandConfig = ConfigurationUtils.getConfigurationSection(parameters, "commands");
    }
    if (parameters.contains("unlock")) {
        String unlockWarp = parameters.getString("unlock");
        if (unlockWarp == null || unlockWarp.isEmpty() || unlockedWarps.contains(unlockWarp)) {
            return SpellResult.NO_ACTION;
        }
        if (warpConfig == null && commandConfig == null) {
            return SpellResult.FAIL;
        }
        unlockedWarps.add(unlockWarp);
        unlockedString = StringUtils.join(unlockedWarps, ",");
        mageData.set(unlockKey, unlockedString);
        String warpName = unlockWarp;
        ConfigurationSection config = warpConfig == null ? null : warpConfig.getConfigurationSection(unlockWarp);
        if (config != null) {
            warpName = config.getString("name", warpName);
        } else {
            config = commandConfig == null ? null : commandConfig.getConfigurationSection(unlockWarp);
            if (config != null) {
                warpName = config.getString("name", warpName);
            }
        }
        warpName = CompatibilityLib.getCompatibilityUtils().translateColors(warpName);
        String unlockMessage = context.getMessage("unlock_warp").replace("$name", warpName);
        context.sendMessageKey("unlock_warp", unlockMessage);
        return SpellResult.CAST;
    }
    if (parameters.contains("lock")) {
        String lockWarpString = parameters.getString("lock");
        String[] lockWarps = StringUtils.split(lockWarpString, ',');
        boolean locked = false;
        for (String lockWarp : lockWarps) {
            if (unlockedWarps.contains(lockWarp)) {
                locked = true;
                unlockedWarps.remove(lockWarp);
            }
        }
        if (locked) {
            unlockedString = StringUtils.join(unlockedWarps, ",");
            mageData.set(unlockKey, unlockedString);
        }
        return locked ? SpellResult.DEACTIVATE : SpellResult.NO_ACTION;
    }
    if (parameters.contains("addfriend")) {
        String friendName = parameters.getString("addfriend");
        if (friendName == null || friendName.isEmpty()) {
            return SpellResult.NO_ACTION;
        }
        Player online = null;
        if (friendName.equals("target")) {
            Entity targetEntity = context.getTargetEntity();
            if (targetEntity != null && targetEntity instanceof Player) {
                online = (Player) targetEntity;
            }
        } else if (friendName.equals("source")) {
            Entity sourceEntity = context.getEntity();
            if (sourceEntity != null && sourceEntity instanceof Player) {
                online = (Player) sourceEntity;
            }
        } else {
            online = CompatibilityLib.getDeprecatedUtils().getPlayer(friendName);
        }
        if (online == null) {
            return SpellResult.FAIL;
        }
        String uuid = online.getUniqueId().toString();
        if (friends.contains(uuid)) {
            return SpellResult.NO_ACTION;
        }
        friends.add(uuid);
        friendString = StringUtils.join(friends, ",");
        mageData.set(friendKey, friendString);
        String message = context.getMessage("add_friend").replace("$name", online.getDisplayName());
        context.sendMessageKey("add_friend", message);
        return SpellResult.CAST;
    }
    if (parameters.contains("removefriend")) {
        String friendName = parameters.getString("removefriend");
        Player online = CompatibilityLib.getDeprecatedUtils().getPlayer(friendName);
        if (online == null) {
            return SpellResult.FAIL;
        }
        String uuid = online.getUniqueId().toString();
        if (!friends.contains(uuid)) {
            return SpellResult.NO_ACTION;
        }
        friends.remove(uuid);
        friendString = StringUtils.join(friends, ",");
        mageData.set(friendKey, friendString);
        String message = context.getMessage("remove_friend").replace("$name", online.getDisplayName());
        context.sendMessageKey("remove_friend", message);
        return SpellResult.DEACTIVATE;
    }
    // Add configured options
    Location playerLocation = mage.getLocation();
    Set<RecallType> optionTypes = new HashSet<>();
    Collection<ConfigurationSection> optionConfiguration = ConfigurationUtils.getNodeList(parameters, "options");
    if (optionConfiguration != null) {
        for (ConfigurationSection optionConfig : optionConfiguration) {
            Waypoint newWaypoint = new Waypoint(context, optionConfig);
            options.add(newWaypoint);
            optionTypes.add(newWaypoint.type);
        }
    }
    // Automatically append enabled types if not defined in options
    boolean allowAll = parameters.getBoolean("allow_all", true);
    for (RecallType testType : RecallType.values()) {
        if (!optionTypes.contains(testType) && parameters.getBoolean("allow_" + testType.name().toLowerCase(), allowAll && testType.showByDefault)) {
            switch(testType) {
                case FRIENDS:
                    for (String friendId : friends) {
                        Waypoint targetLocation = getFriend(friendId);
                        if (targetLocation != null && targetLocation.isValid(allowCrossWorld, playerLocation)) {
                            options.add(targetLocation);
                        }
                    }
                    break;
                case REMOVE_FRIENDS:
                    for (String friendId : friends) {
                        Waypoint targetFriend = getRemoveFriend(friendId);
                        if (targetFriend != null) {
                            options.add(targetFriend);
                        }
                    }
                    break;
                case WARP:
                    // Legacy warp config
                    if (warpConfig != null) {
                        Collection<String> warpKeys = warpConfig.getKeys(false);
                        for (String warpKey : warpKeys) {
                            ConfigurationSection config = warpConfig.getConfigurationSection(warpKey);
                            config.set("warp", warpKey);
                            Waypoint warp = new Waypoint(context, config);
                            options.add(warp);
                        }
                    }
                    break;
                case COMMAND:
                    // Legacy command config
                    if (commandConfig != null) {
                        Collection<String> commandKeys = commandConfig.getKeys(false);
                        for (String commandKey : commandKeys) {
                            ConfigurationSection config = commandConfig.getConfigurationSection(commandKey);
                            Waypoint command = new Waypoint(context, config);
                            options.add(command);
                        }
                    }
                    break;
                case WAND:
                    List<LostWand> lostWands = mage.getLostWands();
                    for (LostWand lostWand : lostWands) {
                        Waypoint targetLocation = getWaypoint(player, testType, lostWand.getLocation(), parameters, context);
                        if (targetLocation != null && targetLocation.isValid(allowCrossWorld, playerLocation)) {
                            options.add(targetLocation);
                        }
                    }
                    break;
                case SOULS:
                    List<DeathLocation> deathLocations = controller.getDeathLocations(player);
                    if (deathLocations != null) {
                        for (DeathLocation death : deathLocations) {
                            Waypoint targetLocation = getWaypoint(player, testType, death.getLocation(), parameters, context);
                            if (targetLocation != null && targetLocation.isValid(allowCrossWorld, playerLocation)) {
                                ItemStack[] items = death.getItems();
                                int itemCount = items == null ? 0 : items.length;
                                targetLocation.description = targetLocation.description.replace("$items", Integer.toString(itemCount)).replace("$xp", Integer.toString(death.getExperiencePoints()));
                                options.add(targetLocation);
                            }
                        }
                    }
                    break;
                case ALL_REGIONS:
                case REGIONS:
                    boolean allRegions = testType == RecallType.ALL_REGIONS;
                    Set<String> warpProviders = controller.getPlayerWarpProviderKeys();
                    for (String key : warpProviders) {
                        String allowKey = allRegions ? "all_" : "";
                        boolean allowDefault = allRegions ? false : true;
                        if (parameters.getBoolean("allow_" + allowKey + key.toLowerCase(), allowDefault)) {
                            Collection<PlayerWarp> warps = allRegions ? controller.getAllPlayerWarps(key) : controller.getPlayerWarps(player, key);
                            if (warps == null) {
                                break;
                            }
                            for (PlayerWarp warp : warps) {
                                Location location = warp.getLocation();
                                String description = warp.getDescription();
                                if (description == null) {
                                    description = context.getMessage("description_" + key, context.getMessage("description_regions"));
                                }
                                ItemData icon;
                                MaterialAndData warpIcon = (MaterialAndData) warp.getIcon();
                                if (warpIcon != null) {
                                    icon = context.getController().getOrCreateItem(warpIcon);
                                } else {
                                    icon = getIcon(context, parameters, "icon_" + key);
                                    if (icon == null) {
                                        icon = getIcon(context, parameters, "icon_regions");
                                    }
                                }
                                Waypoint waypoint = new Waypoint(context, RecallType.REGIONS, location, warp.getName(), context.getMessage("cast_" + key, context.getMessage("cast_regions")), context.getMessage("no_target_" + key, context.getMessage("no_target_regions")), description, icon, true);
                                if (waypoint.isValid(allowCrossWorld, playerLocation)) {
                                    options.add(waypoint);
                                }
                            }
                        }
                    }
                    break;
                default:
                    Waypoint targetLocation = getWaypoint(player, testType, null, parameters, context);
                    if (targetLocation != null && targetLocation.isValid(allowCrossWorld, playerLocation)) {
                        options.add(targetLocation);
                    }
                    break;
            }
        }
    }
    // Process special commands
    if (parameters.contains("warp")) {
        String warpName = parameters.getString("warp");
        Waypoint waypoint = getWarp(warpName);
        if (tryTeleport(player, waypoint)) {
            if (teleport) {
                return doTeleport();
            }
            return SpellResult.CAST;
        }
        return SpellResult.FAIL;
    } else if (parameters.contains("type")) {
        String typeString = parameters.getString("type", "");
        if (parameters.getBoolean("allow_marker", true)) {
            if (typeString.equalsIgnoreCase("remove")) {
                if (removeMarker()) {
                    return SpellResult.TARGET_SELECTED;
                }
                return SpellResult.FAIL;
            }
            if (typeString.equalsIgnoreCase("place")) {
                Block block = context.getLocation().getBlock();
                if (parameters.getBoolean("marker_requires_build", true) && !context.hasBuildPermission(block)) {
                    return SpellResult.NO_TARGET;
                }
                if (hasMarker() && parameters.getBoolean("confirm_marker", true)) {
                    showMarkerConfirm(context);
                    return SpellResult.CAST;
                }
                if (placeMarker(block, 1)) {
                    return SpellResult.TARGET_SELECTED;
                }
                return SpellResult.FAIL;
            }
        }
        RecallType recallType;
        try {
            recallType = RecallType.valueOf(typeString.toUpperCase());
            ;
        } catch (Exception ex) {
            controller.getLogger().warning("Invalid recall type: " + typeString);
            return SpellResult.FAIL;
        }
        Waypoint location = getWaypoint(player, recallType, null, parameters, context);
        if (tryTeleport(player, location)) {
            if (teleport) {
                return doTeleport();
            }
            return SpellResult.CAST;
        }
        return SpellResult.FAIL;
    }
    if (options.size() == 0) {
        return SpellResult.NO_TARGET;
    }
    String inventoryTitle = context.getMessage(titleKey, parameters.getString("title", "Recall"));
    int invSize = (int) Math.ceil(options.size() / 9.0f) * 9;
    Inventory displayInventory = CompatibilityLib.getCompatibilityUtils().createInventory(null, invSize, inventoryTitle);
    int index = 0;
    for (Waypoint waypoint : options) {
        if (waypoint.permission != null && !player.hasPermission(waypoint.permission))
            continue;
        boolean isPlaceholder = waypoint.type == RecallType.PLACEHOLDER;
        boolean isValid = !isPlaceholder && waypoint.isValid(allowCrossWorld, playerLocation);
        boolean isUnavailable = false;
        if (!isPlaceholder && !parameters.getBoolean("allow_" + waypoint.type.name().toLowerCase(), true)) {
            isUnavailable = true;
        }
        if (!isUnavailable && waypoint.locked && (waypoint.warpName == null || !unlockedWarps.contains(waypoint.warpName))) {
            if (!waypoint.showUnavailable) {
                continue;
            }
            isUnavailable = true;
        }
        if (!isValid) {
            isUnavailable = true;
        }
        if (isUnavailable && !waypoint.showUnavailable) {
            waypoint.unavailable = true;
            isPlaceholder = true;
        }
        ItemStack waypointItem = null;
        if (isPlaceholder) {
            String iconPlaceholderKey = parameters.getString("placeholder_icon", "air");
            waypointItem = controller.createItem(iconPlaceholderKey);
            if (waypointItem == null) {
                waypointItem = new ItemStack(DefaultWaypointMaterial);
            }
        } else if (isUnavailable) {
            if (waypoint.unavailableIcon != null) {
                waypointItem = waypoint.unavailableIcon.getItemStack(1);
            } else if (waypoint.iconURL != null && !waypoint.iconURL.isEmpty()) {
                waypointItem = controller.getURLSkull(waypoint.iconURL);
            } else if (waypoint.icon != null) {
                waypointItem = waypoint.icon.getItemStack(1);
            }
        } else {
            if (waypoint.iconURL != null && !waypoint.iconURL.isEmpty()) {
                waypointItem = controller.getURLSkull(waypoint.iconURL);
            } else if (waypoint.icon != null) {
                waypointItem = waypoint.icon.getItemStack(1);
            }
        }
        ItemMeta meta = waypointItem == null ? null : waypointItem.getItemMeta();
        if (meta == null && !isPlaceholder) {
            waypointItem = new ItemStack(DefaultWaypointMaterial);
            meta = waypointItem.getItemMeta();
            controller.getLogger().warning("Invalid waypoint icon for " + waypoint.name);
        }
        if (meta != null) {
            String name = waypoint.name;
            if (!isValid || isUnavailable || isPlaceholder) {
                name = context.getMessage("unavailable_name", " ").replace("$name", name);
            }
            meta.setDisplayName(name);
            if (waypoint.description != null && waypoint.description.length() > 0) {
                List<String> lore = new ArrayList<>();
                CompatibilityLib.getInventoryUtils().wrapText(context.parameterize(waypoint.description), lore);
                meta.setLore(lore);
            }
            String invalidMessage = context.getMessage("invalid_description");
            if (!isValid) {
                List<String> lore = meta.getLore();
                if (lore == null) {
                    lore = new ArrayList<>();
                }
                CompatibilityLib.getInventoryUtils().wrapText(invalidMessage, lore);
                meta.setLore(lore);
            } else if (isUnavailable && waypoint.unavailableMessage != null && waypoint.unavailableMessage.length() > 0) {
                List<String> lore = meta.getLore();
                if (lore == null) {
                    lore = new ArrayList<>();
                }
                CompatibilityLib.getInventoryUtils().wrapText(waypoint.unavailableMessage, lore);
                meta.setLore(lore);
            }
            waypointItem.setItemMeta(meta);
            waypointItem = CompatibilityLib.getItemUtils().makeReal(waypointItem);
            CompatibilityLib.getItemUtils().hideFlags(waypointItem, CompatibilityConstants.ALL_HIDE_FLAGS);
            CompatibilityLib.getNBTUtils().setString(waypointItem, "waypoint", "true");
            CompatibilityLib.getItemUtils().makeUnbreakable(waypointItem);
            if (isPlaceholder) {
                CompatibilityLib.getNBTUtils().setBoolean(waypointItem, "placeholder", true);
            }
            if (isUnavailable) {
                CompatibilityLib.getNBTUtils().setBoolean(waypointItem, "unavailable", true);
            }
        }
        displayInventory.setItem(index, waypointItem);
        index++;
        // The inventory will limit its own size
        if (index >= displayInventory.getSize())
            break;
    }
    context.playEffects("menu");
    mage.activateGUI(this, displayInventory);
    isActive = true;
    return SpellResult.PENDING;
}
Also used : Entity(org.bukkit.entity.Entity) ArrayList(java.util.ArrayList) MageController(com.elmakers.mine.bukkit.api.magic.MageController) LostWand(com.elmakers.mine.bukkit.api.wand.LostWand) PlayerWarp(com.elmakers.mine.bukkit.api.protection.PlayerWarp) MagicController(com.elmakers.mine.bukkit.magic.MagicController) ArrayList(java.util.ArrayList) List(java.util.List) ItemMeta(org.bukkit.inventory.meta.ItemMeta) HashSet(java.util.HashSet) Player(org.bukkit.entity.Player) DeathLocation(com.elmakers.mine.bukkit.api.magic.DeathLocation) MagicWarp(com.elmakers.mine.bukkit.warp.MagicWarp) Mage(com.elmakers.mine.bukkit.api.magic.Mage) MaterialAndData(com.elmakers.mine.bukkit.block.MaterialAndData) Block(org.bukkit.block.Block) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Location(org.bukkit.Location) DeathLocation(com.elmakers.mine.bukkit.api.magic.DeathLocation) ItemData(com.elmakers.mine.bukkit.api.item.ItemData)

Example 2 with MagicWarp

use of com.elmakers.mine.bukkit.warp.MagicWarp in project MagicPlugin by elBukkit.

the class MagicWarpCommandExecutor method onSendWarp.

private void onSendWarp(CommandSender sender, Entity entity, String warpName) {
    Location location = magicController.getWarp(warpName);
    if (location == null || location.getWorld() == null) {
        MagicWarp magicWarp = magicController.getWarps().getMagicWarp(warpName);
        if (magicWarp != null) {
            String worldName = magicWarp.getWorldName();
            if (worldName != null) {
                sender.sendMessage(ChatColor.YELLOW + "Attempting to load target world " + ChatColor.WHITE + worldName + ChatColor.YELLOW + ", please wait");
                controller.createWorld(worldName);
                location = magicWarp.getLocation();
            }
        }
    }
    if (location == null || location.getWorld() == null) {
        sender.sendMessage(ChatColor.RED + "The target location for warp: " + ChatColor.DARK_RED + warpName + ChatColor.RED + " is not available");
        return;
    }
    entity.teleport(location);
}
Also used : MagicWarp(com.elmakers.mine.bukkit.warp.MagicWarp) Location(org.bukkit.Location)

Example 3 with MagicWarp

use of com.elmakers.mine.bukkit.warp.MagicWarp in project MagicPlugin by elBukkit.

the class MagicWarpCommandExecutor method onDescribeWarp.

private void onDescribeWarp(CommandSender sender, String warpName) {
    MagicWarp warp = magicController.getWarps().getMagicWarp(warpName);
    if (warp == null) {
        Location genericWarp = magicController.getWarp(warpName);
        if (genericWarp != null) {
            sender.sendMessage(ChatColor.AQUA + "Non-Magic warp " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + " goes to " + TextUtils.printLocation(genericWarp, 0));
            return;
        }
        sender.sendMessage(ChatColor.RED + "Unknown warp: " + ChatColor.DARK_RED + warpName);
        return;
    }
    warp.describe(sender);
}
Also used : MagicWarp(com.elmakers.mine.bukkit.warp.MagicWarp) Location(org.bukkit.Location)

Example 4 with MagicWarp

use of com.elmakers.mine.bukkit.warp.MagicWarp in project MagicPlugin by elBukkit.

the class MagicWarpCommandExecutor method onConfigureWarp.

private void onConfigureWarp(CommandSender sender, String warpName, String[] parameters) {
    MagicWarp warp = magicController.getWarps().getMagicWarp(warpName);
    if (warp == null) {
        sender.sendMessage(ChatColor.RED + "Unknown warp: " + ChatColor.DARK_RED + warpName);
        return;
    }
    if (parameters.length == 0) {
        sender.sendMessage(ChatColor.RED + "Missing parameter name");
        return;
    }
    String parameterKey = parameters[0];
    String value = "";
    MagicController magic = (MagicController) controller;
    if (parameters.length > 0) {
        value = StringUtils.join(Arrays.copyOfRange(parameters, 1, parameters.length), ' ');
    }
    if (parameterKey.equalsIgnoreCase("marker_icon")) {
        if (value.isEmpty()) {
            warp.removeMarker(magic);
            warp.setMarkerIcon(null);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.RED + ", cleared " + ChatColor.YELLOW + "marker icon");
        } else {
            warp.setMarkerIcon(value);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + "marker icon" + ChatColor.AQUA + " to " + ChatColor.GOLD + value);
        }
    } else if (parameterKey.equalsIgnoreCase("name")) {
        if (value.isEmpty()) {
            warp.setName(null);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.RED + ", cleared " + ChatColor.YELLOW + parameterKey);
        } else {
            warp.setName(value);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + parameterKey + ChatColor.AQUA + " to " + ChatColor.GOLD + value);
        }
    } else if (parameterKey.equalsIgnoreCase("description")) {
        if (value.isEmpty()) {
            warp.setDescription(null);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.RED + ", cleared " + ChatColor.YELLOW + parameterKey);
        } else {
            warp.setDescription(value);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + parameterKey + ChatColor.AQUA + " to " + ChatColor.GOLD + value);
        }
    } else if (parameterKey.equalsIgnoreCase("marker_set")) {
        warp.removeMarker(magic);
        if (value.isEmpty()) {
            warp.setMarkerSet(null);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.RED + ", cleared " + ChatColor.YELLOW + "marker set");
        } else {
            warp.setMarkerSet(value);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + "marker set" + ChatColor.AQUA + " to " + ChatColor.GOLD + value);
        }
    } else if (parameterKey.equalsIgnoreCase("icon")) {
        if (value.isEmpty()) {
            warp.setIcon(null);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.RED + ", cleared " + ChatColor.YELLOW + parameterKey);
        } else {
            warp.setIcon(value);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + parameterKey + ChatColor.AQUA + " to " + ChatColor.GOLD + value);
        }
    } else if (parameterKey.equalsIgnoreCase("group")) {
        if (value.isEmpty()) {
            warp.setGroup(null);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.RED + ", cleared " + ChatColor.YELLOW + parameterKey);
        } else {
            warp.setGroup(value);
            sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + parameterKey + ChatColor.AQUA + " to " + ChatColor.GOLD + value);
        }
    } else if (parameterKey.equalsIgnoreCase("locked")) {
        boolean bValue = value.equalsIgnoreCase("true");
        warp.setLocked(bValue);
        sender.sendMessage(ChatColor.AQUA + "Configured warp: " + ChatColor.DARK_AQUA + warpName + ChatColor.AQUA + ", set " + ChatColor.YELLOW + parameterKey + ChatColor.AQUA + " to " + ChatColor.GOLD + bValue);
    } else {
        sender.sendMessage(ChatColor.RED + "Unknown warp parameter: " + ChatColor.YELLOW + parameterKey);
        return;
    }
    warp.checkMarker(magic);
}
Also used : MagicWarp(com.elmakers.mine.bukkit.warp.MagicWarp) MagicController(com.elmakers.mine.bukkit.magic.MagicController)

Aggregations

MagicWarp (com.elmakers.mine.bukkit.warp.MagicWarp)4 Location (org.bukkit.Location)3 MagicController (com.elmakers.mine.bukkit.magic.MagicController)2 ItemData (com.elmakers.mine.bukkit.api.item.ItemData)1 DeathLocation (com.elmakers.mine.bukkit.api.magic.DeathLocation)1 Mage (com.elmakers.mine.bukkit.api.magic.Mage)1 MageController (com.elmakers.mine.bukkit.api.magic.MageController)1 PlayerWarp (com.elmakers.mine.bukkit.api.protection.PlayerWarp)1 LostWand (com.elmakers.mine.bukkit.api.wand.LostWand)1 MaterialAndData (com.elmakers.mine.bukkit.block.MaterialAndData)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Block (org.bukkit.block.Block)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 Entity (org.bukkit.entity.Entity)1 Player (org.bukkit.entity.Player)1 Inventory (org.bukkit.inventory.Inventory)1 ItemStack (org.bukkit.inventory.ItemStack)1 ItemMeta (org.bukkit.inventory.meta.ItemMeta)1