Search in sources :

Example 1 with ItemFlagGui

use of br.net.fabiozumbi12.RedProtect.Sponge.guis.ItemFlagGui in project RedProtect by FabioZumbi12.

the class CommandHandlers method handleFlag.

public static void handleFlag(Player p, String flag, String value, Region r) {
    if (checkCmd(flag, "help")) {
        sendFlagHelp(p);
        return;
    }
    if (r == null) {
        RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.todo.that");
        return;
    }
    Object objflag = RedProtect.get().getUtil().parseObject(value);
    if ((RedProtect.get().getPermissionHandler().hasFlagPerm(p, flag) && (RedProtect.get().getConfigManager().configRoot().flags.containsKey(flag) || RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag))) || flag.equalsIgnoreCase("info")) {
        if (r.isAdmin(p) || r.isLeader(p) || RedProtect.get().getPermissionHandler().hasPerm(p, "redprotect.command.admin.flag")) {
            if (checkCmd(flag, "info")) {
                p.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + "------------[" + RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.values") + "]------------");
                p.sendMessage(r.getFlagInfo());
                p.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + "------------------------------------");
                return;
            }
            if (value.equalsIgnoreCase("remove")) {
                if (RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag) && r.getFlags().containsKey(flag)) {
                    r.removeFlag(flag);
                    RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.removed").replace("{flag}", flag).replace("{region}", r.getName()));
                    RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " REMOVED FLAG " + flag + " of region " + r.getName());
                    return;
                } else {
                    RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.notset").replace("{flag}", flag));
                    return;
                }
            }
            if (!value.equals("")) {
                if (RedProtect.get().getConfigManager().getDefFlagsValues().containsKey(flag) && !RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag)) {
                    // flag clan
                    if (flag.equalsIgnoreCase("clan")) {
                        if (!RedProtect.get().hooks.checkSC() || !RedProtect.get().getPermissionHandler().hasPerm(p, "redprotect.admin.flag.clan")) {
                            sendFlagHelp(p);
                            return;
                        }
                        if (!RedProtect.get().hooks.clanManager.isClan(value)) {
                            RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.invalidclan").replace("{tag}", value));
                            return;
                        }
                        Clan clan = RedProtect.get().hooks.clanManager.getClan(value);
                        if (!clan.isLeader(p)) {
                            RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.clancommand");
                            return;
                        }
                        if (r.setFlag(p, flag, value)) {
                            RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagString(flag));
                            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                        }
                        return;
                    }
                    if (objflag instanceof Boolean) {
                        if (r.setFlag(p, flag, objflag)) {
                            RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
                            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                        }
                    } else {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.usage") + " <true/false>");
                    }
                    return;
                }
                if (RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag)) {
                    if (!validate(flag, objflag)) {
                        SendFlagUsageMessage(p, flag);
                        return;
                    }
                    if (r.setFlag(p, flag, objflag)) {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagString(flag));
                        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                    }
                    return;
                }
                sendFlagHelp(p);
            } else {
                // Flag clan
                if (flag.equalsIgnoreCase("clan")) {
                    if (RedProtect.get().hooks.checkSC()) {
                        ClanPlayer clan = RedProtect.get().hooks.clanManager.getClanPlayer(p);
                        if (clan == null) {
                            RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.haveclan");
                            return;
                        }
                        if (!clan.isLeader()) {
                            RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.clancommand");
                            return;
                        }
                        if (r.getFlagString(flag).equalsIgnoreCase("")) {
                            if (r.setFlag(p, flag, clan.getTag())) {
                                RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.setclan").replace("{clan}", "'" + clan.getClan().getColorTag() + "'"));
                            }
                        } else {
                            RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.denyclan").replace("{clan}", "'" + r.getFlagString(flag) + "'"));
                            r.setFlag(p, flag, "");
                        }
                        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                        return;
                    } else {
                        sendFlagHelp(p);
                        return;
                    }
                }
                // Item flags
                if (RedProtect.get().getPermissionHandler().hasPerm(p, "redprotect.flag.item-gui")) {
                    if (flag.equalsIgnoreCase("deny-enter-items") || flag.equalsIgnoreCase("allow-enter-items") || flag.equalsIgnoreCase("allow-place") || flag.equalsIgnoreCase("allow-break")) {
                        ItemFlagGui itemGui = new ItemFlagGui(p, r, flag);
                        itemGui.open();
                        return;
                    }
                }
                // Mob flags
                if (RedProtect.get().getPermissionHandler().hasPerm(p, "redprotect.flag.spawn-mob-gui")) {
                    if (flag.equalsIgnoreCase("spawn-animals") || flag.equalsIgnoreCase("spawn-monsters")) {
                        MobFlagGui mobFlagGui = new MobFlagGui(p, r, flag);
                        mobFlagGui.open();
                        return;
                    }
                }
                if (RedProtect.get().getConfigManager().getDefFlagsValues().containsKey(flag)) {
                    if (r.setFlag(p, flag, !r.getFlagBool(flag))) {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
                        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                    }
                } else {
                    if (RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag)) {
                        SendFlagUsageMessage(p, flag);
                    } else {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.usage") + " <true/false>");
                    }
                    sendFlagHelp(p);
                }
            }
        } else {
            RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.nopermregion");
        }
    } else {
        RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.noperm");
    }
}
Also used : MobFlagGui(br.net.fabiozumbi12.RedProtect.Bukkit.guis.MobFlagGui) Clan(net.sacredlabyrinth.phaed.simpleclans.Clan) ItemFlagGui(br.net.fabiozumbi12.RedProtect.Bukkit.guis.ItemFlagGui) ClanPlayer(net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)

