Search in sources :

Example 1 with LootCustomConfig

use of com.magmaguy.elitemobs.config.LootCustomConfig in project EliteMobs by MagmaGuy.

the class EliteMobs method reloadConfiguration.

public void reloadConfiguration() {
    reloadConfig();
    MobPowersCustomConfig mobPowersCustomConfig = new MobPowersCustomConfig();
    mobPowersCustomConfig.reloadCustomConfig();
    LootCustomConfig lootCustomConfig = new LootCustomConfig();
    lootCustomConfig.reloadLootConfig();
    TranslationCustomConfig translationCustomConfig = new TranslationCustomConfig();
    translationCustomConfig.reloadCustomConfig();
    ConfigValues configValues = new ConfigValues();
    configValues.initializeConfigValues();
    getLogger().info("EliteMobs config reloaded!");
}
Also used : TranslationCustomConfig(com.magmaguy.elitemobs.config.TranslationCustomConfig) ConfigValues(com.magmaguy.elitemobs.config.ConfigValues) MobPowersCustomConfig(com.magmaguy.elitemobs.config.MobPowersCustomConfig) LootCustomConfig(com.magmaguy.elitemobs.config.LootCustomConfig)

Example 2 with LootCustomConfig

use of com.magmaguy.elitemobs.config.LootCustomConfig in project EliteMobs by MagmaGuy.

the class EliteMobs method onEnable.

