use of com.magmaguy.elitemobs.elitedrops.EliteDropsHandler 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));
}
use of com.magmaguy.elitemobs.elitedrops.EliteDropsHandler 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!");
}
use of com.magmaguy.elitemobs.elitedrops.EliteDropsHandler 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;
}
}
Aggregations