Example 2 with ItemFlagGui

use of br.net.fabiozumbi12.RedProtect.Sponge.guis.ItemFlagGui in project RedProtect by FabioZumbi12.

the class CommandHandlers method handleFlag.

public static void handleFlag(Player p, String flag, String value, Region r) {
    if (checkCmd(flag, "help")) {
        sendFlagHelp(p);
        return;
    }
    if (r == null) {
        RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.todo.that");
        return;
    }
    Object objflag = RedProtect.get().getUtil().parseObject(value);
    if ((RedProtect.get().getPermissionHandler().hasFlagPerm(p, flag) && (RedProtect.get().getConfigManager().configRoot().flags.containsKey(flag) || RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag))) || flag.equalsIgnoreCase("info")) {
        if (r.isAdmin(p) || r.isLeader(p) || RedProtect.get().getPermissionHandler().hasPerm(p, "redprotect.command.admin.flag")) {
            if (checkCmd(flag, "info")) {
                p.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().getLanguageManager().get("general.color") + "------------[" + RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.values") + "]------------"));
                p.sendMessage(r.getFlagInfo());
                p.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().getLanguageManager().get("general.color") + "------------------------------------"));
                return;
            }
            if (value.equalsIgnoreCase("remove")) {
                if (RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag) && r.getFlags().containsKey(flag)) {
                    r.removeFlag(flag);
                    RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.removed").replace("{flag}", flag).replace("{region}", r.getName()));
                    RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " REMOVED FLAG " + flag + " of region " + r.getName());
                    return;
                } else {
                    RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.notset").replace("{flag}", flag));
                    return;
                }
            }
            if (!value.equals("")) {
                if (RedProtect.get().getConfigManager().getDefFlagsValues().containsKey(flag)) {
                    if (objflag instanceof Boolean) {
                        if (r.setFlag(RedProtect.get().getVersionHelper().getCause(p), flag, objflag)) {
                            RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
                            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                        }
                        return;
                    } else {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.usage") + " <true/false>");
                        return;
                    }
                }
                if (RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag)) {
                    if (!validate(flag, objflag)) {
                        SendFlagUsageMessage(p, flag);
                        return;
                    }
                    if (r.setFlag(RedProtect.get().getVersionHelper().getCause(p), flag, objflag)) {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagString(flag));
                        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                    }
                    return;
                }
                sendFlagHelp(p);
            } else {
                // Item flags
                if (flag.equalsIgnoreCase("deny-enter-items") || flag.equalsIgnoreCase("allow-enter-items") || flag.equalsIgnoreCase("allow-place") || flag.equalsIgnoreCase("allow-break")) {
                    ItemFlagGui itemGui = new ItemFlagGui(p, r, flag);
                    itemGui.open();
                    return;
                }
                if (RedProtect.get().getConfigManager().getDefFlagsValues().containsKey(flag)) {
                    if (r.setFlag(RedProtect.get().getVersionHelper().getCause(p), flag, !r.getFlagBool(flag))) {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
                        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
                    }
                } else {
                    if (RedProtect.get().getConfigManager().ADMIN_FLAGS.contains(flag)) {
                        SendFlagUsageMessage(p, flag);
                    } else {
                        RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.flag.usage") + " <true/false>");
                    }
                    sendFlagHelp(p);
                }
            }
        } else {
            RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.nopermregion");
        }
    } else {
        RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.flag.noperm");
    }
}
Also used : ItemFlagGui(br.net.fabiozumbi12.RedProtect.Sponge.guis.ItemFlagGui)

Aggregations

ItemFlagGui (br.net.fabiozumbi12.RedProtect.Bukkit.guis.ItemFlagGui)1 MobFlagGui (br.net.fabiozumbi12.RedProtect.Bukkit.guis.MobFlagGui)1 ItemFlagGui (br.net.fabiozumbi12.RedProtect.Sponge.guis.ItemFlagGui)1 Clan (net.sacredlabyrinth.phaed.simpleclans.Clan)1 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)1