@Override
public void onEnable() {
    getLogger().info("EliteMobs - Enabled!");
    //Load loot from config
    loadConfiguration();
    MobPowersCustomConfig mobPowersCustomConfig = new MobPowersCustomConfig();
    mobPowersCustomConfig.initializeMobPowersConfig();
    LootCustomConfig lootCustomConfig = new LootCustomConfig();
    lootCustomConfig.LootCustomConfig();
    TranslationCustomConfig translationCustomConfig = new TranslationCustomConfig();
    translationCustomConfig.initializeTranslationConfig();
    ConfigValues configValues = new ConfigValues();
    configValues.initializeConfigValues();
    //Parse loot
    EliteDropsHandler superDrops = new EliteDropsHandler();
    superDrops.superDropParser();
    //Get world list
    worldScanner();
    //Start the repeating tasks such as scanners
    repeatingTaskRunner();
    //Hook up all listeners, some depend on config
    this.getServer().getPluginManager().registerEvents(this, this);
    //Mob damage
    this.getServer().getPluginManager().registerEvents(new DamageHandler(this), this);
    //Mob loot
    this.getServer().getPluginManager().registerEvents(new DropsHandler(), this);
    //getloot GUI
    this.getServer().getPluginManager().registerEvents(new LootGUI(), this);
    //Minor mob powers
    for (String string : MetadataHandler.minorPowerList()) {
        //don't load powers that require no even listeners
        if (!(string.equalsIgnoreCase("MovementSpeed")) && !(string.equalsIgnoreCase("Invisibility")) && !(string.equalsIgnoreCase("DoubleHealth")) && !(string.equalsIgnoreCase("DoubleDamage"))) {
            try {
                String earlypath = "com.magmaguy.elitemobs.minorpowers.";
                String finalString = earlypath + string;
                Class<?> clazz = Class.forName(finalString);
                Object instance = clazz.newInstance();
                this.getServer().getPluginManager().registerEvents((Listener) instance, this);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            }
        }
    }
    for (String string : MetadataHandler.majorPowerList()) {
        //don't load powers that require no even listeners
        try {
            String earlypath = "com.magmaguy.elitemobs.majorpowers.";
            String finalString = earlypath + string;
            Class<?> clazz = Class.forName(finalString);
            Object instance = clazz.newInstance();
            this.getServer().getPluginManager().registerEvents((Listener) instance, this);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }
    //Mob scanner
    this.getServer().getPluginManager().registerEvents(new MobScanner(this), this);
    //Natural EliteMobs Spawning
    if (ConfigValues.defaultConfig.getBoolean("Natural EliteMob spawning")) {
        this.getServer().getPluginManager().registerEvents(new NaturalMobSpawner(this), this);
        getLogger().info("EliteMobs - Natural EliteMob Spawning enabled!");
    }
    //Natural Mob Metadata Assigner
    this.getServer().getPluginManager().registerEvents(new NaturalMobMetadataAssigner(this), this);
    //Visual effects
    this.getServer().getPluginManager().registerEvents(new MinorPowerPowerStance(), this);
    this.getServer().getPluginManager().registerEvents(new MajorPowerPowerStance(), this);
    //Loot
    if (ConfigValues.defaultConfig.getBoolean("Aggressive EliteMobs can drop config loot (level 5 EliteMobs and up)")) {
        this.getServer().getPluginManager().registerEvents(new EliteDropsHandler(), this);
        getLogger().info("EliteMobs - EliteMob loot enabled!");
    }
    //Minecraft behavior canceller
    if (ConfigValues.defaultConfig.getBoolean("Prevent creepers from killing passive mobs")) {
        this.getServer().getPluginManager().registerEvents(new PreventCreeperPassiveEntityDamage(this), this);
        getLogger().info("EliteMobs - Creeper passive mob collateral damage canceller enabled!");
    }
    this.getServer().getPluginManager().registerEvents(new ChunkUnloadMetadataPurge(this), this);
    //Commands
    this.getCommand("elitemobs").setExecutor(new CommandHandler(this));
}
Also used : TranslationCustomConfig(com.magmaguy.elitemobs.config.TranslationCustomConfig) EliteDropsHandler(com.magmaguy.elitemobs.elitedrops.EliteDropsHandler) ChunkUnloadMetadataPurge(com.magmaguy.elitemobs.collateralminecraftchanges.ChunkUnloadMetadataPurge) ConfigValues(com.magmaguy.elitemobs.config.ConfigValues) LootGUI(com.magmaguy.elitemobs.commands.LootGUI) MinorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance) MobScanner(com.magmaguy.elitemobs.mobscanner.MobScanner) CommandHandler(com.magmaguy.elitemobs.commands.CommandHandler) NaturalMobSpawner(com.magmaguy.elitemobs.naturalmobspawner.NaturalMobSpawner) DamageHandler(com.magmaguy.elitemobs.mobcustomizer.DamageHandler) PreventCreeperPassiveEntityDamage(com.magmaguy.elitemobs.collateralminecraftchanges.PreventCreeperPassiveEntityDamage) MobPowersCustomConfig(com.magmaguy.elitemobs.config.MobPowersCustomConfig) LootCustomConfig(com.magmaguy.elitemobs.config.LootCustomConfig) NaturalMobMetadataAssigner(com.magmaguy.elitemobs.naturalmobspawner.NaturalMobMetadataAssigner) EliteDropsHandler(com.magmaguy.elitemobs.elitedrops.EliteDropsHandler) DropsHandler(com.magmaguy.elitemobs.mobcustomizer.DropsHandler) MajorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MajorPowerPowerStance)

Example 3 with LootCustomConfig

use of com.magmaguy.elitemobs.config.LootCustomConfig in project EliteMobs by MagmaGuy.

the class ReloadConfigCommandHandler method reloadConfiguration.

public void reloadConfiguration() {
    //Reload all configs
    Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).reloadConfig();
    MobPowersCustomConfig mobPowersCustomConfig = new MobPowersCustomConfig();
    mobPowersCustomConfig.reloadCustomConfig();
    LootCustomConfig lootCustomConfig = new LootCustomConfig();
    lootCustomConfig.reloadLootConfig();
    TranslationCustomConfig translationCustomConfig = new TranslationCustomConfig();
    translationCustomConfig.reloadCustomConfig();
    ConfigValues configValues = new ConfigValues();
    configValues.initializeConfigValues();
    //reload config-based initialized data
    EliteDropsHandler eliteDropsHandler = new EliteDropsHandler();
    eliteDropsHandler.superDropParser();
    Bukkit.getLogger().info("EliteMobs config reloaded!");
}
Also used : TranslationCustomConfig(com.magmaguy.elitemobs.config.TranslationCustomConfig) EliteDropsHandler(com.magmaguy.elitemobs.elitedrops.EliteDropsHandler) ConfigValues(com.magmaguy.elitemobs.config.ConfigValues) MobPowersCustomConfig(com.magmaguy.elitemobs.config.MobPowersCustomConfig) LootCustomConfig(com.magmaguy.elitemobs.config.LootCustomConfig)

Example 4 with LootCustomConfig

use of com.magmaguy.elitemobs.config.LootCustomConfig in project EliteMobs by MagmaGuy.

the class CommandHandler method onCommand.

@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
    // /elitemobs SpawnMob with variable arg length
    if (args.length > 0 && args[0].equalsIgnoreCase("SpawnMob")) {
        if (commandSender instanceof ConsoleCommandSender || commandSender instanceof Player && commandSender.hasPermission("elitemobs.SpawnMob")) {
            SpawnMobCommandHandler spawnMob = new SpawnMobCommandHandler();
            spawnMob.spawnMob(commandSender, args);
            return true;
        } else if (commandSender instanceof Player && !commandSender.hasPermission("elitemobs.SpawnMob")) {
            Player player = (Player) commandSender;
            if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.SpawnMob");
            } else {
                player.sendMessage("You do not have the permission " + "elitemobs.SpawnMob");
            }
            return true;
        }
    }
    switch(args.length) {
        //just /elitemobs
        case 0:
            validCommands(commandSender);
            return true;
        // /elitemobs stats | /elitemobs getloot (for GUI menu)
        case 1:
            if (args[0].equalsIgnoreCase("stats") && commandSender instanceof Player && commandSender.hasPermission("elitemobs.stats") || args[0].equalsIgnoreCase("stats") && commandSender instanceof ConsoleCommandSender) {
                StatsCommandHandler stats = new StatsCommandHandler();
                stats.statsHandler(commandSender);
                return true;
            } else if (args[0].equalsIgnoreCase("stats") && commandSender instanceof Player && !commandSender.hasPermission("elitemobs.stats")) {
                Player player = (Player) commandSender;
                if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                    player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.stats");
                } else {
                    player.sendMessage("You do not have the permission " + "elitemobs.stats");
                }
                return true;
            } else if (args[0].equalsIgnoreCase("getloot") && commandSender instanceof Player && commandSender.hasPermission("elitemobs.getloot") || args[0].equalsIgnoreCase("gl") && commandSender instanceof Player && commandSender.hasPermission("elitemobs.getloot")) {
                LootGUI lootGUI = new LootGUI();
                lootGUI.lootGUI((Player) commandSender);
                return true;
            }
            validCommands(commandSender);
            return true;
        // /elitemobs killall aggressiveelites | /elitemobs killall passiveelites
        case 2:
            //valid /elitemobs reload config
            if (args[0].equalsIgnoreCase("reload") && commandSender instanceof Player && args[1].equalsIgnoreCase("configs") && commandSender.hasPermission("elitemobs.reload.configs")) {
                Player player = (Player) commandSender;
                ReloadConfigCommandHandler reloadConfigCommandHandler = new ReloadConfigCommandHandler();
                reloadConfigCommandHandler.reloadConfiguration();
                getLogger().info("EliteMobs configs reloaded!");
                player.sendTitle("EliteMobs config reloaded!", "Reloaded config, loot, mobPowers and translation");
                return true;
            //invalid /elitemobs reload config
            } else if (args[0].equalsIgnoreCase("reload") && commandSender instanceof Player && args[1].equalsIgnoreCase("config") && !commandSender.hasPermission("elitemobs.reload.config")) {
                Player player = (Player) commandSender;
                if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                    player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.reload.configs");
                } else {
                    player.sendMessage("You do not have the permission " + "elitemobs.reload.configs");
                }
                return true;
            //valid /elitemobs reload loot
            } else if (args[0].equalsIgnoreCase("reload") && commandSender instanceof Player && args[1].equalsIgnoreCase("loot") && commandSender.hasPermission("elitemobs.reload.loot")) {
                Player player = (Player) commandSender;
                LootCustomConfig lootCustomConfig = new LootCustomConfig();
                lootCustomConfig.reloadLootConfig();
                EliteDropsHandler eliteDropsHandler = new EliteDropsHandler();
                eliteDropsHandler.superDropParser();
                getLogger().info("EliteMobs loot reloaded!");
                player.sendTitle("EliteMobs loot reloaded!", "Reloaded loot.yml");
                return true;
            //invalid /elitemobs reload loot
            } else if (args[0].equalsIgnoreCase("reload") && commandSender instanceof Player && args[1].equalsIgnoreCase("loot") && !commandSender.hasPermission("elitemobs.reload.loot")) {
                Player player = (Player) commandSender;
                if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                    player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.reload.loot");
                } else {
                    player.sendMessage("You do not have the permission " + "elitemobs.reload.loot");
                }
                return true;
            //valid /elitemobs getloot | /elitemobs gl
            } else if (args[0].equalsIgnoreCase("getloot") && commandSender instanceof Player && commandSender.hasPermission("elitemobs.getloot") || args[0].equalsIgnoreCase("gl") && commandSender instanceof Player && commandSender.hasPermission("elitemobs.getloot")) {
                Player player = (Player) commandSender;
                GetLootCommandHandler getLootCommandHandler = new GetLootCommandHandler();
                if (getLootCommandHandler.getLootHandler(player, args[1])) {
                    return true;
                } else {
                    player.sendTitle("", "Could not find that item name.");
                    return true;
                }
            //invalid /elitemobs getloot | /elitemobs gl
            } else if (args[0].equalsIgnoreCase("getloot") && !commandSender.hasPermission("elitemobs.getloot") || args[0].equalsIgnoreCase("gl") && !commandSender.hasPermission("elitemobs.getloot")) {
                Player player = (Player) commandSender;
                if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                    player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.getloot");
                } else {
                    player.sendMessage("You do not have the permission " + "elitemobs.getloot");
                }
                return true;
            } else if (args[0].equalsIgnoreCase("killall") && args[1].equalsIgnoreCase("aggressiveelites")) {
                if (commandSender.hasPermission("elitemobs.killall.aggressiveelites")) {
                    int counter = 0;
                    for (World world : EliteMobs.worldList) {
                        for (LivingEntity livingEntity : world.getLivingEntities()) {
                            if (livingEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && ValidAgressiveMobFilter.ValidAgressiveMobFilter(livingEntity)) {
                                livingEntity.remove();
                                counter++;
                            }
                        }
                    }
                    commandSender.sendMessage("Killed " + counter + " aggressive EliteMobs.");
                    return true;
                } else if (commandSender instanceof Player) {
                    Player player = ((Player) commandSender);
                    if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                        player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.killall.aggressiveelites");
                    } else {
                        player.sendMessage("You do not have the permission " + "elitemobs.killall.aggressiveelites");
                    }
                }
            } else if (args[0].equalsIgnoreCase("killall") && args[1].equalsIgnoreCase("passiveelites")) {
                if (commandSender.hasPermission("elitemobs.killall.passiveelites")) {
                    for (World world : EliteMobs.worldList) {
                        for (LivingEntity livingEntity : world.getLivingEntities()) {
                            if (livingEntity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD) && ValidPassiveMobFilter.ValidPassiveMobFilter(livingEntity)) {
                                livingEntity.remove();
                            }
                        }
                    }
                    return true;
                } else if (commandSender instanceof Player) {
                    Player player = ((Player) commandSender);
                    if (Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig().getBoolean("Use titles to warn players they are missing a permission")) {
                        player.sendTitle("I'm afraid I can't let you do that, " + player.getDisplayName() + ".", "You need the following permission: " + "elitemobs.killall.passiveelites");
                    } else {
                        player.sendMessage("You do not have the permission " + "elitemobs.killall.passiveelites");
                    }
                }
            }
            validCommands(commandSender);
            return true;
        // /elitemobs giveloot [player] [loot]
        case 3:
            if (commandSender instanceof ConsoleCommandSender || commandSender instanceof Player && commandSender.hasPermission("elitemobs.giveloot")) {
                if (args[0].equalsIgnoreCase("giveloot")) {
                    if (validPlayer(args[1])) {
                        Player receiver = Bukkit.getServer().getPlayer(args[1]);
                        GetLootCommandHandler getLootCommandHandler = new GetLootCommandHandler();
                        if (args[2].equalsIgnoreCase("random") || args[2].equalsIgnoreCase("r")) {
                            Random random = new Random();
                            int index = random.nextInt(lootList.size());
                            ItemStack itemStack = new ItemStack(lootList.get(index));
                            receiver.getInventory().addItem(itemStack);
                            return true;
                        } else if (getLootCommandHandler.getLootHandler(receiver, args[2])) {
                            return true;
                        } else if (!getLootCommandHandler.getLootHandler(receiver, args[2])) {
                            if (commandSender instanceof ConsoleCommandSender) {
                                getLogger().info("Can't give loot to player - loot not found.");
                                return true;
                            } else if (commandSender instanceof Player) {
                                Player player = (Player) commandSender;
                                player.sendTitle("Can't give loot to player - loot not found.", "");
                                return true;
                            }
                        }
                    } else {
                        if (commandSender instanceof ConsoleCommandSender) {
                            getLogger().info("Can't give loot to player - player not found.");
                            return true;
                        } else if (commandSender instanceof Player) {
                            Player player = (Player) commandSender;
                            player.sendTitle("Can't give loot to player - player not found.", "");
                            return true;
                        }
                    }
                }
            }
            validCommands(commandSender);
            return true;
        //invalid commands
        default:
            validCommands(commandSender);
            return true;
    }
}
Also used : Player(org.bukkit.entity.Player) EliteDropsHandler(com.magmaguy.elitemobs.elitedrops.EliteDropsHandler) World(org.bukkit.World) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) LivingEntity(org.bukkit.entity.LivingEntity) Random(java.util.Random) LootCustomConfig(com.magmaguy.elitemobs.config.LootCustomConfig) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

LootCustomConfig (com.magmaguy.elitemobs.config.LootCustomConfig)4 ConfigValues (com.magmaguy.elitemobs.config.ConfigValues)3 MobPowersCustomConfig (com.magmaguy.elitemobs.config.MobPowersCustomConfig)3 TranslationCustomConfig (com.magmaguy.elitemobs.config.TranslationCustomConfig)3 EliteDropsHandler (com.magmaguy.elitemobs.elitedrops.EliteDropsHandler)3 ChunkUnloadMetadataPurge (com.magmaguy.elitemobs.collateralminecraftchanges.ChunkUnloadMetadataPurge)1 PreventCreeperPassiveEntityDamage (com.magmaguy.elitemobs.collateralminecraftchanges.PreventCreeperPassiveEntityDamage)1 CommandHandler (com.magmaguy.elitemobs.commands.CommandHandler)1 LootGUI (com.magmaguy.elitemobs.commands.LootGUI)1 DamageHandler (com.magmaguy.elitemobs.mobcustomizer.DamageHandler)1 DropsHandler (com.magmaguy.elitemobs.mobcustomizer.DropsHandler)1 MobScanner (com.magmaguy.elitemobs.mobscanner.MobScanner)1 NaturalMobMetadataAssigner (com.magmaguy.elitemobs.naturalmobspawner.NaturalMobMetadataAssigner)1 NaturalMobSpawner (com.magmaguy.elitemobs.naturalmobspawner.NaturalMobSpawner)1 MajorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MajorPowerPowerStance)1 MinorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)1 Random (java.util.Random)1 World (org.bukkit.World)1 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)1 LivingEntity (org.bukkit.entity.LivingEntity)1