From d180e5fd2923d12af65fd5eb03ecc3f817ca2f69 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Tue, 16 Jun 2015 05:33:29 -0700 Subject: [PATCH 01/28] Update to 7.0 --- .gitignore | 6 + Giants/dependency-reduced-pom.xml | 35 + Giants/pom.xml | 102 +++ .../Mammothskier/Giants/BarAPI/HealthBar.java | 97 +++ .../java/me/Mammothskier/Giants/Giants.java | 82 ++ .../Giants/entity/DamageListener.java | 109 +++ .../Mammothskier/Giants/entity/Entities.java | 386 +++++++++ .../Giants/entity/GiantListeners.java | 279 +++++++ .../Giants/entity/MagmaCubeListeners.java | 246 ++++++ .../Giants/entity/SlimeListeners.java | 250 ++++++ .../Giants/events/JockeySpawnEvent.java | 333 ++++++++ .../Giants/events/SpawnEvent.java | 437 ++++++++++ .../Giants/files/FileHandler.java | 306 +++++++ .../me/Mammothskier/Giants/files/Files.java | 19 + .../me/Mammothskier/Giants/util/Metrics.java | 759 ++++++++++++++++++ .../me/Mammothskier/Giants/util/NMSUtils.java | 98 +++ Giants/src/main/resources/attacks.yml | 51 ++ Giants/src/main/resources/biomes.yml | 64 ++ Giants/src/main/resources/config.yml | 17 + Giants/src/main/resources/entities.yml | 67 ++ Giants/src/main/resources/jockey.yml | 6 + {src => Giants/src}/main/resources/plugin.yml | 0 .../java/me/Mammothskier/Giants/Attacks.java | 109 --- .../java/me/Mammothskier/Giants/Commands.java | 294 ------- .../Giants/events/GiantSpawnEvent.java | 475 ----------- .../Giants/events/MagmaCubeSpawnEvent.java | 546 ------------- .../Giants/utils/DropsManager.java | 434 ---------- v1_7_R3/pom.xml | 30 + .../nms/v1_7_R3/CustomEntityGiantZombie.java | 78 ++ .../entity/nms/v1_7_R3/CustomEntityType.java | 181 +++++ .../entity/nms/v1_7_R3/EntityCreator.java | 19 + v1_7_R4/pom.xml | 23 + .../nms/v1_7_R4/CustomEntityGiantZombie.java | 78 ++ .../entity/nms/v1_7_R4/CustomEntityType.java | 175 ++++ .../entity/nms/v1_7_R4/EntityCreator.java | 19 + v1_8_R1/pom.xml | 23 + .../nms/v1_8_R1/CustomEntityGiantZombie.java | 79 ++ .../entity/nms/v1_8_R1/CustomEntityType.java | 175 ++++ .../entity/nms/v1_8_R1/EntityCreator.java | 17 + v1_8_R2/pom.xml | 36 + .../nms/v1_8_R2/CustomEntityGiantZombie.java | 80 ++ .../entity/nms/v1_8_R2/CustomEntityType.java | 175 ++++ .../entity/nms/v1_8_R2/EntityCreator.java | 19 + v1_8_R3/pom.xml | 23 + .../nms/v1_8_R3/CustomEntityGiantZombie.java | 79 ++ .../entity/nms/v1_8_R3/CustomEntityType.java | 175 ++++ .../entity/nms/v1_8_R3/EntityCreator.java | 17 + 47 files changed, 5250 insertions(+), 1858 deletions(-) create mode 100644 Giants/dependency-reduced-pom.xml create mode 100644 Giants/pom.xml create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/Giants.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/files/Files.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/util/Metrics.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java create mode 100644 Giants/src/main/resources/attacks.yml create mode 100644 Giants/src/main/resources/biomes.yml create mode 100644 Giants/src/main/resources/config.yml create mode 100644 Giants/src/main/resources/entities.yml create mode 100644 Giants/src/main/resources/jockey.yml rename {src => Giants/src}/main/resources/plugin.yml (100%) delete mode 100644 src/main/java/me/Mammothskier/Giants/Attacks.java delete mode 100644 src/main/java/me/Mammothskier/Giants/Commands.java delete mode 100644 src/main/java/me/Mammothskier/Giants/events/GiantSpawnEvent.java delete mode 100644 src/main/java/me/Mammothskier/Giants/events/MagmaCubeSpawnEvent.java delete mode 100644 src/main/java/me/Mammothskier/Giants/utils/DropsManager.java create mode 100644 v1_7_R3/pom.xml create mode 100644 v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java create mode 100644 v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityType.java create mode 100644 v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/EntityCreator.java create mode 100644 v1_7_R4/pom.xml create mode 100644 v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java create mode 100644 v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityType.java create mode 100644 v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/EntityCreator.java create mode 100644 v1_8_R1/pom.xml create mode 100644 v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java create mode 100644 v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityType.java create mode 100644 v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/EntityCreator.java create mode 100644 v1_8_R2/pom.xml create mode 100644 v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java create mode 100644 v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityType.java create mode 100644 v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/EntityCreator.java create mode 100644 v1_8_R3/pom.xml create mode 100644 v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java create mode 100644 v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityType.java create mode 100644 v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/EntityCreator.java diff --git a/.gitignore b/.gitignore index 7f893ed..5b96e02 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,12 @@ tmp/ .classpath .settings/ .loadpath +target/ +Giants/target/ +v1_7_R3/target/ +v1_7_R4/target/ +v1_8_R1/target/ +v1_8_R2/target/ # External tool builders .externalToolBuilders/ diff --git a/Giants/dependency-reduced-pom.xml b/Giants/dependency-reduced-pom.xml new file mode 100644 index 0000000..112991e --- /dev/null +++ b/Giants/dependency-reduced-pom.xml @@ -0,0 +1,35 @@ + + + + Giants-Parent + me.Mammothskier + 7.0-Beta + + 4.0.0 + Giants + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + confuser-repo + http://ci.frostcast.net/plugin/repository/everything + + + + + org.bukkit + bukkit + 1.8.7-R0.1-SNAPSHOT + compile + + + me.confuser + BarAPI + 3.3 + compile + + + + diff --git a/Giants/pom.xml b/Giants/pom.xml new file mode 100644 index 0000000..c4f52ab --- /dev/null +++ b/Giants/pom.xml @@ -0,0 +1,102 @@ + + 4.0.0 + + me.Mammothskier + Giants-Parent + 7.0 + + Giants + + + + org.bukkit + bukkit + 1.8.7-R0.1-SNAPSHOT + jar + + + + me.confuser + BarAPI + 3.3 + jar + + + + me.Mammothskier + Giants-v1_7_R3 + v1 + + + org.bukkit + craftbukkit + + + true + + + + me.Mammothskier + Giants-v1_7_R4 + v1 + + + org.bukkit + craftbukkit + + + true + + + + me.Mammothskier + Giants-v1_8_R1 + v1 + + + org.bukkit + craftbukkit + + + true + + + + me.Mammothskier + Giants-v1_8_R2 + v1 + + + org.bukkit + craftbukkit + + + true + + + + me.Mammothskier + Giants-v1_8_R3 + v1 + + + org.bukkit + craftbukkit + + + true + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + confuser-repo + http://ci.frostcast.net/plugin/repository/everything + + + \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java b/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java new file mode 100644 index 0000000..8b9b581 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java @@ -0,0 +1,97 @@ +package me.Mammothskier.Giants.BarAPI; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.entity.Entities; +import me.Mammothskier.Giants.files.Files; +import me.confuser.barapi.BarAPI; + +public class HealthBar implements Listener { + private Giants _giants; + + public HealthBar(Giants giants) { + _giants = giants; + _giants.getServer().getPluginManager().registerEvents(this, giants); + } + + @EventHandler + public void changeHealthBar(EntityDamageByEntityEvent event) { + Entity entity = event.getEntity(); + Entity damager = event.getDamager(); + if (entity == null || damager == null) { + return; + } + if (Entities.isGiantZombie(entity) || Entities.isGiantLavaSlime(entity) || Entities.isGiantSlime(entity)) { + if (damager instanceof Projectile) { + damager = (Entity) ((Projectile) damager).getShooter(); + } + if (damager instanceof Player) { + Player player = (Player) damager; + setupBar(player, entity); + } + } + } + + @EventHandler + public void onDeath(EntityDeathEvent event) { + Entity entity = event.getEntity(); + if (Entities.isGiantZombie(entity) || Entities.isGiantLavaSlime(entity) || Entities.isGiantSlime(entity)) { + Entity killer = event.getEntity().getKiller(); + if (killer instanceof Player) { + Player player = (Player) killer; + if(BarAPI.hasBar(player)) { + BarAPI.removeBar(player); + } + } + } + } + + public void setupBar(Player player, Entity entity) { + EntityType entityType = entity.getType(); + Double health = ((Damageable) entity).getHealth(); + Double maxHealth = ((Damageable) entity).getMaxHealth(); + float percent = (float) (health/maxHealth); + String size = null; + + switch (entityType) { + case GIANT: + String giantName = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Zombie"); + giantName = ChatColor.translateAlternateColorCodes('&', giantName); + if (player.hasPermission("giants.barAPI") || player.hasPermission("giants.*") || player.isOp()) { + BarAPI.setMessage(player, giantName, percent * 100); + } + break; + case SLIME: + String slimeName = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Slime"); + slimeName = ChatColor.translateAlternateColorCodes('&', slimeName); + size = Integer.toString(((Slime) entity).getSize()); + if (player.hasPermission("giants.barAPI") || player.hasPermission("giants.*") || player.isOp()) { + BarAPI.setMessage(player, slimeName.replace("{size}", size), percent* 100); + } + break; + case MAGMA_CUBE: + String magmacubeName = Giants.getProperty(Files.ENTITIES, "Magma Cube Configuration.Magma Cube Stats.BarAPI.Display Name.Giant Lava Slime"); + magmacubeName = ChatColor.translateAlternateColorCodes('&', magmacubeName); + size = Integer.toString(((MagmaCube) entity).getSize()); + if (player.hasPermission("giants.barAPI") || player.hasPermission("giants.*") || player.isOp()) { + BarAPI.setMessage(player, magmacubeName.replace("{size}", size), percent* 100); + } + break; + default: + break; + + } + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Giants.java b/Giants/src/main/java/me/Mammothskier/Giants/Giants.java new file mode 100644 index 0000000..fb30d57 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/Giants.java @@ -0,0 +1,82 @@ +package me.Mammothskier.Giants; + +import java.io.IOException; +import java.util.List; +import java.util.logging.Logger; + +import me.Mammothskier.Giants.entity.Entities; +import me.Mammothskier.Giants.files.FileHandler; +import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.util.Metrics; +import me.Mammothskier.Giants.util.NMSUtils; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPlugin; + +public class Giants extends JavaPlugin { + private static FileHandler fileHandler; + public final Logger log = Logger.getLogger("Minecraft"); + + @Override + public void onEnable() { + NMSUtils.registerEntities(); + + PluginDescriptionFile pdf = this.getDescription(); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + pdf.getName() + " Version " + pdf.getVersion() + " Has Been Enabled!"); + + try { + Metrics metrics = new Metrics(this); + metrics.start(); + } catch (IOException e) { + // Failed to submit the stats :-( + } + + this.getCommand("giants").setExecutor(new Commands(this)); + new Entities(this); + fileHandler = new FileHandler(this); + updateEntities(); + } + + @Override + public void onDisable() { + NMSUtils.unregisterEntities(); + } + + public static String getProperty(Files file, String path) { + return fileHandler.getProperty(file, path); + } + + public static List getPropertyList(Files file, String path) { + return fileHandler.getPropertyList(file, path); + } + + public static FileHandler getFileHandler() { + return fileHandler; + } + + public static void updateEntities() { + if (Entities.GiantZombie == true && getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Zombie").equalsIgnoreCase("false")) + Entities.GiantZombie = false; + + if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime").equalsIgnoreCase("true")) { + Entities.GiantSlime = true; + } else { + Entities.GiantSlime = false; + } + + if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Lava Slime").equalsIgnoreCase("true")) { + Entities.GiantLavaSlime = true; + } else { + Entities.GiantLavaSlime = false; + } + + if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { + Entities.GiantJockey = true; + } else { + Entities.GiantJockey = false; + } + + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java new file mode 100644 index 0000000..32b7837 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java @@ -0,0 +1,109 @@ +package me.Mammothskier.Giants.entity; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class DamageListener implements Listener { + private Giants _giants; + public DamageListener(Giants giants) { + _giants = giants; + _giants.getServer().getPluginManager().registerEvents(this, giants); + } + + @EventHandler + public void onEntityDamageEvent(EntityDamageEvent event) { + Entity entity = event.getEntity(); + if (Entities.isGiant(entity)) { + if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FALLING_BLOCK) { + String string = "true"; + if (Entities.isGiantZombie(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Zombie"); + else if (Entities.isGiantSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Slime"); + else if (Entities.isGiantLavaSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Lava Slime"); + + if (string.equalsIgnoreCase("false")) { + event.setCancelled(true); + } + } + + if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) { + String string = "true"; + if (Entities.isGiantZombie(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Zombie"); + else if (Entities.isGiantSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Slime"); + if (string.equalsIgnoreCase("false")) { + event.setCancelled(true); + } + } + if (event.getCause() == DamageCause.THORNS) { + String string = "true"; + if (Entities.isGiantZombie(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Zombie"); + else if (Entities.isGiantSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Slime"); + else if (Entities.isGiantLavaSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime"); + if (string.equalsIgnoreCase("false")) { + event.setCancelled(true); + } + } + } + } + + public void onArrowDamage(EntityDamageByEntityEvent event) { + Entity entity = event.getEntity(); + if (Entities.isGiant(entity)) { + if (event.getDamager() instanceof Arrow){ + int damage; + String string = ""; + if (Entities.isGiantZombie(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Zombie"); + else if (Entities.isGiantSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Slime"); + else if (Entities.isGiantSlime(entity)) + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Lava Slime"); + try { + damage = Integer.parseInt(string); + } catch (Exception e) { + damage = 10; + } + if(damage == 0){ + event.setCancelled(true); + return; + } + event.setDamage(damage + 0.0); + } + } + } + + + @EventHandler + public void damage(EntityDamageByEntityEvent event){ + Entity entity = event.getEntity(); + int s; + if ((event.getDamager() instanceof Player) && (Entities.isGiantLavaSlime(entity))){ + MagmaCube magmacube = (MagmaCube) event.getEntity(); + s = magmacube.getSize(); + if (s > 4){ + double damage = event.getDamage(); + double health = ((Damageable) event.getEntity()).getHealth(); + ((Damageable) entity).setHealth(Math.max(0, Math.min(health - damage, ((Damageable) entity).getMaxHealth()))); + event.setCancelled(true); + } + } + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java new file mode 100644 index 0000000..9a7e709 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java @@ -0,0 +1,386 @@ +package me.Mammothskier.Giants.entity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; +import org.bukkit.entity.Giant; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.scheduler.BukkitScheduler; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.events.JockeySpawnEvent; +import me.Mammothskier.Giants.events.SpawnEvent; +import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.util.NMSUtils; + +public class Entities implements Listener { + private static Giants _giants; + public static boolean GiantZombie = false; + public static boolean GiantSlime = false; + public static boolean GiantLavaSlime = false; + public static boolean GiantJockey = false; + + public static final EntityType[] zombieReplacements = {EntityType.ZOMBIE, EntityType.MUSHROOM_COW, EntityType.PIG_ZOMBIE, EntityType.ENDERMAN}; + public static final EntityType[] slimeReplacements = {EntityType.ZOMBIE,EntityType.MUSHROOM_COW, EntityType.PIG_ZOMBIE, EntityType.SLIME, EntityType.ENDERMAN}; + public static final EntityType[] lavaSlimeReplacements = {EntityType.PIG_ZOMBIE, EntityType.ZOMBIE, EntityType.MAGMA_CUBE, EntityType.ENDERMAN, EntityType.BLAZE}; + + public Entities(Giants giants) { + _giants = giants; + _giants.getServer().getPluginManager().registerEvents(this, giants); + new DamageListener(_giants); + new DropsManager(_giants); + new GiantListeners(_giants); + new SlimeListeners(_giants); + new MagmaCubeListeners(_giants); + jockeySpawner(); + } + + @EventHandler (priority = EventPriority.NORMAL) + public void onSpawnEvent (CreatureSpawnEvent event) { + Entity entity = (Entity) event.getEntity(); + EntityType type = event.getEntityType(); + SpawnReason spawnReason = event.getSpawnReason(); + + if(event.isCancelled()){ + return; + } + + if (type == EntityType.SLIME || type == EntityType.MAGMA_CUBE && ((Slime) entity).getSize() == 4) return; + + if ((spawnReason == SpawnReason.NATURAL || spawnReason == SpawnReason.SPAWNER) && isASpawnReplacement(type)) { + Random rand = new Random(); + + EntityType spawn = null; + int i = -1; + while (spawn == null) { + i = rand.nextInt(3); + if (i== 0 && isASpawnReplacementFor(type, EntityType.GIANT)) { + spawn = EntityType.GIANT; + } else if (i == 1 && isASpawnReplacementFor(type, EntityType.SLIME)) { + spawn = EntityType.SLIME; + } else if (i == 2 && isASpawnReplacementFor(type, EntityType.MAGMA_CUBE)){ + spawn = EntityType.MAGMA_CUBE; + } + } + if (!isEnabled(spawn)) { + return; + } + + String string = ""; + if (spawn.equals(EntityType.GIANT)) { + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Zombie"); + } else if (spawn.equals(EntityType.SLIME)) { + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Slime"); + } else if (spawn.equals(EntityType.MAGMA_CUBE)) { + string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Lava Slime"); + } + + Float sRate; + try { + sRate = Float.parseFloat(string); + } catch (NumberFormatException e) { + sRate = 10f; + } + + if (rand.nextFloat()*100 < sRate) { + Location location = entity.getLocation(); + double x = location.getX(); + double y = location.getY(); + double z = location.getZ(); + + int x2 = (int) x; + int y2 = (int) y; + int z2 = (int) z; + + int spawngiant = 1; + double checkcount = 1; + + String s; + int size; + + //Comment out this next line to allow random spawning. + //spawn = EntityType.GIANT; + + switch (spawn) { + case GIANT: + while (checkcount <= 15) { + if (entity.getWorld().getBlockAt(new Location(entity.getWorld(), x2, y2 + checkcount, z2)).getType() != Material.AIR) { + spawngiant = 0; + } + checkcount++; + } + break; + case SLIME: + s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); + try { + size = Integer.parseInt(s); + } catch (Exception e) { + size = 12; + } + while (checkcount <= size) { + if (entity.getWorld().getBlockAt(new Location(entity.getWorld(), x2, y2 + checkcount, z2)).getType() != Material.AIR) { + spawngiant = 0; + } + checkcount++; + } + break; + case MAGMA_CUBE: + s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime"); + try { + size = Integer.parseInt(s); + } catch (Exception e) { + size = 12; + } + while (checkcount <= size) { + if (entity.getWorld().getBlockAt(new Location(entity.getWorld(), x2, y2 + checkcount, z2)).getType() != Material.AIR) { + spawngiant = 0; + } + checkcount++; + } + break; + default: + break; + } + //Commment out the following line to enable chance of spawning. + //spawngiant = 1; + if (spawngiant == 1) { + SpawnEvent SE = new SpawnEvent(location, spawn); + Bukkit.getServer().getPluginManager().callEvent(SE); + event.setCancelled(true); + } + } + } + } + + public static void createGiant (Location location, SpawnReason reason) { + NMSUtils.createGiant(location, reason); + } + + private boolean isEnabled(EntityType spawn) { + boolean enabled = false; + if (spawn == null) { + return false; + } + switch (spawn) { + case GIANT: + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Zombie").equalsIgnoreCase("true") && GiantZombie == true) + enabled = true; + break; + case SLIME: + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime").equalsIgnoreCase("true") && GiantSlime == true) + enabled = true; + break; + case MAGMA_CUBE: + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Lava Slime").equalsIgnoreCase("true") && GiantLavaSlime == true) + + enabled = true; + break; + default: + break; + } + return enabled; + } + + public static boolean isGiantZombie(Entity entity) { + return entity.getType() == EntityType.GIANT ? true : false; + } + + public static boolean isGiantSlime(Entity entity) { + if (entity.getType() == EntityType.SLIME) { + Slime slime = (Slime) entity; + if (slime.getSize() > 4) + return true; + } + return false; + } + + public static boolean isGiantLavaSlime(Entity entity) { + if (entity.getType() == EntityType.MAGMA_CUBE) { + Slime slime = (Slime) entity; + if (slime.getSize() > 4) + return true; + } + return false; + } + + public static boolean isGiantJockey(Entity entity) { + switch (entity.getType()) { + case GIANT: + if ((isGiantSlime(entity.getVehicle())) || (isGiantLavaSlime(entity.getVehicle())) || (entity.getVehicle().getType() == EntityType.GHAST)) { + return true; + } + break; + case SLIME: + if ((isGiantSlime(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { + return true; + } + break; + case MAGMA_CUBE: + if ((isGiantLavaSlime(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { + return true; + } + break; + case GHAST: + if (entity.getPassenger().getType() == EntityType.GIANT) { + return true; + } + break; + default: + break; + } + return false; + } + + public static boolean isGiantJockeyMount(Entity entity) { + return (isGiantJockey(entity) && isGiantZombie(entity.getPassenger())); + } + + public static boolean isGiantJockeyRider(Entity entity) { + return (isGiantJockey(entity) && isGiantZombie(entity)); + } + + public static List getEntitySpawnReplacements(EntityType type) { + List list = new ArrayList(); + switch (type) { + case GIANT: + for (EntityType t : zombieReplacements) list.add(t); + break; + case SLIME: + for (EntityType t : slimeReplacements) list.add(t); + break; + case MAGMA_CUBE: + for (EntityType t : lavaSlimeReplacements) list.add(t); + break; + default: + break; + } + + return list; + } + + public static List getGiantSpawnWorlds(EntityType entityType) { + switch (entityType) { + case GIANT: + return Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Zombie"); + case SLIME: + return Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Slime"); + case MAGMA_CUBE: + return Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Lava Slime"); + default: + return null; + } + } + + public static List getJockeySpawnWorlds() { + return Giants.getPropertyList(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds"); + } + + public static void callSpawnDebug(Entity entity) { + if (entity == null) + return; + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Enabled").equalsIgnoreCase("true")) { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + if (player.hasPermission("giants.debug") || player.hasPermission("giants.*") || player.isOp()) { + String x = String.valueOf(Math.round(entity.getLocation().getX())); + String y = String.valueOf(Math.round(entity.getLocation().getY())); + String z = String.valueOf(Math.round(entity.getLocation().getZ())); + switch (entity.getType()) { + case GIANT: + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A giant zombie has spawned at X:" + x +", Y:" + y + ", Z:" + z +"."); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A giant zombie has spawned at X:" + x +", Y:" + y + ", Z:" + z +"."); + break; + case SLIME: + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A giant slime has spawned at X:" + x +", Y:" + y + ", Z:" + z +"."); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A giant slime has spawned at X:" + x +", Y:" + y + ", Z:" + z +"."); + break; + case MAGMA_CUBE: + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A giant lava slime has spawned at X:" + x +", Y:" + y + ", Z:" + z +"."); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A giant lava slime has spawned at X:" + x +", Y:" + y + ", Z:" + z +"."); + break; + default: + break; + } + } + } + } + } + + public static boolean isGiant(Entity entity) { + if (isGiantZombie(entity)) + return true; + if (isGiantSlime(entity)) + return true; + if (isGiantLavaSlime(entity)) + return true; + return false; + } + + private void jockeySpawner() { + if (GiantJockey == true) { + BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); + scheduler.scheduleSyncRepeatingTask(_giants, new Runnable() { + + public void run() { + for (World world : _giants.getServer().getWorlds()) { + for (Entity entity : world.getEntities()) { + if ((entity instanceof Slime) || (entity instanceof MagmaCube) || (entity instanceof Ghast)) { + for (Entity entity2 : entity.getNearbyEntities(15, 12, 15)) { + if ((entity2 instanceof Giant) && (entity.getPassenger() == null) && (entity2.getVehicle() == null)) { + Entity passenger = entity2; + JockeySpawnEvent JSE = new JockeySpawnEvent(entity, passenger); + Bukkit.getServer().getPluginManager().callEvent(JSE); + } + } + } + } + } + } + }, 0L, 20L); + } + } + + private boolean isASpawnReplacement(EntityType entityType) { + for (EntityType e : zombieReplacements) + if (e == entityType) return true; + for (EntityType e : slimeReplacements) + if (e == entityType) return true; + for (EntityType e : lavaSlimeReplacements) + if (e == entityType) return true; + return false; + } + + private boolean isASpawnReplacementFor(EntityType replacement, EntityType entityType) { + if (entityType == null) return false; + switch(entityType) { + case GIANT: + for (EntityType e : zombieReplacements) + if (e == replacement) return true; + case SLIME: + for (EntityType e : slimeReplacements) + if (e == replacement) return true; + case MAGMA_CUBE: + for (EntityType e : lavaSlimeReplacements) + if (e == replacement) return true; + + default: + break; + } + return false; + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java new file mode 100644 index 0000000..1b6dfc3 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java @@ -0,0 +1,279 @@ +package me.Mammothskier.Giants.entity; + +import java.util.Random; +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.util.Vector; + +public class GiantListeners implements Listener { + private Giants _giants; + + public GiantListeners(Giants giants) { + _giants = giants; + _giants.getServer().getPluginManager().registerEvents(this, giants); + } + + @EventHandler + public void onFireAttack(EntityTargetEvent event) { + String ticks1 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); + String ticks2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant"); + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int ticksTarget; + int ticksGiant; + try { + ticksTarget = Integer.parseInt(ticks1); + ticksGiant = Integer.parseInt(ticks2); + } catch (Exception e) { + ticksTarget = 0; + ticksGiant = 0; + } + + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantZombie(entity)) { + if(!(target == null)){ + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled").contains("Giant Zombie")) { + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); + } + try { + event.getTarget().setFireTicks(ticksTarget); + event.getEntity().setFireTicks(ticksGiant); + } catch (Exception e) { + } + } else { + event.setTarget(target); + } + } + } + } + } + + @EventHandler + public void onLightningAttack(EntityTargetEvent event) { + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantZombie(entity)) { + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack").contains("Giant Zombie")) { + try { + target.getLocation().getWorld().strikeLightning(target.getLocation()); + } catch (Exception e) { + } + } else { + event.setTarget(target); + } + } + } + } + + @EventHandler + public void onShrapnelAttack(EntityTargetEvent event) { + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int Amt; + double Health; + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantZombie(entity)) { + Location spawnLocation = entity.getLocation(); + Location loc = spawnLocation; + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Enabled").contains("Giant Zombie")) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Zombies to Spawn"); + String config2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Health"); + try { + Amt = Integer.parseInt(config); + Health = Double.parseDouble(config2); + } catch (Exception e) { + Amt = 3; + Health = 20; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")){ + if (target instanceof LivingEntity){ + target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); + } + } + for (int i = 1; i <= Amt; i++){ + if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies").equalsIgnoreCase("true")) { + Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); + ((Zombie) e).setBaby(true); + ((Damageable) e).setMaxHealth(Health); + ((Damageable) e).setHealth(Health); + } + else{ + Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); + ((Damageable) e).setMaxHealth(Health); + ((Damageable) e).setHealth(Health); + } + } + } + } + } + } + + @EventHandler + public void onThrownBoulderAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + boolean inRange = false; + Random pick = new Random(); + int chance = 0; + int bDamage; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + + for (Entity entity : player.getNearbyEntities(15, 12, 15)) { + if (Entities.isGiantZombie(entity)) { + if (entity.getNearbyEntities(15, 12, 15).contains(player) && !entity.getNearbyEntities(5, 3, 5).contains(player)) { + inRange = true; + } + if (inRange == true) { + if (chance == 50) { + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").contains("Giant Zombie")) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); + try { + bDamage = Integer.parseInt(config); + } catch (Exception e) { + bDamage = 1; + } + Vector direction = ((LivingEntity) entity).getEyeLocation().getDirection().multiply(2); + Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); + fireball.setShooter((LivingEntity) entity); + fireball.setYield(bDamage); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); + } + } + } + } + } + } + } + + @EventHandler + public void onKickAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled").contains("Giant Zombie")) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height"); + double height; + + try { + height = Double.parseDouble(config); + } catch (Exception e) { + height = 1; + } + + Random pick = new Random(); + int chance = 0; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(5, 5, 5)) { + if (Entities.isGiantZombie(entity)) { + if (entity.getNearbyEntities(5, 5, 5).contains(player)) { + player.setVelocity(new Vector(0, height, 0)); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); + } + } + } + } + } + } + } + + @EventHandler + public void onStompAttack(PlayerMoveEvent event) { + boolean sound = false; + boolean fire = false; + float power = 1.0f; + Player player = event.getPlayer(); + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled").contains("Giant Zombie")) { + Random pick = new Random(); + int chance = 0; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(3, 2, 3)) { + if (Entities.isGiantZombie(entity)) { + if (entity.getNearbyEntities(3, 2, 3).contains(player)) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); + if (Giants.getProperty(Files.ATTACKS, + "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { + fire = true; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + sound = true; + } + + try { + power = Float.parseFloat(config); + } catch (Exception e) { + power = 0.0f; + } + Location location = player.getLocation(); + location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); + if (sound == true){ + location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); + } + } + } + } + } + } + } + + @EventHandler + public void zombiesOnDeath(EntityDeathEvent event) { + Entity entity = event.getEntity(); + if (Entities.isGiantZombie(entity)) { + if(Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled").contains("Giant Zombie")){ + Location spawnLocation = entity.getLocation(); + Location loc = spawnLocation; + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn"); + String config2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health"); + int zombAmt; + double zombHealth; + + try { + zombAmt = Integer.parseInt(config); + zombHealth = Double.parseDouble(config2); + }catch (Exception e) { + zombAmt = 1; + zombHealth = 20; + } + for (int i = 1; i <= zombAmt; i++){ + if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies").equalsIgnoreCase("true")) { + Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); + ((Zombie) e).setBaby(true); + ((Damageable) e).setMaxHealth(zombHealth); + ((Damageable) e).setHealth(zombHealth); + } + else{ + Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); + ((Damageable) e).setMaxHealth(zombHealth); + ((Damageable) e).setHealth(zombHealth); + } + } + + } + } + } +} \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java new file mode 100644 index 0000000..2828777 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java @@ -0,0 +1,246 @@ +package me.Mammothskier.Giants.entity; + +import java.util.Random; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.util.Vector; + +public class MagmaCubeListeners implements Listener { + private Giants _magmacubes; + + public MagmaCubeListeners(Giants magmacubes) { + _magmacubes = magmacubes; + _magmacubes.getServer().getPluginManager().registerEvents(this, magmacubes); + } + + @EventHandler + public void onFireAttack(EntityTargetEvent event) { + String ticks1 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); + String ticks2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Magma Cube"); + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int ticksTarget; + int ticksGiant; + int s; + try { + ticksTarget = Integer.parseInt(ticks1); + ticksGiant = Integer.parseInt(ticks2); + } catch (Exception e) { + ticksTarget = 0; + ticksGiant = 0; + } + + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantLavaSlime(entity)) { + if(!(target == null)){ + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled").contains("Giant Lava Slime")) { + MagmaCube magmacube = (MagmaCube) event.getEntity(); + s = magmacube.getSize(); + if (s > 4){ + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); + } + try { + event.getTarget().setFireTicks(ticksTarget); + event.getEntity().setFireTicks(ticksGiant); + } catch (Exception e) { + } + } else { + event.setTarget(target); + } + } + } + } + } + } + + @EventHandler + public void onLightningAttack(EntityTargetEvent event) { + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int s; + + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantLavaSlime(entity)) { + MagmaCube magmacube = (MagmaCube) event.getEntity(); + s = magmacube.getSize(); + if (s > 4){ + if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack").contains("Giant Lava Slime")) { + try { + target.getLocation().getWorld().strikeLightning(target.getLocation()); + } catch (Exception e) { + } + } else { + event.setTarget(target); + } + } + } + } + } + + @EventHandler + public void LavaAttack(EntityTargetEvent event){ + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int s; + + if((Entities.isGiantLavaSlime(entity)) && (target instanceof Player)){ + MagmaCube magmacube = (MagmaCube) event.getEntity(); + s = magmacube.getSize(); + if (s > 4){ + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lava Attack").contains("Giant Lava Slime")) { + target.getLocation().getBlock().setType(Material.LAVA); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); + target.getLocation().getWorld().playSound(target.getLocation(), Sound.LAVA_POP, 1, 0); + } + } + } + } + } + + @EventHandler + public void onStompAttack(PlayerMoveEvent event) { + boolean sound = false; + boolean fire = false; + float power = 1.0f; + Player player = event.getPlayer(); + if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled").equalsIgnoreCase("true")) { + Random pick = new Random(); + int chance = 0; + int s; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(3, 2, 3)) { + if (Entities.isGiantLavaSlime(entity)) { + MagmaCube magmacube = (MagmaCube) entity; + s = magmacube.getSize(); + if (s > 4){ + if (entity.getNearbyEntities(3, 2, 3).contains(player)) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); + if (Giants.getProperty(Files.ATTACKS, + "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { + fire = true; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + sound = true; + } + + try { + power = Float.parseFloat(config); + } catch (Exception e) { + power = 0.0f; + } + + Location location = player.getLocation(); + location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); + if (sound == true){ + location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); + } + } + } + } + } + } + } + } + + @EventHandler + public void ThrownBoulderAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + boolean inRange = false; + Random pick = new Random(); + int chance = 0; + int bDamage; + int s; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + + for (Entity entity : player.getNearbyEntities(15, 12, 15)) { + if (Entities.isGiantLavaSlime(entity)) { + MagmaCube magmacube = (MagmaCube) entity; + s = magmacube.getSize(); + if (s > 4){ + if (entity.getNearbyEntities(15, 12, 15).contains(player) && !entity.getNearbyEntities(5, 3, 5).contains(player)) { + inRange = true; + } + if (inRange == true) { + if (chance == 50) { + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").contains("Giant Lava Slime")) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); + try { + bDamage = Integer.parseInt(config); + } catch (Exception e) { + bDamage = 1; + } + + Vector direction = ((LivingEntity) entity).getEyeLocation().getDirection().multiply(2); + Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); + fireball.setShooter((LivingEntity) entity); + fireball.setYield(bDamage); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); + } + } + } + } + } + } + } + } + + @EventHandler + public void onKickAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled").contains("Giant Lava Slime")) { + int s; + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height"); + double height; + + try { + height = Double.parseDouble(config); + } catch (Exception e) { + height = 1; + } + + Random pick = new Random(); + int chance = 0; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(5, 5, 5)) { + if (Entities.isGiantLavaSlime(entity)) { + MagmaCube magmacube = (MagmaCube) entity; + s = magmacube.getSize(); + if (s > 4){ + if (entity.getNearbyEntities(5, 5, 5).contains(player)) { + player.setVelocity(new Vector(0, height, 0)); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java new file mode 100644 index 0000000..89653f5 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java @@ -0,0 +1,250 @@ +package me.Mammothskier.Giants.entity; + +import java.util.Random; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +public class SlimeListeners implements Listener { + private Giants _slimes; + + public SlimeListeners(Giants slimes) { + _slimes = slimes; + _slimes.getServer().getPluginManager().registerEvents(this, slimes); + } + + @EventHandler + public void onLightningAttack(EntityTargetEvent event) { + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int s; + + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantSlime(entity)) { + Slime slime = (Slime) event.getEntity(); + s = slime.getSize(); + if (s > 4){ + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack").contains("Giant Slime")) { + try { + target.getLocation().getWorld().strikeLightning(target.getLocation()); + } catch (Exception e) { + } + } else { + event.setTarget(target); + } + } + } + } + } + + @EventHandler + public void onFireAttack(EntityTargetEvent event) { + String ticks1 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); + String ticks2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Slime"); + Entity entity = event.getEntity(); + Entity target = event.getTarget(); + int ticksTarget; + int ticksGiant; + int s; + try { + ticksTarget = Integer.parseInt(ticks1); + ticksGiant = Integer.parseInt(ticks2); + } catch (Exception e) { + ticksTarget = 0; + ticksGiant = 0; + } + + if ((entity instanceof LivingEntity)) { + if (Entities.isGiantSlime(entity)) { + Slime slime = (Slime) event.getEntity(); + s = slime.getSize(); + if (s > 4){ + if(!(target == null)){ + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled").contains("Giant Slime")) { + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); + } + try { + event.getTarget().setFireTicks(ticksTarget); + event.getEntity().setFireTicks(ticksGiant); + } catch (Exception e) { + } + } else { + event.setTarget(target); + } + } + } + } + } + } + + @EventHandler + public void ThrownBoulderAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + boolean inRange = false; + Random pick = new Random(); + int chance = 0; + int bDamage; + int s; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + + for (Entity entity : player.getNearbyEntities(15, 12, 15)) { + if (Entities.isGiantSlime(entity)) { + Slime slime = (Slime) entity; + s = slime.getSize(); + if (s > 4){ + if (entity.getNearbyEntities(15, 12, 15).contains(player) && !entity.getNearbyEntities(5, 3, 5).contains(player)) { + inRange = true; + } + if (inRange == true) { + if (chance == 50) { + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").contains("Giant Slime")) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); + try { + bDamage = Integer.parseInt(config); + } catch (Exception e) { + bDamage = 1; + } + Vector direction = ((LivingEntity) entity).getEyeLocation().getDirection().multiply(2); + Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); + fireball.setShooter((LivingEntity) entity); + fireball.setYield(bDamage); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); + } + } + } + } + } + } + } + } + + @EventHandler + public void onKickAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled").contains("Giant Slime")) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height"); + double height; + int s; + + try { + height = Double.parseDouble(config); + } catch (Exception e) { + height = 1; + } + + Random pick = new Random(); + int chance = 0; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(5, 5, 5)) { + if (Entities.isGiantSlime(entity)) { + Slime slime = (Slime) entity; + s = slime.getSize(); + if (s > 4){ + if (entity.getNearbyEntities(5, 5, 5).contains(player)) { + player.setVelocity(new Vector(0, height, 0)); + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); + } + } + } + } + } + } + } + } + + @EventHandler + public void onStompAttack(PlayerMoveEvent event) { + boolean sound = false; + boolean fire = false; + float power = 1.0f; + Player player = event.getPlayer(); + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled").contains("Giant Slime")) { + Random pick = new Random(); + int chance = 0; + int s; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(3, 2, 3)) { + if (Entities.isGiantSlime(entity)) { + Slime slime = (Slime) entity; + s = slime.getSize(); + if (s > 4){ + if (entity.getNearbyEntities(3, 2, 3).contains(player)) { + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); + if (Giants.getProperty(Files.ATTACKS, + "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { + fire = true; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + sound = true; + } + + try { + power = Float.parseFloat(config); + } catch (Exception e) { + power = 0.0f; + } + Location location = player.getLocation(); + location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); + if (sound == true){ + location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); + } + } + } + } + } + } + } + } + + @EventHandler + public void poisonAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Poison Attack").contains("Giant Slime")){ + Random pick = new Random(); + int chance = 0; + double length; + String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Poison Attack.length"); + try { + length = Double.parseDouble(config); + } catch (Exception e) { + length = 5; + } + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(3, 2, 3)) { + if (Entities.isGiantSlime(entity)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) (length*20), 3)); + } + } + } + } + } +} \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java b/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java new file mode 100644 index 0000000..ee69405 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java @@ -0,0 +1,333 @@ +package me.Mammothskier.Giants.events; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.Location; +import org.bukkit.block.Biome; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class JockeySpawnEvent extends Event implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + + public JockeySpawnEvent (Entity entity, Entity passenger) { + Location location = entity.getLocation(); + + Biome biome = location.getWorld().getBiome(location.getBlockX(), location.getBlockZ()); + + if (!isCancelled()) { + if (biome == Biome.SWAMPLAND) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Swampland.Swampland").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SWAMPLAND_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Swampland.Swampland Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.FOREST) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Forest.Forest").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.FOREST_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Forest.Forest Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.TAIGA) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.TAIGA_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.TAIGA_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.COLD_TAIGA) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.COLD_TAIGA_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.COLD_TAIGA_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MEGA_TAIGA) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Taiga").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MEGA_TAIGA_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Taiga Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MEGA_SPRUCE_TAIGA) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MEGA_SPRUCE_TAIGA_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.PLAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Plains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.ICE_PLAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Ice Plains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.ICE_PLAINS_SPIKES) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Ice Plains Spikes").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SUNFLOWER_PLAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Sunflower Plains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.OCEAN) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Ocean").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.DEEP_OCEAN) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Deep Ocean").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.FROZEN_OCEAN) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Frozen Ocean").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.RIVER) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.River.River").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.FROZEN_RIVER) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.River.Frozen River").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.BEACH) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Beach").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.STONE_BEACH) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Stone Beach").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.COLD_BEACH) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Cold Beach").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.EXTREME_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.EXTREME_HILLS_PLUS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.EXTREME_HILLS_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.EXTREME_HILLS_PLUS_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MUSHROOM_ISLAND) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Island").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MUSHROOM_SHORE) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Shore").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.DESERT) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.DESERT_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.DESERT_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if ((biome == Biome.JUNGLE) || (biome == Biome.JUNGLE_EDGE)) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if ((biome == Biome.JUNGLE_HILLS) || (biome == Biome.JUNGLE_EDGE)) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if ((biome == Biome.JUNGLE_MOUNTAINS) || (biome == Biome.JUNGLE_EDGE) || (biome == Biome.JUNGLE_EDGE_MOUNTAINS)) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.BIRCH_FOREST) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.BIRCH_FOREST_HILLS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.BIRCH_FOREST_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.BIRCH_FOREST_HILLS_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SAVANNA) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SAVANNA_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SAVANNA_PLATEAU) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Plateau").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SAVANNA_PLATEAU_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Plateau Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.ROOFED_FOREST) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.ROOFED_FOREST_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MESA) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MESA_BRYCE) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Bryce").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MESA_PLATEAU) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MESA_PLATEAU_FOREST) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MESA_PLATEAU_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.MESA_PLATEAU_FOREST_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SMALL_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Small Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.ICE_MOUNTAINS) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Ice Mountains").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.HELL) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Hell").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + if (biome == Biome.SKY) { + if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Sky").equalsIgnoreCase("true")) { + entity.setPassenger(passenger); + } + } + } + } + + + public boolean isCancelled() { + return cancel; + } + + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java b/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java new file mode 100644 index 0000000..8d58488 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java @@ -0,0 +1,437 @@ +package me.Mammothskier.Giants.events; + +import java.util.ArrayList; +import java.util.List; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.entity.Entities; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Biome; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Slime; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; + +public class SpawnEvent extends Event{ + private static boolean cancelled = false; + private Entity entity; + private Location location; + private static final HandlerList handlers = new HandlerList(); + + public SpawnEvent(Location loc, EntityType entityType) { + location = loc; + Biome biome = loc.getWorld().getBiome(loc.getBlockX(), loc.getBlockZ()); + double health = 100; + int size = 0; + + if (entityType.equals(EntityType.SLIME) || entityType.equals(EntityType.MAGMA_CUBE)) { + String s; + if (entityType.equals(EntityType.SLIME)) + s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); + else s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime"); + + try { + size = Integer.parseInt(s); + } catch (Exception e) { + size = 12; + } + } + + if (entityType == EntityType.GIANT && !Entities.GiantZombie) + setCancelled(true); + if (entityType == EntityType.SLIME && !Entities.GiantSlime) { + setCancelled(true); + } + if (entityType == EntityType.MAGMA_CUBE && !Entities.GiantLavaSlime) { + setCancelled(true); + } + + if ((!isCancelled()) && (Entities.getGiantSpawnWorlds(entityType).contains(loc.getWorld().getName()))) { + Entity entity = null; + + if (biome.toString().toLowerCase().contains("Swampland".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Swampland"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Forest".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Forest"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Taiga".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Taiga"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Plains".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Plains"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Extreme_Hills".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Extreme Hills"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Mushroom".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Mushroom Island"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Desert".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Desert"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Jungle".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Jungle"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Birch".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Birch Forest"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Savanna".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Savanna"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Roofed_Forest".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Roofed Forest"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Mesa".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Mesa"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Small_Mountains".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Small Mountains"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Ice_Mountains".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Ocean".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ocean"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("River".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.River"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Hell".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Hell"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + if (biome.toString().toLowerCase().contains("Sky".toLowerCase())) { + List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Sky"); + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + } + + Entities.callSpawnDebug(entity); + + if (entity != null) { + ((Damageable) entity).setMaxHealth(health); + ((Damageable) entity).setHealth(health); + if (entity.getType() == EntityType.GIANT) { + EntityEquipment armour = ((LivingEntity) entity).getEquipment(); + String config = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items"); + String[] s = config.split(":"); + + float rate = 0f; + try { + rate = Float.parseFloat(Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate")); + } catch (Exception e){ + rate = 0; + } + + try { + for (int i = 0; i < s.length; i++) { + Material m = Material.getMaterial(s[i].toUpperCase()); + ItemStack item = new ItemStack(m); + if (i == 0) { + armour.setHelmet(item); + armour.setHelmetDropChance(rate); + } else if (i == 1) { + armour.setChestplate(item); + armour.setChestplateDropChance(rate); + } else if (i == 2) { + armour.setLeggings(item); + armour.setLeggingsDropChance(rate); + } else if (i == 3) { + armour.setBoots(item); + armour.setBootsDropChance(rate); + } else if (i == 4) { + armour.setItemInHand(item); + armour.setItemInHandDropChance(rate); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + public void setCancelled(boolean cancel) { + cancelled = cancel; + } + + public static boolean isCancelled() { + return cancelled; + } + + public Entity getEntity() { + return entity; + } + + public Location getLocation() { + return location; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + public static List getNearbyEntities(Location loc, int size) { + List entities = new ArrayList(); + + for (Entity e : loc.getWorld().getEntities()) + if (loc.distance(e.getLocation()) <= size) + entities.add(e); + return entities; + } + + public static Entity getGiantZombie(List entities, Location loc) { + Entity e2 = null; + for (Entity e : getNearbyEntities(loc, 5)) { + if (Entities.isGiantZombie(e)) { + e2 = e; + break; + } + } + return e2; + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java b/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java new file mode 100644 index 0000000..65c302c --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java @@ -0,0 +1,306 @@ +package me.Mammothskier.Giants.files; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.PluginDescriptionFile; + +import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.Giants; + +public class FileHandler { + private final Giants _giants; + private final HashMap _configurations; + + public FileHandler(Giants giants) { + _giants = giants; + _configurations = new HashMap(); + loadWorlds(); + loadFiles(); + loadVersion(); + loadDefaultDrop("Giant"); + loadDefaultDrop("Slime"); + loadDefaultDrop("MagmaCube"); + } + + private String loadVersion() { + PluginDescriptionFile pdf = _giants.getDescription(); + String version = pdf.getVersion(); + if (version == null) { + return null; + } + return version; + } + + public List loadWorlds() { + List worldList = new ArrayList(); + for (World w : _giants.getServer().getWorlds()) { + worldList.add(w.getName()); + } + return worldList; + } + + private boolean checkDependencies(String plugin) { + if (Bukkit.getPluginManager().getPlugin(plugin) != null) { + return true; + } + return false; + } + + private String[] loadDefaultDrop(String arg) { + String[] drops = null; + switch(arg){ + case "Giant Zombie": + drops = new String[]{ "1-0-0;1;100/100;GIANT STONE;Dropped by a Giant Zombie" }; + break; + case "Giant Slime": + drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Slime" }; + break; + case "Giant Lava Slime": + drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Lava Slime" }; + break; + default: + break; + } + return drops; + } + + private List loadEntities() { + List list = new ArrayList(); + list.add("Giant Zombie"); + list.add("Giant Slime"); + list.add("Giant Lava Slime"); + return list; + } + + public void loadFiles() { + for (Files file : Files.values()) { + File confFile = new File(file.getPath()); + + if (confFile.exists()) { + if (_configurations.containsKey(file)) { + _configurations.remove(file); + } + YamlConfiguration conf = YamlConfiguration.loadConfiguration(confFile); + _configurations.put(file, conf); + } else { + File parentFile = confFile.getParentFile(); + + if (!parentFile.exists()) { + parentFile.mkdirs(); + } + this.createFiles(file, confFile); + } + } + } + + private void createFiles(Files files, File file) { + switch (files) { + case CONFIG: + YamlConfiguration Config = YamlConfiguration.loadConfiguration(file); + Config.set("Giants Configuration.File Version", loadVersion()); + Config.set("Giants Configuration.Dependencies.BarAPI", checkDependencies("BarAPI")); + Config.set("Giants Configuration.Entities.Giant Zombie", true); + Config.set("Giants Configuration.Entities.Giant Slime", false); + Config.set("Giants Configuration.Entities.Giant Lava Slime", false); + Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Bugs", new String("This entity of Giants is extremely experimental and does not have many features. Bugs may be present.")); + Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Files", new String("Config files for this entity will NOT load unless enabled.")); + Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Enabled", false); + Config.set("Giants Configuration.Sounds", true); + Config.set("Giants Configuration.Debug Mode.Enabled", false); + Config.set("Giants Configuration.Debug Mode.Debug Message", "&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z"); + try { + Config.save(file); + } catch (IOException e) { + } + _configurations.put(files, Config); + break; + case BIOMES: + YamlConfiguration Biomes = YamlConfiguration.loadConfiguration(file); + Biomes.set("Giants Configuration.File Version", loadVersion()); + Biomes.set("Giants Configuration.Biome Settings.Swampland", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Forest", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Taiga", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Plains", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Extreme Hills", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Mushroom Island", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Desert", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Jungle", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Birch Forest", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Savanna", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Roofed Forest", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Mesa", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Other.Small Mountains", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Other.Ice Mountains", loadEntities()); + Biomes.set("Giants Configuration.Biome Settings.Other.Ocean", ""); + Biomes.set("Giants Configuration.Biome Settings.Other.River", ""); + Biomes.set("Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"); + Biomes.set("Giants Configuration.Biome Settings.Other.Sky", ""); + try { + Biomes.save(file); + } catch (IOException e) { + } + _configurations.put(files, Biomes); + break; + case ENTITIES: + YamlConfiguration entities = YamlConfiguration.loadConfiguration(file); + entities.set("Entities Configuration.File Version", loadVersion()); +// Worlds + entities.set("Entities Configuration.Spawn Settings.Worlds.Giant Zombie", loadWorlds()); + entities.set("Entities Configuration.Spawn Settings.Worlds.Giant Slime", loadWorlds()); + entities.set("Entities Configuration.Spawn Settings.Worlds.Giant Lava Slime", loadWorlds()); +// Spawn Chance + entities.set("Entities Configuration.Spawn Settings.Chance.Giant Zombie", new Integer(10)); + entities.set("Entities Configuration.Spawn Settings.Chance.Giant Slime", new Integer(10)); + entities.set("Entities Configuration.Spawn Settings.Chance.Giant Lava Slime", new Integer(10)); +// Size + entities.set("Entities Configuration.Spawn Settings.Size.Giant Slime", new Integer(12)); + entities.set("Entities Configuration.Spawn Settings.Size.Giant Lava Slime", new Integer(12)); +// Health + entities.set("Entities Configuration.Stats.Health.Giant Zombie", new Integer(100)); + entities.set("Entities Configuration.Stats.Health.Giant Slime", new Integer(100)); + entities.set("Entities Configuration.Stats.Health.Giant Lava Slime", new Integer(100)); +// Experience + entities.set("Entities Configuration.Stats.Experience.Giant Zombie", new Integer(5)); + entities.set("Entities Configuration.Stats.Experience.Giant Slime", new Integer(5)); + entities.set("Entities Configuration.Stats.Experience.Giant Lava Slime", new Integer(5)); +// Armour + entities.set("Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items", + new String("chainmail_helmet:chainmail_chestplate:chainmail_leggings:chainmail_boots:diamond_sword")); + entities.set("Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate", new Float(8.5)); +// Drops + entities.set("Entities Configuration.Stats.Drops.Giant Zombie", Arrays.asList(loadDefaultDrop("Giant Zombie"))); + entities.set("Entities Configuration.Stats.Drops.Giant Slime", Arrays.asList(loadDefaultDrop("Giant Slime"))); + entities.set("Entities Configuration.Stats.Drops.Giant Lava Slime", Arrays.asList(loadDefaultDrop("Giant Lava Slime"))); +// BarAPI + entities.set("Entities Configuration.Stats.BarAPI.Display Name.Giant Zombie", "&2Giant Zombie"); + entities.set("Entities Configuration.Stats.BarAPI.Display Name.Giant Slime", "&2Giant Slime Size {size}"); + entities.set("Entities Configuration.Stats.BarAPI.Display Name.Giant Lava Slime", "&2Giant Lava Slime Size {size}"); +// Damage + entities.set("Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Zombie", new Integer(10)); + entities.set("Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Slime", new Integer(10)); + entities.set("Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Lava Slime", new Integer(10)); + entities.set("Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Zombie", true); + entities.set("Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Slime", true); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Zombie",false); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Slime",false); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Lava Slime",false); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Zombie", false); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Slime", false); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime", false); + try { + entities.save(file); + } catch (IOException e) { + } + _configurations.put(files, entities); + break; + + case ATTACKS: + YamlConfiguration attacks = YamlConfiguration.loadConfiguration(file); + attacks.set("Attacks Configuration.File Version", loadVersion()); + attacks.set("Attacks Configuration.Attack Mechanisms.Lightning Attack", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)); + attacks.set("Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Lava Attack", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height", new Integer(1)); + attacks.set("Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target", new Integer(100)); + attacks.set("Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant", new Integer(100)); + attacks.set("Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", loadEntities()); + attacks.set("Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage", new Integer(1)); + attacks.set("Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Enabled", Arrays.asList("Giant Zombie")); + attacks.set("Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies", false); + attacks.set("Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Zombies to Spawn", new Integer(3)); + attacks.set("Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Health", new Integer(20)); + attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled", false); + attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies", false); + attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn", new Integer(5)); + attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20)); + try { + attacks.save(file); + } catch (IOException e) { + } + _configurations.put(files, attacks); + break; + case JOCKEY: + if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { + YamlConfiguration Jockey = YamlConfiguration.loadConfiguration(file); + Jockey.set("Jockey Configuration.File Version", loadVersion()); + Jockey.set("Jockey Configuration", new String("This entity of Giants is extremely experimental and does not have many features")); + Jockey.set("Jockey Configuration.Spawn Settings.Worlds", loadWorlds()); + try { + Jockey.save(file); + } catch (IOException e) { + } + _configurations.put(files, Jockey); + } + break; + case JOCKEYBIOMES: + if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { + YamlConfiguration JockeyBiomes = YamlConfiguration.loadConfiguration(file); + JockeyBiomes.set("Giants Configuration.File Version", loadVersion()); + JockeyBiomes.set("Giants Configuration.Biome Settings.Swampland", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Forest", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Taiga", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Plains", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Extreme Hills", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Mushroom Island", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Desert", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Jungle", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Birch Forest", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Savanna", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Roofed Forest", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Mesa", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Small Mountains", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Ice Mountains", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Ocean", false); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.River", false); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Hell", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Sky", true); + try { + JockeyBiomes.save(file); + } catch (IOException e) { + } + _configurations.put(files, JockeyBiomes); + } + break; + default: + break; + } + } + + public String getProperty(Files file, String path) { + FileConfiguration conf = _configurations.get(file); + + if (conf != null) { + String prop = conf.getString(path, "NULL"); + + if (!prop.equalsIgnoreCase("NULL")) + return prop; + conf.set(path, null); + } + return null; + } + + public List getPropertyList(Files file, String path) { + FileConfiguration conf = _configurations.get(file); + + if (conf != null) { + List prop = conf.getStringList(path); + if (!prop.contains("NULL")) + return prop; + conf.set(path, null); + } + return null; + } +} \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/Files.java b/Giants/src/main/java/me/Mammothskier/Giants/files/Files.java new file mode 100644 index 0000000..c35ece2 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/files/Files.java @@ -0,0 +1,19 @@ +package me.Mammothskier.Giants.files; + +public enum Files { + CONFIG("plugins/Giants/config.yml"), + ENTITIES("plugins/Giants/entities.yml"), BIOMES("plugins/Giants/biomes.yml"), + ATTACKS("plugins/Giants/attacks.yml"), + JOCKEY("plugins/Giants/Jockey/jockey.yml"), JOCKEYBIOMES("plugins/Giants/Jockey/biomes.yml"); + + private final String _path; + + private Files(final String path) { + _path = path; + } + + public String getPath() { + return _path; + } + +} \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/Metrics.java b/Giants/src/main/java/me/Mammothskier/Giants/util/Metrics.java new file mode 100644 index 0000000..6c1b552 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/util/Metrics.java @@ -0,0 +1,759 @@ +/* + * Copyright 2011-2013 Tyler Blair. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and contributors and should not be interpreted as representing official policies, + * either expressed or implied, of anybody else. + */ +package me.Mammothskier.Giants.util; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.scheduler.BukkitTask; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.Proxy; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.UUID; +import java.util.logging.Level; +import java.util.zip.GZIPOutputStream; + +public class Metrics { + + /** + * The current revision number + */ + private final static int REVISION = 7; + + /** + * The base url of the metrics domain + */ + private static final String BASE_URL = "http://report.mcstats.org"; + + /** + * The url used to report a server's status + */ + private static final String REPORT_URL = "/plugin/%s"; + + /** + * Interval of time to ping (in minutes) + */ + private static final int PING_INTERVAL = 15; + + /** + * The plugin this metrics submits for + */ + private final Plugin plugin; + + /** + * All of the custom graphs to submit to metrics + */ + private final Set graphs = Collections.synchronizedSet(new HashSet()); + + /** + * The plugin configuration file + */ + private final YamlConfiguration configuration; + + /** + * The plugin configuration file + */ + private final File configurationFile; + + /** + * Unique server id + */ + private final String guid; + + /** + * Debug mode + */ + private final boolean debug; + + /** + * Lock for synchronization + */ + private final Object optOutLock = new Object(); + + /** + * The scheduled task + */ + private volatile BukkitTask task = null; + + public Metrics(final Plugin plugin) throws IOException { + if (plugin == null) { + throw new IllegalArgumentException("Plugin cannot be null"); + } + + this.plugin = plugin; + + // load the config + configurationFile = getConfigFile(); + configuration = YamlConfiguration.loadConfiguration(configurationFile); + + // add some defaults + configuration.addDefault("opt-out", false); + configuration.addDefault("guid", UUID.randomUUID().toString()); + configuration.addDefault("debug", false); + + // Do we need to create the file? + if (configuration.get("guid", null) == null) { + configuration.options().header("http://mcstats.org").copyDefaults(true); + configuration.save(configurationFile); + } + + // Load the guid then + guid = configuration.getString("guid"); + debug = configuration.getBoolean("debug", false); + } + + /** + * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics + * website. Plotters can be added to the graph object returned. + * + * @param name The name of the graph + * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given + */ + public Graph createGraph(final String name) { + if (name == null) { + throw new IllegalArgumentException("Graph name cannot be null"); + } + + // Construct the graph object + final Graph graph = new Graph(name); + + // Now we can add our graph + graphs.add(graph); + + // and return back + return graph; + } + + /** + * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend + * + * @param graph The name of the graph + */ + public void addGraph(final Graph graph) { + if (graph == null) { + throw new IllegalArgumentException("Graph cannot be null"); + } + + graphs.add(graph); + } + + /** + * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the + * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 + * ticks. + * + * @return True if statistics measuring is running, otherwise false. + */ + public boolean start() { + synchronized (optOutLock) { + // Did we opt out? + if (isOptOut()) { + return false; + } + + // Is metrics already running? + if (task != null) { + return true; + } + + // Begin hitting the server with glorious data + task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { + + private boolean firstPost = true; + + public void run() { + try { + // This has to be synchronized or it can collide with the disable method. + synchronized (optOutLock) { + // Disable Task, if it is running and the server owner decided to opt-out + if (isOptOut() && task != null) { + task.cancel(); + task = null; + // Tell all plotters to stop gathering information. + for (Graph graph : graphs) { + graph.onOptOut(); + } + } + } + + // We use the inverse of firstPost because if it is the first time we are posting, + // it is not a interval ping, so it evaluates to FALSE + // Each time thereafter it will evaluate to TRUE, i.e PING! + postPlugin(!firstPost); + + // After the first post we set firstPost to false + // Each post thereafter will be a ping + firstPost = false; + } catch (IOException e) { + if (debug) { + Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); + } + } + } + }, 0, PING_INTERVAL * 1200); + + return true; + } + } + + /** + * Has the server owner denied plugin metrics? + * + * @return true if metrics should be opted out of it + */ + public boolean isOptOut() { + synchronized (optOutLock) { + try { + // Reload the metrics file + configuration.load(getConfigFile()); + } catch (IOException ex) { + if (debug) { + Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); + } + return true; + } catch (InvalidConfigurationException ex) { + if (debug) { + Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); + } + return true; + } + return configuration.getBoolean("opt-out", false); + } + } + + /** + * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. + * + * @throws java.io.IOException + */ + public void enable() throws IOException { + // This has to be synchronized or it can collide with the check in the task. + synchronized (optOutLock) { + // Check if the server owner has already set opt-out, if not, set it. + if (isOptOut()) { + configuration.set("opt-out", false); + configuration.save(configurationFile); + } + + // Enable Task, if it is not running + if (task == null) { + start(); + } + } + } + + /** + * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. + * + * @throws java.io.IOException + */ + public void disable() throws IOException { + // This has to be synchronized or it can collide with the check in the task. + synchronized (optOutLock) { + // Check if the server owner has already set opt-out, if not, set it. + if (!isOptOut()) { + configuration.set("opt-out", true); + configuration.save(configurationFile); + } + + // Disable Task, if it is running + if (task != null) { + task.cancel(); + task = null; + } + } + } + + /** + * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status + * + * @return the File object for the config file + */ + public File getConfigFile() { + // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use + // is to abuse the plugin object we already have + // plugin.getDataFolder() => base/plugins/PluginA/ + // pluginsFolder => base/plugins/ + // The base is not necessarily relative to the startup directory. + File pluginsFolder = plugin.getDataFolder().getParentFile(); + + // return => base/plugins/PluginMetrics/config.yml + return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml"); + } + + /** + * Generic method that posts a plugin to the metrics website + */ + private void postPlugin(final boolean isPing) throws IOException { + // Server software specific section + PluginDescriptionFile description = plugin.getDescription(); + String pluginName = description.getName(); + boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled + String pluginVersion = description.getVersion(); + String serverVersion = Bukkit.getVersion(); + int playersOnline = Bukkit.getServer().getOnlinePlayers().size(); + + // END server software specific section -- all code below does not use any code outside of this class / Java + + // Construct the post data + StringBuilder json = new StringBuilder(1024); + json.append('{'); + + // The plugin's description file containg all of the plugin data such as name, version, author, etc + appendJSONPair(json, "guid", guid); + appendJSONPair(json, "plugin_version", pluginVersion); + appendJSONPair(json, "server_version", serverVersion); + appendJSONPair(json, "players_online", Integer.toString(playersOnline)); + + // New data as of R6 + String osname = System.getProperty("os.name"); + String osarch = System.getProperty("os.arch"); + String osversion = System.getProperty("os.version"); + String java_version = System.getProperty("java.version"); + int coreCount = Runtime.getRuntime().availableProcessors(); + + // normalize os arch .. amd64 -> x86_64 + if (osarch.equals("amd64")) { + osarch = "x86_64"; + } + + appendJSONPair(json, "osname", osname); + appendJSONPair(json, "osarch", osarch); + appendJSONPair(json, "osversion", osversion); + appendJSONPair(json, "cores", Integer.toString(coreCount)); + appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0"); + appendJSONPair(json, "java_version", java_version); + + // If we're pinging, append it + if (isPing) { + appendJSONPair(json, "ping", "1"); + } + + if (graphs.size() > 0) { + synchronized (graphs) { + json.append(','); + json.append('"'); + json.append("graphs"); + json.append('"'); + json.append(':'); + json.append('{'); + + boolean firstGraph = true; + + final Iterator iter = graphs.iterator(); + + while (iter.hasNext()) { + Graph graph = iter.next(); + + StringBuilder graphJson = new StringBuilder(); + graphJson.append('{'); + + for (Plotter plotter : graph.getPlotters()) { + appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue())); + } + + graphJson.append('}'); + + if (!firstGraph) { + json.append(','); + } + + json.append(escapeJSON(graph.getName())); + json.append(':'); + json.append(graphJson); + + firstGraph = false; + } + + json.append('}'); + } + } + + // close json + json.append('}'); + + // Create the url + URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName))); + + // Connect to the website + URLConnection connection; + + // Mineshafter creates a socks proxy, so we can safely bypass it + // It does not reroute POST requests so we need to go around it + if (isMineshafterPresent()) { + connection = url.openConnection(Proxy.NO_PROXY); + } else { + connection = url.openConnection(); + } + + + byte[] uncompressed = json.toString().getBytes(); + byte[] compressed = gzip(json.toString()); + + // Headers + connection.addRequestProperty("User-Agent", "MCStats/" + REVISION); + connection.addRequestProperty("Content-Type", "application/json"); + connection.addRequestProperty("Content-Encoding", "gzip"); + connection.addRequestProperty("Content-Length", Integer.toString(compressed.length)); + connection.addRequestProperty("Accept", "application/json"); + connection.addRequestProperty("Connection", "close"); + + connection.setDoOutput(true); + + if (debug) { + System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); + } + + // Write the data + OutputStream os = connection.getOutputStream(); + os.write(compressed); + os.flush(); + + // Now read the response + final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String response = reader.readLine(); + + // close resources + os.close(); + reader.close(); + + if (response == null || response.startsWith("ERR") || response.startsWith("7")) { + if (response == null) { + response = "null"; + } else if (response.startsWith("7")) { + response = response.substring(response.startsWith("7,") ? 2 : 1); + } + + throw new IOException(response); + } else { + // Is this the first update this hour? + if (response.equals("1") || response.contains("This is your first update this hour")) { + synchronized (graphs) { + final Iterator iter = graphs.iterator(); + + while (iter.hasNext()) { + final Graph graph = iter.next(); + + for (Plotter plotter : graph.getPlotters()) { + plotter.reset(); + } + } + } + } + } + } + + /** + * GZip compress a string of bytes + * + * @param input + * @return + */ + public static byte[] gzip(String input) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + GZIPOutputStream gzos = null; + + try { + gzos = new GZIPOutputStream(baos); + gzos.write(input.getBytes("UTF-8")); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (gzos != null) try { + gzos.close(); + } catch (IOException ignore) { + } + } + + return baos.toByteArray(); + } + + /** + * Check if mineshafter is present. If it is, we need to bypass it to send POST requests + * + * @return true if mineshafter is installed on the server + */ + private boolean isMineshafterPresent() { + try { + Class.forName("mineshafter.MineServer"); + return true; + } catch (Exception e) { + return false; + } + } + + /** + * Appends a json encoded key/value pair to the given string builder. + * + * @param json + * @param key + * @param value + * @throws UnsupportedEncodingException + */ + private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { + boolean isValueNumeric = false; + + try { + if (value.equals("0") || !value.endsWith("0")) { + Double.parseDouble(value); + isValueNumeric = true; + } + } catch (NumberFormatException e) { + isValueNumeric = false; + } + + if (json.charAt(json.length() - 1) != '{') { + json.append(','); + } + + json.append(escapeJSON(key)); + json.append(':'); + + if (isValueNumeric) { + json.append(value); + } else { + json.append(escapeJSON(value)); + } + } + + /** + * Escape a string to create a valid JSON string + * + * @param text + * @return + */ + private static String escapeJSON(String text) { + StringBuilder builder = new StringBuilder(); + + builder.append('"'); + for (int index = 0; index < text.length(); index++) { + char chr = text.charAt(index); + + switch (chr) { + case '"': + case '\\': + builder.append('\\'); + builder.append(chr); + break; + case '\b': + builder.append("\\b"); + break; + case '\t': + builder.append("\\t"); + break; + case '\n': + builder.append("\\n"); + break; + case '\r': + builder.append("\\r"); + break; + default: + if (chr < ' ') { + String t = "000" + Integer.toHexString(chr); + builder.append("\\u" + t.substring(t.length() - 4)); + } else { + builder.append(chr); + } + break; + } + } + builder.append('"'); + + return builder.toString(); + } + + /** + * Encode text as UTF-8 + * + * @param text the text to encode + * @return the encoded text, as UTF-8 + */ + private static String urlEncode(final String text) throws UnsupportedEncodingException { + return URLEncoder.encode(text, "UTF-8"); + } + + /** + * Represents a custom graph on the website + */ + public static class Graph { + + /** + * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is + * rejected + */ + private final String name; + + /** + * The set of plotters that are contained within this graph + */ + private final Set plotters = new LinkedHashSet(); + + private Graph(final String name) { + this.name = name; + } + + /** + * Gets the graph's name + * + * @return the Graph's name + */ + public String getName() { + return name; + } + + /** + * Add a plotter to the graph, which will be used to plot entries + * + * @param plotter the plotter to add to the graph + */ + public void addPlotter(final Plotter plotter) { + plotters.add(plotter); + } + + /** + * Remove a plotter from the graph + * + * @param plotter the plotter to remove from the graph + */ + public void removePlotter(final Plotter plotter) { + plotters.remove(plotter); + } + + /** + * Gets an unmodifiable set of the plotter objects in the graph + * + * @return an unmodifiable {@link java.util.Set} of the plotter objects + */ + public Set getPlotters() { + return Collections.unmodifiableSet(plotters); + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(final Object object) { + if (!(object instanceof Graph)) { + return false; + } + + final Graph graph = (Graph) object; + return graph.name.equals(name); + } + + /** + * Called when the server owner decides to opt-out of BukkitMetrics while the server is running. + */ + protected void onOptOut() { + } + } + + /** + * Interface used to collect custom data for a plugin + */ + public static abstract class Plotter { + + /** + * The plot's name + */ + private final String name; + + /** + * Construct a plotter with the default plot name + */ + public Plotter() { + this("Default"); + } + + /** + * Construct a plotter with a specific plot name + * + * @param name the name of the plotter to use, which will show up on the website + */ + public Plotter(final String name) { + this.name = name; + } + + /** + * Get the current value for the plotted point. Since this function defers to an external function it may or may + * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called + * from any thread so care should be taken when accessing resources that need to be synchronized. + * + * @return the current value for the point to be plotted. + */ + public abstract int getValue(); + + /** + * Get the column name for the plotted point + * + * @return the plotted point's column name + */ + public String getColumnName() { + return name; + } + + /** + * Called after the website graphs have been updated + */ + public void reset() { + } + + @Override + public int hashCode() { + return getColumnName().hashCode(); + } + + @Override + public boolean equals(final Object object) { + if (!(object instanceof Plotter)) { + return false; + } + + final Plotter plotter = (Plotter) object; + return plotter.name.equals(name) && plotter.getValue() == getValue(); + } + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java new file mode 100644 index 0000000..675b9f9 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java @@ -0,0 +1,98 @@ +package me.Mammothskier.Giants.util; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import me.Mammothskier.Giants.entity.Entities; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; + +public class NMSUtils { + + public static String getBukkitVersion() { + Matcher matcher = Pattern.compile("v\\d+_\\d+_R\\d+").matcher(Bukkit.getServer().getClass().getPackage().getName()); + if (matcher.find()) { + return matcher.group(); + } else { + return null; + } + } + + public static String getMinecraftVersion() { + Matcher matcher = Pattern.compile("(\\(MC: )([\\d\\.]+)(\\))").matcher(Bukkit.getVersion()); + if (matcher.find()) { + return matcher.group(2); + } else { + return null; + } + } + + public static void createGiant(Location location, SpawnReason reason) { + String version = NMSUtils.getBukkitVersion(); + if (Entities.GiantZombie == true) { + switch (version) { + case("v1_7_R3"): + me.Mammothskier.Giants.entity.nms.v1_7_R3.EntityCreator.createEntity(location, reason); + break; + case("v1_7_R4"): + me.Mammothskier.Giants.entity.nms.v1_7_R4.EntityCreator.createEntity(location, reason); + break; + case("v1_8_R1"): + me.Mammothskier.Giants.entity.nms.v1_8_R1.EntityCreator.createEntity(location, reason); + break; + case("v1_8_R2"): + me.Mammothskier.Giants.entity.nms.v1_8_R2.EntityCreator.createEntity(location, reason); + break; + case("v1_8_R3"): + me.Mammothskier.Giants.entity.nms.v1_8_R3.EntityCreator.createEntity(location, reason); + break; + } + } + } + + public static void registerEntities() { + String version = NMSUtils.getBukkitVersion(); + if ("v1_7_R3".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_7_R3 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_7_R3.CustomEntityType.registerEntities(); + } else if ("v1_7_R4".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_7_R4 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_7_R4.CustomEntityType.registerEntities(); + } else if ("v1_8_R1".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_8_R1 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_8_R1.CustomEntityType.registerEntities(); + } else if ("v1_8_R2".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_8_R2 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_8_R2.CustomEntityType.registerEntities(); + } else if ("v1_8_R3".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_8_R2 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_8_R3.CustomEntityType.registerEntities(); + } else { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.RED + "Minecraft server version " + version + "does not support Giant Zombies.Disabling Giant Zombies"); + Entities.GiantZombie = false; + } + } + + public static void unregisterEntities() { + String version = NMSUtils.getBukkitVersion(); + if ("v1_7_R3".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_7_R3.CustomEntityType.unregisterEntities(); + } else if ("v1_7_R4".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_7_R4.CustomEntityType.unregisterEntities(); + } else if ("v1_8_R1".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_8_R1.CustomEntityType.unregisterEntities(); + } else if ("v1_8_R2".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_8_R2.CustomEntityType.unregisterEntities(); + } else if ("v1_8_R3".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_8_R3.CustomEntityType.unregisterEntities(); + } + } +} diff --git a/Giants/src/main/resources/attacks.yml b/Giants/src/main/resources/attacks.yml new file mode 100644 index 0000000..b9c2800 --- /dev/null +++ b/Giants/src/main/resources/attacks.yml @@ -0,0 +1,51 @@ +Attacks Configuration: + File Version: ${project.build.version} + Attack Mechanisms: + Lightning Attack: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Stomp Attack: + Enabled: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Explosion Power: 1 + Light Fire: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Lava Attack: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Kick Attack: + Enabled: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Kick Height: 1 + Fire Attack: + Enabled: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Ticks for Target: 100 + Ticks for Giant: 100 + Throw Boulder Attack: + Enabled: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Block Damage: 1 + Shrapnel Attack: + Enabled: + - Giant Zombie + Baby Zombies: false + Zombies to Spawn: 3 + Health: 20 + Spawn Zombies On Death: + Enabled: false + Baby Zombies: false + Zombies to Spawn: 5 + Health: 20 diff --git a/Giants/src/main/resources/biomes.yml b/Giants/src/main/resources/biomes.yml new file mode 100644 index 0000000..7eb2d13 --- /dev/null +++ b/Giants/src/main/resources/biomes.yml @@ -0,0 +1,64 @@ +Giants Configuration: + File Version: ${project.build.version} + Biome Settings: + Swampland: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Forest: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Taiga: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Plains: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Extreme Hills: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Mushroom Island: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Desert: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Jungle: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Birch Forest: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Savanna: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Roofed Forest: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Mesa: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Other: + Small Mountains: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Ice Mountains: + - Giant Zombie + - Giant Slime + - Giant Lava Slime + Ocean: '' + River: '' + Hell: '- Giant Lava Slime' + Sky: '' diff --git a/Giants/src/main/resources/config.yml b/Giants/src/main/resources/config.yml new file mode 100644 index 0000000..d726397 --- /dev/null +++ b/Giants/src/main/resources/config.yml @@ -0,0 +1,17 @@ +Giants Configuration: + File Version: ${project.build.version} + Dependencies: + BarAPI: false + Entities: + Giant Zombie: true + Giant Slime: false + Giant Lava Slime: false + Giant Jockey: + Warning: + Bugs: This entity of Giants is extremely experimental and does not have many features. Bugs may be present. + Files: Config files for this entity will NOT load unless enabled. + Enabled: true + Sounds: true + Debug Mode: + Enabled: false + Debug Message: '&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z' diff --git a/Giants/src/main/resources/entities.yml b/Giants/src/main/resources/entities.yml new file mode 100644 index 0000000..0440f65 --- /dev/null +++ b/Giants/src/main/resources/entities.yml @@ -0,0 +1,67 @@ +Entities Configuration: + File Version: ${project.build.version} + Spawn Settings: + Worlds: + Giant Zombie: + - world + - world_nether + - world_the_end + Giant Slime: + - world + - world_nether + - world_the_end + Giant Lava Slime: + - world + - world_nether + - world_the_end + Chance: + Giant Zombie: 10 + Giant Slime: 10 + Giant Lava Slime: 10 + Size: + Giant Slime: 12 + Giant Lava Slime: 12 + Stats: + Health: + Giant Zombie: 100 + Giant Slime: 100 + Giant Lava Slime: 100 + Experience: + Giant Zombie: 5 + Giant Slime: 5 + Giant Lava Slime: 5 + Equipped Armour: + Giant Zombie: + Items: chainmail_helmet:chainmail_chestplate:chainmail_leggings:chainmail_boots:diamond_sword + Equipped Item Drop Rate: 8.5 + Drops: + Giant Zombie: + - 1-0-0;1;100/100;GIANT STONE;Dropped by a Giant Zombie + Giant Slime: + - 1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Slime + Giant Lava Slime: + - 1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Lava Slime + BarAPI: + Display Name: + Giant Zombie: '&2Giant Zombie' + Giant Slime: '&2Giant Slime Size {size}' + Giant Lava Slime: '&2Giant Lava Slime Size {size}' + Damage Settings: + Arrows: + Damage done by arrow: + Giant Zombie: 10 + Giant Slime: 10 + Giant Lava Slime: 10 + Fire: + Allow Fire Damage: + Giant Zombie: true + Giant Slime: true + Block Damage: + Allow Suffocation: + Giant Zombie: false + Giant Slime: false + Giant Lava Slime: false + Allow Cacti Damage: + Giant Zombie: false + Giant Slime: false + Giant Lava Slime: false diff --git a/Giants/src/main/resources/jockey.yml b/Giants/src/main/resources/jockey.yml new file mode 100644 index 0000000..22f9191 --- /dev/null +++ b/Giants/src/main/resources/jockey.yml @@ -0,0 +1,6 @@ +Jockey Configuration: + Spawn Settings: + Worlds: + - world + - world_nether + - world_the_end diff --git a/src/main/resources/plugin.yml b/Giants/src/main/resources/plugin.yml similarity index 100% rename from src/main/resources/plugin.yml rename to Giants/src/main/resources/plugin.yml diff --git a/src/main/java/me/Mammothskier/Giants/Attacks.java b/src/main/java/me/Mammothskier/Giants/Attacks.java deleted file mode 100644 index c6011e1..0000000 --- a/src/main/java/me/Mammothskier/Giants/Attacks.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.Mammothskier.Giants; - -import org.bukkit.entity.Entity; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Damageable; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - -public class Attacks { - - public Attacks(Giants attacks) { - - } - - public void fireAttack(Entity attacker, Entity target, int ticksAttacker, int ticksTarget, boolean sound){ - attacker.setFireTicks(ticksAttacker); - target.setFireTicks(ticksTarget); - if (sound == true){ - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE_IGNITE, 1, 0); - } - } - - public void jumpAttack(Entity attacker, Entity target, double height, float power, boolean blockDamage, boolean sound){ - attacker.setVelocity(new Vector(0,height, 0)); - Location location = attacker.getLocation(); - location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, false, blockDamage); - if (attacker.getNearbyEntities(2, 4, 2).contains(target)){ - Vector direction = target.getLocation().toVector().subtract(target.getLocation().toVector()).normalize(); - direction.setX( direction.getX()*2 ); - direction.setY( direction.getY()*2 ); - direction.setZ( direction.getZ()*2 ); - target.setVelocity(direction); - } - if (sound == true){ - - } - } - - public void kickAttack(Entity target, double height, boolean sound){ - target.setVelocity(new Vector(0, height, 0)); - if (sound == true){ - target.getLocation().getWorld().playSound(target.getLocation(), Sound.LAVA_POP, 1, 0); - } - } - - public void lavaAttack(Entity target, boolean sound){ - target.getLocation().getBlock().setType(Material.LAVA); - if (sound == true){ - target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); - target.getLocation().getWorld().playSound(target.getLocation(), Sound.LAVA_POP, 1, 0); - } - } - - public void lightningAttack(Entity target){ - try { - Location location = target.getLocation(); - location.getWorld().strikeLightning(location); - } catch (Exception e) { - } - } - - public void poisonAttack(Player player, Double length) { - player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) (length*20), 3)); - } - - public void spawnZombies(Location location, int amount, double health, boolean baby, boolean sound){ - for (int i = 1; i <= amount; i++){ - if (baby == true) { - Entity e = location.getWorld().spawnEntity(location, EntityType.ZOMBIE); - ((Zombie) e).setBaby(true); - ((Damageable) e).setMaxHealth(health); - ((Damageable) e).setHealth(health); - } - else{ - Entity e = location.getWorld().spawnEntity(location, EntityType.ZOMBIE); - ((Damageable) e).setMaxHealth(health); - ((Damageable) e).setHealth(health); - } - } - if (sound == true){ - location.getWorld().playSound(location, Sound.EXPLODE, 1, 0); - } - } - - public void stompAttack(Location location, float power, boolean fire, boolean sound){ - location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); - if (sound == true){ - location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); - } - } - - public void throwBoulderAttack(LivingEntity attacker, boolean sound){ - Vector direction = ((LivingEntity) attacker).getEyeLocation().getDirection().multiply(2); - Fireball fireball = attacker.getWorld().spawn(((LivingEntity) attacker).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); - fireball.setShooter(attacker); - if (sound == true){ - Location location = attacker.getLocation(); - location.getWorld().playSound(location, Sound.GHAST_FIREBALL, 1, 0); - } - } -} diff --git a/src/main/java/me/Mammothskier/Giants/Commands.java b/src/main/java/me/Mammothskier/Giants/Commands.java deleted file mode 100644 index f6034a0..0000000 --- a/src/main/java/me/Mammothskier/Giants/Commands.java +++ /dev/null @@ -1,294 +0,0 @@ -package me.Mammothskier.Giants; - -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.plugin.PluginDescriptionFile; - -public class Commands implements CommandExecutor { - private Giants _giants; - - public Commands(Giants giants) { - _giants = giants; - } - - public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - if (commandLabel.equalsIgnoreCase("giants")) { - if (sender instanceof Player){ - Player player = (Player) sender; - if (args.length == 0){ - if (player.hasPermission("giants.reload") || player.hasPermission("giants.*") || player.hasPermission("giants.debug") || player.hasPermission("giants.spawn") || player.isOp()) { - player.sendMessage(ChatColor.GREEN + "===== Giants Commands ===== \n" + - "/giants reload: Reloads the config file.\n" + - "/giants spawn [entitytype] : Spawns entity at the location given \n" + - "/giants version: Displays the version of the plugin running on the server"); - } else { - player.sendMessage(ChatColor.RED + "You do not have permission to use this command"); - } - return true; - } - if (args[0].equalsIgnoreCase("reload")) { - if ((player.hasPermission("giants.reload")) || (player.isOp()) || (player.hasPermission("giants.*"))) { - if ((player.hasPermission("giants.reload")) || (player.isOp())) { - API.getFileHandler().loadFiles(); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "Giants config file reloaded."); - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants]" + ChatColor.GREEN + player + "has reloaded the giants config"); - _giants.log.info("Giants config file reloaded."); - } else { - sender.sendMessage(ChatColor.RED + "You do not have permission to use this command"); - } - } - return true; - } - if (args[0].equalsIgnoreCase("spawn")){ - if((player.hasPermission("giants.spawn")) || (player.isOp()) || player.hasPermission("giants.*")){ - if (args.length >= 2){ - if(args[1].equalsIgnoreCase("giant")){ - double health; - - String string = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.Health"); - try { - health = Double.parseDouble(string); - } catch (Exception e) { - health = 100; - } - - if(args.length == 2){ - Location loc = (Location) player.getEyeLocation(); - Location location = loc; - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant has been spawned"); - } - if(args.length == 5){ - Location location = player.getLocation(); - double locx = player.getLocation().getX(); - double locy = player.getLocation().getY(); - double locz = player.getLocation().getZ(); - - try { - locx = Integer.parseInt(args[2]); - locy = Integer.parseInt(args[3]); - locz = Integer.parseInt(args[4]); - - } catch (Exception e) { - } - location.setX(locx); - location.setY(locy); - location.setZ(locz); - Location loc = location; - - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant has been spawned at x:" + locx + " y:" + locy + "z:" + locz); - } - return true; - } - if(args[1].equalsIgnoreCase("slime")){ - Location loc = (Location) player.getEyeLocation(); - Location location = loc; - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Size"); - String string2 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Health"); - int size; - double health; - try { - size = Integer.parseInt(string); - health = Double.parseDouble(string2); - } catch (Exception e) { - size = 12; - health = size^2; - } - if(args.length == 2){ - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Slime has been spawned"); - } - if(args.length == 5){ - double locx = player.getLocation().getX(); - double locy = player.getLocation().getY(); - double locz = player.getLocation().getZ(); - - try { - locx = Integer.parseInt(args[2]); - locy = Integer.parseInt(args[3]); - locz = Integer.parseInt(args[4]); - } catch (Exception e) { - } - loc.setX(locx); - loc.setY(locy); - loc.setZ(locz); - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Slime has been spawned"); - } - return true; - } - - if(args[1].equalsIgnoreCase("jockey")){ - Location loc = (Location) player.getEyeLocation(); - Location location = loc; - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Size"); - String string2 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Health"); - String string3 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.Health"); - int size; - double giantHealth; - double slimeHealth; - try { - size = Integer.parseInt(string); - slimeHealth = Double.parseDouble(string2); - giantHealth = Double.parseDouble(string3); - } catch (Exception e) { - size = 12; - slimeHealth = size^2; - giantHealth = 100; - } - if(args.length == 2){ - Slime slime = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - slime.setSize(size); - slime.setMaxHealth(slimeHealth); - slime.setHealth(slimeHealth); - Giant giant = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - giant.setMaxHealth(giantHealth); - slime.setPassenger(giant); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Jockey has been spawned"); - } - if(args.length == 5){ - double locx = player.getLocation().getX(); - double locy = player.getLocation().getY(); - double locz = player.getLocation().getZ(); - - try { - locx = Integer.parseInt(args[2]); - locy = Integer.parseInt(args[3]); - locz = Integer.parseInt(args[4]); - } catch (Exception e) { - } - loc.setX(locx); - loc.setY(locy); - loc.setZ(locz); - Slime slime = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - slime.setSize(size); - slime.setMaxHealth(slimeHealth); - slime.setHealth(slimeHealth); - Giant giant = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - giant.setMaxHealth(giantHealth); - slime.setPassenger(giant); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Jockey has been spawned"); - } - return true; - } - - if((args[1].equalsIgnoreCase("lavaslime")) || (args[1].equalsIgnoreCase("magma_cube")) || (args[1].equalsIgnoreCase("magma"))|| (args[1].equalsIgnoreCase("magmacube"))){ - Location loc = (Location) player.getEyeLocation(); - Location location = loc; - String string = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.Size"); - String string2 = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.Health"); - int size; - double health; - try { - size = Integer.parseInt(string); - health = Double.parseDouble(string2); - } catch (Exception e) { - size = 12; - health = size^2; - } - if(args.length == 2){ - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Magma Cube has been spawned"); - } - if(args.length == 5){ - double locx = player.getLocation().getX(); - double locy = player.getLocation().getY(); - double locz = player.getLocation().getZ(); - - try { - locx = Integer.parseInt(args[2]); - locy = Integer.parseInt(args[3]); - locz = Integer.parseInt(args[4]); - } catch (Exception e) { - } - loc.setX(locx); - loc.setY(locy); - loc.setZ(locz); - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Magma Cube has been spawned"); - } - return true; - } - else { - player.sendMessage(ChatColor.RED + "Unknown Entity Type! I recognise giant, slime, magmacube and jockey."); - } - } - else { - player.sendMessage(ChatColor.RED + "Not enough arguements!"); - } - } - return true; - } - if (args[0].equalsIgnoreCase("version")){ - if((player.hasPermission("giants.version")) || (player.isOp())){ - PluginDescriptionFile pdf = Bukkit.getPluginManager().getPlugin("Giants").getDescription(); - player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + pdf.getName() + " Version " + pdf.getVersion() + " is currently Enabled!"); - } - return true; - } - else { - if (player.hasPermission("giants.reload") || player.hasPermission("giants.*") || player.hasPermission("giants.debug") || player.hasPermission("giants.spawn") || player.isOp()) { - player.sendMessage(ChatColor.RED + "Unknown Command!"); - } - return true; - } - } - else { - if (args.length == 0){ - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "===== Giants Commands ===== \n" + - "/giants reload: Reloads the config file.\n" + - "/giants version: Displays the version of the plugin running on the server"); - return true; - } - if (args[0].equalsIgnoreCase("reload")) { - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] "+ ChatColor.GREEN + "Giants config files reloaded."); - API.getFileHandler().loadFiles(); - _giants.log.info("Giants config file reloaded."); - return true; - } - if (args[0].equalsIgnoreCase("version")){ - PluginDescriptionFile pdf = Bukkit.getPluginManager().getPlugin("Giants").getDescription(); - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + pdf.getName() + " Version " + pdf.getVersion() + " is currently Enabled!"); - return true; - } - else{ - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Unknown Command!"); - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "===== Giants Commands ===== \n" + - "/giants reload: Reloads the config files.\n" + - "/giants version: Displays the version of the plugin running on the server"); - } - } - } - return true; - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/events/GiantSpawnEvent.java b/src/main/java/me/Mammothskier/Giants/events/GiantSpawnEvent.java deleted file mode 100644 index be46f19..0000000 --- a/src/main/java/me/Mammothskier/Giants/events/GiantSpawnEvent.java +++ /dev/null @@ -1,475 +0,0 @@ -package me.Mammothskier.Giants.events; - -import org.bukkit.Location; -import org.bukkit.block.Biome; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -public class GiantSpawnEvent extends Event { - private static boolean cancelled = false; - private Entity entity; - private Location location; - private static final HandlerList handlers = new HandlerList(); - - - public GiantSpawnEvent(Location loc) { - location = loc; - double health; - Biome biome = loc.getWorld().getBiome(loc.getBlockX(), loc.getBlockZ()); - - String string = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.Health"); - - try { - health = Double.parseDouble(string); - } catch (Exception e) { - health = 100; - } - - if (!API.getGiantSpawnWorlds().contains(loc.getWorld().getName())) { - setCancelled(true); - } - - if(API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant").equalsIgnoreCase("false")){ - setCancelled(true); - } - - if (!isCancelled()) { - if (biome == Biome.SWAMPLAND) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Swampland.Swampland").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SWAMPLAND_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Swampland.Swampland Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FOREST) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Forest.Forest").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Forest.Forest Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Taiga").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Taiga Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Taiga Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Cold Taiga").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Cold Taiga Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Cold Taiga Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_TAIGA) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Mega Taiga").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Mega Taiga Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Mega Spruce Taiga").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.PLAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Plains.Plains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_PLAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Plains.Ice Plains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_PLAINS_SPIKES) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Plains.Ice Plains Spikes").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SUNFLOWER_PLAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Plains.Sunflower Plains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.OCEAN) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Ocean.Ocean").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DEEP_OCEAN) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Ocean.Deep Ocean").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FROZEN_OCEAN) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Ocean.Frozen Ocean").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.RIVER) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.River.River").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FROZEN_RIVER) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.River.Frozen River").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BEACH) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Beach.Beach").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.STONE_BEACH) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Beach.Stone Beach").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_BEACH) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Beach.Cold Beach").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MUSHROOM_ISLAND) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mushroom Island.Mushroom Island").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MUSHROOM_SHORE) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mushroom Island.Mushroom Shore").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Desert.Desert").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Desert.Desert Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Desert.Desert Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Jungle.Jungle").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE_HILLS) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Jungle.Jungle Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE_MOUNTAINS) || (biome == Biome.JUNGLE_EDGE) || (biome == Biome.JUNGLE_EDGE_MOUNTAINS)) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Jungle.Jungle Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Birch Forest.Birch Forest").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Birch Forest.Birch Forest Hills").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Birch Forest.Birch Forest Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Savanna.Savanna").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Savanna.Savanna Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Savanna.Savanna Plateau").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Savanna.Savanna Plateau Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ROOFED_FOREST) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Roofed Forest.Roofed Forest").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ROOFED_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mesa.Mesa").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_BRYCE) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mesa.Mesa Bryce").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mesa.Mesa Plateau").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mesa.Mesa Plateau Forest").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mesa.Mesa Plateau Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SMALL_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Other.Small Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Other.Ice Mountains").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.HELL) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Other.Hell").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SKY) { - if (API.getFileHandler().getProperty(Files.GIANTBIOMES, "Giant Configuration.Biome Settings.Other.Sky").equalsIgnoreCase("true")) { - Giant entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - } - } - - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - - public static boolean isCancelled() { - return cancelled; - } - - public Entity getEntity() { - return entity; - } - - public Location getLocation() { - return location; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/events/MagmaCubeSpawnEvent.java b/src/main/java/me/Mammothskier/Giants/events/MagmaCubeSpawnEvent.java deleted file mode 100644 index c763b3b..0000000 --- a/src/main/java/me/Mammothskier/Giants/events/MagmaCubeSpawnEvent.java +++ /dev/null @@ -1,546 +0,0 @@ -package me.Mammothskier.Giants.events; - -import org.bukkit.Location; -import org.bukkit.block.Biome; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.MagmaCube; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - - -public class MagmaCubeSpawnEvent extends Event { - private static boolean cancelled = false; - private Entity entity; - private Location location; - private static final HandlerList handlers = new HandlerList(); - - - public MagmaCubeSpawnEvent(Location loc) { - location = loc; - Biome biome = loc.getWorld().getBiome(loc.getBlockX(), loc.getBlockZ()); - String string = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.Size"); - - - String string2 = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.Health"); - int size; - double health = 1; - try { - size = Integer.parseInt(string); - health = Double.parseDouble(string2); - } catch (Exception e) { - size = 12; - } - - - if (!API.getMagmaCubeSpawnWorlds().contains(loc.getWorld().getName())) { - setCancelled(true); - } - - - if (!API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Magma Cube").equalsIgnoreCase("true")){ - setCancelled(true); - } - - - if (!isCancelled()) { - if (biome == Biome.SWAMPLAND) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Swampland.Swampland").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SWAMPLAND_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Swampland.Swampland Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FOREST) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Forest.Forest").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Forest.Forest Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Taiga").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Taiga Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Taiga Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Cold Taiga").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Cold Taiga Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Cold Taiga Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_TAIGA) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Mega Taiga").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Mega Taiga Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Mega Spruce Taiga").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.PLAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Plains.Plains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_PLAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Plains.Ice Plains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_PLAINS_SPIKES) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Plains.Ice Plains Spikes").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SUNFLOWER_PLAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Plains.Sunflower Plains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.OCEAN) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Ocean.Ocean").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DEEP_OCEAN) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Ocean.Deep Ocean").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FROZEN_OCEAN) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Ocean.Frozen Ocean").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.RIVER) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.River.River").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FROZEN_RIVER) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.River.Frozen River").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BEACH) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Beach.Beach").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.STONE_BEACH) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Beach.Stone Beach").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_BEACH) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Beach.Cold Beach").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MUSHROOM_ISLAND) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mushroom Island.Mushroom Island").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MUSHROOM_SHORE) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mushroom Island.Mushroom Shore").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Desert.Desert").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Desert.Desert Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Desert.Desert Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Jungle.Jungle").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE_HILLS) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Jungle.Jungle Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE_MOUNTAINS) || (biome == Biome.JUNGLE_EDGE) || (biome == Biome.JUNGLE_EDGE_MOUNTAINS)) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Jungle.Jungle Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest Hills").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Savanna.Savanna").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Savanna.Savanna Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Savanna.Savanna Plateau").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Savanna.Savanna Plateau Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ROOFED_FOREST) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Roofed Forest.Roofed Forest").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ROOFED_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mesa.Mesa").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_BRYCE) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mesa.Mesa Bryce").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau Forest").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SMALL_MOUNTAINS) { - if(API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Other.Small Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Other.Ice Mountains").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.HELL) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Other.Hell").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SKY) { - if (API.getFileHandler().getProperty(Files.MAGMACUBEBIOMES, "Magma Cube Configuration.Biome Settings.Other.Sky").equalsIgnoreCase("true")) { - MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - } - } - - - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - - - public static boolean isCancelled() { - return cancelled; - } - - - public Entity getEntity() { - return entity; - } - - - public Location getLocation() { - return location; - } - - - public HandlerList getHandlers() { - return handlers; - } - - - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/src/main/java/me/Mammothskier/Giants/utils/DropsManager.java b/src/main/java/me/Mammothskier/Giants/utils/DropsManager.java deleted file mode 100644 index 2615f07..0000000 --- a/src/main/java/me/Mammothskier/Giants/utils/DropsManager.java +++ /dev/null @@ -1,434 +0,0 @@ -package me.Mammothskier.Giants.utils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - -import org.bukkit.ChatColor; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentWrapper; -import org.bukkit.entity.Entity; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Slime; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import me.Mammothskier.Giants.Giants; - -public class DropsManager { - - public DropsManager(Giants drops) { - } - - public List setDrop(Entity entity, List newDrop) { - List drops = new ArrayList(); - - switch (entity.getType()) { - case GIANT: - for (String dropList : newDrop) { - Random rand = new Random(); - String[] s = dropList.split(";"); - - if (s.length == 5) { - String item = s[0]; - String style= ""; - String effect = ""; - String effectLevel= ""; - String amount = s[1]; - String rate = s[2]; - String name = s[3]; - String lore = s[4]; - List itemLore; - int id = 0; - int num = 100; - int amt = 1; - int den = 100; - short color = 0; - int effectID = 0; - int effectLevelID = 0; - - if (item.contains("-")){ - String[] split = item.split("-"); - if (split.length == 3){ - item = split[0]; - effect = split[1]; - effectLevel = split[2]; - } - } - if (item.contains(":")){ - String[] split = item.split(":"); - if (split.length == 2){ - item = split[0]; - style = split[1]; - } - } - if (amount.contains("-")){ - int lowerAmount; - int upperAmount; - String[] split = amount.split("-"); - String lAmount = split[0]; - String uAmount = split[1]; - try { - lowerAmount = Integer.parseInt(lAmount); - upperAmount = Integer.parseInt(uAmount); - } catch (Exception e) { - lowerAmount = 1; - upperAmount = 1; - } - amt = rand.nextInt(upperAmount - lowerAmount + 1) + lowerAmount - 1; - amount = String.valueOf(amt); - } - if (rate.contains("/")){ - String[] split = rate.split("/"); - if (split.length == 2){ - try { - num = Integer.parseInt(split[0]); - den = Integer.parseInt(split[1]); - } catch (Exception e) { - num = 100; - den = 100; - } - } - } - - try { - id = Integer.parseInt(item); - effectID = Integer.parseInt(effect); - effectLevelID = Integer.parseInt(effectLevel); - color = Short.parseShort(style); - amt = Integer.parseInt(amount); - } catch (Exception e) { - - } - int randNum = rand.nextInt(den); - - if (name != null) { - name = ChatColor.translateAlternateColorCodes('&', name); - } - - if (lore != null) { - lore = ChatColor.translateAlternateColorCodes('&', lore); - } - - itemLore = Arrays.asList(lore); - - - if (num >= randNum){ - ItemStack newItem = new ItemStack(id, amt, color); - ItemMeta itemMeta = newItem.getItemMeta(); - itemMeta.setDisplayName(name); - itemMeta.setLore(itemLore); - newItem.setItemMeta(itemMeta); - - newItem.setDurability(color); - if ((effectID == 0) || (effectLevelID == 0)) { - - } else if ((effectLevelID >= Enchantment.getById(effectID).getStartLevel()) && (effectLevelID <= Enchantment.getById(effectID).getMaxLevel())) { - Enchantment enchantment = new EnchantmentWrapper(effectID); - newItem.addEnchantment(enchantment, effectLevelID); - } else { - - } - - drops.add(newItem); - } - } - else { - return null; - } - } - return drops; - - case SLIME: - for (String dropList : newDrop) { - Random rand = new Random(); - String[] s = dropList.split(";"); - - if (s.length == 6) { - String item = s[0]; - String style= ""; - String effect = ""; - String effectLevel= ""; - String amount = s[1]; - String rate = s[2]; - String sizeRange = s[3]; - String name = s[4]; - String lore = s[5]; - List itemLore; - int id = 0; - int num = 100; - int den = 100; - int amt = 1; - short color = 0; - int effectID = 0; - int effectLevelID = 0; - int lsize = 4; - int usize = 12; - - Slime slime = (Slime) entity; - int size = slime.getSize(); - - if (item.contains("-")){ - String[] split = item.split("-"); - if (split.length == 3){ - item = split[0]; - effect = split[1]; - effectLevel = split[2]; - } - } - if (item.contains(":")){ - String[] split = item.split(":"); - if (split.length == 2){ - item = split[0]; - style = split[1]; - } - } - if (amount.contains("-")){ - int lowerAmount; - int upperAmount; - String[] split = amount.split("-"); - String lAmount = split[0]; - String uAmount = split[1]; - try { - lowerAmount = Integer.parseInt(lAmount); - upperAmount = Integer.parseInt(uAmount); - } catch (Exception e) { - lowerAmount = 1; - upperAmount = 1; - } - amt = rand.nextInt(upperAmount - lowerAmount + 1) + lowerAmount - 1; - amount = String.valueOf(amt); - } - if (rate.contains("/")){ - String[] split = rate.split("/"); - if (split.length == 2){ - try { - num = Integer.parseInt(split[0]); - den = Integer.parseInt(split[1]); - } catch (Exception e) { - num = 100; - den = 100; - } - } - } - - if (sizeRange.contains("-")) { - String[] split = sizeRange.split("-"); - if (split.length == 2){ - try { - lsize = Integer.parseInt(split[0]); - usize = Integer.parseInt(split[1]); - } catch (Exception e) { - num = 5; - den = 12; - } - } - } else { - try { - lsize = Integer.parseInt(sizeRange); - usize = Integer.parseInt(sizeRange); - } catch (Exception e) { - lsize = 5; - usize = 5; - } - } - - try { - id = Integer.parseInt(item); - effectID = Integer.parseInt(effect); - effectLevelID = Integer.parseInt(effectLevel); - color = Short.parseShort(style); - amt = Integer.parseInt(amount); - } catch (Exception e) { - - } - int randNum = rand.nextInt(den); - - if (name != null) { - name = ChatColor.translateAlternateColorCodes('&', name); - } - - if (lore != null) { - lore = ChatColor.translateAlternateColorCodes('&', lore); - } - - itemLore = Arrays.asList(lore); - - if ((lsize <= size) && (size <= usize)) { - if (num >= randNum){ - ItemStack newItem = new ItemStack(id, amt, color); - ItemMeta itemMeta = newItem.getItemMeta(); - - itemMeta.setDisplayName(name); - itemMeta.setLore(itemLore); - newItem.setItemMeta(itemMeta); - - newItem.setDurability(color); - if ((effectID == 0) || (effectLevelID == 0)) { - - } else if ((effectLevelID >= Enchantment.getById(effectID).getStartLevel()) && (effectLevelID <= Enchantment.getById(effectID).getMaxLevel())) { - Enchantment enchantment = new EnchantmentWrapper(effectID); - newItem.addEnchantment(enchantment, effectLevelID); - } else { - - } - - drops.add(newItem); - } - } - } else { - return null; - } - } - return drops; - - case MAGMA_CUBE: - for (String dropList : newDrop) { - Random rand = new Random(); - String[] s = dropList.split(";"); - - if (s.length == 6) { - String item = s[0]; - String style= ""; - String effect = ""; - String effectLevel= ""; - String amount = s[1]; - String rate = s[2]; - String sizeRange = s[3]; - String name = s[4]; - String lore = s[5]; - List itemLore; - int id = 0; - int num = 100; - int den = 100; - int amt = 1; - short color = 0; - int effectID = 0; - int effectLevelID = 0; - int lsize = 4; - int usize = 12; - - MagmaCube magmacube = (MagmaCube) entity; - int size = magmacube.getSize(); - - if (item.contains("-")){ - String[] split = item.split("-"); - if (split.length == 3){ - item = split[0]; - effect = split[1]; - effectLevel = split[2]; - } - } - if (item.contains(":")){ - String[] split = item.split(":"); - if (split.length == 2){ - item = split[0]; - style = split[1]; - } - } - if (amount.contains("-")){ - int lowerAmount; - int upperAmount; - String[] split = amount.split("-"); - String lAmount = split[0]; - String uAmount = split[1]; - try { - lowerAmount = Integer.parseInt(lAmount); - upperAmount = Integer.parseInt(uAmount); - } catch (Exception e) { - lowerAmount = 1; - upperAmount = 1; - } - amt = rand.nextInt(upperAmount - lowerAmount + 1) + lowerAmount - 1; - amount = String.valueOf(amt); - } - if (rate.contains("/")){ - String[] split = rate.split("/"); - if (split.length == 2){ - try { - num = Integer.parseInt(split[0]); - den = Integer.parseInt(split[1]); - } catch (Exception e) { - num = 100; - den = 100; - } - } - } - - if (sizeRange.contains("-")) { - String[] split = sizeRange.split("-"); - if (split.length == 2){ - try { - lsize = Integer.parseInt(split[0]); - usize = Integer.parseInt(split[1]); - } catch (Exception e) { - num = 5; - den = 12; - } - } - } else { - try { - lsize = Integer.parseInt(sizeRange); - usize = Integer.parseInt(sizeRange); - } catch (Exception e) { - lsize = 5; - usize = 5; - } - } - - try { - id = Integer.parseInt(item); - effectID = Integer.parseInt(effect); - effectLevelID = Integer.parseInt(effectLevel); - color = Short.parseShort(style); - amt = Integer.parseInt(amount); - } catch (Exception e) { - - } - int randNum = rand.nextInt(den); - - if (name != null) { - name = ChatColor.translateAlternateColorCodes('&', name); - } - - if (lore != null) { - lore = ChatColor.translateAlternateColorCodes('&', lore); - } - - itemLore = Arrays.asList(lore); - - if ((lsize <= size) && (size <= usize)) { - if (num >= randNum){ - ItemStack newItem = new ItemStack(id, amt, color); - ItemMeta itemMeta = newItem.getItemMeta(); - - itemMeta.setDisplayName(name); - itemMeta.setLore(itemLore); - newItem.setItemMeta(itemMeta); - - newItem.setDurability(color); - if ((effectID == 0) || (effectLevelID == 0)) { - - } else if ((effectLevelID >= Enchantment.getById(effectID).getStartLevel()) && (effectLevelID <= Enchantment.getById(effectID).getMaxLevel())) { - Enchantment enchantment = new EnchantmentWrapper(effectID); - newItem.addEnchantment(enchantment, effectLevelID); - } else { - - } - - drops.add(newItem); - } - } - } else { - return null; - } - } - return drops; - - default: - break; - } - return drops; - } -} \ No newline at end of file diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml new file mode 100644 index 0000000..e84dc8b --- /dev/null +++ b/v1_7_R3/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + + Giants for v1_7_R3 + Giants-v1_7_R3 + v1 + jar + + + me.Mammothskier + Giants-Parent + 7.0 + + + + + org.bukkit + bukkit + 1.7.9-R0.2 + jar + + + + org.bukkit + craftbukkit + 1.7.9-R0.2 + jar + + + \ No newline at end of file diff --git a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java new file mode 100644 index 0000000..61a701f --- /dev/null +++ b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java @@ -0,0 +1,78 @@ +package me.Mammothskier.Giants.entity.nms.v1_7_R3; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_7_R3.util.UnsafeList; + +import net.minecraft.server.v1_7_R3.EntityGiantZombie; +import net.minecraft.server.v1_7_R3.EntityHuman; +import net.minecraft.server.v1_7_R3.EntityIronGolem; +import net.minecraft.server.v1_7_R3.EntitySkeleton; +import net.minecraft.server.v1_7_R3.EntityVillager; +import net.minecraft.server.v1_7_R3.PathfinderGoalFloat; +import net.minecraft.server.v1_7_R3.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_7_R3.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_7_R3.PathfinderGoalMeleeAttack; +import net.minecraft.server.v1_7_R3.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_7_R3.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_7_R3.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_7_R3.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_7_R3.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_7_R3.PathfinderGoalSelector; +import net.minecraft.server.v1_7_R3.World; +import net.minecraft.server.v1_7_R3.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntitySkeleton.class, 1.0D, true)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + @Override + protected void aC() { + super.aW(); + this.getAttributeInstance(GenericAttributes.b).setValue(35D); + this.getAttributeInstance(GenericAttributes.a).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); + } + + protected void n() { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1, true)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1, true)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, 0, true)); + } +} diff --git a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityType.java b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityType.java new file mode 100644 index 0000000..0838146 --- /dev/null +++ b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityType.java @@ -0,0 +1,181 @@ +package me.Mammothskier.Giants.entity.nms.v1_7_R3; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_7_R3.BiomeBase; +import net.minecraft.server.v1_7_R3.BiomeMeta; +import net.minecraft.server.v1_7_R3.Entity; +import net.minecraft.server.v1_7_R3.EntityInsentient; +import net.minecraft.server.v1_7_R3.EntityTypes; +import net.minecraft.server.v1_7_R3.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "as", "at", "au", "av" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "as", "at", "au", "av" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/EntityCreator.java b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/EntityCreator.java new file mode 100644 index 0000000..ed200f7 --- /dev/null +++ b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/EntityCreator.java @@ -0,0 +1,19 @@ +package me.Mammothskier.Giants.entity.nms.v1_7_R3; + +import net.minecraft.server.v1_7_R3.World; + +import me.Mammothskier.Giants.entity.nms.v1_7_R3.CustomEntityGiantZombie; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R3.CraftWorld; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml new file mode 100644 index 0000000..5c14a2f --- /dev/null +++ b/v1_7_R4/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + Giants for v1_7_R4 + Giants-v1_7_R4 + v1 + jar + + + me.Mammothskier + Giants-Parent + 7.0 + + + + + org.bukkit + craftbukkit + 1.7.10-R0.1-SNAPSHOT + jar + + + \ No newline at end of file diff --git a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java new file mode 100644 index 0000000..76c0874 --- /dev/null +++ b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java @@ -0,0 +1,78 @@ +package me.Mammothskier.Giants.entity.nms.v1_7_R4; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList; + +import net.minecraft.server.v1_7_R4.EntityGiantZombie; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.EntityIronGolem; +import net.minecraft.server.v1_7_R4.EntitySkeleton; +import net.minecraft.server.v1_7_R4.EntityVillager; +import net.minecraft.server.v1_7_R4.PathfinderGoalFloat; +import net.minecraft.server.v1_7_R4.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_7_R4.PathfinderGoalMeleeAttack; +import net.minecraft.server.v1_7_R4.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_7_R4.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_7_R4.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_7_R4.PathfinderGoalSelector; +import net.minecraft.server.v1_7_R4.World; +import net.minecraft.server.v1_7_R4.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntitySkeleton.class, 1.0D, true)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + @Override + protected void aD() { + super.aW(); + this.getAttributeInstance(GenericAttributes.b).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); + } + + protected void n() { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1, true)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1, true)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, 0, true)); + } +} diff --git a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityType.java b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityType.java new file mode 100644 index 0000000..bc7edbd --- /dev/null +++ b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_7_R4; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_7_R4.BiomeBase; +import net.minecraft.server.v1_7_R4.BiomeMeta; +import net.minecraft.server.v1_7_R4.Entity; +import net.minecraft.server.v1_7_R4.EntityInsentient; +import net.minecraft.server.v1_7_R4.EntityTypes; +import net.minecraft.server.v1_7_R4.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.getBiomes()){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "as", "at", "au", "av" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "as", "at", "au", "av" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/EntityCreator.java b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/EntityCreator.java new file mode 100644 index 0000000..724345d --- /dev/null +++ b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/EntityCreator.java @@ -0,0 +1,19 @@ +package me.Mammothskier.Giants.entity.nms.v1_7_R4; + +import net.minecraft.server.v1_7_R4.World; + +import me.Mammothskier.Giants.entity.nms.v1_7_R4.CustomEntityGiantZombie; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} diff --git a/v1_8_R1/pom.xml b/v1_8_R1/pom.xml new file mode 100644 index 0000000..ef39ed1 --- /dev/null +++ b/v1_8_R1/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + Giants for v1_8_R1 + Giants-v1_8_R1 + v1 + jar + + + me.Mammothskier + Giants-Parent + 7.0 + + + + + org.bukkit + craftbukkit + 1.8-R0.1-SNAPSHOT + jar + + + \ No newline at end of file diff --git a/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java new file mode 100644 index 0000000..82d5b31 --- /dev/null +++ b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java @@ -0,0 +1,79 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R1; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_8_R1.util.UnsafeList; + +import net.minecraft.server.v1_8_R1.EntityGiantZombie; +import net.minecraft.server.v1_8_R1.EntityHuman; +import net.minecraft.server.v1_8_R1.EntityIronGolem; +import net.minecraft.server.v1_8_R1.EntityPigZombie; +import net.minecraft.server.v1_8_R1.EntitySkeleton; +import net.minecraft.server.v1_8_R1.EntityVillager; +import net.minecraft.server.v1_8_R1.PathfinderGoalFloat; +import net.minecraft.server.v1_8_R1.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_8_R1.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_8_R1.PathfinderGoalMeleeAttack; +import net.minecraft.server.v1_8_R1.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_8_R1.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_8_R1.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_8_R1.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_8_R1.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_8_R1.PathfinderGoalSelector; +import net.minecraft.server.v1_8_R1.World; +import net.minecraft.server.v1_8_R1.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntitySkeleton.class, 1.0D, true)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + @Override + protected void aW() { + super.aW(); + this.getAttributeInstance(GenericAttributes.b).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); + } + + protected void n() { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1.0D, true)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } +} diff --git a/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityType.java b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityType.java new file mode 100644 index 0000000..cc50044 --- /dev/null +++ b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R1; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_8_R1.BiomeBase; +import net.minecraft.server.v1_8_R1.BiomeMeta; +import net.minecraft.server.v1_8_R1.Entity; +import net.minecraft.server.v1_8_R1.EntityInsentient; +import net.minecraft.server.v1_8_R1.EntityTypes; +import net.minecraft.server.v1_8_R1.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.getBiomes()){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "at", "au", "av", "aw" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "at", "au", "av", "aw" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/EntityCreator.java b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/EntityCreator.java new file mode 100644 index 0000000..55cc365 --- /dev/null +++ b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/EntityCreator.java @@ -0,0 +1,17 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R1; + +import net.minecraft.server.v1_8_R1.World; + +import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.craftbukkit.v1_8_R1.CraftWorld; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml new file mode 100644 index 0000000..8068a19 --- /dev/null +++ b/v1_8_R2/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + + Giants for v1_8_R2 + Giants-v1_8_R2 + v1 + jar + + + me.Mammothskier + Giants-Parent + 7.0 + + + + + org.bukkit + bukkit + 1.8.3-R0.1-SNAPSHOT + jar + + + org.bukkit + craftbukkit + 1.8.3-R0.1-SNAPSHOT + jar + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + \ No newline at end of file diff --git a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java new file mode 100644 index 0000000..a2fa6a2 --- /dev/null +++ b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java @@ -0,0 +1,80 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R2; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_8_R2.util.UnsafeList; + +import net.minecraft.server.v1_8_R2.EntityGiantZombie; +import net.minecraft.server.v1_8_R2.EntityHuman; +import net.minecraft.server.v1_8_R2.EntityIronGolem; +import net.minecraft.server.v1_8_R2.EntitySkeleton; +import net.minecraft.server.v1_8_R2.EntityVillager; +import net.minecraft.server.v1_8_R2.GenericAttributes; +import net.minecraft.server.v1_8_R2.PathfinderGoalFloat; +import net.minecraft.server.v1_8_R2.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_8_R2.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_8_R2.PathfinderGoalMeleeAttack; +import net.minecraft.server.v1_8_R2.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_8_R2.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_8_R2.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_8_R2.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_8_R2.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_8_R2.PathfinderGoalSelector; +import net.minecraft.server.v1_8_R2.World; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntitySkeleton.class, 1.0D, true)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + @Override + protected void initAttributes() { + super.initAttributes(); + this.getAttributeInstance(GenericAttributes.b).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected void n() { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1.0D, true)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, EntityHuman.class)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } +} diff --git a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityType.java b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityType.java new file mode 100644 index 0000000..0705bfc --- /dev/null +++ b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R2; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_8_R2.BiomeBase; +import net.minecraft.server.v1_8_R2.BiomeBase.BiomeMeta; +import net.minecraft.server.v1_8_R2.Entity; +import net.minecraft.server.v1_8_R2.EntityInsentient; +import net.minecraft.server.v1_8_R2.EntityTypes; +import net.minecraft.server.v1_8_R2.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.getBiomes()){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "at", "au", "av", "aw" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "at", "au", "av", "aw" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/EntityCreator.java b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/EntityCreator.java new file mode 100644 index 0000000..56af3b3 --- /dev/null +++ b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/EntityCreator.java @@ -0,0 +1,19 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R2; + +import net.minecraft.server.v1_8_R2.World; + +import me.Mammothskier.Giants.entity.nms.v1_8_R2.CustomEntityGiantZombie; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R2.CraftWorld; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml new file mode 100644 index 0000000..a2d4dff --- /dev/null +++ b/v1_8_R3/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + Giants for v1_8_R3 + Giants-v1_8_R3 + v1 + jar + + + me.Mammothskier + Giants-Parent + 7.0 + + + + + org.bukkit + craftbukkit + 1.8.7-R0.1-SNAPSHOT + jar + + + \ No newline at end of file diff --git a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java new file mode 100644 index 0000000..deec0c4 --- /dev/null +++ b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java @@ -0,0 +1,79 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R3; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_8_R3.util.UnsafeList; + +import net.minecraft.server.v1_8_R3.EntityGiantZombie; +import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityIronGolem; +import net.minecraft.server.v1_8_R3.EntityPigZombie; +import net.minecraft.server.v1_8_R3.EntitySkeleton; +import net.minecraft.server.v1_8_R3.EntityVillager; +import net.minecraft.server.v1_8_R3.PathfinderGoalFloat; +import net.minecraft.server.v1_8_R3.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_8_R3.PathfinderGoalMeleeAttack; +import net.minecraft.server.v1_8_R3.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_8_R3.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_8_R3.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_8_R3.PathfinderGoalSelector; +import net.minecraft.server.v1_8_R3.World; +import net.minecraft.server.v1_8_R3.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntitySkeleton.class, 1.0D, true)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + @Override + protected void initAttributes() { + super.initAttributes(); + this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); + } + + protected void n() { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1.0D, true)); + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } +} diff --git a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityType.java b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityType.java new file mode 100644 index 0000000..277de0d --- /dev/null +++ b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R3; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_8_R3.BiomeBase; +import net.minecraft.server.v1_8_R3.BiomeBase.BiomeMeta; +import net.minecraft.server.v1_8_R3.Entity; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityTypes; +import net.minecraft.server.v1_8_R3.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.getBiomes()){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "at", "au", "av", "aw" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "at", "au", "av", "aw" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/EntityCreator.java b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/EntityCreator.java new file mode 100644 index 0000000..362b18b --- /dev/null +++ b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/EntityCreator.java @@ -0,0 +1,17 @@ +package me.Mammothskier.Giants.entity.nms.v1_8_R3; + +import net.minecraft.server.v1_8_R3.World; + +import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} From c6f5ee99e19f520a0e1b44d6e7ccd1f05a087256 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Tue, 16 Jun 2015 05:34:22 -0700 Subject: [PATCH 02/28] Update to 7.0 --- .../java/me/Mammothskier/Giants/Commands.java | 361 ++++++++++++ .../Giants/entity/DropsManager.java | 529 +++++++++++++++++ pom.xml | 122 ++-- .../Mammothskier/Giants/BarAPI/HealthBar.java | 97 ---- .../java/me/Mammothskier/Giants/Giants.java | 138 ----- .../Giants/events/JockeySpawnEvent.java | 333 ----------- .../Giants/events/SlimeSpawnEvent.java | 534 ----------------- .../Giants/files/FileHandler.java | 548 ------------------ .../me/Mammothskier/Giants/files/Files.java | 20 - .../Giants/listeners/GiantListeners.java | 452 --------------- .../Giants/listeners/JockeyListeners.java | 14 - .../Giants/listeners/MagmaCubeListeners.java | 437 -------------- .../Giants/listeners/SlimeListeners.java | 438 -------------- .../me/Mammothskier/Giants/utils/API.java | 165 ------ 14 files changed, 936 insertions(+), 3252 deletions(-) create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/Commands.java create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java delete mode 100644 src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java delete mode 100644 src/main/java/me/Mammothskier/Giants/Giants.java delete mode 100644 src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java delete mode 100644 src/main/java/me/Mammothskier/Giants/events/SlimeSpawnEvent.java delete mode 100644 src/main/java/me/Mammothskier/Giants/files/FileHandler.java delete mode 100644 src/main/java/me/Mammothskier/Giants/files/Files.java delete mode 100644 src/main/java/me/Mammothskier/Giants/listeners/GiantListeners.java delete mode 100644 src/main/java/me/Mammothskier/Giants/listeners/JockeyListeners.java delete mode 100644 src/main/java/me/Mammothskier/Giants/listeners/MagmaCubeListeners.java delete mode 100644 src/main/java/me/Mammothskier/Giants/listeners/SlimeListeners.java delete mode 100644 src/main/java/me/Mammothskier/Giants/utils/API.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Commands.java b/Giants/src/main/java/me/Mammothskier/Giants/Commands.java new file mode 100644 index 0000000..0e63d20 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/Commands.java @@ -0,0 +1,361 @@ +package me.Mammothskier.Giants; + +import me.Mammothskier.Giants.entity.Entities; +import me.Mammothskier.Giants.events.SpawnEvent; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.PluginDescriptionFile; + +public class Commands implements CommandExecutor { + private Giants _giants; + + public Commands(Giants giants) { + _giants = giants; + } + + public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { + if (commandLabel.equalsIgnoreCase("giants")) { + if (sender instanceof Player){ + Player player = (Player) sender; + if (args.length == 0){ + if (player.hasPermission("giants.reload") || player.hasPermission("giants.*") || player.hasPermission("giants.debug") || player.hasPermission("giants.spawn") || player.isOp()) { + player.sendMessage(ChatColor.GREEN + "===== Giants Commands ===== \n" + + "/giants reload: Reloads the config file.\n" + + "/giants spawn [entitytype] : Spawns entity at the location given \n" + + "/giants version: Displays the version of the plugin running on the server"); + } else { + player.sendMessage(ChatColor.RED + "You do not have permission to use this command"); + } + return true; + } + if (args[0].equalsIgnoreCase("reload")) { + if ((player.hasPermission("giants.reload")) || (player.isOp()) || (player.hasPermission("giants.*"))) { + if ((player.hasPermission("giants.reload")) || (player.isOp())) { + Giants.getFileHandler().loadFiles(); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "Giants config file reloaded."); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants]" + ChatColor.GREEN + player.getName() + "has reloaded the giants config"); + _giants.log.info("Giants config file reloaded."); + } else { + sender.sendMessage(ChatColor.RED + "You do not have permission to use this command"); + } + } + return true; + } + if (args[0].equalsIgnoreCase("spawn")){ + if((player.hasPermission("giants.spawn")) || (player.isOp()) || player.hasPermission("giants.*")){ + if (args.length >= 2){ + if(args[1].equalsIgnoreCase("zombie")){ + Giant entity = null; + double health; + + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Zombie"); + try { + health = Double.parseDouble(string); + } catch (Exception e) { + health = 100; + } + + if(args.length == 2){ + Location loc = (Location) player.getEyeLocation(); + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = (Giant) SpawnEvent.getGiantZombie(SpawnEvent.getNearbyEntities(loc, 10), loc); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant has been spawned"); + } + if(args.length == 5){ + Location location = player.getLocation(); + double locx = player.getLocation().getX(); + double locy = player.getLocation().getY(); + double locz = player.getLocation().getZ(); + + try { + locx = Integer.parseInt(args[2]); + locy = Integer.parseInt(args[3]); + locz = Integer.parseInt(args[4]); + + } catch (Exception e) { + } + location.setX(locx); + location.setY(locy); + location.setZ(locz); + Location loc = location; + if (Entities.GiantZombie == true) { + Entities.createGiant(loc, SpawnReason.NATURAL); + entity = (Giant) SpawnEvent.getGiantZombie(SpawnEvent.getNearbyEntities(loc, 10), loc); + } else { + entity = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); + } + + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant has been spawned at x:" + locx + " y:" + locy + "z:" + locz); + } + + if (entity != null) { + ((Damageable) entity).setMaxHealth(health); + ((Damageable) entity).setHealth(health); + if (entity.getType() == EntityType.GIANT) { + EntityEquipment armour = ((LivingEntity) entity).getEquipment(); + String config = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items"); + String[] s = config.split(":"); + + float rate = 0f; + try { + rate = Float.parseFloat(Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate")); + } catch (Exception e){ + rate = 0; + } + + try { + for (int i = 0; i < s.length; i++) { + Material m = Material.getMaterial(s[i].toUpperCase()); + ItemStack item = new ItemStack(m); + if (i == 0) { + armour.setHelmet(item); + armour.setHelmetDropChance(rate); + } else if (i == 1) { + armour.setChestplate(item); + armour.setChestplateDropChance(rate); + } else if (i == 2) { + armour.setLeggings(item); + armour.setLeggingsDropChance(rate); + } else if (i == 3) { + armour.setBoots(item); + armour.setBootsDropChance(rate); + } else if (i == 4) { + armour.setItemInHand(item); + armour.setItemInHandDropChance(rate); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return true; + } + if(args[1].equalsIgnoreCase("slime")){ + Location loc = (Location) player.getEyeLocation(); + Location location = loc; + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); + String string2 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Slime"); + int size; + double health; + try { + size = Integer.parseInt(string); + health = Double.parseDouble(string2); + } catch (Exception e) { + size = 12; + health = size^2; + } + if(args.length == 2){ + Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); + entity.setSize(size); + entity.setMaxHealth(health); + entity.setHealth(health); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Slime has been spawned"); + } + if(args.length == 5){ + double locx = player.getLocation().getX(); + double locy = player.getLocation().getY(); + double locz = player.getLocation().getZ(); + + try { + locx = Integer.parseInt(args[2]); + locy = Integer.parseInt(args[3]); + locz = Integer.parseInt(args[4]); + } catch (Exception e) { + } + loc.setX(locx); + loc.setY(locy); + loc.setZ(locz); + Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); + entity.setSize(size); + entity.setMaxHealth(health); + entity.setHealth(health); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Slime has been spawned"); + } + return true; + } + + if(args[1].equalsIgnoreCase("jockey")){ + Location loc = (Location) player.getEyeLocation(); + Location location = loc; +<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/Commands.java + String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Size"); + String string2 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Health"); + String string3 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.Health"); +======= + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); + String string2 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Slime"); + String string3 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Zombie"); +>>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/Commands.java + int size; + double giantHealth; + double slimeHealth; + try { + size = Integer.parseInt(string); + slimeHealth = Double.parseDouble(string2); + giantHealth = Double.parseDouble(string3); + } catch (Exception e) { + size = 12; + slimeHealth = size^2; + giantHealth = 100; + } + if(args.length == 2){ + Slime slime = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); + slime.setSize(size); + slime.setMaxHealth(slimeHealth); + slime.setHealth(slimeHealth); +<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/Commands.java + Giant giant = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); + giant.setMaxHealth(giantHealth); +======= + Entities.createGiant(loc, SpawnReason.NATURAL); + + Entity giant = SpawnEvent.getGiantZombie(SpawnEvent.getNearbyEntities(loc, 10), loc); + ((Damageable) giant).setMaxHealth(giantHealth); +>>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/Commands.java + slime.setPassenger(giant); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Jockey has been spawned"); + } + if(args.length == 5){ + double locx = player.getLocation().getX(); + double locy = player.getLocation().getY(); + double locz = player.getLocation().getZ(); + + try { + locx = Integer.parseInt(args[2]); + locy = Integer.parseInt(args[3]); + locz = Integer.parseInt(args[4]); + } catch (Exception e) { + } + loc.setX(locx); + loc.setY(locy); + loc.setZ(locz); + Slime slime = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); + slime.setSize(size); + slime.setMaxHealth(slimeHealth); + slime.setHealth(slimeHealth); + Giant giant = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); + giant.setMaxHealth(giantHealth); + slime.setPassenger(giant); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Jockey has been spawned"); + } + return true; + } + + if((args[1].equalsIgnoreCase("lavaslime")) || (args[1].equalsIgnoreCase("magma_cube")) || (args[1].equalsIgnoreCase("magma"))|| (args[1].equalsIgnoreCase("magmacube"))){ + Location loc = (Location) player.getEyeLocation(); + Location location = loc; + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime"); + String string2 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Lava Slime"); + int size; + double health; + try { + size = Integer.parseInt(string); + health = Double.parseDouble(string2); + } catch (Exception e) { + size = 12; + health = size^2; + } + if(args.length == 2){ + MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); + entity.setSize(size); + entity.setMaxHealth(health); + entity.setHealth(health); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Magma Cube has been spawned"); + } + if(args.length == 5){ + double locx = player.getLocation().getX(); + double locy = player.getLocation().getY(); + double locz = player.getLocation().getZ(); + + try { + locx = Integer.parseInt(args[2]); + locy = Integer.parseInt(args[3]); + locz = Integer.parseInt(args[4]); + } catch (Exception e) { + } + loc.setX(locx); + loc.setY(locy); + loc.setZ(locz); + MagmaCube entity = (MagmaCube) loc.getWorld().spawnEntity(location, EntityType.MAGMA_CUBE); + entity.setSize(size); + entity.setMaxHealth(health); + entity.setHealth(health); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Magma Cube has been spawned"); + } + return true; + } + else { +<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/Commands.java + player.sendMessage(ChatColor.RED + "Unknown Entity Type! I recognise giant, slime, magmacube and jockey."); +======= + player.sendMessage(ChatColor.RED + "Unknown Entity Type! I recognise zombie, slime, lavaslime and jockey."); +>>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/Commands.java + } + } + else { + player.sendMessage(ChatColor.RED + "Not enough arguements!"); + } + } + return true; + } + if (args[0].equalsIgnoreCase("version")){ + PluginDescriptionFile pdf = Bukkit.getPluginManager().getPlugin("Giants").getDescription(); + player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + pdf.getName() + " Version " + pdf.getVersion() + " is currently Enabled!"); + return true; + } + else { + if (player.hasPermission("giants.reload") || player.hasPermission("giants.*") || player.hasPermission("giants.debug") || player.hasPermission("giants.spawn") || player.isOp()) { + player.sendMessage(ChatColor.RED + "Unknown Command!"); + } + return true; + } + } + else { + if (args.length == 0){ + Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "===== Giants Commands ===== \n" + + "/giants reload: Reloads the config file.\n" + + "/giants version: Displays the version of the plugin running on the server"); + return true; + } + if (args[0].equalsIgnoreCase("reload")) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] "+ ChatColor.GREEN + "Giants config files reloaded."); + Giants.getFileHandler().loadFiles(); + _giants.log.info("Giants config file reloaded."); + return true; + } + if (args[0].equalsIgnoreCase("version")){ + PluginDescriptionFile pdf = Bukkit.getPluginManager().getPlugin("Giants").getDescription(); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + pdf.getName() + " Version " + pdf.getVersion() + " is currently Enabled!"); + return true; + } + else{ + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Unknown Command!"); + Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "===== Giants Commands ===== \n" + + "/giants reload: Reloads the config files.\n" + + "/giants version: Displays the version of the plugin running on the server"); + } + } + } + return true; + } +} \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java new file mode 100644 index 0000000..00105c4 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java @@ -0,0 +1,529 @@ +package me.Mammothskier.Giants.entity; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/utils/DropsManager.java +import org.bukkit.ChatColor; +======= +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; + +import org.bukkit.ChatColor; +import org.bukkit.Sound; +>>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentWrapper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class DropsManager implements Listener { + + private Giants _giants; + + public DropsManager(Giants giants) { + _giants = giants; + _giants.getServer().getPluginManager().registerEvents(this, giants); + } + + @EventHandler + public void onGiantDrops(EntityDeathEvent event) throws IOException{ + Entity entity = event.getEntity(); + + + if (Entities.isGiantZombie(entity)) { + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Zombie"); + int exp; + + try { + exp = Integer.parseInt(string); + } catch (Exception e) { + exp = 5; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); + } + event.setDroppedExp(exp); + List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie"); + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + return; + } + + List drops = new ArrayList(); + drops = setDrop(entity, newDrop); + + event.getDrops().addAll(drops); + } + if (Entities.isGiantSlime(entity)) { + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Slime"); + int exp; + + try { + exp = Integer.parseInt(string); + } catch (Exception e) { + exp = 5; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_DEATH, 1, 0); + } + event.setDroppedExp(exp); + List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Slime"); + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + return; + } + + List drops = new ArrayList(); + + drops = setDrop(entity, newDrop); + + event.getDrops().addAll(drops); + } + + + if (Entities.isGiantLavaSlime(entity)) { + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Lava Slime"); + int exp; + + try { + exp = Integer.parseInt(string); + } catch (Exception e) { + exp = 5; + } + if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); + } + event.setDroppedExp(exp); + List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Lava Slime"); + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + return; + } + + List drops = new ArrayList(); + + drops = setDrop(entity, newDrop); + + event.getDrops().addAll(drops); + } + } + + + public static List setDrop(Entity entity, List newDrop) { + List drops = new ArrayList(); + + switch (entity.getType()) { + case GIANT: + for (String dropList : newDrop) { + Random rand = new Random(); + String[] s = dropList.split(";"); + + if (s.length == 5) { + String item = s[0]; + String style= ""; + String effect = ""; + String effectLevel= ""; + String amount = s[1]; + String rate = s[2]; + String name = s[3]; + String lore = s[4]; + List itemLore; + int id = 0; + int num = 100; + int amt = 1; + int den = 100; + short color = 0; + int effectID = 0; + int effectLevelID = 0; + + if (item.contains("-")){ + String[] split = item.split("-"); + if (split.length == 3){ + item = split[0]; + effect = split[1]; + effectLevel = split[2]; + } + } + if (item.contains(":")){ + String[] split = item.split(":"); + if (split.length == 2){ + item = split[0]; + style = split[1]; + } + } + if (amount.contains("-")){ + int lowerAmount; + int upperAmount; + String[] split = amount.split("-"); + String lAmount = split[0]; + String uAmount = split[1]; + try { + lowerAmount = Integer.parseInt(lAmount); + upperAmount = Integer.parseInt(uAmount); + } catch (Exception e) { + lowerAmount = 1; + upperAmount = 1; + } + amt = rand.nextInt(upperAmount - lowerAmount + 1) + lowerAmount - 1; + amount = String.valueOf(amt); + } + if (rate.contains("/")){ + String[] split = rate.split("/"); + if (split.length == 2){ + try { + num = Integer.parseInt(split[0]); + den = Integer.parseInt(split[1]); + } catch (Exception e) { + num = 100; + den = 100; + } + } + } + + try { + id = Integer.parseInt(item); + effectID = Integer.parseInt(effect); + effectLevelID = Integer.parseInt(effectLevel); + color = Short.parseShort(style); + amt = Integer.parseInt(amount); + } catch (Exception e) { + + } + int randNum = rand.nextInt(den); + + if (name != null) { + name = ChatColor.translateAlternateColorCodes('&', name); + } + + if (lore != null) { + lore = ChatColor.translateAlternateColorCodes('&', lore); + } + + itemLore = Arrays.asList(lore); + + + if (num >= randNum){ + ItemStack newItem = new ItemStack(id, amt, color); + ItemMeta itemMeta = newItem.getItemMeta(); + itemMeta.setDisplayName(name); + itemMeta.setLore(itemLore); + newItem.setItemMeta(itemMeta); + + newItem.setDurability(color); + if ((effectID == 0) || (effectLevelID == 0)) { + + } else if ((effectLevelID >= Enchantment.getById(effectID).getStartLevel()) && (effectLevelID <= Enchantment.getById(effectID).getMaxLevel())) { + Enchantment enchantment = new EnchantmentWrapper(effectID); + newItem.addEnchantment(enchantment, effectLevelID); + } else { + + } + + drops.add(newItem); + } + } + else { + return null; + } + } + return drops; + + case SLIME: + for (String dropList : newDrop) { + Random rand = new Random(); + String[] s = dropList.split(";"); + + if (s.length == 6) { + String item = s[0]; + String style= ""; + String effect = ""; + String effectLevel= ""; + String amount = s[1]; + String rate = s[2]; + String sizeRange = s[3]; + String name = s[4]; + String lore = s[5]; + List itemLore; + int id = 0; + int num = 100; + int den = 100; + int amt = 1; + short color = 0; + int effectID = 0; + int effectLevelID = 0; + int lsize = 4; + int usize = 12; + + Slime slime = (Slime) entity; + int size = slime.getSize(); + + if (item.contains("-")){ + String[] split = item.split("-"); + if (split.length == 3){ + item = split[0]; + effect = split[1]; + effectLevel = split[2]; + } + } + if (item.contains(":")){ + String[] split = item.split(":"); + if (split.length == 2){ + item = split[0]; + style = split[1]; + } + } + if (amount.contains("-")){ + int lowerAmount; + int upperAmount; + String[] split = amount.split("-"); + String lAmount = split[0]; + String uAmount = split[1]; + try { + lowerAmount = Integer.parseInt(lAmount); + upperAmount = Integer.parseInt(uAmount); + } catch (Exception e) { + lowerAmount = 1; + upperAmount = 1; + } + amt = rand.nextInt(upperAmount - lowerAmount + 1) + lowerAmount - 1; + amount = String.valueOf(amt); + } + if (rate.contains("/")){ + String[] split = rate.split("/"); + if (split.length == 2){ + try { + num = Integer.parseInt(split[0]); + den = Integer.parseInt(split[1]); + } catch (Exception e) { + num = 100; + den = 100; + } + } + } + + if (sizeRange.contains("-")) { + String[] split = sizeRange.split("-"); + if (split.length == 2){ + try { + lsize = Integer.parseInt(split[0]); + usize = Integer.parseInt(split[1]); + } catch (Exception e) { + num = 5; + den = 12; + } + } + } else { + try { + lsize = Integer.parseInt(sizeRange); + usize = Integer.parseInt(sizeRange); + } catch (Exception e) { + lsize = 5; + usize = 5; + } + } + + try { + id = Integer.parseInt(item); + effectID = Integer.parseInt(effect); + effectLevelID = Integer.parseInt(effectLevel); + color = Short.parseShort(style); + amt = Integer.parseInt(amount); + } catch (Exception e) { + + } + int randNum = rand.nextInt(den); + + if (name != null) { + name = ChatColor.translateAlternateColorCodes('&', name); + } + + if (lore != null) { + lore = ChatColor.translateAlternateColorCodes('&', lore); + } + + itemLore = Arrays.asList(lore); + + if ((lsize <= size) && (size <= usize)) { + if (num >= randNum){ + ItemStack newItem = new ItemStack(id, amt, color); + ItemMeta itemMeta = newItem.getItemMeta(); + + itemMeta.setDisplayName(name); + itemMeta.setLore(itemLore); + newItem.setItemMeta(itemMeta); + + newItem.setDurability(color); + if ((effectID == 0) || (effectLevelID == 0)) { + + } else if ((effectLevelID >= Enchantment.getById(effectID).getStartLevel()) && (effectLevelID <= Enchantment.getById(effectID).getMaxLevel())) { + Enchantment enchantment = new EnchantmentWrapper(effectID); + newItem.addEnchantment(enchantment, effectLevelID); + } else { + + } + + drops.add(newItem); + } + } + } else { + return null; + } + } + return drops; + + case MAGMA_CUBE: + for (String dropList : newDrop) { + Random rand = new Random(); + String[] s = dropList.split(";"); + + if (s.length == 6) { + String item = s[0]; + String style= ""; + String effect = ""; + String effectLevel= ""; + String amount = s[1]; + String rate = s[2]; + String sizeRange = s[3]; + String name = s[4]; + String lore = s[5]; + List itemLore; + int id = 0; + int num = 100; + int den = 100; + int amt = 1; + short color = 0; + int effectID = 0; + int effectLevelID = 0; + int lsize = 4; + int usize = 12; + + MagmaCube magmacube = (MagmaCube) entity; + int size = magmacube.getSize(); + + if (item.contains("-")){ + String[] split = item.split("-"); + if (split.length == 3){ + item = split[0]; + effect = split[1]; + effectLevel = split[2]; + } + } + if (item.contains(":")){ + String[] split = item.split(":"); + if (split.length == 2){ + item = split[0]; + style = split[1]; + } + } + if (amount.contains("-")){ + int lowerAmount; + int upperAmount; + String[] split = amount.split("-"); + String lAmount = split[0]; + String uAmount = split[1]; + try { + lowerAmount = Integer.parseInt(lAmount); + upperAmount = Integer.parseInt(uAmount); + } catch (Exception e) { + lowerAmount = 1; + upperAmount = 1; + } + amt = rand.nextInt(upperAmount - lowerAmount + 1) + lowerAmount - 1; + amount = String.valueOf(amt); + } + if (rate.contains("/")){ + String[] split = rate.split("/"); + if (split.length == 2){ + try { + num = Integer.parseInt(split[0]); + den = Integer.parseInt(split[1]); + } catch (Exception e) { + num = 100; + den = 100; + } + } + } + + if (sizeRange.contains("-")) { + String[] split = sizeRange.split("-"); + if (split.length == 2){ + try { + lsize = Integer.parseInt(split[0]); + usize = Integer.parseInt(split[1]); + } catch (Exception e) { + num = 5; + den = 12; + } + } + } else { + try { + lsize = Integer.parseInt(sizeRange); + usize = Integer.parseInt(sizeRange); + } catch (Exception e) { + lsize = 5; + usize = 5; + } + } + + try { + id = Integer.parseInt(item); + effectID = Integer.parseInt(effect); + effectLevelID = Integer.parseInt(effectLevel); + color = Short.parseShort(style); + amt = Integer.parseInt(amount); + } catch (Exception e) { + + } + int randNum = rand.nextInt(den); + + if (name != null) { + name = ChatColor.translateAlternateColorCodes('&', name); + } + + if (lore != null) { + lore = ChatColor.translateAlternateColorCodes('&', lore); + } + + itemLore = Arrays.asList(lore); + + if ((lsize <= size) && (size <= usize)) { + if (num >= randNum){ + ItemStack newItem = new ItemStack(id, amt, color); + ItemMeta itemMeta = newItem.getItemMeta(); + + itemMeta.setDisplayName(name); + itemMeta.setLore(itemLore); + newItem.setItemMeta(itemMeta); + + newItem.setDurability(color); + if ((effectID == 0) || (effectLevelID == 0)) { + + } else if ((effectLevelID >= Enchantment.getById(effectID).getStartLevel()) && (effectLevelID <= Enchantment.getById(effectID).getMaxLevel())) { + Enchantment enchantment = new EnchantmentWrapper(effectID); + newItem.addEnchantment(enchantment, effectLevelID); + } else { + + } + + drops.add(newItem); + } + } + } else { + return null; + } + } + return drops; + + default: + break; + } + return drops; + } +} diff --git a/pom.xml b/pom.xml index d5620bb..70de53d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,25 +1,34 @@ - - - 4.0.0 - - - - - me.mammothskier - giants - 6.4-SNAPSHOT - jar - - - - - Giants - - - - + + 4.0.0 + me.Mammothskier + Giants-Parent + 7.0 + pom + + v1_7_R3 + v1_7_R4 + v1_8_R1 + v1_8_R2 + v1_8_R3 + Giants + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + confuser-repo + http://ci.frostcast.net/plugin/repository/everything + + + + bukkit-repo + http://repo.bukkit.org/content/groups/public + + + ${basedir}/src/main/java @@ -37,7 +46,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.0 1.7 1.7 @@ -54,8 +63,17 @@ shade + + + me.Mammothskier:Giants* + + ** + + + + me.Mammothskier:Giants* org.mcstats.bukkit:metrics @@ -67,59 +85,16 @@ - - - - - - - bukkit-repo - Bukkit Repository - http://repo.bukkit.org/content/groups/public/ - - - Plugin Metrics - http://repo.mcstats.org/content/repositories/public - - - confuser-repo - http://ci.frostcast.net/plugin/repository/everything - - - - - - - org.bukkit - craftbukkit - 1.7.2-R0.3-SNAPSHOT - jar - compile - - - org.mcstats.bukkit - metrics - R7 - compile - - - me.confuser - BarAPI - 3.0 - compile - - - - + + UTF-8 UNKNOWN UNKNOWN UNKNOWN UNKNOWN - - - + + stable @@ -203,9 +178,4 @@ - - - - - - + \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java b/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java deleted file mode 100644 index 18186a8..0000000 --- a/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java +++ /dev/null @@ -1,97 +0,0 @@ -package me.Mammothskier.Giants.BarAPI; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Damageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Slime; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDeathEvent; - -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; -import me.confuser.barapi.BarAPI; - -public class HealthBar implements Listener { - private Giants _giants; - - public HealthBar(Giants giants) { - _giants = giants; - _giants.getServer().getPluginManager().registerEvents(this, giants); - } - - @EventHandler - public void changeHealthBar(EntityDamageByEntityEvent event) { - Entity entity = event.getEntity(); - Entity damager = event.getDamager(); - if (entity == null || damager == null) { - return; - } - if (API.isGiant(entity) || API.isGiantMagmaCube(entity) || API.isGiantSlime(entity)) { - if (damager instanceof Projectile) { - damager = ((Projectile) damager).getShooter(); - } - if (damager instanceof Player) { - Player player = (Player) damager; - setupBar(player, entity); - } - } - } - - @EventHandler - public void onDeath(EntityDeathEvent event) { - Entity entity = event.getEntity(); - if (API.isGiant(entity) || API.isGiantMagmaCube(entity) || API.isGiantSlime(entity)) { - Entity killer = event.getEntity().getKiller(); - if (killer instanceof Player) { - Player player = (Player) killer; - if(BarAPI.hasBar(player)) { - BarAPI.removeBar(player); - } - } - } - } - - public void setupBar(Player player, Entity entity) { - EntityType entityType = entity.getType(); - Double health = ((Damageable) entity).getHealth(); - Double maxHealth = ((Damageable) entity).getMaxHealth(); - float percent = (float) (health/maxHealth); - String size = null; - - switch (entityType) { - case GIANT: - String giantName = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.BarAPI.Display Name"); - giantName = ChatColor.translateAlternateColorCodes('&', giantName); - if (player.hasPermission("giants.barAPI") || player.hasPermission("giants.*") || player.isOp()) { - BarAPI.setMessage(player, giantName, percent * 100); - } - break; - case SLIME: - String slimeName = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.BarAPI.Display Name"); - slimeName = ChatColor.translateAlternateColorCodes('&', slimeName); - size = Integer.toString(((Slime) entity).getSize()); - if (player.hasPermission("giants.barAPI") || player.hasPermission("giants.*") || player.isOp()) { - BarAPI.setMessage(player, slimeName.replace("{size}", size), percent* 100); - } - break; - case MAGMA_CUBE: - String magmacubeName = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.BarAPI.Display Name"); - magmacubeName = ChatColor.translateAlternateColorCodes('&', magmacubeName); - size = Integer.toString(((MagmaCube) entity).getSize()); - if (player.hasPermission("giants.barAPI") || player.hasPermission("giants.*") || player.isOp()) { - BarAPI.setMessage(player, magmacubeName.replace("{size}", size), percent* 100); - } - break; - default: - break; - - } - } -} diff --git a/src/main/java/me/Mammothskier/Giants/Giants.java b/src/main/java/me/Mammothskier/Giants/Giants.java deleted file mode 100644 index c720aa8..0000000 --- a/src/main/java/me/Mammothskier/Giants/Giants.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.Mammothskier.Giants; - -import java.io.IOException; -import java.util.logging.Logger; - -import me.Mammothskier.Giants.BarAPI.HealthBar; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.java.JavaPlugin; -import org.mcstats.Metrics; - - -public class Giants extends JavaPlugin{ - - public final Logger log = Logger.getLogger("Minecraft"); - - /* - * CHANGE LOG: - * ====== - * V1.1 : - * Giants no longer spawn from spawn eggs - * changed spawn chance to a float so it can store decimals - * Removed Damage modifier - it causes a player to kill a Giant instantly - * ====== - * V1.2 : - * Fixed spelling error for Experience in config - * ====== - * V2.0 : - * ====== - * Biome Spawn settings - * ====== - * V2.1 : - * Update to CB 1.4.6-R0.1 - * Fixed Giants not targetting players if Fire Attack is set to False - * ====== - * V3.0 : - * Added more Biome Spawn options - * Added Giant Spawn Egg - * ====== - * V3.1 : - * Added 'Other' Biome option incase other plugins modify where mobs can spawn - * ====== - * V3.2 : - * Temporarily Disabled Spout Features due to servers getting errors if they did not have the SpoutPlugin - * ====== - * V3.3 : - * Added a check to see if the server has the SpoutPlugin before enabling Spout features - * ====== - * V3.4 : - * Fixed errors when a player interacts while the server does not have the SpoutPlugin - * ====== - * V4.0 : - * Update to craftbukkit-1.4.6-R0.3 and SpoutPlugin 1412 - * Added Kick Attack - * Added Lightning Attack - * \giants reload can now be used in console - * ====== - * V5.0 : - * Updated to Craftbukkit-1.4.7-R0.1 and SpoutPlugin 1.4.7-R0.2 - * Added "Throw Boulder Attack" - * Added "Stomp Attack" - * Added "Spawn Zombies Attack" - * Added Sounds to some of the Attack Mechanisms (the ones that don't have sounds) - * Added Config to set the height the player is kicked (for the Kick Attack) - * Cleaned code - * Organized the config.yml - * Added option to use Spout features - * ====== - * v6.0: - * Update to CB 1.7.2-R0.3 - * Added 1.7 biome support - * Fixed zombie attack - * removed spoutcraft support due to being unupdated - * Added /giants spawn command - * Organized config.yml - * ====== - * V6.1 : - * Added support for giant slimes and magmacubes - * Added attacks to slimes and magmacubes - * Fixed health issue - * Moved biome settings to another file - * Changed name of zombie attack - * Added damage settings - * Added /giants version command - * Added metrics support - * ====== - * v6.2 : - * Added health settings to giant's shrapnel and spawn zombies attack - * Fixed error on magmacube spawns - * Added error message to commands - * ====== - * v6.3 : - * Updated the drop system and format - * Added a poison attack to slimes - * added block settings for stomp attacks - * ====== - * V6.4 : - * Added support for lore and custom item names - * Added file version to each file - * Added Giant Jockey Entity - * Added support for BarAPI - * Fixed Slime's health bug - * ====== - */ - - @Override - public void onEnable(){ - new API(this); - PluginDescriptionFile pdf = this.getDescription(); - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + pdf.getName() + " Version " + pdf.getVersion() + " Has Been Enabled!"); - try { - Metrics metrics = new Metrics(this); - metrics.start(); - } catch (IOException e) { - // Failed to submit the stats :-( - } - - if ((API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Dependencies.BarAPI").equalsIgnoreCase("true")) && - (Bukkit.getPluginManager().getPlugin("BarAPI") != null)) { - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "Found BarAPI: Enabling BarAPI features."); - new HealthBar(this); - } else if (Bukkit.getPluginManager().getPlugin("BarAPI") != null) { - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "Found BarAPI: Config set to ignore BarAPI features. \n" + - "Disabling BarAPI features."); - } else { - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "Cannot Find BarAPI: Disabling BarAPI features."); - } - - if (API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GOLD + "You have Giant Jockeys Enabled! \n" + - "This entity of Giants is extremely experimental and does not have many features."); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java b/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java deleted file mode 100644 index 83416c6..0000000 --- a/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java +++ /dev/null @@ -1,333 +0,0 @@ -package me.Mammothskier.Giants.events; - -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -import org.bukkit.Location; -import org.bukkit.block.Biome; -import org.bukkit.entity.Entity; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class JockeySpawnEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; - - public JockeySpawnEvent (Entity entity, Entity passenger) { - Location location = entity.getLocation(); - - Biome biome = location.getWorld().getBiome(location.getBlockX(), location.getBlockZ()); - - if (!isCancelled()) { - if (biome == Biome.SWAMPLAND) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Swampland.Swampland").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SWAMPLAND_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Swampland.Swampland Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.FOREST) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Forest.Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Forest.Forest Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.TAIGA) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.COLD_TAIGA) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.COLD_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.COLD_TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MEGA_TAIGA) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MEGA_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.PLAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Plains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ICE_PLAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Ice Plains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ICE_PLAINS_SPIKES) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Ice Plains Spikes").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SUNFLOWER_PLAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Sunflower Plains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.OCEAN) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Ocean").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DEEP_OCEAN) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Deep Ocean").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.FROZEN_OCEAN) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Frozen Ocean").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.RIVER) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.River.River").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.FROZEN_RIVER) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.River.Frozen River").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BEACH) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Beach").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.STONE_BEACH) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Stone Beach").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.COLD_BEACH) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Cold Beach").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MUSHROOM_ISLAND) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Island").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MUSHROOM_SHORE) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Shore").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DESERT) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DESERT_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DESERT_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if ((biome == Biome.JUNGLE) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if ((biome == Biome.JUNGLE_HILLS) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if ((biome == Biome.JUNGLE_MOUNTAINS) || (biome == Biome.JUNGLE_EDGE) || (biome == Biome.JUNGLE_EDGE_MOUNTAINS)) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Plateau").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Plateau Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ROOFED_FOREST) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ROOFED_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_BRYCE) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Bryce").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SMALL_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Small Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ICE_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Ice Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.HELL) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Hell").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SKY) { - if (API.getFileHandler().getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Sky").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - } - } - - - public boolean isCancelled() { - return cancel; - } - - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/src/main/java/me/Mammothskier/Giants/events/SlimeSpawnEvent.java b/src/main/java/me/Mammothskier/Giants/events/SlimeSpawnEvent.java deleted file mode 100644 index d4459fd..0000000 --- a/src/main/java/me/Mammothskier/Giants/events/SlimeSpawnEvent.java +++ /dev/null @@ -1,534 +0,0 @@ -package me.Mammothskier.Giants.events; - -import org.bukkit.Location; -import org.bukkit.block.Biome; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Slime; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -public class SlimeSpawnEvent extends Event { - private static boolean cancelled = false; - private Entity entity; - private Location location; - private static final HandlerList handlers = new HandlerList(); - - public SlimeSpawnEvent(Location loc) { - location = loc; - Biome biome = loc.getWorld().getBiome(loc.getBlockX(), loc.getBlockZ()); - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Size"); - String string2 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Health"); - int size; - double health; - try { - size = Integer.parseInt(string); - health = Double.parseDouble(string2); - } catch (Exception e) { - size = 12; - health = size^2; - } - - if (!API.getSlimeSpawnWorlds().contains(loc.getWorld().getName())) { - setCancelled(true); - } - - if(!API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime").equalsIgnoreCase("true")){ - setCancelled(true); - } - - if (!isCancelled()) { - if (biome == Biome.SWAMPLAND) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Swampland.Swampland").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SWAMPLAND_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Swampland.Swampland Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FOREST) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Forest.Forest").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Forest.Forest Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Taiga").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Taiga Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Taiga Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Cold Taiga").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Cold Taiga Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_TAIGA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Cold Taiga Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_TAIGA) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Mega Taiga").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Mega Taiga Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Mega Spruce Taiga").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MEGA_SPRUCE_TAIGA_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.PLAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Plains.Plains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_PLAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Plains.Ice Plains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_PLAINS_SPIKES) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Plains.Ice Plains Spikes").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SUNFLOWER_PLAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Plains.Sunflower Plains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.OCEAN) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Ocean.Ocean").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DEEP_OCEAN) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Ocean.Deep Ocean").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FROZEN_OCEAN) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Ocean.Frozen Ocean").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.RIVER) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.River.River").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.FROZEN_RIVER) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.River.Frozen River").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BEACH) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Beach.Beach").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.STONE_BEACH) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Beach.Stone Beach").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.COLD_BEACH) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Beach.Cold Beach").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MUSHROOM_ISLAND) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mushroom Island.Mushroom Island").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MUSHROOM_SHORE) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mushroom Island.Mushroom Shore").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Desert.Desert").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Desert.Desert Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.DESERT_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Desert.Desert Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Jungle.Jungle").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE_HILLS) || (biome == Biome.JUNGLE_EDGE)) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Jungle.Jungle Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if ((biome == Biome.JUNGLE_MOUNTAINS) || (biome == Biome.JUNGLE_EDGE) || (biome == Biome.JUNGLE_EDGE_MOUNTAINS)) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Jungle.Jungle Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Birch Forest.Birch Forest").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Birch Forest.Birch Forest Hills").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Birch Forest.Birch Forest Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Savanna.Savanna").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Savanna.Savanna Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Savanna.Savanna Plateau").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SAVANNA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Savanna.Savanna Plateau Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ROOFED_FOREST) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Roofed Forest.Roofed Forest").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ROOFED_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mesa.Mesa").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_BRYCE) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mesa.Mesa Bryce").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mesa.Mesa Plateau").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mesa.Mesa Plateau Forest").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mesa.Mesa Plateau Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SMALL_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Other.Small Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.ICE_MOUNTAINS) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Other.Ice Mountains").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.HELL) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Other.Hell").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - if (biome == Biome.SKY) { - if (API.getFileHandler().getProperty(Files.SLIMEBIOMES, "Slime Configuration.Biome Settings.Other.Sky").equalsIgnoreCase("true")) { - Slime entity = (Slime) loc.getWorld().spawnEntity(location, EntityType.SLIME); - entity.setSize(size); - entity.setMaxHealth(health); - entity.setHealth(health); - } - } - } - } - - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - - public static boolean isCancelled() { - return cancelled; - } - - public Entity getEntity() { - return entity; - } - - public Location getLocation() { - return location; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/files/FileHandler.java b/src/main/java/me/Mammothskier/Giants/files/FileHandler.java deleted file mode 100644 index 716106e..0000000 --- a/src/main/java/me/Mammothskier/Giants/files/FileHandler.java +++ /dev/null @@ -1,548 +0,0 @@ -package me.Mammothskier.Giants.files; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.PluginDescriptionFile; - -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.Giants; - -public class FileHandler { - private final Giants _giants; - private final HashMap _configurations; - - public FileHandler(Giants giants) { - _giants = giants; - _configurations = new HashMap(); - loadWorlds(); - loadFiles(); - loadVersion(); - loadDefaultDrop("Giant"); - loadDefaultDrop("Slime"); - loadDefaultDrop("MagmaCube"); - } - - private String loadVersion() { - PluginDescriptionFile pdf = _giants.getDescription(); - String version = pdf.getVersion(); - if (version == null) { - return null; - } - return version; - } - - public List loadWorlds() { - List worldList = new ArrayList(); - for (World w : _giants.getServer().getWorlds()) { - worldList.add(w.getName()); - } - return worldList; - } - - private boolean checkDependencies(String plugin) { - if (Bukkit.getPluginManager().getPlugin(plugin) != null) { - return true; - } - return false; - } - - private String[] loadDefaultDrop(String arg) { - String[] drops = null; - switch(arg){ - case "Giant": - drops = new String[]{ "1-0-0;1;100/100;GIANT STONE;Dropped by a Giant" }; - break; - case "Slime": - drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Slime" }; - break; - case "MagmaCube": - drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Magma Cube" }; - break; - default: - break; - } - return drops; - } - - public void loadFiles() { - for (Files file : Files.values()) { - File confFile = new File(file.getPath()); - - if (confFile.exists()) { - if (_configurations.containsKey(file)) { - _configurations.remove(file); - } - YamlConfiguration conf = YamlConfiguration.loadConfiguration(confFile); - _configurations.put(file, conf); - } else { - File parentFile = confFile.getParentFile(); - - if (!parentFile.exists()) { - parentFile.mkdirs(); - } - this.createFiles(file, confFile); - } - } - } - - private void createFiles(Files files, File file) { - switch (files) { - case CONFIG: - YamlConfiguration Config = YamlConfiguration.loadConfiguration(file); - Config.set("Giants Configuration.File Version", loadVersion()); - Config.set("Giants Configuration.Dependencies.BarAPI", checkDependencies("BarAPI")); - Config.set("Giants Configuration.Entities.Giant", true); - Config.set("Giants Configuration.Entities.Giant Slime", false); - Config.set("Giants Configuration.Entities.Giant Magma Cube", false); - Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Bugs", new String("This entity of Giants is extremely experimental and does not have many features. Bugs may be present.")); - Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Files", new String("Config files for this entity will NOT load unless enabled.")); - Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Enabled", false); - Config.set("Giants Configuration.Debug Mode.Enabled", false); - Config.set("Giants Configuration.Debug Mode.Debug Message", "&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z"); - try { - Config.save(file); - } catch (IOException e) { - } - _configurations.put(files, Config); - break; - case GIANT: - YamlConfiguration Giant = YamlConfiguration.loadConfiguration(file); - Giant.set("Giant Configuration.File Version", loadVersion()); - Giant.set("Giant Configuration.Spawn Settings.Chance", new Integer(10)); - Giant.set("Giant Configuration.Spawn Settings.Worlds", loadWorlds()); - Giant.set("Giant Configuration.Giant Stats.Health", new Integer(100)); - Giant.set("Giant Configuration.Giant Stats.Experience", new Integer(5)); - Giant.set("Giant Configuration.Giant Stats.Drops", Arrays.asList(loadDefaultDrop("Giant"))); - Giant.set("Giant Configuration.Giant Stats.BarAPI.Display Name", "&2Giant"); - Giant.set("Giant Configuration.Damage Settings.Arrows.Damage done by arrow", new Integer(10)); - Giant.set("Giant Configuration.Damage Settings.Fire.Allow Fire Damage", true); - Giant.set("Giant Configuration.Damage Settings.Block Damage.Allow Suffocation", false); - Giant.set("Giant Configuration.Damage Settings.Block Damage.Allow Cacti Damage", false); - Giant.set("Giant Configuration.Attack Mechanisms.Lightning Attack", false); - Giant.set("Giant Configuration.Attack Mechanisms.Stomp Attack.Enabled", false); - Giant.set("Giant Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)); - Giant.set("Giant Configuration.Attack Mechanisms.Stomp Attack.Light Fire", false); - Giant.set("Giant Configuration.Attack Mechanisms.Kick Attack.Enabled", false); - Giant.set("Giant Configuration.Attack Mechanisms.Kick Attack.Kick Height", new Integer(1)); - Giant.set("Giant Configuration.Attack Mechanisms.Fire Attack.Enabled", false); - Giant.set("Giant Configuration.Attack Mechanisms.Fire Attack.Ticks for Target", new Integer(100)); - Giant.set("Giant Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant", new Integer(100)); - Giant.set("Giant Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", false); - Giant.set("Giant Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage", new Integer(1)); - Giant.set("Giant Configuration.Attack Mechanisms.Shrapnel Attack.Enabled", false); - Giant.set("Giant Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies", false); - Giant.set("Giant Configuration.Attack Mechanisms.Shrapnel Attack.Zombies to Spawn", new Integer(3)); - Giant.set("Giant Configuration.Attack Mechanisms.Shrapnel Attack.Health", new Integer(20)); - Giant.set("Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled", false); - Giant.set("Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies", false); - Giant.set("Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn", new Integer(5)); - Giant.set("Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20)); - Giant.set("Giant Configuration.Sounds.Stomp Attack", true); - Giant.set("Giant Configuration.Sounds.Fire Attack", true); - Giant.set("Giant Configuration.Sounds.Throw Boulder Attack", true); - Giant.set("Giant Configuration.Sounds.Kick Attack", true); - Giant.set("Giant Configuration.Sounds.Shrapnel Attack", true); - Giant.set("Giant Configuration.Sounds.Death", true); - try { - Giant.save(file); - } catch (IOException e) { - } - _configurations.put(files, Giant); - break; - case GIANTBIOMES: - YamlConfiguration GiantBiomes = YamlConfiguration.loadConfiguration(file); - GiantBiomes.set("Giant Configuration.File Version", loadVersion()); - GiantBiomes.set("Giant Configuration.Biome Settings.Swampland.Swampland", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Swampland.Swampland Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Forest.Forest", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Forest.Forest Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Taiga", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Taiga Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Taiga Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Cold Taiga", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Cold Taiga Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Cold Taiga Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Mega Taiga", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Mega Taiga Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Mega Spruce Taiga", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Plains.Plains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Plains.Ice Plains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Plains.Ice Plains Spikes", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Plains.Sunflower Plains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Ocean.Ocean", false); - GiantBiomes.set("Giant Configuration.Biome Settings.Ocean.Deep Ocean", false); - GiantBiomes.set("Giant Configuration.Biome Settings.Ocean.Frozen Ocean", true); - GiantBiomes.set("Giant Configuration.Biome Settings.River.River", true); - GiantBiomes.set("Giant Configuration.Biome Settings.River.Frozen River", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Beach.Beach", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Beach.Stone Beach", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Beach.Cold Beach", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mushroom Island.Mushroom Island", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mushroom Island.Mushroom Shore", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Desert.Desert", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Desert.Desert Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Desert.Desert Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Jungle.Jungle", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Jungle.Jungle Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Jungle.Jungle Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Birch Forest.Birch Forest", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Birch Forest.Birch Forest Hills", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Birch Forest.Birch Forest Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Savanna.Savanna", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Savanna.Savanna Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Savanna.Savanna Plateau", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Savanna.Savanna Plateau Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Roofed Forest.Roofed Forest", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mesa.Mesa", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mesa.Mesa Bryce", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mesa.Mesa Plateau", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mesa.Mesa Plateau Forest", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mesa.Mesa Plateau Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Other.Small Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Other.Ice Mountains", true); - GiantBiomes.set("Giant Configuration.Biome Settings.Other.Hell", false); - GiantBiomes.set("Giant Configuration.Biome Settings.Other.Sky", false); - try { - GiantBiomes.save(file); - } catch (IOException e) { - } - _configurations.put(files, GiantBiomes); - break; - case SLIME: - YamlConfiguration Slime = YamlConfiguration.loadConfiguration(file); - Slime.set("Slime Configuration.File Version", loadVersion()); - Slime.set("Slime Configuration.Spawn Settings.Chance", new Integer(10)); - Slime.set("Slime Configuration.Spawn Settings.Worlds", loadWorlds()); - Slime.set("Slime Configuration.Spawn Settings.Worlds", loadWorlds()); - Slime.set("Slime Configuration.Slime Stats.Size", new Integer(12)); - Slime.set("Slime Configuration.Slime Stats.Health", new Integer(100)); - Slime.set("Slime Configuration.Slime Stats.Experience", new Integer(5)); - Slime.set("Slime Configuration.Slime Stats.Drops", Arrays.asList(loadDefaultDrop("Slime"))); - Slime.set("Slime Configuration.Slime Stats.BarAPI.Display Name", "&2Giant Slime Size {size}"); - Slime.set("Slime Configuration.Damage Settings.Arrows.Damage done by arrow", new Integer(10)); - Slime.set("Slime Configuration.Damage Settings.Fire.Allow Fire Damage", true); - Slime.set("Slime Configuration.Damage Settings.Block Damage.Allow Suffocation",false); - Slime.set("Slime Configuration.Damage Settings.Block Damage.Allow Cacti Damage", false); - Slime.set("Slime Configuration.Attack Mechanisms.Lightning Attack", false); - Slime.set("Slime Configuration.Attack Mechanisms.Stomp Attack.Enabled", false); - Slime.set("Slime Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)); - Slime.set("Slime Configuration.Attack Mechanisms.Stomp Attack.Light Fire", false); - Slime.set("Slime Configuration.Attack Mechanisms.Kick Attack.Enabled", false); - Slime.set("Slime Configuration.Attack Mechanisms.Kick Attack.Kick Height", new Integer(1)); - Slime.set("Slime Configuration.Attack Mechanisms.Fire Attack.Enabled", false); - Slime.set("Slime Configuration.Attack Mechanisms.Fire Attack.Ticks for Target", new Integer(100)); - Slime.set("Slime Configuration.Attack Mechanisms.Fire Attack.Ticks for Slime", new Integer(100)); - Slime.set("Slime Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", false); - Slime.set("Slime Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage", new Integer(1)); - Slime.set("Slime Configuration.Attack Mechanisms.Poison Attack.Enabled", true); - Slime.set("Slime Configuration.Attack Mechanisms.Poison Attack.length", new Integer(5)); - Slime.set("Slime Configuration.Sounds.Stomp Attack", true); - Slime.set("Slime Configuration.Sounds.Fire Attack", true); - Slime.set("Slime Configuration.Sounds.Throw Boulder Attack", true); - Slime.set("Slime Configuration.Sounds.Kick Attack", true); - Slime.set("Slime Configuration.Sounds.Death", true); - try { - Slime.save(file); - } catch (IOException e) { - } - _configurations.put(files, Slime); - break; - case SLIMEBIOMES: - YamlConfiguration SlimeBiomes = YamlConfiguration.loadConfiguration(file); - SlimeBiomes.set("Slime Configuration.File Version", loadVersion()); - SlimeBiomes.set("Slime Configuration.Biome Settings.Swampland.Swampland", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Swampland.Swampland Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Forest.Forest", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Forest.Forest Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Taiga", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Taiga Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Taiga Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Cold Taiga", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Cold Taiga Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Cold Taiga Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Mega Taiga", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Mega Taiga Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Mega Spruce Taiga", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Plains.Plains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Plains.Ice Plains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Plains.Ice Plains Spikes", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Plains.Sunflower Plains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Ocean.Ocean", false); - SlimeBiomes.set("Slime Configuration.Biome Settings.Ocean.Deep Ocean", false); - SlimeBiomes.set("Slime Configuration.Biome Settings.Ocean.Frozen Ocean", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.River.River", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.River.Frozen River", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Beach.Beach", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Beach.Stone Beach", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Beach.Cold Beach", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mushroom Island.Mushroom Island", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mushroom Island.Mushroom Shore", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Desert.Desert", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Desert.Desert Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Desert.Desert Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Jungle.Jungle", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Jungle.Jungle Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Jungle.Jungle Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Birch Forest.Birch Forest", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Birch Forest.Birch Forest Hills", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Birch Forest.Birch Forest Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Savanna.Savanna", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Savanna.Savanna Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Savanna.Savanna Plateau", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Savanna.Savanna Plateau Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Roofed Forest.Roofed Forest", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mesa.Mesa", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mesa.Mesa Bryce", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mesa.Mesa Plateau", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mesa.Mesa Plateau Forest", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mesa.Mesa Plateau Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Other.Small Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Other.Ice Mountains", true); - SlimeBiomes.set("Slime Configuration.Biome Settings.Other.Hell", false); - SlimeBiomes.set("Slime Configuration.Biome Settings.Other.Sky", false); - try { - SlimeBiomes.save(file); - } catch (IOException e) { - } - _configurations.put(files, SlimeBiomes); - break; - case MAGMACUBE: - YamlConfiguration MagmaCube = YamlConfiguration.loadConfiguration(file); - MagmaCube.set("Magma Cube Configuration.File Version", loadVersion()); - MagmaCube.set("Magma Cube Configuration.Spawn Settings.Chance", new Integer(10)); - MagmaCube.set("Magma Cube Configuration.Spawn Settings.Worlds", loadWorlds()); - MagmaCube.set("Magma Cube Configuration.Magma Cube Stats.Size", new Integer(12)); - MagmaCube.set("Magma Cube Configuration.Magma Cube Stats.Health", new Integer(100)); - MagmaCube.set("Magma Cube Configuration.Magma Cube Stats.Experience", new Integer(5)); - MagmaCube.set("Magma Cube Configuration.Magma Cube Stats.Drops", Arrays.asList(loadDefaultDrop("MagmaCube"))); - MagmaCube.set("Magma Cube Configuration.Magma Cube Stats.BarAPI.Display Name", "&2Giant Magma Cube Size {size}"); - MagmaCube.set("Magma Cube Configuration.Damage Settings.Arrows.Damage done by arrow", true); - MagmaCube.set("Magma Cube Configuration.Damage Settings.Block Damage.Allow Suffocation", false); - MagmaCube.set("Magma Cube Configuration.Damage Settings.Block Damage.Allow Cacti Damage", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Lightning Attack", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Stomp Attack.Enabled", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Stomp Attack.Light Fire", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Lava Attack", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Kick Attack.Enabled", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Kick Attack.Kick Height", new Integer(1)); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Fire Attack.Enabled", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Fire Attack.Ticks for Target", new Integer(100)); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Fire Attack.Ticks for Magma Cube", new Integer(100)); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", false); - MagmaCube.set("Magma Cube Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage", new Integer(1)); - MagmaCube.set("Magma Cube Configuration.Sounds.Fire Attack", true); - MagmaCube.set("Magma Cube Configuration.Sounds.Throw Boulder Attack", true); - MagmaCube.set("Magma Cube Configuration.Sounds.Kick Attack", true); - MagmaCube.set("Magma Cube Configuration.Sounds.Lava Attack", true); - MagmaCube.set("Magma Cube Configuration.Sounds.Death", true); - try { - MagmaCube.save(file); - } catch (IOException e) { - } - _configurations.put(files, MagmaCube); - break; - case MAGMACUBEBIOMES: - YamlConfiguration MagmaCubeBiomes = YamlConfiguration.loadConfiguration(file); - MagmaCubeBiomes.set("Magma Cube Configuration.File Version", loadVersion()); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Swampland.Swampland", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Swampland.Swampland Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Forest.Forest", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Forest.Forest Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Taiga", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Taiga Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Taiga Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Cold Taiga", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Cold Taiga Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Cold Taiga Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Mega Taiga", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Mega Taiga Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Mega Spruce Taiga", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Plains.Plains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Plains.Ice Plains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Plains.Ice Plains Spikes", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Plains.Sunflower Plains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Ocean.Ocean", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Ocean.Deep Ocean", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Ocean.Frozen Ocean", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.River.River", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.River.Frozen River", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Beach.Beach", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Beach.Stone Beach", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Beach.Cold Beach", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mushroom Island.Mushroom Island", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mushroom Island.Mushroom Shore", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Desert.Desert", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Desert.Desert Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Desert.Desert Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Jungle.Jungle", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Jungle.Jungle Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Jungle.Jungle Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest Hills", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Savanna.Savanna", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Savanna.Savanna Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Savanna.Savanna Plateau", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Savanna.Savanna Plateau Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Roofed Forest.Roofed Forest", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mesa.Mesa", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mesa.Mesa Bryce", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau Forest", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Other.Small Mountains", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Other.Ice Mountains", true); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Other.Hell", false); - MagmaCubeBiomes.set("Magma Cube Configuration.Biome Settings.Other.Sky", false); - try { - MagmaCubeBiomes.save(file); - } catch (IOException e) { - } - _configurations.put(files, MagmaCubeBiomes); - break; - case JOCKEY: - if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { - YamlConfiguration Jockey = YamlConfiguration.loadConfiguration(file); - Jockey.set("Jockey Configuration.File Version", loadVersion()); - Jockey.set("Jockey Configuration", new String("This entity of Giants is extremely experimental and does not have many features")); - Jockey.set("Jockey Configuration.Spawn Settings.Worlds", loadWorlds()); - try { - Jockey.save(file); - } catch (IOException e) { - } - _configurations.put(files, Jockey); - } - break; - case JOCKEYBIOMES: - if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { - YamlConfiguration JockeyBiomes = YamlConfiguration.loadConfiguration(file); - JockeyBiomes.set("Jockey Configuration.File Version", loadVersion()); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Swampland.Swampland", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Swampland.Swampland Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Forest.Forest", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Forest.Forest Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Taiga", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Taiga Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Taiga Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Cold Taiga", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Cold Taiga Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Cold Taiga Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Mega Taiga", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Mega Taiga Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Plains.Plains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Plains.Ice Plains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Plains.Ice Plains Spikes", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Plains.Sunflower Plains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Ocean.Ocean", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Ocean.Deep Ocean", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Ocean.Frozen Ocean", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.River.River", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.River.Frozen River", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Beach.Beach", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Beach.Stone Beach", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Beach.Cold Beach", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Island", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Shore", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Desert.Desert", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Desert.Desert Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Desert.Desert Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Jungle.Jungle", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Jungle.Jungle Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Jungle.Jungle Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Birch Forest.Birch Forest", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Savanna.Savanna", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Savanna.Savanna Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Savanna.Savanna Plateau", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Savanna.Savanna Plateau Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mesa.Mesa", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mesa.Mesa Bryce", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mesa.Mesa Plateau", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Other.Small Mountains", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Other.Ice Mountains", true); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Other.Hell", false); - JockeyBiomes.set("Jockey Configuration.Biome Settings.Other.Sky", false); - try { - JockeyBiomes.save(file); - } catch (IOException e) { - } - _configurations.put(files, JockeyBiomes); - } - break; - default: - break; - } - } - - public String getProperty(Files file, String path) { - FileConfiguration conf = _configurations.get(file); - - if (conf != null) { - String prop = conf.getString(path, "NULL"); - - if (!prop.equalsIgnoreCase("NULL")) - return prop; - conf.set(path, null); - } - return null; - } - - public List getPropertyList(Files file, String path) { - FileConfiguration conf = _configurations.get(file); - - if (conf != null) { - List prop = conf.getStringList(path); - if (!prop.contains("NULL")) - return prop; - conf.set(path, null); - } - return null; - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/files/Files.java b/src/main/java/me/Mammothskier/Giants/files/Files.java deleted file mode 100644 index 8cc665f..0000000 --- a/src/main/java/me/Mammothskier/Giants/files/Files.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.Mammothskier.Giants.files; - -public enum Files { - CONFIG("plugins/Giants/config.yml"), - GIANT("plugins/Giants/Giant/giant.yml"), GIANTBIOMES("plugins/Giants/Giant/biomes.yml"), - MAGMACUBE("plugins/Giants/Magma Cube/magmacube.yml"), MAGMACUBEBIOMES("plugins/Giants/Magma Cube/biomes.yml"), - SLIME("plugins/Giants/Slime/slime.yml"), SLIMEBIOMES("plugins/Giants/Slime/biomes.yml"), - JOCKEY("plugins/Giants/Jockey/jockey.yml"), JOCKEYBIOMES("plugins/Giants/Jockey/biomes.yml"); - - private final String _path; - - private Files(final String path) { - _path = path; - } - - public String getPath() { - return _path; - } - -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/listeners/GiantListeners.java b/src/main/java/me/Mammothskier/Giants/listeners/GiantListeners.java deleted file mode 100644 index 8d7de24..0000000 --- a/src/main/java/me/Mammothskier/Giants/listeners/GiantListeners.java +++ /dev/null @@ -1,452 +0,0 @@ -package me.Mammothskier.Giants.listeners; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.io.*; - -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.events.GiantSpawnEvent; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentWrapper; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Damageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -public class GiantListeners implements Listener { - private Giants _giants; - - public GiantListeners(Giants giants) { - _giants = giants; - _giants.getServer().getPluginManager().registerEvents(this, giants); - } - - @EventHandler - public void onGiantSpawn(GiantSpawnEvent event) { - if (API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Enabled").equalsIgnoreCase("true")) { - String message = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Debug Message"); - if (message != null) { - for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (player.hasPermission("giants.debug") || player.hasPermission("giants.*") || player.isOp()) { - message = ChatColor.translateAlternateColorCodes('&', message); - String x = String.valueOf(Math.round(event.getLocation().getX())); - String y = String.valueOf(Math.round(event.getLocation().getY())); - String z = String.valueOf(Math.round(event.getLocation().getZ())); - player.sendMessage(message.replace("%X", x).replace("%Y", y).replace("%Z", z).replace("{entity}", "Giant")); - Bukkit.getConsoleSender().sendMessage(message.replace("%X", x).replace("%Y", y).replace("%Z", z).replace("{entity}", "Giant")); - } - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void GiantsSpawnEvent(CreatureSpawnEvent event) { - Entity entity = event.getEntity(); - EntityType type = event.getEntityType(); - SpawnReason spawnReason = event.getSpawnReason(); - if(event.isCancelled()){ - return; - } - - if (!API.getGiantSpawnWorlds().contains(entity.getWorld().getName())) { - return; - } - - if ((spawnReason == SpawnReason.NATURAL)) { - if ((type == EntityType.ZOMBIE) || (type == EntityType.COW) || (type == EntityType.MUSHROOM_COW) || (type == EntityType.PIG_ZOMBIE) || (type == EntityType.ENDERMAN)) { - String string = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Spawn Settings.Chance"); - float sRate; - try { - sRate = Float.parseFloat(string); - } catch (NumberFormatException e) { - sRate = 10; - } - float chance = 100 - sRate; - - Random rand = new Random(); - double choice = rand.nextInt(100) < chance ? 1 : 0; - if (choice == 0) { - Location location = event.getEntity().getLocation(); - double x = location.getX(); - double y = location.getY(); - double z = location.getZ(); - - int x2 = (int) x; - int y2 = (int) y; - int z2 = (int) z; - - int spawngiant = 1; - double checkcount = 0.01; - while (checkcount < 10) { - y2 += checkcount; - - if (entity.getWorld().getBlockTypeIdAt(x2, y2, z2) != 0) { - spawngiant = 0; - } - checkcount++; - } - if (spawngiant == 1) { - GiantSpawnEvent GSE = new GiantSpawnEvent(location); - Bukkit.getServer().getPluginManager().callEvent(GSE); - } - } - } - } - } - - @EventHandler - public void arrowDamage(EntityDamageByEntityEvent event){ - Entity entity = event.getEntity(); - if((event.getDamager() instanceof Arrow) && (API.isGiant(entity))){ - int damage; - String string = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Damage Settings.Arrows.Damage done by arrow"); - try { - damage = Integer.parseInt(string); - } catch (Exception e) { - damage = 10; - } - if(damage == 0){ - event.setCancelled(true); - return; - } - event.setDamage(damage + 0.0); - } - } - - @EventHandler - public void fireDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - if (API.isGiant(entity)){ - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Damage Settings.Fire.Allow Fire Damage").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK){ - event.setCancelled(true); - } - } - } - } - - @EventHandler - public void suffocationDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - if (API.isGiant(entity)){ - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Damage Settings.Block Damage.Allow Suffocation").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FALLING_BLOCK){ - event.setCancelled(true); - } - } - } - } - - @EventHandler - public void cactiDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - if (API.isGiant(entity)){ - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Damage Settings.Block Damage.Allow Cacti Damage").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.THORNS){ - event.setCancelled(true); - } - } - } - } - - @EventHandler - public void onFireAttack(EntityTargetEvent event) { - String ticks1 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); - String ticks2 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant"); - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int ticksTarget; - int ticksGiant; - try { - ticksTarget = Integer.parseInt(ticks1); - ticksGiant = Integer.parseInt(ticks2); - } catch (Exception e) { - ticksTarget = 0; - ticksGiant = 0; - } - - if ((entity instanceof LivingEntity)) { - if (API.isGiant(entity)) { - if(!(target == null)){ - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Fire Attack.Enabled").equalsIgnoreCase("true")) { - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Sounds.Fire Attack").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); - } - try { - event.getTarget().setFireTicks(ticksTarget); - event.getEntity().setFireTicks(ticksGiant); - } catch (Exception e) { - } - } else { - event.setTarget(target); - } - } - } - } - } - - @EventHandler - public void onLightningAttack(EntityTargetEvent event) { - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - - if ((entity instanceof LivingEntity)) { - if (API.isGiant(entity)) { - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Lightning Attack").equalsIgnoreCase("true")) { - try { - target.getLocation().getWorld().strikeLightning(target.getLocation()); - } catch (Exception e) { - } - } else { - event.setTarget(target); - } - } - } - } - - @EventHandler - public void onShrapnelAttack(EntityTargetEvent event) { - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int Amt; - double Health; - if ((entity instanceof LivingEntity)) { - if (API.isGiant(entity)) { - Location spawnLocation = entity.getLocation(); - Location loc = spawnLocation; - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Shrapnel Attack.Enabled").equalsIgnoreCase("true")) { - String config = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Shrapnel Attack.Zombies to Spawn"); - String config2 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Shrapnel Attack.Health"); - try { - Amt = Integer.parseInt(config); - Health = Double.parseDouble(config2); - } catch (Exception e) { - Amt = 3; - Health = 20; - } - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Sounds.Shrapnel Attack").equalsIgnoreCase("true")){ - if (target instanceof LivingEntity){ - target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); - } - } - for (int i = 1; i <= Amt; i++){ - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies").equalsIgnoreCase("true")) { - Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); - ((Zombie) e).setBaby(true); - ((Damageable) e).setMaxHealth(Health); - ((Damageable) e).setHealth(Health); - } - else{ - Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); - ((Damageable) e).setMaxHealth(Health); - ((Damageable) e).setHealth(Health); - } - } - } - } - } - } - - @EventHandler - public void onThrownBoulderAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - boolean inRange = false; - Random pick = new Random(); - int chance = 0; - int bDamage; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - - for (Entity entity : player.getNearbyEntities(15, 12, 15)) { - if (API.isGiant(entity)) { - if (entity.getNearbyEntities(15, 12, 15).contains(player) && !entity.getNearbyEntities(5, 3, 5).contains(player)) { - inRange = true; - } - if (inRange == true) { - if (chance == 50) { - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").equalsIgnoreCase("true")) { - String config = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); - try { - bDamage = Integer.parseInt(config); - } catch (Exception e) { - bDamage = 1; - } - Vector direction = ((LivingEntity) entity).getEyeLocation().getDirection().multiply(2); - Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); - fireball.setShooter((LivingEntity) entity); - fireball.setYield(bDamage); - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Sounds.Throw Boulder Attack").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); - } - } - } - } - } - } - } - - @EventHandler - public void onKickAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Kick Attack.Enabled").equalsIgnoreCase("true")) { - String config = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Kick Attack.Kick Height"); - double height; - - try { - height = Double.parseDouble(config); - } catch (Exception e) { - height = 1; - } - - Random pick = new Random(); - int chance = 0; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(5, 5, 5)) { - if (API.isGiant(entity)) { - if (entity.getNearbyEntities(5, 5, 5).contains(player)) { - player.setVelocity(new Vector(0, height, 0)); - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Sounds.Kick Attack").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); - } - } - } - } - } - } - } - - @EventHandler - public void onStompAttack(PlayerMoveEvent event) { - boolean sound = false; - boolean fire = false; - float power = 1.0f; - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Stomp Attack.Enabled").equalsIgnoreCase("true")) { - Random pick = new Random(); - int chance = 0; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(3, 2, 3)) { - if (API.isGiant(entity)) { - if (entity.getNearbyEntities(3, 2, 3).contains(player)) { - String config = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); - if (API.getFileHandler().getProperty(Files.GIANT, - "Giant Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { - fire = true; - } - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Sounds.Stomp Attack").equalsIgnoreCase("true")) { - sound = true; - } - - try { - power = Float.parseFloat(config); - } catch (Exception e) { - power = 0.0f; - } - API.createAttack().stompAttack(player.getLocation(), power, fire, sound); - } - } - } - } - } - } - - @EventHandler - public void zombiesOnDeath(EntityDeathEvent event) { - Entity entity = event.getEntity(); - if (API.isGiant(entity)) { - if(API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled").equalsIgnoreCase("true")){ - Location spawnLocation = entity.getLocation(); - Location loc = spawnLocation; - String config = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn"); - String config2 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Health"); - int zombAmt; - double zombHealth; - - try { - zombAmt = Integer.parseInt(config); - zombHealth = Double.parseDouble(config2); - }catch (Exception e) { - zombAmt = 1; - zombHealth = 20; - } - for (int i = 1; i <= zombAmt; i++){ - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies").equalsIgnoreCase("true")) { - Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); - ((Zombie) e).setBaby(true); - ((Damageable) e).setMaxHealth(zombHealth); - ((Damageable) e).setHealth(zombHealth); - } - else{ - Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); - ((Damageable) e).setMaxHealth(zombHealth); - ((Damageable) e).setHealth(zombHealth); - } - } - - } - } - } - - @EventHandler - public void onGiantDrops(EntityDeathEvent event) throws IOException{ - Entity entity = event.getEntity(); - String string = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.Experience"); - int exp; - - try { - exp = Integer.parseInt(string); - } catch (Exception e) { - exp = 5; - } - - if (API.isGiant(entity)) { - if (API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Sounds.Death").equalsIgnoreCase("true")) { - entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); - } - event.setDroppedExp(exp); - List newDrop = API.getFileHandler().getPropertyList(Files.GIANT, "Giant Configuration.Giant Stats.Drops"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { - return; - } - - List drops = new ArrayList(); - drops = API.createDrop().setDrop(entity, newDrop); - - event.getDrops().addAll(drops); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/listeners/JockeyListeners.java b/src/main/java/me/Mammothskier/Giants/listeners/JockeyListeners.java deleted file mode 100644 index e41b877..0000000 --- a/src/main/java/me/Mammothskier/Giants/listeners/JockeyListeners.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.Mammothskier.Giants.listeners; - -import me.Mammothskier.Giants.Giants; -import org.bukkit.event.Listener; - -public class JockeyListeners implements Listener { - private Giants _jockeys; - - - public JockeyListeners(Giants jockey) { - _jockeys = jockey; - _jockeys.getServer().getPluginManager().registerEvents(this, jockey); - } -} diff --git a/src/main/java/me/Mammothskier/Giants/listeners/MagmaCubeListeners.java b/src/main/java/me/Mammothskier/Giants/listeners/MagmaCubeListeners.java deleted file mode 100644 index c0679c4..0000000 --- a/src/main/java/me/Mammothskier/Giants/listeners/MagmaCubeListeners.java +++ /dev/null @@ -1,437 +0,0 @@ -package me.Mammothskier.Giants.listeners; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.events.MagmaCubeSpawnEvent; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentWrapper; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Damageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -public class MagmaCubeListeners implements Listener { - private Giants _magmacubes; - - public MagmaCubeListeners(Giants magmacubes) { - _magmacubes = magmacubes; - _magmacubes.getServer().getPluginManager().registerEvents(this, magmacubes); - } - - @EventHandler - public void onMagmaCubeSpawn(MagmaCubeSpawnEvent event) { - if (API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Enabled").equalsIgnoreCase("true")) { - String message = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Debug Message"); - if (message != null) { - for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (player.hasPermission("giants.debug") || player.hasPermission("giants.*") || player.isOp()) { - message = ChatColor.translateAlternateColorCodes('&', message); - String x = String.valueOf(Math.round(event.getLocation().getX())); - String y = String.valueOf(Math.round(event.getLocation().getY())); - String z = String.valueOf(Math.round(event.getLocation().getZ())); - player.sendMessage(message.replace("%X", x).replace("%Y", y).replace("%Z", z).replace("{entity}", "Giant Magma Cube")); - Bukkit.getConsoleSender().sendMessage(message.replace("%X", x).replace("%Y", y).replace("%Z", z).replace("{entity}", "Giant Magma Cube")); - } - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void MagmaCubeSpawnEvent(CreatureSpawnEvent event) { - Entity entity = event.getEntity(); - EntityType type = event.getEntityType(); - SpawnReason spawnReason = event.getSpawnReason(); - if(event.isCancelled()){ - return; - } - - if (!API.getMagmaCubeSpawnWorlds().contains(entity.getWorld().getName())) { - return; - } - if ((spawnReason == SpawnReason.NATURAL)) { - if ((type == EntityType.ZOMBIE) || (type == EntityType.COW) || (type == EntityType.MUSHROOM_COW) || (type == EntityType.PIG_ZOMBIE) || (type == EntityType.ENDERMAN) || (type == EntityType.MAGMA_CUBE)) { - String string = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Spawn Settings.Chance"); - float sRate; - try { - sRate = Float.parseFloat(string); - } catch (NumberFormatException e) { - sRate = 0; - } - float chance = 100 - sRate; - - Random rand = new Random(); - double choice = rand.nextInt(100) < chance ? 1 : 0; - if (choice == 0) { - Location location = event.getEntity().getLocation(); - double x = location.getX(); - double y = location.getY(); - double z = location.getZ(); - - int x2 = (int) x; - int y2 = (int) y; - int z2 = (int) z; - - int spawnmagmacube = 1; - double checkcount = 0.01; - while (checkcount < 10) { - y2 += checkcount; - - if (entity.getWorld().getBlockTypeIdAt(x2, y2, z2) != 0) { - spawnmagmacube = 0; - } - checkcount++; - } - if (spawnmagmacube == 1) { - MagmaCubeSpawnEvent MCSE = new MagmaCubeSpawnEvent(location); - Bukkit.getServer().getPluginManager().callEvent(MCSE); - } - } - } - } - } - - @EventHandler - public void ArrowDamage(EntityDamageByEntityEvent event){ - Entity entity = event.getEntity(); - if((event.getDamager() instanceof Arrow) && (API.isGiantMagmaCube(entity))){ - int damage; - int s; - String string2 = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Damage Settings.Arrows.Damage done by arrow"); - try { - damage = Integer.parseInt(string2); - } catch (Exception e) { - damage = 10; - } - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - if(damage == 0){ - event.setCancelled(true); - return; - } - event.setDamage(damage + 0.0); - } - } - } - - @EventHandler - public void suffocationDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - int s; - if (API.isGiantMagmaCube(entity)){ - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Damage Settings.Block Damage.Allow Suffocation").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FALLING_BLOCK){ - event.setCancelled(true); - } - } - } - } - } - - @EventHandler - public void cactiDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - int s; - if (API.isGiantMagmaCube(entity)){ - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Damage Settings.Block Damage.Allow Cacti Damage").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.THORNS){ - event.setCancelled(true); - } - } - } - } - } - - @EventHandler - public void damage(EntityDamageByEntityEvent event){ - Entity entity = event.getEntity(); - int s; - if ((event.getDamager() instanceof Player) && (API.isGiantMagmaCube(entity))){ - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - double damage = event.getDamage(); - double health = ((Damageable) event.getEntity()).getHealth(); - ((Damageable) entity).setHealth(Math.max(0, Math.min(health - damage, ((Damageable) entity).getMaxHealth()))); - event.setCancelled(true); - } - } - } - - @EventHandler - public void onFireAttack(EntityTargetEvent event) { - String ticks1 = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); - String ticks2 = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Fire Attack.Ticks for Magma Cube"); - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int ticksTarget; - int ticksGiant; - int s; - try { - ticksTarget = Integer.parseInt(ticks1); - ticksGiant = Integer.parseInt(ticks2); - } catch (Exception e) { - ticksTarget = 0; - ticksGiant = 0; - } - - if ((entity instanceof LivingEntity)) { - if (API.isGiantMagmaCube(entity)) { - if(!(target == null)){ - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Fire Attack.Enabled").equalsIgnoreCase("true")) { - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Sounds.Fire Attack").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); - } - try { - event.getTarget().setFireTicks(ticksTarget); - event.getEntity().setFireTicks(ticksGiant); - } catch (Exception e) { - } - } else { - event.setTarget(target); - } - } - } - } - } - } - - @EventHandler - public void onLightningAttack(EntityTargetEvent event) { - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int s; - - if ((entity instanceof LivingEntity)) { - if (API.isGiantMagmaCube(entity)) { - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Lightning Attack").equalsIgnoreCase("true")) { - try { - target.getLocation().getWorld().strikeLightning(target.getLocation()); - } catch (Exception e) { - } - } else { - event.setTarget(target); - } - } - } - } - } - - @EventHandler - public void LavaAttack(EntityTargetEvent event){ - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int s; - - if((API.isGiantMagmaCube(entity)) && (target instanceof Player)){ - MagmaCube magmacube = (MagmaCube) event.getEntity(); - s = magmacube.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Lava Attack").equalsIgnoreCase("true")) { - target.getLocation().getBlock().setType(Material.LAVA); - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Sounds.Lava Attack").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); - target.getLocation().getWorld().playSound(target.getLocation(), Sound.LAVA_POP, 1, 0); - } - } - } - } - } - - @EventHandler - public void onStompAttack(PlayerMoveEvent event) { - boolean sound = false; - boolean fire = false; - float power = 1.0f; - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Stomp Attack.Enabled").equalsIgnoreCase("true")) { - Random pick = new Random(); - int chance = 0; - int s; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(3, 2, 3)) { - if (API.isGiantMagmaCube(entity)) { - MagmaCube magmacube = (MagmaCube) entity; - s = magmacube.getSize(); - if (s > 4){ - if (entity.getNearbyEntities(3, 2, 3).contains(player)) { - String config = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); - if (API.getFileHandler().getProperty(Files.MAGMACUBE, - "Magma Cube Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { - fire = true; - } - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Sounds.Stomp Attack").equalsIgnoreCase("true")) { - sound = true; - } - - try { - power = Float.parseFloat(config); - } catch (Exception e) { - power = 0.0f; - } - API.createAttack().stompAttack(player.getLocation(), power, fire, sound); - } - } - } - } - } - } - } - - @EventHandler - public void ThrownBoulderAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - boolean inRange = false; - Random pick = new Random(); - int chance = 0; - int bDamage; - int s; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - - for (Entity entity : player.getNearbyEntities(15, 12, 15)) { - if (API.isGiantMagmaCube(entity)) { - MagmaCube magmacube = (MagmaCube) entity; - s = magmacube.getSize(); - if (s > 4){ - if (entity.getNearbyEntities(15, 12, 15).contains(player) && !entity.getNearbyEntities(5, 3, 5).contains(player)) { - inRange = true; - } - if (inRange == true) { - if (chance == 50) { - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").equalsIgnoreCase("true")) { - String config = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); - try { - bDamage = Integer.parseInt(config); - } catch (Exception e) { - bDamage = 1; - } - - Vector direction = ((LivingEntity) entity).getEyeLocation().getDirection().multiply(2); - Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); - fireball.setShooter((LivingEntity) entity); - fireball.setYield(bDamage); - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Sounds.Throw Boulder Attack").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); - } - } - } - } - } - } - } - } - - @EventHandler - public void onKickAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Kick Attack.Enabled").equalsIgnoreCase("true")) { - int s; - String config = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Attack Mechanisms.Kick Attack.Kick Height"); - double height; - - try { - height = Double.parseDouble(config); - } catch (Exception e) { - height = 1; - } - - Random pick = new Random(); - int chance = 0; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(5, 5, 5)) { - if (API.isGiantMagmaCube(entity)) { - MagmaCube magmacube = (MagmaCube) entity; - s = magmacube.getSize(); - if (s > 4){ - if (entity.getNearbyEntities(5, 5, 5).contains(player)) { - player.setVelocity(new Vector(0, height, 0)); - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Sounds.Kick Attack").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); - } - } - } - } - } - } - } - } - - @EventHandler - public void GiantMagmaCubeDrops(EntityDeathEvent event) { - Entity entity = event.getEntity(); - String string = API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.Experience"); - int exp; - - try { - exp = Integer.parseInt(string); - } catch (Exception e) { - exp = 5; - } - - if (API.isGiantMagmaCube(entity)) { - if (API.getFileHandler().getProperty(Files.MAGMACUBE, "Magma Cube Configuration.Sounds.Death").equalsIgnoreCase("true")) { - entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); - } - event.setDroppedExp(exp); - List newDrop = API.getFileHandler().getPropertyList(Files.MAGMACUBE, "Magma Cube Configuration.Magma Cube Stats.Drops"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { - return; - } - - List drops = new ArrayList(); - - drops = API.createDrop().setDrop(entity, newDrop); - - event.getDrops().addAll(drops); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/listeners/SlimeListeners.java b/src/main/java/me/Mammothskier/Giants/listeners/SlimeListeners.java deleted file mode 100644 index 29fd25e..0000000 --- a/src/main/java/me/Mammothskier/Giants/listeners/SlimeListeners.java +++ /dev/null @@ -1,438 +0,0 @@ -package me.Mammothskier.Giants.listeners; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.events.SlimeSpawnEvent; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.utils.API; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -public class SlimeListeners implements Listener { - private Giants _slimes; - - public SlimeListeners(Giants slimes) { - _slimes = slimes; - _slimes.getServer().getPluginManager().registerEvents(this, slimes); - } - - @EventHandler - public void onSlimeSpawn(SlimeSpawnEvent event) { - if (API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Enabled").equalsIgnoreCase("true")) { - String message = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Debug Message"); - if (message != null) { - for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (player.hasPermission("giants.debug") || player.hasPermission("giants.*") || player.isOp()) { - message = ChatColor.translateAlternateColorCodes('&', message); - String x = String.valueOf(Math.round(event.getLocation().getX())); - String y = String.valueOf(Math.round(event.getLocation().getY())); - String z = String.valueOf(Math.round(event.getLocation().getZ())); - player.sendMessage(message.replace("%X", x).replace("%Y", y).replace("%Z", z).replace("{entity}", "Giant Slime")); - Bukkit.getConsoleSender().sendMessage(message.replace("%X", x).replace("%Y", y).replace("%Z", z).replace("{entity}", "Giant Slime")); - } - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void SlimeSpawnEvent(CreatureSpawnEvent event) { - Entity entity = event.getEntity(); - EntityType type = event.getEntityType(); - SpawnReason spawnReason = event.getSpawnReason(); - if(event.isCancelled()){ - return; - } - if (!API.getSlimeSpawnWorlds().contains(entity.getWorld().getName())) { - return; - } - - if ((spawnReason == SpawnReason.NATURAL)) { - if ((type == EntityType.ZOMBIE) || (type == EntityType.COW) || (type == EntityType.MUSHROOM_COW) || (type == EntityType.PIG_ZOMBIE) || (type == EntityType.ENDERMAN) || (type == EntityType.SLIME)) { - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Spawn Settings.Chance"); - float sRate; - try { - sRate = Float.parseFloat(string); - } catch (NumberFormatException e) { - sRate = 0; - } - float chance = 100 - sRate; - - Random rand = new Random(); - double choice = rand.nextInt(100) < chance ? 1 : 0; - if (choice == 0) { - Location location = event.getEntity().getLocation(); - double x = location.getX(); - double y = location.getY(); - double z = location.getZ(); - - int x2 = (int) x; - int y2 = (int) y; - int z2 = (int) z; - - int spawnslime = 1; - double checkcount = 0.01; - while (checkcount < 10) { - y2 += checkcount; - - if (entity.getWorld().getBlockTypeIdAt(x2, y2, z2) != 0) { - spawnslime = 0; - } - checkcount++; - } - if (spawnslime == 1) { - SlimeSpawnEvent SSE = new SlimeSpawnEvent(location); - Bukkit.getServer().getPluginManager().callEvent(SSE); - } - } - } - } - } - - @EventHandler - public void ArrowDamage(EntityDamageByEntityEvent event){ - Entity entity = event.getEntity(); - if((event.getDamager() instanceof Arrow) && (API.isGiantSlime(entity))){ - int damage; - int s; - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Damage Settings.Arrows.Damage done by arrow"); - try { - damage = Integer.parseInt(string); - } catch (Exception e) { - damage = 10; - } - Slime slime = (Slime) event.getEntity(); - s = slime.getSize(); - if (s > 4){ - if(damage == 0){ - event.setCancelled(true); - return; - } - event.setDamage(damage + 0.0); - } - } - } - - @EventHandler - public void fireDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - int s; - if (API.isGiantSlime(entity)){ - Slime slime = (Slime) event.getEntity(); - s = slime.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Damage Settings.Fire.Allow Fire Damage").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK){ - event.setCancelled(true); - } - } - } - } - } - - @EventHandler - public void suffocationDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - int s; - if (API.isGiantSlime(entity)){ - Slime slime = (Slime) event.getEntity(); - s = slime.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Damage Settings.Block Damage.Allow Suffocation").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FALLING_BLOCK){ - event.setCancelled(true); - } - } - } - } - } - - @EventHandler - public void cactiDamage(EntityDamageEvent event){ - Entity entity = event.getEntity(); - int s; - if (API.isGiantSlime(entity)){ - Slime slime = (Slime) event.getEntity(); - s = slime.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Damage Settings.Block Damage.Allow Cacti Damage").equalsIgnoreCase("false")){ - if (event.getCause() == DamageCause.THORNS){ - event.setCancelled(true); - } - } - } - } - } - - @EventHandler - public void onLightningAttack(EntityTargetEvent event) { - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int s; - - if ((entity instanceof LivingEntity)) { - if (API.isGiantSlime(entity)) { - Slime slime = (Slime) event.getEntity(); - s = slime.getSize(); - if (s > 4){ - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Lightning Attack").equalsIgnoreCase("true")) { - try { - target.getLocation().getWorld().strikeLightning(target.getLocation()); - } catch (Exception e) { - } - } else { - event.setTarget(target); - } - } - } - } - } - - @EventHandler - public void onFireAttack(EntityTargetEvent event) { - String ticks1 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); - String ticks2 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Fire Attack.Ticks for Slime"); - Entity entity = event.getEntity(); - Entity target = event.getTarget(); - int ticksTarget; - int ticksGiant; - int s; - try { - ticksTarget = Integer.parseInt(ticks1); - ticksGiant = Integer.parseInt(ticks2); - } catch (Exception e) { - ticksTarget = 0; - ticksGiant = 0; - } - - if ((entity instanceof LivingEntity)) { - if (API.isGiantSlime(entity)) { - Slime slime = (Slime) event.getEntity(); - s = slime.getSize(); - if (s > 4){ - if(!(target == null)){ - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Fire Attack.Enabled").equalsIgnoreCase("true")) { - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Sounds.Fire Attack").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); - } - try { - event.getTarget().setFireTicks(ticksTarget); - event.getEntity().setFireTicks(ticksGiant); - } catch (Exception e) { - } - } else { - event.setTarget(target); - } - } - } - } - } - } - - @EventHandler - public void ThrownBoulderAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - boolean inRange = false; - Random pick = new Random(); - int chance = 0; - int bDamage; - int s; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - - for (Entity entity : player.getNearbyEntities(15, 12, 15)) { - if (API.isGiantMagmaCube(entity)) { - Slime slime = (Slime) entity; - s = slime.getSize(); - if (s > 4){ - if (entity.getNearbyEntities(15, 12, 15).contains(player) && !entity.getNearbyEntities(5, 3, 5).contains(player)) { - inRange = true; - } - if (inRange == true) { - if (chance == 50) { - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").equalsIgnoreCase("true")) { - String config = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); - try { - bDamage = Integer.parseInt(config); - } catch (Exception e) { - bDamage = 1; - } - Vector direction = ((LivingEntity) entity).getEyeLocation().getDirection().multiply(2); - Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); - fireball.setShooter((LivingEntity) entity); - fireball.setYield(bDamage); - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Sounds.Throw Boulder Attack").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); - } - } - } - } - } - } - } - } - - @EventHandler - public void onKickAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Kick Attack.Enabled").equalsIgnoreCase("true")) { - String config = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Kick Attack.Kick Height"); - double height; - int s; - - try { - height = Double.parseDouble(config); - } catch (Exception e) { - height = 1; - } - - Random pick = new Random(); - int chance = 0; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(5, 5, 5)) { - if (API.isGiantSlime(entity)) { - Slime slime = (Slime) entity; - s = slime.getSize(); - if (s > 4){ - if (entity.getNearbyEntities(5, 5, 5).contains(player)) { - player.setVelocity(new Vector(0, height, 0)); - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Sounds.Kick Attack").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); - } - } - } - } - } - } - } - } - - @EventHandler - public void onStompAttack(PlayerMoveEvent event) { - boolean sound = false; - boolean fire = false; - float power = 1.0f; - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Stomp Attack.Enabled").equalsIgnoreCase("true")) { - Random pick = new Random(); - int chance = 0; - int s; - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(3, 2, 3)) { - if (API.isGiantSlime(entity)) { - Slime slime = (Slime) entity; - s = slime.getSize(); - if (s > 4){ - if (entity.getNearbyEntities(3, 2, 3).contains(player)) { - String config = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); - if (API.getFileHandler().getProperty(Files.SLIME, - "Slime Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { - fire = true; - } - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Sounds.Stomp Attack").equalsIgnoreCase("true")) { - sound = true; - } - - try { - power = Float.parseFloat(config); - } catch (Exception e) { - power = 0.0f; - } - API.createAttack().stompAttack(player.getLocation(), power, fire, sound); - } - } - } - } - } - } - } - - @EventHandler - public void poisonAttack(PlayerMoveEvent event) { - Player player = event.getPlayer(); - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Poison Attack").equalsIgnoreCase("true")){ - Random pick = new Random(); - int chance = 0; - double length; - String config = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Attack Mechanisms.Poison Attack.length"); - try { - length = Double.parseDouble(config); - } catch (Exception e) { - length = 5; - } - for (int counter = 1; counter <= 1; counter++) { - chance = 1 + pick.nextInt(100); - } - if (chance == 50) { - for (Entity entity : player.getNearbyEntities(3, 2, 3)) { - if (API.isGiantSlime(entity)) { - API.createAttack().poisonAttack(player, length); - } - } - } - } - } - - @EventHandler - public void GiantSlimeDrops(EntityDeathEvent event) { - Entity entity = event.getEntity(); - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Experience"); - int exp; - - try { - exp = Integer.parseInt(string); - } catch (Exception e) { - exp = 5; - } - - if (API.isGiantSlime(entity)) { - if (API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Sounds.Death").equalsIgnoreCase("true")) { - entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_DEATH, 1, 0); - } - event.setDroppedExp(exp); - List newDrop = API.getFileHandler().getPropertyList(Files.SLIME, "Slime Configuration.Slime Stats.Drops"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { - return; - } - - List drops = new ArrayList(); - - drops = API.createDrop().setDrop(entity, newDrop); - - event.getDrops().addAll(drops); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/Mammothskier/Giants/utils/API.java b/src/main/java/me/Mammothskier/Giants/utils/API.java deleted file mode 100644 index f2c5379..0000000 --- a/src/main/java/me/Mammothskier/Giants/utils/API.java +++ /dev/null @@ -1,165 +0,0 @@ -package me.Mammothskier.Giants.utils; - -import java.util.List; - -import me.Mammothskier.Giants.Attacks; -import me.Mammothskier.Giants.Commands; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.events.JockeySpawnEvent; -import me.Mammothskier.Giants.files.FileHandler; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.listeners.GiantListeners; -import me.Mammothskier.Giants.listeners.JockeyListeners; -import me.Mammothskier.Giants.listeners.MagmaCubeListeners; -import me.Mammothskier.Giants.listeners.SlimeListeners; - -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Giant; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Slime; -import org.bukkit.scheduler.BukkitScheduler; - -public class API { - private static Giants _giants; - private Commands commands; - private static FileHandler fileHandler; - private static Attacks Attacks; - private static DropsManager drops; - - public API(Giants giants) { - _giants = giants; - new GiantListeners(_giants); - new SlimeListeners(_giants); - new MagmaCubeListeners(_giants); - new JockeyListeners(_giants); - commands = new Commands(_giants); - _giants.getCommand("giants").setExecutor(commands); - fileHandler = new FileHandler(_giants); - Attacks = new Attacks(_giants); - drops = new DropsManager(_giants); - - if (getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { - BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); - scheduler.scheduleSyncRepeatingTask(_giants, new Runnable() { - - @Override - public void run() { - for (World world : _giants.getServer().getWorlds()) { - for (Entity entity : world.getEntities()) { - if ((entity instanceof Slime) || (entity instanceof MagmaCube) || (entity instanceof Ghast)) { - for (Entity entity2 : entity.getNearbyEntities(15, 12, 15)) { - if ((entity2 instanceof Giant) && (entity.getPassenger() == null) && (entity2.getVehicle() == null)) { - Entity passenger = entity2; - JockeySpawnEvent JSE = new JockeySpawnEvent(entity, passenger); - Bukkit.getServer().getPluginManager().callEvent(JSE); - } - } - } - } - } - } - }, 0L, 20L); - } - } - - public static boolean isGiant(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant"); - if (config.equalsIgnoreCase("false")){ - return false; - } - return entity instanceof Giant; - } - - public static boolean isGiantSlime(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime"); - if (config.equalsIgnoreCase("false")){ - return false; - } - - if (entity instanceof Slime){ - Slime slime = (Slime) entity; - if ( slime.getSize() > 4){ - return entity instanceof Slime; - } - } - return false; - } - - public static boolean isGiantMagmaCube(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Magma Cube"); - if (config.equalsIgnoreCase("false")){ - return false; - } - if (entity instanceof MagmaCube){ - MagmaCube magmacube = (MagmaCube) entity; - if (magmacube.getSize() > 4){ - return entity instanceof MagmaCube; - } - } - return false; - } - - public static boolean isGiantJockey(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey"); - if (config.equalsIgnoreCase("false")){ - return false; - } - switch (entity.getType()) { - case GIANT: - if ((isGiantSlime(entity.getVehicle())) || (isGiantMagmaCube(entity.getVehicle())) || (entity.getVehicle().getType() == EntityType.GHAST)) { - return true; - } - break; - case SLIME: - if ((isGiantSlime(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { - return true; - } - break; - case MAGMA_CUBE: - if ((isGiantMagmaCube(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { - return true; - } - break; - case GHAST: - if (entity.getPassenger().getType() == EntityType.GIANT) { - return true; - } - break; - default: - break; - } - return false; - } - - public static List getGiantSpawnWorlds() { - return getFileHandler().getPropertyList(Files.GIANT, "Giant Configuration.Spawn Settings.Worlds"); - } - - public static List getSlimeSpawnWorlds() { - return getFileHandler().getPropertyList(Files.SLIME, "Slime Configuration.Spawn Settings.Worlds"); - } - - public static List getMagmaCubeSpawnWorlds() { - return getFileHandler().getPropertyList(Files.MAGMACUBE, "Magma Cube Configuration.Spawn Settings.Worlds"); - } - - public static List getJockeySpawnWorlds() { - return getFileHandler().getPropertyList(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds"); - } - - public static FileHandler getFileHandler() { - return fileHandler; - } - - public static Attacks createAttack() { - return Attacks; - } - - public static DropsManager createDrop() { - return drops; - } -} \ No newline at end of file From 861efae7806623452e27dbcfa7e17821e7a90ffd Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 7 Mar 2016 00:08:03 -0700 Subject: [PATCH 03/28] 1.9 Update This commit to branch Razor applies preliminary fixes to Giants for mc v1_9_R1 --- Giants/pom.xml | 15 +- .../java/me/Mammothskier/Giants/Commands.java | 37 +-- .../java/me/Mammothskier/Giants/Giants.java | 19 +- .../Giants/entity/DropsManager.java | 11 +- .../Giants/events/SpawnEvent.java | 268 +++--------------- .../Giants/files/ConfigValues.java | 225 +++++++++++++++ .../Giants/files/FileHandler.java | 69 ++++- .../me/Mammothskier/Giants/util/NMSUtils.java | 9 +- Giants/src/main/resources/attacks.yml | 51 ---- Giants/src/main/resources/biomes.yml | 113 ++++---- Giants/src/main/resources/config.yml | 13 +- Giants/src/main/resources/entities.yml | 67 ----- {src => Giants/src}/main/resources/giant.yml | 0 .../src}/main/resources/magmacube.yml | 0 {src => Giants/src}/main/resources/slime.yml | 0 pom.xml | 4 +- .../me/Mammothskier/Giants/utils/API.java | 165 +++++++++++ src/main/resources/biomes.yml | 77 ----- src/main/resources/config.yml | 16 -- src/main/resources/jockey.yml | 6 - src/main/resources/plugin.yml | 31 ++ v1_7_R3/dependency-reduced-pom.xml | 27 ++ v1_7_R3/pom.xml | 13 + .../nms/v1_7_R3/CustomEntityGiantZombie.java | 11 +- v1_7_R4/dependency-reduced-pom.xml | 21 ++ v1_7_R4/pom.xml | 14 +- .../nms/v1_7_R4/CustomEntityGiantZombie.java | 11 +- v1_8_R1/dependency-reduced-pom.xml | 21 ++ v1_8_R1/pom.xml | 14 +- v1_8_R2/dependency-reduced-pom.xml | 33 +++ v1_8_R2/pom.xml | 14 +- .../nms/v1_8_R2/CustomEntityGiantZombie.java | 11 +- v1_8_R3/dependency-reduced-pom.xml | 21 ++ v1_8_R3/pom.xml | 14 +- .../nms/v1_8_R3/CustomEntityGiantZombie.java | 12 +- v1_9_R1/pom.xml | 37 +++ .../nms/v1_9_R1/CustomEntityGiantZombie.java | 87 ++++++ .../entity/nms/v1_9_R1/CustomEntityType.java | 175 ++++++++++++ .../entity/nms/v1_9_R1/EntityCreator.java | 17 ++ 39 files changed, 1186 insertions(+), 563 deletions(-) create mode 100644 Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java delete mode 100644 Giants/src/main/resources/attacks.yml delete mode 100644 Giants/src/main/resources/entities.yml rename {src => Giants/src}/main/resources/giant.yml (100%) rename {src => Giants/src}/main/resources/magmacube.yml (100%) rename {src => Giants/src}/main/resources/slime.yml (100%) create mode 100644 src/main/java/me/Mammothskier/Giants/utils/API.java delete mode 100644 src/main/resources/biomes.yml delete mode 100644 src/main/resources/config.yml delete mode 100644 src/main/resources/jockey.yml create mode 100644 src/main/resources/plugin.yml create mode 100644 v1_7_R3/dependency-reduced-pom.xml create mode 100644 v1_7_R4/dependency-reduced-pom.xml create mode 100644 v1_8_R1/dependency-reduced-pom.xml create mode 100644 v1_8_R2/dependency-reduced-pom.xml create mode 100644 v1_8_R3/dependency-reduced-pom.xml create mode 100644 v1_9_R1/pom.xml create mode 100644 v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java create mode 100644 v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityType.java create mode 100644 v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/EntityCreator.java diff --git a/Giants/pom.xml b/Giants/pom.xml index c4f52ab..3571bc0 100644 --- a/Giants/pom.xml +++ b/Giants/pom.xml @@ -3,7 +3,7 @@ me.Mammothskier Giants-Parent - 7.0 + 7.0-Beta Giants @@ -85,6 +85,19 @@ true + + + + me.Mammothskier + Giants-v1_9_R1 + v1 + + + org.bukkit + craftbukkit + + + true diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Commands.java b/Giants/src/main/java/me/Mammothskier/Giants/Commands.java index 0e63d20..31dc91c 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/Commands.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/Commands.java @@ -2,7 +2,7 @@ import me.Mammothskier.Giants.entity.Entities; import me.Mammothskier.Giants.events.SpawnEvent; -import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.files.ConfigValues; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -66,7 +66,7 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa Giant entity = null; double health; - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Zombie"); + String string = Giants.getProperty(ConfigValues.zombieHealth); try { health = Double.parseDouble(string); } catch (Exception e) { @@ -112,12 +112,12 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa ((Damageable) entity).setHealth(health); if (entity.getType() == EntityType.GIANT) { EntityEquipment armour = ((LivingEntity) entity).getEquipment(); - String config = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items"); + String config = Giants.getProperty(ConfigValues.zombieArmour); String[] s = config.split(":"); float rate = 0f; try { - rate = Float.parseFloat(Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate")); + rate = Float.parseFloat(Giants.getProperty(ConfigValues.armourDropRate)); } catch (Exception e){ rate = 0; } @@ -153,8 +153,8 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa if(args[1].equalsIgnoreCase("slime")){ Location loc = (Location) player.getEyeLocation(); Location location = loc; - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); - String string2 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Slime"); + String string = Giants.getProperty(ConfigValues.slimeSize); + String string2 = Giants.getProperty(ConfigValues.slimeHealth); int size; double health; try { @@ -197,15 +197,9 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa if(args[1].equalsIgnoreCase("jockey")){ Location loc = (Location) player.getEyeLocation(); Location location = loc; -<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/Commands.java - String string = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Size"); - String string2 = API.getFileHandler().getProperty(Files.SLIME, "Slime Configuration.Slime Stats.Health"); - String string3 = API.getFileHandler().getProperty(Files.GIANT, "Giant Configuration.Giant Stats.Health"); -======= - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); - String string2 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Slime"); - String string3 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Zombie"); ->>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/Commands.java + String string = Giants.getProperty(ConfigValues.slimeSize); + String string2 = Giants.getProperty(ConfigValues.slimeHealth); + String string3 = Giants.getProperty(ConfigValues.zombieHealth); int size; double giantHealth; double slimeHealth; @@ -223,15 +217,10 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa slime.setSize(size); slime.setMaxHealth(slimeHealth); slime.setHealth(slimeHealth); -<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/Commands.java - Giant giant = (Giant) loc.getWorld().spawnEntity(location, EntityType.GIANT); - giant.setMaxHealth(giantHealth); -======= Entities.createGiant(loc, SpawnReason.NATURAL); Entity giant = SpawnEvent.getGiantZombie(SpawnEvent.getNearbyEntities(loc, 10), loc); ((Damageable) giant).setMaxHealth(giantHealth); ->>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/Commands.java slime.setPassenger(giant); player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant Jockey has been spawned"); } @@ -264,8 +253,8 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa if((args[1].equalsIgnoreCase("lavaslime")) || (args[1].equalsIgnoreCase("magma_cube")) || (args[1].equalsIgnoreCase("magma"))|| (args[1].equalsIgnoreCase("magmacube"))){ Location loc = (Location) player.getEyeLocation(); Location location = loc; - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime"); - String string2 = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Lava Slime"); + String string = Giants.getProperty(ConfigValues.lavaSlimeSize); + String string2 = Giants.getProperty(ConfigValues.lavaSlimeHealth); int size; double health; try { @@ -305,11 +294,7 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa return true; } else { -<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/Commands.java - player.sendMessage(ChatColor.RED + "Unknown Entity Type! I recognise giant, slime, magmacube and jockey."); -======= player.sendMessage(ChatColor.RED + "Unknown Entity Type! I recognise zombie, slime, lavaslime and jockey."); ->>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/Commands.java } } else { diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Giants.java b/Giants/src/main/java/me/Mammothskier/Giants/Giants.java index fb30d57..9d5a097 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/Giants.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/Giants.java @@ -5,6 +5,7 @@ import java.util.logging.Logger; import me.Mammothskier.Giants.entity.Entities; +import me.Mammothskier.Giants.files.ConfigValues; import me.Mammothskier.Giants.files.FileHandler; import me.Mammothskier.Giants.files.Files; import me.Mammothskier.Giants.util.Metrics; @@ -44,35 +45,45 @@ public void onDisable() { NMSUtils.unregisterEntities(); } + @Deprecated public static String getProperty(Files file, String path) { return fileHandler.getProperty(file, path); } + @Deprecated public static List getPropertyList(Files file, String path) { return fileHandler.getPropertyList(file, path); } + public static String getProperty(ConfigValues value) { + return fileHandler.getProperty(value); + } + + public static List getPropertyList(ConfigValues values) { + return fileHandler.getPropertyList(values); + } + public static FileHandler getFileHandler() { return fileHandler; } public static void updateEntities() { - if (Entities.GiantZombie == true && getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Zombie").equalsIgnoreCase("false")) + if (Entities.GiantZombie == true && getProperty(ConfigValues.zombieBoolean).equalsIgnoreCase("false")) Entities.GiantZombie = false; - if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime").equalsIgnoreCase("true")) { + if (getProperty(ConfigValues.slimeBoolean).equalsIgnoreCase("true")) { Entities.GiantSlime = true; } else { Entities.GiantSlime = false; } - if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Lava Slime").equalsIgnoreCase("true")) { + if (getProperty(ConfigValues.lavaSlimeBoolean).equalsIgnoreCase("true")) { Entities.GiantLavaSlime = true; } else { Entities.GiantLavaSlime = false; } - if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { + if (getProperty(ConfigValues.jockeyBoolean).equalsIgnoreCase("true")) { Entities.GiantJockey = true; } else { Entities.GiantJockey = false; diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java index 00105c4..d4f27a4 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java @@ -6,15 +6,11 @@ import java.util.List; import java.util.Random; -<<<<<<< HEAD:src/main/java/me/Mammothskier/Giants/utils/DropsManager.java -import org.bukkit.ChatColor; -======= import me.Mammothskier.Giants.Giants; import me.Mammothskier.Giants.files.Files; import org.bukkit.ChatColor; import org.bukkit.Sound; ->>>>>>> origin/master:Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentWrapper; import org.bukkit.entity.Entity; @@ -38,6 +34,7 @@ public DropsManager(Giants giants) { @EventHandler public void onGiantDrops(EntityDeathEvent event) throws IOException{ Entity entity = event.getEntity(); + boolean enabled = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Drops.Enable Drop Manager").equalsIgnoreCase("true"); if (Entities.isGiantZombie(entity)) { @@ -54,7 +51,7 @@ public void onGiantDrops(EntityDeathEvent event) throws IOException{ } event.setDroppedExp(exp); List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]") || enabled == false) { return; } @@ -77,7 +74,7 @@ public void onGiantDrops(EntityDeathEvent event) throws IOException{ } event.setDroppedExp(exp); List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Slime"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]") || enabled == false) { return; } @@ -103,7 +100,7 @@ public void onGiantDrops(EntityDeathEvent event) throws IOException{ } event.setDroppedExp(exp); List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Lava Slime"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]") || enabled == false) { return; } diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java b/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java index 8d58488..6d08ccf 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java @@ -60,290 +60,75 @@ public SpawnEvent(Location loc, EntityType entityType) { if (biome.toString().toLowerCase().contains("Swampland".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Swampland"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Forest".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Forest"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Taiga".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Taiga"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Plains".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Plains"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Extreme_Hills".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Extreme Hills"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Mushroom".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Mushroom Island"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Desert".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Desert"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Jungle".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Jungle"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Birch".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Birch Forest"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Savanna".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Savanna"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Roofed_Forest".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Roofed Forest"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Mesa".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Mesa"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Small_Mountains".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Small Mountains"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Ice_Mountains".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Ocean".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ocean"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("River".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.River"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Hell".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Hell"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } if (biome.toString().toLowerCase().contains("Sky".toLowerCase())) { List l = Giants.getPropertyList(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Sky"); - if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || - (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || - (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { - if (entityType.equals(EntityType.GIANT)) { - Entities.createGiant(loc, SpawnReason.NATURAL); - - entity = getGiantZombie(getNearbyEntities(loc, 10), loc); - - } else { - entity = (Slime) loc.getWorld().spawnEntity(location, entityType); - ((Slime) entity).setSize(size); - } - } + entity = spawnMob(entityType, l, loc, size); } Entities.callSpawnDebug(entity); @@ -391,6 +176,23 @@ public SpawnEvent(Location loc, EntityType entityType) { } } } + + private Entity spawnMob(EntityType entityType, List l, Location loc, int size) { + if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || + (entityType.equals(EntityType.SLIME) && l.contains("Giant Slime")) || + (entityType.equals(EntityType.MAGMA_CUBE) && l.contains("Giant Lava Slime"))) { + if (entityType.equals(EntityType.GIANT)) { + Entities.createGiant(loc, SpawnReason.NATURAL); + + entity = getGiantZombie(getNearbyEntities(loc, 10), loc); + + } else { + entity = (Slime) loc.getWorld().spawnEntity(location, entityType); + ((Slime) entity).setSize(size); + } + } + return entity; + } public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java b/Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java new file mode 100644 index 0000000..83c57c0 --- /dev/null +++ b/Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java @@ -0,0 +1,225 @@ +package me.Mammothskier.Giants.files; + +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.PluginDescriptionFile; + +public enum ConfigValues { + /** + * value commons (any using ConfigValues(String key, String value) as a constructor should be here). + * These values will be put at the top of each file. + */ + fileVersion("Giants Configuration.File Version", loadVersion()), + + /** + * These file values will go in the config.yml file. + */ + dependencies(Files.CONFIG, "Giants Configuration.Dependencies.BarAPI", FileHandler.checkDependencies("BarAPI")), + zombieBoolean(Files.CONFIG,"Giants Configuration.Entities.Giant Zombie", true), + slimeBoolean(Files.CONFIG, "Giants Configuration.Entities.Giant Slime", false), + lavaSlimeBoolean(Files.CONFIG, "Giants Configuration.Entities.Giant Lava Slime", false), + jockeyWarningBugs(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Bugs", "This entity of Giants is extremely experimental and does not have many features. Bugs may be present."), + jockeyWarningFiles(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Files", "Config files for this entity will NOT load unless enabled."), + jockeyBoolean(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled", false), + soundsBoolean(Files.CONFIG, "Giants Configuration.Sounds", true), + debugBoolean(Files.CONFIG, "Giants Configuration.Debug Mode.Enabled", false), + debugMessage(Files.CONFIG, "Giants Configuration.Debug Mode.Debug Message", "&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z"), + + /** + * These file values will go in the biome.yml file. + */ + biomeSwampland(Files.BIOMES,"Giants Configuration.Biome Settings.Swampland", FileHandler.loadEntities()), + biomeForest(Files.BIOMES, "Giants Configuration.Biome Settings.Forest", FileHandler.loadEntities()), + biomeTaiga(Files.BIOMES, "Giants Configuration.Biome Settings.Taiga", FileHandler.loadEntities()), + biomePlains(Files.BIOMES, "Giants Configuration.Biome Settings.Plains", FileHandler.loadEntities()), + biomeExtremeHills(Files.BIOMES, "Giants Configuration.Biome Settings.Extreme Hills", FileHandler.loadEntities()), + biomeMushroomIsland(Files.BIOMES, "Giants Configuration.Biome Settings.Mushroom Island", FileHandler.loadEntities()), + biomeDesert(Files.BIOMES, "Giants Configuration.Biome Settings.Desert", FileHandler.loadEntities()), + biomeJungle(Files.BIOMES, "Giants Configuration.Biome Settings.Jungle", FileHandler.loadEntities()), + biomeBirchForest(Files.BIOMES, "Giants Configuration.Biome Settings.Birch Forest", FileHandler.loadEntities()), + biomeSavanna(Files.BIOMES, "Giants Configuration.Biome Settings.Savanna", FileHandler.loadEntities()), + biomeRoofedForest(Files.BIOMES, "Giants Configuration.Biome Settings.Roofed Forest",FileHandler.loadEntities()), + biomeMesa(Files.BIOMES, "Giants Configuration.Biome Settings.Mesa",FileHandler.loadEntities()), + biomeSmallMountains(Files.BIOMES,"Giants Configuration.Biome Settings.Other.Small Mountains",FileHandler.loadEntities()), + biomeIceMountains(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains",FileHandler.loadEntities()), + biomeOcean(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ocean", ""), + biomeRiver(Files.BIOMES, "Giants Configuration.Biome Settings.Other.River", ""), + biomeHell(Files.BIOMES,"Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"), + biomeSky(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Sky", ""), + + /** + * These file values will go in the entities.yml file. + */ +//Worlds + zombieWorld(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Zombie", FileHandler.loadWorlds()), + slimeWorld(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Slime", FileHandler.loadWorlds()), + lavaslimeWorld(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Lava Slime", FileHandler.loadWorlds()), +//Size + slimeSize(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime", new Integer(12)), + lavaSlimeSize(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime", new Integer(12)), +//Speed + zombieSpeed(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie", new Integer(3)), +//Health + zombieHealth(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Zombie", new Integer(100)), + slimeHealth(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Slime", new Integer(100)), + lavaSlimeHealth(Files.ENTITIES, "Entities Configuration.Stats.Health.Giant Lava Slime", new Integer(100)), +//Experience + zombieExperience(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Zombie", new Integer(5)), + slimeExperience(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Slime", new Integer(5)), + lavaSlimeExperience(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Lava Slime", new Integer(5)), +//Armour + zombieArmour(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items", + new String("chainmail_helmet:chainmail_chestplate:chainmail_leggings:chainmail_boots:diamond_sword")), + armourDropRate(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate", new Float(8.5)), +//Drops + dropManager(Files.ENTITIES, "Entities Configuration.Stats.Drops.Enable Drop Manager", true), + zombieDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie", Arrays.asList(FileHandler.loadDefaultDrop("Giant Zombie"))), + slimeDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Slime", Arrays.asList(FileHandler.loadDefaultDrop("Giant Slime"))), + lavaSlimeDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Lava Slime", Arrays.asList(FileHandler.loadDefaultDrop("Giant Lava Slime"))), +//BarAPI + zombieBarAPI(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Zombie", "&2Giant Zombie"), + slimeBarAPI(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Slime", "&2Giant Slime Size {size}"), + lavaSlimeBarAPI(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Lava Slime", "&2Giant Lava Slime Size {size}"), +//Damage + zombieArrowDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Zombie", new Integer(10)), + slimeArrowDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Slime", new Integer(10)), + lavaSlimeArrowDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Lava Slime", new Integer(10)), + zombieAllowFireDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Zombie", true), + slimeAllowFireDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Slime", true), + zombieAllowSuffocation(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Zombie",false), + slimeAllowSuffocation(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Slime",false), + lavaSlimeAllowSuffocation(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Lava Slime",false), + zombieAllowCactiDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Zombie", false), + slimeAllowCactiDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Slime", false), + lavaSlimeAllowCactiDamage(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime", false), +//Targets + zombieAggressiveToVillage(Files.ENTITIES, "Entities Configuration.Target Settings.Target Villagers", false), + + /** + * These file values will go in attacks.yml + */ + lightningAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack", FileHandler.loadEntities()), + stompAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled", FileHandler.loadEntities()), + stompAttackPower(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)), + stompAttackFire(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire", FileHandler.loadEntities()), + lavaAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lava Attack", FileHandler.loadEntities()), + kickAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled", FileHandler.loadEntities()), + kickAttackHeight(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height", new Integer(1)), + fireAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled", FileHandler.loadEntities()), + fireAttackTargetTicks(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target", new Integer(100)), + fireAttackGiantTicks(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant", new Integer(100)), + bouldAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", FileHandler.loadEntities()), + bouldAttackBlockDamage(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage", new Integer(1)), + shrapnelAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Enabled", Arrays.asList("Giant Zombie")), + shrapnelAttackBabies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies", false), + shrapnelAttackZombies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Zombies to Spawn", new Integer(3)), + shrapnelAttackHealth(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Health", new Integer(20)), + zombiesOnDeath(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled", false), + zombiesOnDeathBabies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies", false), + zombiesOnDeathZombies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn", new Integer(5)), + zombiesOnDeathHealth(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20)), + + /** + * These file values will go in jockey.yml + */ + jockeyWarning(Files.JOCKEY, "Jockey Configuration", new String("This entity of Giants is extremely experimental and does not have many features")), + jockeyWorlds(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds", FileHandler.loadWorlds()), + + /** + * The file values will go in jockey/biomes.yml + */ + jockeyBiomeSwampland(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Swampland", FileHandler.loadEntities()), + jockeyBiomeForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Forest", FileHandler.loadEntities()), + jockeyBiomeTaiga(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Taiga", FileHandler.loadEntities()), + jockeyBiomePlains(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Plains", FileHandler.loadEntities()), + jockeyBiomeExtremeHills(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Extreme Hills", FileHandler.loadEntities()), + jockeyBiomeMushroomIsland(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Mushroom Island", FileHandler.loadEntities()), + jockeyBiomeDesert(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Desert", FileHandler.loadEntities()), + jockeyBiomeJungle(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Jungle", FileHandler.loadEntities()), + jockeyBiomeBirchForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Birch Forest", FileHandler.loadEntities()), + jockeyBiomeSavanna(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Savanna", FileHandler.loadEntities()), + jockeyBiomeRoofedForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Roofed Forest",FileHandler.loadEntities()), + jockeyBiomeMesa(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Mesa",FileHandler.loadEntities()), + jockeyBiomeSmallMountains(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Other.Small Mountains",FileHandler.loadEntities()), + jockeyBiomeIceMountains(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains",FileHandler.loadEntities()), + jockeyBiomeOcean(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.Ocean", ""), + jockeyBiomeRiver(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.River", ""), + jockeyBiomeHell(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"), + jockeyBiomeSky(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.Sky", ""), + ; + private final String _key; + private final Files _files; + private final String _value; + private final List _values; + + private ConfigValues(Files file, String key, String value) { + _files = file; + _key = key; + _value= value; + _values = null; + } + + private ConfigValues(Files file, String key, int value) { + _files = file; + _key = key; + _value= value + ""; + _values = null; + } + + private ConfigValues(Files file, String key, float value) { + _files = file; + _key = key; + _value= value + ""; + _values = null; + } + + private ConfigValues(Files file, String key, boolean value) { + _files = file; + _key = key; + _value = value == true ? "true" : "false"; + _values = null; + } + + private ConfigValues(String key, String value) { + _files = null; + _key = key; + _value= value; + _values = null; + } + + private ConfigValues(Files file, String key, List value) { + _files = file; + _key = key; + _values= value; + _value = _values.get(0); + } + + public String getKey() { + return _key; + } + + public Files getFile() { + return _files; + } + + public String getValue() { + return _value; + } + + public List getValues() { + return _values; + } + + private static String loadVersion() { + PluginDescriptionFile pdf = + Bukkit.getPluginManager().getPlugin("Giants").getDescription(); + String version = pdf.getVersion(); + if (version == null) { + return null; + } + return version; + } + +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java b/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java index 65c302c..6f3dd5f 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java @@ -31,7 +31,7 @@ public FileHandler(Giants giants) { loadDefaultDrop("MagmaCube"); } - private String loadVersion() { + public String loadVersion() { PluginDescriptionFile pdf = _giants.getDescription(); String version = pdf.getVersion(); if (version == null) { @@ -40,22 +40,22 @@ private String loadVersion() { return version; } - public List loadWorlds() { + public static List loadWorlds() { List worldList = new ArrayList(); - for (World w : _giants.getServer().getWorlds()) { + for (World w : Bukkit.getServer().getWorlds()) { worldList.add(w.getName()); } return worldList; } - private boolean checkDependencies(String plugin) { + public static boolean checkDependencies(String plugin) { if (Bukkit.getPluginManager().getPlugin(plugin) != null) { return true; } return false; } - private String[] loadDefaultDrop(String arg) { + static String[] loadDefaultDrop(String arg) { String[] drops = null; switch(arg){ case "Giant Zombie": @@ -73,7 +73,7 @@ private String[] loadDefaultDrop(String arg) { return drops; } - private List loadEntities() { + public static List loadEntities() { List list = new ArrayList(); list.add("Giant Zombie"); list.add("Giant Slime"); @@ -164,6 +164,8 @@ private void createFiles(Files files, File file) { // Size entities.set("Entities Configuration.Spawn Settings.Size.Giant Slime", new Integer(12)); entities.set("Entities Configuration.Spawn Settings.Size.Giant Lava Slime", new Integer(12)); +// Speed + entities.set("Entities Configuration.Stats.Speed.Giant Zombie", new Integer(3)); // Health entities.set("Entities Configuration.Stats.Health.Giant Zombie", new Integer(100)); entities.set("Entities Configuration.Stats.Health.Giant Slime", new Integer(100)); @@ -177,6 +179,7 @@ private void createFiles(Files files, File file) { new String("chainmail_helmet:chainmail_chestplate:chainmail_leggings:chainmail_boots:diamond_sword")); entities.set("Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate", new Float(8.5)); // Drops + entities.set("Entities Configuration.Stats.Drops.Enable Drop Manager", true); entities.set("Entities Configuration.Stats.Drops.Giant Zombie", Arrays.asList(loadDefaultDrop("Giant Zombie"))); entities.set("Entities Configuration.Stats.Drops.Giant Slime", Arrays.asList(loadDefaultDrop("Giant Slime"))); entities.set("Entities Configuration.Stats.Drops.Giant Lava Slime", Arrays.asList(loadDefaultDrop("Giant Lava Slime"))); @@ -279,6 +282,7 @@ private void createFiles(Files files, File file) { } } + @Deprecated public String getProperty(Files file, String path) { FileConfiguration conf = _configurations.get(file); @@ -291,7 +295,7 @@ public String getProperty(Files file, String path) { } return null; } - + @Deprecated public List getPropertyList(Files file, String path) { FileConfiguration conf = _configurations.get(file); @@ -303,4 +307,55 @@ public List getPropertyList(Files file, String path) { } return null; } + + /** + * Gets the property that is saved at the value location. + * @param ConfigValues value. + * @return String property from the config file the value is saved in. + */ + public String getProperty(ConfigValues value) { + FileConfiguration config = _configurations.get(value.getFile()); + if (config != null) { + String property = config.getString(value.getKey(), "NULL"); + + if (!property.equalsIgnoreCase("NULL")) + return property; + config.set(value.getKey(), value.getValue()); + } + return null; + } + + /** + * Gets the property list that is saved at the value location. + * @param ConfigValues value. + * @return List propertylist from the config file the value is saved in. + */ + public List getPropertyList(ConfigValues value) { + FileConfiguration config = _configurations.get(value.getFile()); + if (config != null) { + List property = config.getStringList(value.getKey()); + + if (!property.contains("NULL")) + return property; + config.set(value.getKey(), value.getValue()); + } + return null; + } + + /** + * Changes the property value at the value location. + * @param value - the value to change + * @param newValue the value to put in place of the current value + */ + public void setProperty(ConfigValues value, Object newValue) { + FileConfiguration config = _configurations.get(value.getFile()); + if (config != null) { + config.set(value.getKey(), newValue); + try { + config.save(new File(value.getFile().getPath())); + } catch (IOException e) { + e.printStackTrace(); + } + } + } } \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java index 675b9f9..3d1f422 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java @@ -49,6 +49,9 @@ public static void createGiant(Location location, SpawnReason reason) { case("v1_8_R3"): me.Mammothskier.Giants.entity.nms.v1_8_R3.EntityCreator.createEntity(location, reason); break; + case("v1_9_R1"): + me.Mammothskier.Giants.entity.nms.v1_8_R3.EntityCreator.createEntity(location, reason); + break; } } } @@ -72,9 +75,13 @@ public static void registerEntities() { Entities.GiantZombie = true; me.Mammothskier.Giants.entity.nms.v1_8_R2.CustomEntityType.registerEntities(); } else if ("v1_8_R3".equals(version)) { - Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_8_R2 found. Enabling Giant Zombies."); + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_8_R3 found. Enabling Giant Zombies."); Entities.GiantZombie = true; me.Mammothskier.Giants.entity.nms.v1_8_R3.CustomEntityType.registerEntities(); + } else if ("v1_9_R1".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_9_R1 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.registerEntities(); } else { Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.RED + "Minecraft server version " + version + "does not support Giant Zombies.Disabling Giant Zombies"); Entities.GiantZombie = false; diff --git a/Giants/src/main/resources/attacks.yml b/Giants/src/main/resources/attacks.yml deleted file mode 100644 index b9c2800..0000000 --- a/Giants/src/main/resources/attacks.yml +++ /dev/null @@ -1,51 +0,0 @@ -Attacks Configuration: - File Version: ${project.build.version} - Attack Mechanisms: - Lightning Attack: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Stomp Attack: - Enabled: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Explosion Power: 1 - Light Fire: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Lava Attack: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Kick Attack: - Enabled: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Kick Height: 1 - Fire Attack: - Enabled: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Ticks for Target: 100 - Ticks for Giant: 100 - Throw Boulder Attack: - Enabled: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Block Damage: 1 - Shrapnel Attack: - Enabled: - - Giant Zombie - Baby Zombies: false - Zombies to Spawn: 3 - Health: 20 - Spawn Zombies On Death: - Enabled: false - Baby Zombies: false - Zombies to Spawn: 5 - Health: 20 diff --git a/Giants/src/main/resources/biomes.yml b/Giants/src/main/resources/biomes.yml index 7eb2d13..0f1b9e7 100644 --- a/Giants/src/main/resources/biomes.yml +++ b/Giants/src/main/resources/biomes.yml @@ -1,64 +1,77 @@ -Giants Configuration: - File Version: ${project.build.version} +Slime Configuration: + File Version: Version Biome Settings: Swampland: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Swampland: true + Swampland Mountains: true Forest: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Forest: true + Forest Hills: true Taiga: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Taiga: true + Taiga Hills: true + Taiga Mountains: true + Cold Taiga: true + Cold Taiga Hills: true + Cold Taiga Mountains: true + Mega Taiga: true + Mega Taiga Hills: true + Mega Spruce Taiga: true + Mega Spruce Taiga Hills: true Plains: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Plains: true + Ice Plains: true + Ice Plains Spikes: true + Sunflower Plains: true + Ocean: + Ocean: false + Deep Ocean: false + Frozen Ocean: true + River: + River: true + Frozen River: true + Beach: + Beach: true + Stone Beach: true + Cold Beach: true Extreme Hills: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Extreme Hills: true + Extreme Hills Plus: true + Extreme Hills Mountains: true + Extreme Hills Plus Mountains: true Mushroom Island: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Mushroom Island: true + Mushroom Shore: true Desert: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Desert: true + Desert Hills: true + Desert Mountains: true Jungle: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Jungle: true + Jungle Hills: true + Jungle Mountains: true Birch Forest: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Birch Forest: true + Birch Forest Hills: true + Birch Forest Mountains: true + Birch Forest Hills Mountains: true Savanna: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Savanna: true + Savanna Mountains: true + Savanna Plateau: true + Savanna Plateau Mountains: true Roofed Forest: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Roofed Forest: true + Roofed Forest Mountains: true Mesa: - - Giant Zombie - - Giant Slime - - Giant Lava Slime + Mesa: true + Mesa Bryce: true + Mesa Plateau: true + Mesa Plateau Forest: true + Mesa Plateau Mountains: true + Mesa Plateau Forest Mountains: true Other: - Small Mountains: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Ice Mountains: - - Giant Zombie - - Giant Slime - - Giant Lava Slime - Ocean: '' - River: '' - Hell: '- Giant Lava Slime' - Sky: '' + Small Mountains: true + Ice Mountains: true + Hell: false + Sky: false diff --git a/Giants/src/main/resources/config.yml b/Giants/src/main/resources/config.yml index d726397..ff86717 100644 --- a/Giants/src/main/resources/config.yml +++ b/Giants/src/main/resources/config.yml @@ -1,17 +1,16 @@ Giants Configuration: - File Version: ${project.build.version} - Dependencies: - BarAPI: false + File Version: Version Entities: - Giant Zombie: true + Giant: true Giant Slime: false - Giant Lava Slime: false + Giant Magma Cube: false Giant Jockey: Warning: Bugs: This entity of Giants is extremely experimental and does not have many features. Bugs may be present. Files: Config files for this entity will NOT load unless enabled. - Enabled: true - Sounds: true + Enabled: false Debug Mode: Enabled: false Debug Message: '&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z' + PluginMetrics: + Enabled: true diff --git a/Giants/src/main/resources/entities.yml b/Giants/src/main/resources/entities.yml deleted file mode 100644 index 0440f65..0000000 --- a/Giants/src/main/resources/entities.yml +++ /dev/null @@ -1,67 +0,0 @@ -Entities Configuration: - File Version: ${project.build.version} - Spawn Settings: - Worlds: - Giant Zombie: - - world - - world_nether - - world_the_end - Giant Slime: - - world - - world_nether - - world_the_end - Giant Lava Slime: - - world - - world_nether - - world_the_end - Chance: - Giant Zombie: 10 - Giant Slime: 10 - Giant Lava Slime: 10 - Size: - Giant Slime: 12 - Giant Lava Slime: 12 - Stats: - Health: - Giant Zombie: 100 - Giant Slime: 100 - Giant Lava Slime: 100 - Experience: - Giant Zombie: 5 - Giant Slime: 5 - Giant Lava Slime: 5 - Equipped Armour: - Giant Zombie: - Items: chainmail_helmet:chainmail_chestplate:chainmail_leggings:chainmail_boots:diamond_sword - Equipped Item Drop Rate: 8.5 - Drops: - Giant Zombie: - - 1-0-0;1;100/100;GIANT STONE;Dropped by a Giant Zombie - Giant Slime: - - 1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Slime - Giant Lava Slime: - - 1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Lava Slime - BarAPI: - Display Name: - Giant Zombie: '&2Giant Zombie' - Giant Slime: '&2Giant Slime Size {size}' - Giant Lava Slime: '&2Giant Lava Slime Size {size}' - Damage Settings: - Arrows: - Damage done by arrow: - Giant Zombie: 10 - Giant Slime: 10 - Giant Lava Slime: 10 - Fire: - Allow Fire Damage: - Giant Zombie: true - Giant Slime: true - Block Damage: - Allow Suffocation: - Giant Zombie: false - Giant Slime: false - Giant Lava Slime: false - Allow Cacti Damage: - Giant Zombie: false - Giant Slime: false - Giant Lava Slime: false diff --git a/src/main/resources/giant.yml b/Giants/src/main/resources/giant.yml similarity index 100% rename from src/main/resources/giant.yml rename to Giants/src/main/resources/giant.yml diff --git a/src/main/resources/magmacube.yml b/Giants/src/main/resources/magmacube.yml similarity index 100% rename from src/main/resources/magmacube.yml rename to Giants/src/main/resources/magmacube.yml diff --git a/src/main/resources/slime.yml b/Giants/src/main/resources/slime.yml similarity index 100% rename from src/main/resources/slime.yml rename to Giants/src/main/resources/slime.yml diff --git a/pom.xml b/pom.xml index 70de53d..da5757f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + 4.0.0 me.Mammothskier @@ -10,8 +11,9 @@ v1_8_R1 v1_8_R2 v1_8_R3 + v1_9_R1 Giants - + spigot-repo diff --git a/src/main/java/me/Mammothskier/Giants/utils/API.java b/src/main/java/me/Mammothskier/Giants/utils/API.java new file mode 100644 index 0000000..8519376 --- /dev/null +++ b/src/main/java/me/Mammothskier/Giants/utils/API.java @@ -0,0 +1,165 @@ +package me.Mammothskier.Giants.utils; + +import java.util.List; + +import me.Mammothskier.Giants.Attacks; +import me.Mammothskier.Giants.Commands; +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.events.JockeySpawnEvent; +import me.Mammothskier.Giants.events.SlimeSpawnEvent; +import me.Mammothskier.Giants.files.FileHandler; +import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.listeners.GiantListeners; +import me.Mammothskier.Giants.listeners.MagmaCubeListeners; +import me.Mammothskier.Giants.listeners.SlimeListeners; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; +import org.bukkit.entity.Giant; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Slime; +import org.bukkit.scheduler.BukkitScheduler; + +public class API { + private static Giants _giants; + private Commands commands; + private static FileHandler fileHandler; + private static Attacks Attacks; + private static DropsManager drops; + + public API(Giants giants) { + _giants = giants; + new GiantListeners(_giants); + new SlimeListeners(_giants); + new MagmaCubeListeners(_giants); + commands = new Commands(_giants); + _giants.getCommand("giants").setExecutor(commands); + fileHandler = new FileHandler(_giants); + Attacks = new Attacks(_giants); + drops = new DropsManager(_giants); + + if (getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { + BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); + scheduler.scheduleSyncRepeatingTask(_giants, new Runnable() { + + @Override + public void run() { + for (World world : _giants.getServer().getWorlds()) { + for (Entity entity : world.getEntities()) { + if ((entity instanceof Slime) || (entity instanceof MagmaCube) || (entity instanceof Ghast)) { + for (Entity entity2 : entity.getNearbyEntities(15, 12, 15)) { + if ((entity2 instanceof Giant) && (entity.getPassenger() == null) && (entity2.getVehicle() == null)) { + Entity passenger = entity2; + JockeySpawnEvent JSE = new JockeySpawnEvent(entity, passenger); + Bukkit.getServer().getPluginManager().callEvent(JSE); + } + } + } + } + } + } + }, 0L, 20L); + } + } + + public static boolean isGiant(Entity entity) { + String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant"); + if (config.equalsIgnoreCase("false")){ + return false; + } + return entity instanceof Giant; + } + + public static boolean isGiantSlime(Entity entity) { + String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime"); + if (config.equalsIgnoreCase("false")){ + return false; + } + + if (entity instanceof Slime){ + Slime slime = (Slime) entity; + if ( slime.getSize() > 4){ + return entity instanceof Slime; + } + } + return false; + } + + public static boolean isGiantMagmaCube(Entity entity) { + String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Magma Cube"); + if (config.equalsIgnoreCase("false")){ + return false; + } + if (entity instanceof MagmaCube){ + MagmaCube magmacube = (MagmaCube) entity; + if (magmacube.getSize() > 4){ + return entity instanceof MagmaCube; + } + } + return false; + } + + public static boolean isGiantJockey(Entity entity) { + String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey"); + if (config.equalsIgnoreCase("false")){ + return false; + } + switch (entity.getType()) { + case GIANT: + if ((isGiantSlime(entity.getVehicle())) || (isGiantMagmaCube(entity.getVehicle())) || (entity.getVehicle().getType() == EntityType.GHAST)) { + return true; + } + break; + case SLIME: + if ((isGiantSlime(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { + return true; + } + break; + case MAGMA_CUBE: + if ((isGiantMagmaCube(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { + return true; + } + break; + case GHAST: + if (entity.getPassenger().getType() == EntityType.GIANT) { + return true; + } + break; + default: + break; + } + return false; + } + + public static List getGiantSpawnWorlds() { + return getFileHandler().getPropertyList(Files.GIANT, "Giant Configuration.Spawn Settings.Worlds"); + } + + public static List getSlimeSpawnWorlds() { + return getFileHandler().getPropertyList(Files.SLIME, "Slime Configuration.Spawn Settings.Worlds"); + } + + public static List getMagmaCubeSpawnWorlds() { + return getFileHandler().getPropertyList(Files.MAGMACUBE, "Magma Cube Configuration.Spawn Settings.Worlds"); + } + + public static List getJockeySpawnWorlds() { + return getFileHandler().getPropertyList(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds"); + } + + public static FileHandler getFileHandler() { + return fileHandler; + } + + public static Attacks createAttack() { + return Attacks; + } + + public static DropsManager createDrop() { + return drops; + } +} diff --git a/src/main/resources/biomes.yml b/src/main/resources/biomes.yml deleted file mode 100644 index 0f1b9e7..0000000 --- a/src/main/resources/biomes.yml +++ /dev/null @@ -1,77 +0,0 @@ -Slime Configuration: - File Version: Version - Biome Settings: - Swampland: - Swampland: true - Swampland Mountains: true - Forest: - Forest: true - Forest Hills: true - Taiga: - Taiga: true - Taiga Hills: true - Taiga Mountains: true - Cold Taiga: true - Cold Taiga Hills: true - Cold Taiga Mountains: true - Mega Taiga: true - Mega Taiga Hills: true - Mega Spruce Taiga: true - Mega Spruce Taiga Hills: true - Plains: - Plains: true - Ice Plains: true - Ice Plains Spikes: true - Sunflower Plains: true - Ocean: - Ocean: false - Deep Ocean: false - Frozen Ocean: true - River: - River: true - Frozen River: true - Beach: - Beach: true - Stone Beach: true - Cold Beach: true - Extreme Hills: - Extreme Hills: true - Extreme Hills Plus: true - Extreme Hills Mountains: true - Extreme Hills Plus Mountains: true - Mushroom Island: - Mushroom Island: true - Mushroom Shore: true - Desert: - Desert: true - Desert Hills: true - Desert Mountains: true - Jungle: - Jungle: true - Jungle Hills: true - Jungle Mountains: true - Birch Forest: - Birch Forest: true - Birch Forest Hills: true - Birch Forest Mountains: true - Birch Forest Hills Mountains: true - Savanna: - Savanna: true - Savanna Mountains: true - Savanna Plateau: true - Savanna Plateau Mountains: true - Roofed Forest: - Roofed Forest: true - Roofed Forest Mountains: true - Mesa: - Mesa: true - Mesa Bryce: true - Mesa Plateau: true - Mesa Plateau Forest: true - Mesa Plateau Mountains: true - Mesa Plateau Forest Mountains: true - Other: - Small Mountains: true - Ice Mountains: true - Hell: false - Sky: false diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml deleted file mode 100644 index ff86717..0000000 --- a/src/main/resources/config.yml +++ /dev/null @@ -1,16 +0,0 @@ -Giants Configuration: - File Version: Version - Entities: - Giant: true - Giant Slime: false - Giant Magma Cube: false - Giant Jockey: - Warning: - Bugs: This entity of Giants is extremely experimental and does not have many features. Bugs may be present. - Files: Config files for this entity will NOT load unless enabled. - Enabled: false - Debug Mode: - Enabled: false - Debug Message: '&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z' - PluginMetrics: - Enabled: true diff --git a/src/main/resources/jockey.yml b/src/main/resources/jockey.yml deleted file mode 100644 index 22f9191..0000000 --- a/src/main/resources/jockey.yml +++ /dev/null @@ -1,6 +0,0 @@ -Jockey Configuration: - Spawn Settings: - Worlds: - - world - - world_nether - - world_the_end diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..0b17c97 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,31 @@ +name: Giants +main: me.Mammothskier.Giants.Giants +version: ${project.build.version} +author: Mammothskier +softdepend: [BarAPI] + +commands: + giants: + description: Shows list of commands. + +permissions: + giants.*: + description: Gives all permissions. + default: false + children: + giants.reload: true + giants.debug: true + giants.spawn: true + giants.barAPI: true + giants.reload: + description: Reloads the config file. + default: false + giants.debug: + description: Shows Debug messages. + default: false + giants.spawn: + description: Spawns a Giant at the given location. + default: false + giants.barAPI: + description: Allows access to the barAPI features. + default: false \ No newline at end of file diff --git a/v1_7_R3/dependency-reduced-pom.xml b/v1_7_R3/dependency-reduced-pom.xml new file mode 100644 index 0000000..5720695 --- /dev/null +++ b/v1_7_R3/dependency-reduced-pom.xml @@ -0,0 +1,27 @@ + + + + Giants-Parent + me.Mammothskier + 7.0 + + 4.0.0 + Giants-v1_7_R3 + Giants for v1_7_R3 + v1 + + + org.bukkit + bukkit + 1.7.9-R0.2 + compile + + + org.bukkit + craftbukkit + 1.7.9-R0.2 + compile + + + + diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index e84dc8b..9e82f9a 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -26,5 +26,18 @@ 1.7.9-R0.2 jar + + + me.Mammothskier + Giants + 7.0-Beta + + + org.bukkit + craftbukkit + + + true + \ No newline at end of file diff --git a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java index 61a701f..cf4032d 100644 --- a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java +++ b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java @@ -4,6 +4,8 @@ import org.bukkit.craftbukkit.v1_7_R3.util.UnsafeList; +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_7_R3.EntityGiantZombie; import net.minecraft.server.v1_7_R3.EntityHuman; import net.minecraft.server.v1_7_R3.EntityIronGolem; @@ -60,9 +62,16 @@ public float getHeadHeight() { @Override protected void aC() { super.aW(); + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } this.getAttributeInstance(GenericAttributes.b).setValue(35D); this.getAttributeInstance(GenericAttributes.a).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D * speed); this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); } diff --git a/v1_7_R4/dependency-reduced-pom.xml b/v1_7_R4/dependency-reduced-pom.xml new file mode 100644 index 0000000..611f69c --- /dev/null +++ b/v1_7_R4/dependency-reduced-pom.xml @@ -0,0 +1,21 @@ + + + + Giants-Parent + me.Mammothskier + 7.0-SNAPSHOT + + 4.0.0 + Giants-v1_7_R4 + Giants for v1_7_R4 + v1 + + + org.bukkit + craftbukkit + 1.7.10-R0.1-SNAPSHOT + compile + + + + diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml index 5c14a2f..e595c71 100644 --- a/v1_7_R4/pom.xml +++ b/v1_7_R4/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0 + 7.0-SNAPSHOT @@ -19,5 +19,17 @@ 1.7.10-R0.1-SNAPSHOT jar + + me.Mammothskier + Giants + 7.0-Beta + + + org.bukkit + craftbukkit + + + true + \ No newline at end of file diff --git a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java index 76c0874..63ad06a 100644 --- a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java +++ b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java @@ -4,6 +4,8 @@ import org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList; +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_7_R4.EntityGiantZombie; import net.minecraft.server.v1_7_R4.EntityHuman; import net.minecraft.server.v1_7_R4.EntityIronGolem; @@ -60,9 +62,16 @@ public float getHeadHeight() { @Override protected void aD() { super.aW(); + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } this.getAttributeInstance(GenericAttributes.b).setValue(35D); this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D * speed); this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); } diff --git a/v1_8_R1/dependency-reduced-pom.xml b/v1_8_R1/dependency-reduced-pom.xml new file mode 100644 index 0000000..3bd239d --- /dev/null +++ b/v1_8_R1/dependency-reduced-pom.xml @@ -0,0 +1,21 @@ + + + + Giants-Parent + me.Mammothskier + 7.0-SNAPSHOT + + 4.0.0 + Giants-v1_8_R1 + Giants for v1_8_R1 + v1 + + + org.bukkit + craftbukkit + 1.8-R0.1-SNAPSHOT + compile + + + + diff --git a/v1_8_R1/pom.xml b/v1_8_R1/pom.xml index ef39ed1..6bdac50 100644 --- a/v1_8_R1/pom.xml +++ b/v1_8_R1/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0 + 7.0-SNAPSHOT @@ -19,5 +19,17 @@ 1.8-R0.1-SNAPSHOT jar + + me.Mammothskier + Giants + 7.0-Beta + + + org.bukkit + craftbukkit + + + true + \ No newline at end of file diff --git a/v1_8_R2/dependency-reduced-pom.xml b/v1_8_R2/dependency-reduced-pom.xml new file mode 100644 index 0000000..4d08d71 --- /dev/null +++ b/v1_8_R2/dependency-reduced-pom.xml @@ -0,0 +1,33 @@ + + + + Giants-Parent + me.Mammothskier + 7.0-SNAPSHOT + + 4.0.0 + Giants-v1_8_R2 + Giants for v1_8_R2 + v1 + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + + org.bukkit + bukkit + 1.8.3-R0.1-SNAPSHOT + compile + + + org.bukkit + craftbukkit + 1.8.3-R0.1-SNAPSHOT + compile + + + + diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml index 8068a19..02cf3e9 100644 --- a/v1_8_R2/pom.xml +++ b/v1_8_R2/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0 + 7.0-SNAPSHOT @@ -25,6 +25,18 @@ 1.8.3-R0.1-SNAPSHOT jar + + me.Mammothskier + Giants + 7.0-Beta + + + org.bukkit + craftbukkit + + + true + diff --git a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java index a2fa6a2..cc37df5 100644 --- a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java +++ b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java @@ -4,6 +4,8 @@ import org.bukkit.craftbukkit.v1_8_R2.util.UnsafeList; +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_8_R2.EntityGiantZombie; import net.minecraft.server.v1_8_R2.EntityHuman; import net.minecraft.server.v1_8_R2.EntityIronGolem; @@ -61,9 +63,16 @@ public float getHeadHeight() { @Override protected void initAttributes() { super.initAttributes(); + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } this.getAttributeInstance(GenericAttributes.b).setValue(35D); this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D * speed); this.getAttributeInstance(GenericAttributes.e).setValue(50.0D); } diff --git a/v1_8_R3/dependency-reduced-pom.xml b/v1_8_R3/dependency-reduced-pom.xml new file mode 100644 index 0000000..3c62771 --- /dev/null +++ b/v1_8_R3/dependency-reduced-pom.xml @@ -0,0 +1,21 @@ + + + + Giants-Parent + me.Mammothskier + 7.0-SNAPSHOT + + 4.0.0 + Giants-v1_8_R3 + Giants for v1_8_R3 + v1 + + + org.bukkit + craftbukkit + 1.8.7-R0.1-SNAPSHOT + compile + + + + diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index a2d4dff..73c890d 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0 + 7.0-SNAPSHOT @@ -19,5 +19,17 @@ 1.8.7-R0.1-SNAPSHOT jar + + me.Mammothskier + Giants + 7.0-Beta + + + org.bukkit + craftbukkit + + + true + \ No newline at end of file diff --git a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java index deec0c4..1a4ec2a 100644 --- a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java +++ b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java @@ -4,6 +4,8 @@ import org.bukkit.craftbukkit.v1_8_R3.util.UnsafeList; +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_8_R3.EntityGiantZombie; import net.minecraft.server.v1_8_R3.EntityHuman; import net.minecraft.server.v1_8_R3.EntityIronGolem; @@ -61,9 +63,16 @@ public float getHeadHeight() { @Override protected void initAttributes() { super.initAttributes(); + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.5D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); } @@ -71,7 +80,6 @@ protected void n() { this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1.0D, true)); this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); - this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml new file mode 100644 index 0000000..c45b910 --- /dev/null +++ b/v1_9_R1/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + + Giants for v1_9_R1 + Giants-v1_9_R1 + v1 + jar + + + me.Mammothskier + Giants-Parent + 7.0-SNAPSHOT + + + + + org.bukkit + craftbukkit + 1.9-R0.1-SNAPSHOT + jar + + + + me.Mammothskier + Giants + 7.0-Beta + + + org.bukkit + craftbukkit + + + true + + + + \ No newline at end of file diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java new file mode 100644 index 0000000..2d24170 --- /dev/null +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -0,0 +1,87 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R1; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_9_R1.util.UnsafeList; + +import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.files.Files; +//import me.Mammothskier.Giants.files.ConfigValues; + +import net.minecraft.server.v1_9_R1.EntityGiantZombie; +import net.minecraft.server.v1_9_R1.EntityHuman; +import net.minecraft.server.v1_9_R1.EntityIronGolem; +import net.minecraft.server.v1_9_R1.EntityPigZombie; +import net.minecraft.server.v1_9_R1.EntitySkeleton; +import net.minecraft.server.v1_9_R1.EntityVillager; +import net.minecraft.server.v1_9_R1.EntityZombie; +import net.minecraft.server.v1_9_R1.PathfinderGoalFloat; +import net.minecraft.server.v1_9_R1.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_9_R1.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_9_R1.PathfinderGoalMeleeAttack; +import net.minecraft.server.v1_9_R1.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_9_R1.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_9_R1.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_9_R1.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_9_R1.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_9_R1.PathfinderGoalSelector; +import net.minecraft.server.v1_9_R1.PathfinderGoalZombieAttack; +import net.minecraft.server.v1_9_R1.World; +import net.minecraft.server.v1_9_R1.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + //this.goalSelector.a(2, new PathfinderGoalZombieAttack((EntityZombie) this, 1.0D, false)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + @Override + protected void initAttributes() { + super.initAttributes(); + String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } + this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); + this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); + } + + protected void o() { + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); +// if (Giants.getProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } +} diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityType.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityType.java new file mode 100644 index 0000000..21d1b4b --- /dev/null +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R1; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_9_R1.BiomeBase; +import net.minecraft.server.v1_9_R1.BiomeBase.BiomeMeta; +import net.minecraft.server.v1_9_R1.Entity; +import net.minecraft.server.v1_9_R1.EntityInsentient; +import net.minecraft.server.v1_9_R1.EntityTypes; +import net.minecraft.server.v1_9_R1.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.i){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "u", "v", "w", "x" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "u", "v", "w", "x" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/EntityCreator.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/EntityCreator.java new file mode 100644 index 0000000..9449ee3 --- /dev/null +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/EntityCreator.java @@ -0,0 +1,17 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R1; + +import net.minecraft.server.v1_9_R1.World; + +import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} From 191ebf66840399396366c7c30324d5b819ee212e Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 6 Jun 2016 06:13:30 -0700 Subject: [PATCH 04/28] 1.9 giants update --- Giants-Files/pom.xml | 31 ++ .../Giants/Files}/ConfigValues.java | 94 ++--- .../Giants/Files}/FileHandler.java | 81 ++--- .../Mammothskier/Giants/Files/FileSetup.java | 62 ++++ .../me/Mammothskier/Giants/Files}/Files.java | 2 +- .../test/java/org/Giants/Files/AppTest.java | 38 ++ Giants/dependency-reduced-pom.xml | 4 +- Giants/pom.xml | 23 +- .../Mammothskier/Giants/BarAPI/HealthBar.java | 2 +- .../java/me/Mammothskier/Giants/Commands.java | 2 +- .../java/me/Mammothskier/Giants/Giants.java | 8 +- .../Giants/entity/DamageListener.java | 24 +- .../Giants/entity/DropsManager.java | 123 ++----- .../Mammothskier/Giants/entity/Entities.java | 53 ++- .../Giants/entity/GiantListeners.java | 89 +++-- .../Giants/entity/MagmaCubeListeners.java | 77 ++-- .../Giants/entity/SlimeListeners.java | 45 ++- .../Giants/events/JockeySpawnEvent.java | 328 +++--------------- .../Giants/events/SpawnEvent.java | 4 +- .../me/Mammothskier/Giants/util/NMSUtils.java | 5 +- pom.xml | 22 +- .../me/Mammothskier/Giants/utils/API.java | 165 --------- src/main/resources/plugin.yml | 31 -- v1_7_R3/dependency-reduced-pom.xml | 27 -- v1_7_R3/pom.xml | 14 +- .../nms/v1_7_R3/CustomEntityGiantZombie.java | 4 +- v1_7_R4/pom.xml | 15 +- .../nms/v1_7_R4/CustomEntityGiantZombie.java | 4 +- v1_8_R1/pom.xml | 15 +- v1_8_R2/pom.xml | 14 +- .../nms/v1_8_R2/CustomEntityGiantZombie.java | 4 +- v1_8_R3/pom.xml | 14 +- .../nms/v1_8_R3/CustomEntityGiantZombie.java | 4 +- v1_9_R1/pom.xml | 7 +- .../nms/v1_9_R1/CustomEntityGiantZombie.java | 24 +- ...CustomPathfinderGoalGiantZombieAttack.java | 38 ++ 36 files changed, 580 insertions(+), 917 deletions(-) create mode 100644 Giants-Files/pom.xml rename {Giants/src/main/java/me/Mammothskier/Giants/files => Giants-Files/src/main/java/me/Mammothskier/Giants/Files}/ConfigValues.java (78%) rename {Giants/src/main/java/me/Mammothskier/Giants/files => Giants-Files/src/main/java/me/Mammothskier/Giants/Files}/FileHandler.java (88%) create mode 100644 Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java rename {Giants/src/main/java/me/Mammothskier/Giants/files => Giants-Files/src/main/java/me/Mammothskier/Giants/Files}/Files.java (91%) create mode 100644 Giants-Files/src/test/java/org/Giants/Files/AppTest.java delete mode 100644 src/main/java/me/Mammothskier/Giants/utils/API.java delete mode 100644 src/main/resources/plugin.yml delete mode 100644 v1_7_R3/dependency-reduced-pom.xml create mode 100644 v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomPathfinderGoalGiantZombieAttack.java diff --git a/Giants-Files/pom.xml b/Giants-Files/pom.xml new file mode 100644 index 0000000..4aece86 --- /dev/null +++ b/Giants-Files/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + me.Mammothskier + Giants-Parent + 7.1-SNAPSHOT + + + Giants-Files + 1.0-SNAPSHOT + Giants-Files + jar + + + + org.bukkit + bukkit + 1.9.4-R0.1-SNAPSHOT + jar + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java similarity index 78% rename from Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java rename to Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java index 83c57c0..5202d81 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/files/ConfigValues.java +++ b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java @@ -1,4 +1,4 @@ -package me.Mammothskier.Giants.files; +package me.Mammothskier.Giants.Files; import java.util.Arrays; import java.util.List; @@ -16,7 +16,7 @@ public enum ConfigValues { /** * These file values will go in the config.yml file. */ - dependencies(Files.CONFIG, "Giants Configuration.Dependencies.BarAPI", FileHandler.checkDependencies("BarAPI")), + dependencies(Files.CONFIG, "Giants Configuration.Dependencies.BarAPI", FileSetup.checkDependencies("BarAPI")), zombieBoolean(Files.CONFIG,"Giants Configuration.Entities.Giant Zombie", true), slimeBoolean(Files.CONFIG, "Giants Configuration.Entities.Giant Slime", false), lavaSlimeBoolean(Files.CONFIG, "Giants Configuration.Entities.Giant Lava Slime", false), @@ -30,20 +30,20 @@ public enum ConfigValues { /** * These file values will go in the biome.yml file. */ - biomeSwampland(Files.BIOMES,"Giants Configuration.Biome Settings.Swampland", FileHandler.loadEntities()), - biomeForest(Files.BIOMES, "Giants Configuration.Biome Settings.Forest", FileHandler.loadEntities()), - biomeTaiga(Files.BIOMES, "Giants Configuration.Biome Settings.Taiga", FileHandler.loadEntities()), - biomePlains(Files.BIOMES, "Giants Configuration.Biome Settings.Plains", FileHandler.loadEntities()), - biomeExtremeHills(Files.BIOMES, "Giants Configuration.Biome Settings.Extreme Hills", FileHandler.loadEntities()), - biomeMushroomIsland(Files.BIOMES, "Giants Configuration.Biome Settings.Mushroom Island", FileHandler.loadEntities()), - biomeDesert(Files.BIOMES, "Giants Configuration.Biome Settings.Desert", FileHandler.loadEntities()), - biomeJungle(Files.BIOMES, "Giants Configuration.Biome Settings.Jungle", FileHandler.loadEntities()), - biomeBirchForest(Files.BIOMES, "Giants Configuration.Biome Settings.Birch Forest", FileHandler.loadEntities()), - biomeSavanna(Files.BIOMES, "Giants Configuration.Biome Settings.Savanna", FileHandler.loadEntities()), - biomeRoofedForest(Files.BIOMES, "Giants Configuration.Biome Settings.Roofed Forest",FileHandler.loadEntities()), - biomeMesa(Files.BIOMES, "Giants Configuration.Biome Settings.Mesa",FileHandler.loadEntities()), - biomeSmallMountains(Files.BIOMES,"Giants Configuration.Biome Settings.Other.Small Mountains",FileHandler.loadEntities()), - biomeIceMountains(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains",FileHandler.loadEntities()), + biomeSwampland(Files.BIOMES,"Giants Configuration.Biome Settings.Swampland", FileSetup.loadEntities()), + biomeForest(Files.BIOMES, "Giants Configuration.Biome Settings.Forest", FileSetup.loadEntities()), + biomeTaiga(Files.BIOMES, "Giants Configuration.Biome Settings.Taiga", FileSetup.loadEntities()), + biomePlains(Files.BIOMES, "Giants Configuration.Biome Settings.Plains", FileSetup.loadEntities()), + biomeExtremeHills(Files.BIOMES, "Giants Configuration.Biome Settings.Extreme Hills", FileSetup.loadEntities()), + biomeMushroomIsland(Files.BIOMES, "Giants Configuration.Biome Settings.Mushroom Island", FileSetup.loadEntities()), + biomeDesert(Files.BIOMES, "Giants Configuration.Biome Settings.Desert", FileSetup.loadEntities()), + biomeJungle(Files.BIOMES, "Giants Configuration.Biome Settings.Jungle", FileSetup.loadEntities()), + biomeBirchForest(Files.BIOMES, "Giants Configuration.Biome Settings.Birch Forest", FileSetup.loadEntities()), + biomeSavanna(Files.BIOMES, "Giants Configuration.Biome Settings.Savanna", FileSetup.loadEntities()), + biomeRoofedForest(Files.BIOMES, "Giants Configuration.Biome Settings.Roofed Forest",FileSetup.loadEntities()), + biomeMesa(Files.BIOMES, "Giants Configuration.Biome Settings.Mesa",FileSetup.loadEntities()), + biomeSmallMountains(Files.BIOMES,"Giants Configuration.Biome Settings.Other.Small Mountains",FileSetup.loadEntities()), + biomeIceMountains(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains",FileSetup.loadEntities()), biomeOcean(Files.BIOMES, "Giants Configuration.Biome Settings.Other.Ocean", ""), biomeRiver(Files.BIOMES, "Giants Configuration.Biome Settings.Other.River", ""), biomeHell(Files.BIOMES,"Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"), @@ -53,9 +53,13 @@ public enum ConfigValues { * These file values will go in the entities.yml file. */ //Worlds - zombieWorld(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Zombie", FileHandler.loadWorlds()), - slimeWorld(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Slime", FileHandler.loadWorlds()), - lavaslimeWorld(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Lava Slime", FileHandler.loadWorlds()), + zombieWorlds(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Zombie", FileSetup.loadWorlds()), + slimeWorlds(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Slime", FileSetup.loadWorlds()), + lavaslimeWorlds(Files.ENTITIES, "Entities Configuration.Spawn Settings.World.Giant Lava Slime", FileSetup.loadWorlds()), +//Spawn chance + zombieChance(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Zombie", new Integer(10)), + slimeChance(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Slime", new Integer(10)), + lavaSlimeChance(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Lava Slime", new Integer(10)), //Size slimeSize(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime", new Integer(12)), lavaSlimeSize(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime", new Integer(12)), @@ -75,9 +79,9 @@ public enum ConfigValues { armourDropRate(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate", new Float(8.5)), //Drops dropManager(Files.ENTITIES, "Entities Configuration.Stats.Drops.Enable Drop Manager", true), - zombieDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie", Arrays.asList(FileHandler.loadDefaultDrop("Giant Zombie"))), - slimeDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Slime", Arrays.asList(FileHandler.loadDefaultDrop("Giant Slime"))), - lavaSlimeDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Lava Slime", Arrays.asList(FileHandler.loadDefaultDrop("Giant Lava Slime"))), + zombieDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie", Arrays.asList(FileSetup.loadDefaultDrop("Giant Zombie"))), + slimeDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Slime", Arrays.asList(FileSetup.loadDefaultDrop("Giant Slime"))), + lavaSlimeDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Lava Slime", Arrays.asList(FileSetup.loadDefaultDrop("Giant Lava Slime"))), //BarAPI zombieBarAPI(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Zombie", "&2Giant Zombie"), slimeBarAPI(Files.ENTITIES, "Entities Configuration.Stats.BarAPI.Display Name.Giant Slime", "&2Giant Slime Size {size}"), @@ -100,17 +104,17 @@ public enum ConfigValues { /** * These file values will go in attacks.yml */ - lightningAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack", FileHandler.loadEntities()), - stompAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled", FileHandler.loadEntities()), + lightningAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack", FileSetup.loadEntities()), + stompAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled", FileSetup.loadEntities()), stompAttackPower(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)), - stompAttackFire(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire", FileHandler.loadEntities()), - lavaAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lava Attack", FileHandler.loadEntities()), - kickAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled", FileHandler.loadEntities()), + stompAttackFire(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire", FileSetup.loadEntities()), + lavaAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lava Attack", FileSetup.loadEntities()), + kickAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled", FileSetup.loadEntities()), kickAttackHeight(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height", new Integer(1)), - fireAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled", FileHandler.loadEntities()), + fireAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled", FileSetup.loadEntities()), fireAttackTargetTicks(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target", new Integer(100)), fireAttackGiantTicks(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant", new Integer(100)), - bouldAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", FileHandler.loadEntities()), + boulderAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled", FileSetup.loadEntities()), bouldAttackBlockDamage(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage", new Integer(1)), shrapnelAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Enabled", Arrays.asList("Giant Zombie")), shrapnelAttackBabies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies", false), @@ -120,30 +124,32 @@ public enum ConfigValues { zombiesOnDeathBabies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies", false), zombiesOnDeathZombies(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn", new Integer(5)), zombiesOnDeathHealth(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20)), + poisonAttack(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Poison Attack", FileSetup.loadEntities()), + poisonAttackLength(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Poison Attack.length", "10.0"), /** * These file values will go in jockey.yml */ jockeyWarning(Files.JOCKEY, "Jockey Configuration", new String("This entity of Giants is extremely experimental and does not have many features")), - jockeyWorlds(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds", FileHandler.loadWorlds()), + jockeyWorlds(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds", FileSetup.loadWorlds()), /** * The file values will go in jockey/biomes.yml */ - jockeyBiomeSwampland(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Swampland", FileHandler.loadEntities()), - jockeyBiomeForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Forest", FileHandler.loadEntities()), - jockeyBiomeTaiga(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Taiga", FileHandler.loadEntities()), - jockeyBiomePlains(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Plains", FileHandler.loadEntities()), - jockeyBiomeExtremeHills(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Extreme Hills", FileHandler.loadEntities()), - jockeyBiomeMushroomIsland(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Mushroom Island", FileHandler.loadEntities()), - jockeyBiomeDesert(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Desert", FileHandler.loadEntities()), - jockeyBiomeJungle(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Jungle", FileHandler.loadEntities()), - jockeyBiomeBirchForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Birch Forest", FileHandler.loadEntities()), - jockeyBiomeSavanna(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Savanna", FileHandler.loadEntities()), - jockeyBiomeRoofedForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Roofed Forest",FileHandler.loadEntities()), - jockeyBiomeMesa(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Mesa",FileHandler.loadEntities()), - jockeyBiomeSmallMountains(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Other.Small Mountains",FileHandler.loadEntities()), - jockeyBiomeIceMountains(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains",FileHandler.loadEntities()), + jockeyBiomeSwampland(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Swampland", FileSetup.loadEntities()), + jockeyBiomeForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Forest", FileSetup.loadEntities()), + jockeyBiomeTaiga(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Taiga", FileSetup.loadEntities()), + jockeyBiomePlains(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Plains", FileSetup.loadEntities()), + jockeyBiomeExtremeHills(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Extreme Hills", FileSetup.loadEntities()), + jockeyBiomeMushroomIsland(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Mushroom Island", FileSetup.loadEntities()), + jockeyBiomeDesert(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Desert", FileSetup.loadEntities()), + jockeyBiomeJungle(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Jungle", FileSetup.loadEntities()), + jockeyBiomeBirchForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Birch Forest", FileSetup.loadEntities()), + jockeyBiomeSavanna(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Savanna", FileSetup.loadEntities()), + jockeyBiomeRoofedForest(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Roofed Forest",FileSetup.loadEntities()), + jockeyBiomeMesa(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Mesa",FileSetup.loadEntities()), + jockeyBiomeSmallMountains(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Other.Small Mountains",FileSetup.loadEntities()), + jockeyBiomeIceMountains(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.Ice Mountains",FileSetup.loadEntities()), jockeyBiomeOcean(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.Ocean", ""), jockeyBiomeRiver(Files.JOCKEYBIOMES, "Giants Configuration.Biome Settings.Other.River", ""), jockeyBiomeHell(Files.JOCKEYBIOMES,"Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"), diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java similarity index 88% rename from Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java rename to Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java index 6f3dd5f..3dfd6a7 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/files/FileHandler.java +++ b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java @@ -1,9 +1,8 @@ -package me.Mammothskier.Giants.files; +package me.Mammothskier.Giants.Files; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -11,33 +10,17 @@ import org.bukkit.World; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.PluginDescriptionFile; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.Files.Files; public class FileHandler { - private final Giants _giants; + public static FileHandler instance; private final HashMap _configurations; - public FileHandler(Giants giants) { - _giants = giants; + public FileHandler() { + instance = this; _configurations = new HashMap(); - loadWorlds(); loadFiles(); - loadVersion(); - loadDefaultDrop("Giant"); - loadDefaultDrop("Slime"); - loadDefaultDrop("MagmaCube"); - } - - public String loadVersion() { - PluginDescriptionFile pdf = _giants.getDescription(); - String version = pdf.getVersion(); - if (version == null) { - return null; - } - return version; } public static List loadWorlds() { @@ -48,38 +31,16 @@ public static List loadWorlds() { return worldList; } - public static boolean checkDependencies(String plugin) { + public static String getInstanceProperty(ConfigValues value) { + return instance != null ? instance.getProperty(value) : null; + } + +/* public static boolean checkDependencies(String plugin) { if (Bukkit.getPluginManager().getPlugin(plugin) != null) { return true; } return false; - } - - static String[] loadDefaultDrop(String arg) { - String[] drops = null; - switch(arg){ - case "Giant Zombie": - drops = new String[]{ "1-0-0;1;100/100;GIANT STONE;Dropped by a Giant Zombie" }; - break; - case "Giant Slime": - drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Slime" }; - break; - case "Giant Lava Slime": - drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Lava Slime" }; - break; - default: - break; - } - return drops; - } - - public static List loadEntities() { - List list = new ArrayList(); - list.add("Giant Zombie"); - list.add("Giant Slime"); - list.add("Giant Lava Slime"); - return list; - } + }*/ public void loadFiles() { for (Files file : Files.values()) { @@ -106,7 +67,7 @@ private void createFiles(Files files, File file) { switch (files) { case CONFIG: YamlConfiguration Config = YamlConfiguration.loadConfiguration(file); - Config.set("Giants Configuration.File Version", loadVersion()); + /*Config.set("Giants Configuration.File Version", loadVersion()); Config.set("Giants Configuration.Dependencies.BarAPI", checkDependencies("BarAPI")); Config.set("Giants Configuration.Entities.Giant Zombie", true); Config.set("Giants Configuration.Entities.Giant Slime", false); @@ -116,7 +77,7 @@ private void createFiles(Files files, File file) { Config.set("Giants Configuration.Entities.Giant Jockey.Warning.Enabled", false); Config.set("Giants Configuration.Sounds", true); Config.set("Giants Configuration.Debug Mode.Enabled", false); - Config.set("Giants Configuration.Debug Mode.Debug Message", "&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z"); + Config.set("Giants Configuration.Debug Mode.Debug Message", "&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z");*/ try { Config.save(file); } catch (IOException e) { @@ -125,7 +86,7 @@ private void createFiles(Files files, File file) { break; case BIOMES: YamlConfiguration Biomes = YamlConfiguration.loadConfiguration(file); - Biomes.set("Giants Configuration.File Version", loadVersion()); + /*Biomes.set("Giants Configuration.File Version", loadVersion()); Biomes.set("Giants Configuration.Biome Settings.Swampland", loadEntities()); Biomes.set("Giants Configuration.Biome Settings.Forest", loadEntities()); Biomes.set("Giants Configuration.Biome Settings.Taiga", loadEntities()); @@ -143,7 +104,7 @@ private void createFiles(Files files, File file) { Biomes.set("Giants Configuration.Biome Settings.Other.Ocean", ""); Biomes.set("Giants Configuration.Biome Settings.Other.River", ""); Biomes.set("Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"); - Biomes.set("Giants Configuration.Biome Settings.Other.Sky", ""); + Biomes.set("Giants Configuration.Biome Settings.Other.Sky", "");*/ try { Biomes.save(file); } catch (IOException e) { @@ -152,7 +113,7 @@ private void createFiles(Files files, File file) { break; case ENTITIES: YamlConfiguration entities = YamlConfiguration.loadConfiguration(file); - entities.set("Entities Configuration.File Version", loadVersion()); +/* entities.set("Entities Configuration.File Version", loadVersion()); // Worlds entities.set("Entities Configuration.Spawn Settings.Worlds.Giant Zombie", loadWorlds()); entities.set("Entities Configuration.Spawn Settings.Worlds.Giant Slime", loadWorlds()); @@ -198,7 +159,7 @@ private void createFiles(Files files, File file) { entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Lava Slime",false); entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Zombie", false); entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Slime", false); - entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime", false); + entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime", false);*/ try { entities.save(file); } catch (IOException e) { @@ -208,7 +169,7 @@ private void createFiles(Files files, File file) { case ATTACKS: YamlConfiguration attacks = YamlConfiguration.loadConfiguration(file); - attacks.set("Attacks Configuration.File Version", loadVersion()); + /*attacks.set("Attacks Configuration.File Version", loadVersion()); attacks.set("Attacks Configuration.Attack Mechanisms.Lightning Attack", loadEntities()); attacks.set("Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled", loadEntities()); attacks.set("Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power", new Integer(1)); @@ -228,7 +189,7 @@ private void createFiles(Files files, File file) { attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled", false); attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies", false); attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn", new Integer(5)); - attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20)); + attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20));*/ try { attacks.save(file); } catch (IOException e) { @@ -238,7 +199,7 @@ private void createFiles(Files files, File file) { case JOCKEY: if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { YamlConfiguration Jockey = YamlConfiguration.loadConfiguration(file); - Jockey.set("Jockey Configuration.File Version", loadVersion()); + Jockey.set("Jockey Configuration.File Version", FileSetup.loadVersion()); Jockey.set("Jockey Configuration", new String("This entity of Giants is extremely experimental and does not have many features")); Jockey.set("Jockey Configuration.Spawn Settings.Worlds", loadWorlds()); try { @@ -251,7 +212,7 @@ private void createFiles(Files files, File file) { case JOCKEYBIOMES: if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { YamlConfiguration JockeyBiomes = YamlConfiguration.loadConfiguration(file); - JockeyBiomes.set("Giants Configuration.File Version", loadVersion()); + JockeyBiomes.set("Giants Configuration.File Version", FileSetup.loadVersion()); JockeyBiomes.set("Giants Configuration.Biome Settings.Swampland", true); JockeyBiomes.set("Giants Configuration.Biome Settings.Forest", true); JockeyBiomes.set("Giants Configuration.Biome Settings.Taiga", true); diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java new file mode 100644 index 0000000..5682567 --- /dev/null +++ b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java @@ -0,0 +1,62 @@ +package me.Mammothskier.Giants.Files; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.plugin.PluginDescriptionFile; + +public class FileSetup { + + public static String loadVersion() { + PluginDescriptionFile pdf = Bukkit.getPluginManager().getPlugin("Giants").getDescription(); + String version = pdf.getVersion(); + if (version == null) { + return null; + } + return version; + } + + public static List loadWorlds() { + List worldList = new ArrayList(); + for (World w : Bukkit.getServer().getWorlds()) { + worldList.add(w.getName()); + } + return worldList; + } + + + public static String[] loadDefaultDrop(String arg) { + String[] drops = null; + switch(arg){ + case "Giant Zombie": + drops = new String[]{ "1-0-0;1;100/100;GIANT STONE;Dropped by a Giant Zombie" }; + break; + case "Giant Slime": + drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Slime" }; + break; + case "Giant Lava Slime": + drops = new String[]{ "1-0-0;1;100/100;4-12;GIANT STONE;Dropped by a Giant Lava Slime" }; + break; + default: + break; + } + return drops; + } + + public static List loadEntities() { + List list = new ArrayList(); + list.add("Giant Zombie"); + list.add("Giant Slime"); + list.add("Giant Lava Slime"); + return list; + } + + public static boolean checkDependencies(String plugin) { + if (Bukkit.getPluginManager().getPlugin(plugin) != null) { + return true; + } + return false; + } +} diff --git a/Giants/src/main/java/me/Mammothskier/Giants/files/Files.java b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/Files.java similarity index 91% rename from Giants/src/main/java/me/Mammothskier/Giants/files/Files.java rename to Giants-Files/src/main/java/me/Mammothskier/Giants/Files/Files.java index c35ece2..847aaed 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/files/Files.java +++ b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/Files.java @@ -1,4 +1,4 @@ -package me.Mammothskier.Giants.files; +package me.Mammothskier.Giants.Files; public enum Files { CONFIG("plugins/Giants/config.yml"), diff --git a/Giants-Files/src/test/java/org/Giants/Files/AppTest.java b/Giants-Files/src/test/java/org/Giants/Files/AppTest.java new file mode 100644 index 0000000..7200245 --- /dev/null +++ b/Giants-Files/src/test/java/org/Giants/Files/AppTest.java @@ -0,0 +1,38 @@ +package org.Giants.Files; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/Giants/dependency-reduced-pom.xml b/Giants/dependency-reduced-pom.xml index 112991e..2e2e589 100644 --- a/Giants/dependency-reduced-pom.xml +++ b/Giants/dependency-reduced-pom.xml @@ -3,10 +3,12 @@ Giants-Parent me.Mammothskier - 7.0-Beta + 7.1-SNAPSHOT 4.0.0 Giants + Giants + 7.1-Beta spigot-repo diff --git a/Giants/pom.xml b/Giants/pom.xml index 3571bc0..2ac9645 100644 --- a/Giants/pom.xml +++ b/Giants/pom.xml @@ -3,15 +3,19 @@ me.Mammothskier Giants-Parent - 7.0-Beta + 7.1-SNAPSHOT + + Giants Giants + 7.1-Beta + jar org.bukkit bukkit - 1.8.7-R0.1-SNAPSHOT + 1.9.4-R0.1-SNAPSHOT jar @@ -22,6 +26,19 @@ jar + + me.Mammothskier + Giants-Files + 1.0-SNAPSHOT + + + org.bukkit + craftbukkit + + + true + + me.Mammothskier Giants-v1_7_R3 @@ -87,7 +104,7 @@ true - + me.Mammothskier Giants-v1_9_R1 v1 diff --git a/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java b/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java index 8b9b581..0db19e1 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java @@ -14,8 +14,8 @@ import org.bukkit.event.entity.EntityDeathEvent; import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.Files.Files; import me.Mammothskier.Giants.entity.Entities; -import me.Mammothskier.Giants.files.Files; import me.confuser.barapi.BarAPI; public class HealthBar implements Listener { diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Commands.java b/Giants/src/main/java/me/Mammothskier/Giants/Commands.java index 31dc91c..5bba6b8 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/Commands.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/Commands.java @@ -1,8 +1,8 @@ package me.Mammothskier.Giants; +import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.entity.Entities; import me.Mammothskier.Giants.events.SpawnEvent; -import me.Mammothskier.Giants.files.ConfigValues; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Giants.java b/Giants/src/main/java/me/Mammothskier/Giants/Giants.java index 9d5a097..b3bb417 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/Giants.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/Giants.java @@ -4,10 +4,10 @@ import java.util.List; import java.util.logging.Logger; +import me.Mammothskier.Giants.Files.ConfigValues; +import me.Mammothskier.Giants.Files.FileHandler; +import me.Mammothskier.Giants.Files.Files; import me.Mammothskier.Giants.entity.Entities; -import me.Mammothskier.Giants.files.ConfigValues; -import me.Mammothskier.Giants.files.FileHandler; -import me.Mammothskier.Giants.files.Files; import me.Mammothskier.Giants.util.Metrics; import me.Mammothskier.Giants.util.NMSUtils; @@ -36,7 +36,7 @@ public void onEnable() { this.getCommand("giants").setExecutor(new Commands(this)); new Entities(this); - fileHandler = new FileHandler(this); + fileHandler = new FileHandler(); updateEntities(); } diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java index 32b7837..ed56690 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java @@ -1,7 +1,7 @@ package me.Mammothskier.Giants.entity; import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.Files.ConfigValues; import org.bukkit.entity.Arrow; import org.bukkit.entity.Damageable; @@ -28,11 +28,11 @@ public void onEntityDamageEvent(EntityDamageEvent event) { if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FALLING_BLOCK) { String string = "true"; if (Entities.isGiantZombie(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Zombie"); + string = Giants.getProperty(ConfigValues.zombieAllowSuffocation); else if (Entities.isGiantSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Slime"); + string = Giants.getProperty(ConfigValues.slimeAllowSuffocation); else if (Entities.isGiantLavaSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Suffocation.Giant Lava Slime"); + string = Giants.getProperty(ConfigValues.lavaSlimeAllowSuffocation); if (string.equalsIgnoreCase("false")) { event.setCancelled(true); @@ -42,9 +42,9 @@ else if (Entities.isGiantLavaSlime(entity)) if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) { String string = "true"; if (Entities.isGiantZombie(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Zombie"); + string = Giants.getProperty(ConfigValues.zombieAllowFireDamage); else if (Entities.isGiantSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Fire.Allow Fire Damage.Giant Slime"); + string = Giants.getProperty(ConfigValues.slimeAllowFireDamage); if (string.equalsIgnoreCase("false")) { event.setCancelled(true); } @@ -52,11 +52,11 @@ else if (Entities.isGiantSlime(entity)) if (event.getCause() == DamageCause.THORNS) { String string = "true"; if (Entities.isGiantZombie(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Zombie"); + string = Giants.getProperty(ConfigValues.zombieAllowCactiDamage); else if (Entities.isGiantSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Slime"); + string = Giants.getProperty(ConfigValues.slimeAllowCactiDamage); else if (Entities.isGiantLavaSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime"); + string = Giants.getProperty(ConfigValues.lavaSlimeAllowCactiDamage); if (string.equalsIgnoreCase("false")) { event.setCancelled(true); } @@ -71,11 +71,11 @@ public void onArrowDamage(EntityDamageByEntityEvent event) { int damage; String string = ""; if (Entities.isGiantZombie(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Zombie"); + string = Giants.getProperty(ConfigValues.zombieArrowDamage); else if (Entities.isGiantSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Slime"); + string = Giants.getProperty(ConfigValues.slimeArrowDamage); else if (Entities.isGiantSlime(entity)) - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Damage Settings.Arrows.Damage done by arrow.Giant Lava Slime"); + string = Giants.getProperty(ConfigValues.lavaSlimeArrowDamage); try { damage = Integer.parseInt(string); } catch (Exception e) { diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java index d4f27a4..9f1e009 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java @@ -1,14 +1,12 @@ package me.Mammothskier.Giants.entity; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; - +import me.Mammothskier.Giants.Files.ConfigValues; import org.bukkit.ChatColor; import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; @@ -31,88 +29,6 @@ public DropsManager(Giants giants) { _giants.getServer().getPluginManager().registerEvents(this, giants); } - @EventHandler - public void onGiantDrops(EntityDeathEvent event) throws IOException{ - Entity entity = event.getEntity(); - boolean enabled = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Drops.Enable Drop Manager").equalsIgnoreCase("true"); - - - if (Entities.isGiantZombie(entity)) { - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Zombie"); - int exp; - - try { - exp = Integer.parseInt(string); - } catch (Exception e) { - exp = 5; - } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); - } - event.setDroppedExp(exp); - List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]") || enabled == false) { - return; - } - - List drops = new ArrayList(); - drops = setDrop(entity, newDrop); - - event.getDrops().addAll(drops); - } - if (Entities.isGiantSlime(entity)) { - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Slime"); - int exp; - - try { - exp = Integer.parseInt(string); - } catch (Exception e) { - exp = 5; - } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_DEATH, 1, 0); - } - event.setDroppedExp(exp); - List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Slime"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]") || enabled == false) { - return; - } - - List drops = new ArrayList(); - - drops = setDrop(entity, newDrop); - - event.getDrops().addAll(drops); - } - - - if (Entities.isGiantLavaSlime(entity)) { - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Lava Slime"); - int exp; - - try { - exp = Integer.parseInt(string); - } catch (Exception e) { - exp = 5; - } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); - } - event.setDroppedExp(exp); - List newDrop = Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Lava Slime"); - if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]") || enabled == false) { - return; - } - - List drops = new ArrayList(); - - drops = setDrop(entity, newDrop); - - event.getDrops().addAll(drops); - } - } - - public static List setDrop(Entity entity, List newDrop) { List drops = new ArrayList(); @@ -523,4 +439,41 @@ public static List setDrop(Entity entity, List newDrop) { } return drops; } + + @EventHandler + public void onEntityDeath(EntityDeathEvent event) { + Entity entity = event.getEntity(); + if (Entities.giantEntities.remove(entity) && Giants.getProperty(ConfigValues.dropManager).equalsIgnoreCase("true")) { + String experience; + List newDrop; + if (Entities.isGiantZombie(entity)) { + experience = Giants.getProperty(ConfigValues.zombieExperience); + newDrop = Giants.getPropertyList(ConfigValues.zombieDrops); + } else if (Entities.isGiantSlime(entity)) { + experience = Giants.getProperty(ConfigValues.slimeExperience); + newDrop = Giants.getPropertyList(ConfigValues.slimeDrops); + } else if (Entities.isGiantLavaSlime(entity)) { + experience = Giants.getProperty(ConfigValues.lavaSlimeExperience); + newDrop = Giants.getPropertyList(ConfigValues.lavaSlimeDrops); + } else { + return; + } + + try { + event.setDroppedExp(Integer.parseInt(experience)); + } catch ( Exception e) { + event.setDroppedExp(5); + } + + if (newDrop == null || newDrop.contains("") || newDrop.toString().equalsIgnoreCase("[]")) { + return; + } + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_ENDERDRAGON_DEATH, 1, 0); + } + + setDrop(entity, newDrop); + + } + } } diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java index 9a7e709..0333d60 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java @@ -8,7 +8,6 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Ghast; @@ -24,9 +23,9 @@ import org.bukkit.scheduler.BukkitScheduler; import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.events.JockeySpawnEvent; import me.Mammothskier.Giants.events.SpawnEvent; -import me.Mammothskier.Giants.files.Files; import me.Mammothskier.Giants.util.NMSUtils; public class Entities implements Listener { @@ -40,6 +39,8 @@ public class Entities implements Listener { public static final EntityType[] slimeReplacements = {EntityType.ZOMBIE,EntityType.MUSHROOM_COW, EntityType.PIG_ZOMBIE, EntityType.SLIME, EntityType.ENDERMAN}; public static final EntityType[] lavaSlimeReplacements = {EntityType.PIG_ZOMBIE, EntityType.ZOMBIE, EntityType.MAGMA_CUBE, EntityType.ENDERMAN, EntityType.BLAZE}; + public static ArrayList giantEntities = new ArrayList(); + public Entities(Giants giants) { _giants = giants; _giants.getServer().getPluginManager().registerEvents(this, giants); @@ -84,11 +85,11 @@ public void onSpawnEvent (CreatureSpawnEvent event) { String string = ""; if (spawn.equals(EntityType.GIANT)) { - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Zombie"); + string = Giants.getProperty(ConfigValues.zombieChance); } else if (spawn.equals(EntityType.SLIME)) { - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Slime"); + string = Giants.getProperty(ConfigValues.slimeChance); } else if (spawn.equals(EntityType.MAGMA_CUBE)) { - string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Chance.Giant Lava Slime"); + string = Giants.getProperty(ConfigValues.lavaSlimeChance); } Float sRate; @@ -127,7 +128,7 @@ public void onSpawnEvent (CreatureSpawnEvent event) { } break; case SLIME: - s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); + s = Giants.getProperty(ConfigValues.slimeSize); try { size = Integer.parseInt(s); } catch (Exception e) { @@ -141,7 +142,7 @@ public void onSpawnEvent (CreatureSpawnEvent event) { } break; case MAGMA_CUBE: - s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime"); + s = Giants.getProperty(ConfigValues.lavaSlimeSize); try { size = Integer.parseInt(s); } catch (Exception e) { @@ -179,15 +180,15 @@ private boolean isEnabled(EntityType spawn) { } switch (spawn) { case GIANT: - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Zombie").equalsIgnoreCase("true") && GiantZombie == true) + if (Giants.getProperty(ConfigValues.zombieBoolean).equalsIgnoreCase("true") && GiantZombie == true) enabled = true; break; case SLIME: - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime").equalsIgnoreCase("true") && GiantSlime == true) + if (Giants.getProperty(ConfigValues.slimeBoolean).equalsIgnoreCase("true") && GiantSlime == true) enabled = true; break; case MAGMA_CUBE: - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Lava Slime").equalsIgnoreCase("true") && GiantLavaSlime == true) + if (Giants.getProperty(ConfigValues.lavaSlimeBoolean).equalsIgnoreCase("true") && GiantLavaSlime == true) enabled = true; break; @@ -277,24 +278,24 @@ public static List getEntitySpawnReplacements(EntityType type) { public static List getGiantSpawnWorlds(EntityType entityType) { switch (entityType) { case GIANT: - return Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Zombie"); + return Giants.getPropertyList(ConfigValues.zombieWorlds); case SLIME: - return Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Slime"); + return Giants.getPropertyList(ConfigValues.slimeWorlds); case MAGMA_CUBE: - return Giants.getPropertyList(Files.ENTITIES, "Entities Configuration.Spawn Settings.Worlds.Giant Lava Slime"); + return Giants.getPropertyList(ConfigValues.lavaslimeWorlds); default: return null; } } public static List getJockeySpawnWorlds() { - return Giants.getPropertyList(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds"); + return Giants.getPropertyList(ConfigValues.jockeyWorlds); } public static void callSpawnDebug(Entity entity) { if (entity == null) return; - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Debug Mode.Enabled").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.debugBoolean).equalsIgnoreCase("true")) { for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (player.hasPermission("giants.debug") || player.hasPermission("giants.*") || player.isOp()) { String x = String.valueOf(Math.round(entity.getLocation().getX())); @@ -337,19 +338,17 @@ private void jockeySpawner() { scheduler.scheduleSyncRepeatingTask(_giants, new Runnable() { public void run() { - for (World world : _giants.getServer().getWorlds()) { - for (Entity entity : world.getEntities()) { - if ((entity instanceof Slime) || (entity instanceof MagmaCube) || (entity instanceof Ghast)) { - for (Entity entity2 : entity.getNearbyEntities(15, 12, 15)) { - if ((entity2 instanceof Giant) && (entity.getPassenger() == null) && (entity2.getVehicle() == null)) { - Entity passenger = entity2; - JockeySpawnEvent JSE = new JockeySpawnEvent(entity, passenger); - Bukkit.getServer().getPluginManager().callEvent(JSE); - } - } + for (Entity entity : giantEntities) { + if ((entity instanceof Slime) || (entity instanceof MagmaCube) || (entity instanceof Ghast)) { + for (Entity entity2 : entity.getNearbyEntities(15, 12, 15)) { + if ((entity2 instanceof Giant) && (entity.getPassenger() == null) && (entity2.getVehicle() == null)) { + Entity passenger = entity2; + JockeySpawnEvent JSE = new JockeySpawnEvent(entity, passenger); + Bukkit.getServer().getPluginManager().callEvent(JSE); + } } - } - } + } + } } }, 0L, 20L); } diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java index 1b6dfc3..9e9c869 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java @@ -2,7 +2,7 @@ import java.util.Random; import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.Files.ConfigValues; import org.bukkit.Location; import org.bukkit.Sound; @@ -18,6 +18,8 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; public class GiantListeners implements Listener { @@ -30,8 +32,8 @@ public GiantListeners(Giants giants) { @EventHandler public void onFireAttack(EntityTargetEvent event) { - String ticks1 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); - String ticks2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Giant"); + String ticks1 = Giants.getProperty(ConfigValues.fireAttackTargetTicks); + String ticks2 = Giants.getProperty(ConfigValues.fireAttackGiantTicks); Entity entity = event.getEntity(); Entity target = event.getTarget(); int ticksTarget; @@ -47,9 +49,9 @@ public void onFireAttack(EntityTargetEvent event) { if ((entity instanceof LivingEntity)) { if (Entities.isGiantZombie(entity)) { if(!(target == null)){ - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled").contains("Giant Zombie")) { - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); + if (Giants.getPropertyList(ConfigValues.fireAttack).contains("Giant Zombie")) { + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.BLOCK_FIRE_AMBIENT , 1, 0); } try { event.getTarget().setFireTicks(ticksTarget); @@ -71,7 +73,7 @@ public void onLightningAttack(EntityTargetEvent event) { if ((entity instanceof LivingEntity)) { if (Entities.isGiantZombie(entity)) { - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack").contains("Giant Zombie")) { + if (Giants.getPropertyList(ConfigValues.lightningAttack).contains("Giant Zombie")) { try { target.getLocation().getWorld().strikeLightning(target.getLocation()); } catch (Exception e) { @@ -93,9 +95,9 @@ public void onShrapnelAttack(EntityTargetEvent event) { if (Entities.isGiantZombie(entity)) { Location spawnLocation = entity.getLocation(); Location loc = spawnLocation; - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Enabled").contains("Giant Zombie")) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Zombies to Spawn"); - String config2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Health"); + if (Giants.getPropertyList(ConfigValues.shrapnelAttack).contains("Giant Zombie")) { + String config = Giants.getProperty(ConfigValues.shrapnelAttackZombies); + String config2 = Giants.getProperty(ConfigValues.shrapnelAttackHealth); try { Amt = Integer.parseInt(config); Health = Double.parseDouble(config2); @@ -103,13 +105,13 @@ public void onShrapnelAttack(EntityTargetEvent event) { Amt = 3; Health = 20; } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")){ + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")){ if (target instanceof LivingEntity){ - target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); + target.getLocation().getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE , 1, 0); } } for (int i = 1; i <= Amt; i++){ - if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Shrapnel Attack.Baby Zombies").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.shrapnelAttackBabies).equalsIgnoreCase("true")) { Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); ((Zombie) e).setBaby(true); ((Damageable) e).setMaxHealth(Health); @@ -144,8 +146,8 @@ public void onThrownBoulderAttack(PlayerMoveEvent event) { } if (inRange == true) { if (chance == 50) { - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").contains("Giant Zombie")) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); + if (Giants.getPropertyList(ConfigValues.boulderAttack).contains("Giant Zombie")) { + String config = Giants.getProperty(ConfigValues.bouldAttackBlockDamage); try { bDamage = Integer.parseInt(config); } catch (Exception e) { @@ -155,8 +157,8 @@ public void onThrownBoulderAttack(PlayerMoveEvent event) { Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); fireball.setShooter((LivingEntity) entity); fireball.setYield(bDamage); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1, 0); } } } @@ -168,8 +170,8 @@ public void onThrownBoulderAttack(PlayerMoveEvent event) { @EventHandler public void onKickAttack(PlayerMoveEvent event) { Player player = event.getPlayer(); - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled").contains("Giant Zombie")) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height"); + if (Giants.getPropertyList(ConfigValues.kickAttack).contains("Giant Zombie")) { + String config = Giants.getProperty(ConfigValues.kickAttackHeight); double height; try { @@ -188,8 +190,8 @@ public void onKickAttack(PlayerMoveEvent event) { if (Entities.isGiantZombie(entity)) { if (entity.getNearbyEntities(5, 5, 5).contains(player)) { player.setVelocity(new Vector(0, height, 0)); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_LAVA_POP, 1, 0); } } } @@ -204,7 +206,7 @@ public void onStompAttack(PlayerMoveEvent event) { boolean fire = false; float power = 1.0f; Player player = event.getPlayer(); - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled").contains("Giant Zombie")) { + if (Giants.getPropertyList(ConfigValues.stompAttack).contains("Giant Zombie")) { Random pick = new Random(); int chance = 0; for (int counter = 1; counter <= 1; counter++) { @@ -214,12 +216,11 @@ public void onStompAttack(PlayerMoveEvent event) { for (Entity entity : player.getNearbyEntities(3, 2, 3)) { if (Entities.isGiantZombie(entity)) { if (entity.getNearbyEntities(3, 2, 3).contains(player)) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); - if (Giants.getProperty(Files.ATTACKS, - "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { + String config = Giants.getProperty(ConfigValues.stompAttackPower); + if (Giants.getProperty(ConfigValues.stompAttackFire).equalsIgnoreCase("true")) { fire = true; } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { sound = true; } @@ -231,7 +232,7 @@ public void onStompAttack(PlayerMoveEvent event) { Location location = player.getLocation(); location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); if (sound == true){ - location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); + location.getWorld().playSound(location, Sound.ENTITY_FIREWORK_LARGE_BLAST, 1, 0); } } } @@ -244,11 +245,11 @@ public void onStompAttack(PlayerMoveEvent event) { public void zombiesOnDeath(EntityDeathEvent event) { Entity entity = event.getEntity(); if (Entities.isGiantZombie(entity)) { - if(Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Enabled").contains("Giant Zombie")){ + if(Giants.getProperty(ConfigValues.zombiesOnDeath).equalsIgnoreCase("true")){ Location spawnLocation = entity.getLocation(); Location loc = spawnLocation; - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn"); - String config2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health"); + String config = Giants.getProperty(ConfigValues.zombiesOnDeathZombies); + String config2 = Giants.getProperty(ConfigValues.zombiesOnDeathHealth); int zombAmt; double zombHealth; @@ -260,7 +261,7 @@ public void zombiesOnDeath(EntityDeathEvent event) { zombHealth = 20; } for (int i = 1; i <= zombAmt; i++){ - if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.zombiesOnDeathBabies).equalsIgnoreCase("true")) { Entity e = loc.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE); ((Zombie) e).setBaby(true); ((Damageable) e).setMaxHealth(zombHealth); @@ -276,4 +277,30 @@ public void zombiesOnDeath(EntityDeathEvent event) { } } } + + @EventHandler + public void poisonAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (Giants.getPropertyList(ConfigValues.poisonAttack).contains("Giant Zombie")){ + Random pick = new Random(); + int chance = 0; + double length; + String config = Giants.getProperty(ConfigValues.poisonAttackLength); + try { + length = Double.parseDouble(config); + } catch (Exception e) { + length = 5; + } + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(3, 2, 3)) { + if (Entities.isGiantZombie(entity)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) (length*20), 3)); + } + } + } + } + } } \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java index 2828777..efae7f0 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java @@ -3,7 +3,7 @@ import java.util.Random; import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.Files.ConfigValues; import org.bukkit.Location; import org.bukkit.Material; @@ -17,6 +17,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; public class MagmaCubeListeners implements Listener { @@ -29,8 +31,8 @@ public MagmaCubeListeners(Giants magmacubes) { @EventHandler public void onFireAttack(EntityTargetEvent event) { - String ticks1 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); - String ticks2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Magma Cube"); + String ticks1 = Giants.getProperty(ConfigValues.fireAttackTargetTicks); + String ticks2 = Giants.getProperty(ConfigValues.fireAttackGiantTicks); Entity entity = event.getEntity(); Entity target = event.getTarget(); int ticksTarget; @@ -47,12 +49,12 @@ public void onFireAttack(EntityTargetEvent event) { if ((entity instanceof LivingEntity)) { if (Entities.isGiantLavaSlime(entity)) { if(!(target == null)){ - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled").contains("Giant Lava Slime")) { + if (Giants.getPropertyList(ConfigValues.fireAttack).contains("Giant Lava Slime")) { MagmaCube magmacube = (MagmaCube) event.getEntity(); s = magmacube.getSize(); if (s > 4){ - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.BLOCK_FIRE_AMBIENT, 1, 0); } try { event.getTarget().setFireTicks(ticksTarget); @@ -79,7 +81,7 @@ public void onLightningAttack(EntityTargetEvent event) { MagmaCube magmacube = (MagmaCube) event.getEntity(); s = magmacube.getSize(); if (s > 4){ - if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack").contains("Giant Lava Slime")) { + if (Giants.getProperty(ConfigValues.lightningAttack).contains("Giant Lava Slime")) { try { target.getLocation().getWorld().strikeLightning(target.getLocation()); } catch (Exception e) { @@ -102,11 +104,11 @@ public void LavaAttack(EntityTargetEvent event){ MagmaCube magmacube = (MagmaCube) event.getEntity(); s = magmacube.getSize(); if (s > 4){ - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lava Attack").contains("Giant Lava Slime")) { + if (Giants.getPropertyList(ConfigValues.lavaAttack).contains("Giant Lava Slime")) { target.getLocation().getBlock().setType(Material.LAVA); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.EXPLODE, 1, 0); - target.getLocation().getWorld().playSound(target.getLocation(), Sound.LAVA_POP, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE , 1, 0); + target.getLocation().getWorld().playSound(target.getLocation(), Sound.BLOCK_LAVA_POP, 1, 0); } } } @@ -119,7 +121,7 @@ public void onStompAttack(PlayerMoveEvent event) { boolean fire = false; float power = 1.0f; Player player = event.getPlayer(); - if (Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.stompAttack).equalsIgnoreCase("true")) { Random pick = new Random(); int chance = 0; int s; @@ -133,12 +135,11 @@ public void onStompAttack(PlayerMoveEvent event) { s = magmacube.getSize(); if (s > 4){ if (entity.getNearbyEntities(3, 2, 3).contains(player)) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); - if (Giants.getProperty(Files.ATTACKS, - "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { + String config = Giants.getProperty(ConfigValues.stompAttackPower); + if (Giants.getProperty(ConfigValues.stompAttackFire).equalsIgnoreCase("true")) { fire = true; } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { sound = true; } @@ -151,7 +152,7 @@ public void onStompAttack(PlayerMoveEvent event) { Location location = player.getLocation(); location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); if (sound == true){ - location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); + location.getWorld().playSound(location, Sound.ENTITY_FIREWORK_LARGE_BLAST, 1, 0); } } } @@ -183,8 +184,8 @@ public void ThrownBoulderAttack(PlayerMoveEvent event) { } if (inRange == true) { if (chance == 50) { - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").contains("Giant Lava Slime")) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); + if (Giants.getPropertyList(ConfigValues.boulderAttack).contains("Giant Lava Slime")) { + String config = Giants.getProperty(ConfigValues.bouldAttackBlockDamage); try { bDamage = Integer.parseInt(config); } catch (Exception e) { @@ -195,8 +196,8 @@ public void ThrownBoulderAttack(PlayerMoveEvent event) { Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); fireball.setShooter((LivingEntity) entity); fireball.setYield(bDamage); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1, 0); } } } @@ -209,9 +210,9 @@ public void ThrownBoulderAttack(PlayerMoveEvent event) { @EventHandler public void onKickAttack(PlayerMoveEvent event) { Player player = event.getPlayer(); - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled").contains("Giant Lava Slime")) { + if (Giants.getPropertyList(ConfigValues.kickAttack).contains("Giant Lava Slime")) { int s; - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height"); + String config = Giants.getProperty(ConfigValues.kickAttackHeight); double height; try { @@ -233,8 +234,8 @@ public void onKickAttack(PlayerMoveEvent event) { if (s > 4){ if (entity.getNearbyEntities(5, 5, 5).contains(player)) { player.setVelocity(new Vector(0, height, 0)); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_LAVA_POP, 1, 0); } } } @@ -243,4 +244,30 @@ public void onKickAttack(PlayerMoveEvent event) { } } } + + @EventHandler + public void poisonAttack(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (Giants.getPropertyList(ConfigValues.poisonAttack).contains("Giant Lava Slime")){ + Random pick = new Random(); + int chance = 0; + double length; + String config = Giants.getProperty(ConfigValues.poisonAttackLength); + try { + length = Double.parseDouble(config); + } catch (Exception e) { + length = 5; + } + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(100); + } + if (chance == 50) { + for (Entity entity : player.getNearbyEntities(3, 2, 3)) { + if (Entities.isGiantLavaSlime(entity)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) (length*20), 3)); + } + } + } + } + } } \ No newline at end of file diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java b/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java index 89653f5..51247bb 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java @@ -3,7 +3,7 @@ import java.util.Random; import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.Files.ConfigValues; import org.bukkit.Location; import org.bukkit.Sound; @@ -39,7 +39,7 @@ public void onLightningAttack(EntityTargetEvent event) { Slime slime = (Slime) event.getEntity(); s = slime.getSize(); if (s > 4){ - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Lightning Attack").contains("Giant Slime")) { + if (Giants.getPropertyList(ConfigValues.lightningAttack).contains("Giant Slime")) { try { target.getLocation().getWorld().strikeLightning(target.getLocation()); } catch (Exception e) { @@ -54,8 +54,8 @@ public void onLightningAttack(EntityTargetEvent event) { @EventHandler public void onFireAttack(EntityTargetEvent event) { - String ticks1 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Target"); - String ticks2 = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Ticks for Slime"); + String ticks1 = Giants.getProperty(ConfigValues.fireAttackTargetTicks); + String ticks2 = Giants.getProperty(ConfigValues.fireAttackGiantTicks); Entity entity = event.getEntity(); Entity target = event.getTarget(); int ticksTarget; @@ -75,9 +75,9 @@ public void onFireAttack(EntityTargetEvent event) { s = slime.getSize(); if (s > 4){ if(!(target == null)){ - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Fire Attack.Enabled").contains("Giant Slime")) { - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - target.getLocation().getWorld().playSound(target.getLocation(), Sound.FIRE, 1, 0); + if (Giants.getPropertyList(ConfigValues.fireAttack).contains("Giant Slime")) { + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + target.getLocation().getWorld().playSound(target.getLocation(), Sound.BLOCK_FIRE_AMBIENT, 1, 0); } try { event.getTarget().setFireTicks(ticksTarget); @@ -115,8 +115,8 @@ public void ThrownBoulderAttack(PlayerMoveEvent event) { } if (inRange == true) { if (chance == 50) { - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Enabled").contains("Giant Slime")) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Throw Boulder Attack.Block Damage"); + if (Giants.getPropertyList(ConfigValues.boulderAttack).contains("Giant Slime")) { + String config = Giants.getProperty(ConfigValues.bouldAttackBlockDamage); try { bDamage = Integer.parseInt(config); } catch (Exception e) { @@ -126,8 +126,8 @@ public void ThrownBoulderAttack(PlayerMoveEvent event) { Fireball fireball = entity.getWorld().spawn(((LivingEntity) entity).getEyeLocation().add(direction.getX(), direction.getY() - 5, direction.getZ()), Fireball.class); fireball.setShooter((LivingEntity) entity); fireball.setYield(bDamage); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1, 0); } } } @@ -140,8 +140,8 @@ public void ThrownBoulderAttack(PlayerMoveEvent event) { @EventHandler public void onKickAttack(PlayerMoveEvent event) { Player player = event.getPlayer(); - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Enabled").contains("Giant Slime")) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Kick Attack.Kick Height"); + if (Giants.getPropertyList(ConfigValues.kickAttack).contains("Giant Slime")) { + String config = Giants.getProperty(ConfigValues.kickAttackHeight); double height; int s; @@ -164,8 +164,8 @@ public void onKickAttack(PlayerMoveEvent event) { if (s > 4){ if (entity.getNearbyEntities(5, 5, 5).contains(player)) { player.setVelocity(new Vector(0, height, 0)); - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { - player.getLocation().getWorld().playSound(player.getLocation(), Sound.LAVA_POP, 1, 0); + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { + player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_LAVA_POP, 1, 0); } } } @@ -181,7 +181,7 @@ public void onStompAttack(PlayerMoveEvent event) { boolean fire = false; float power = 1.0f; Player player = event.getPlayer(); - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Enabled").contains("Giant Slime")) { + if (Giants.getPropertyList(ConfigValues.stompAttack).contains("Giant Slime")) { Random pick = new Random(); int chance = 0; int s; @@ -195,12 +195,11 @@ public void onStompAttack(PlayerMoveEvent event) { s = slime.getSize(); if (s > 4){ if (entity.getNearbyEntities(3, 2, 3).contains(player)) { - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Stomp Attack.Explosion Power"); - if (Giants.getProperty(Files.ATTACKS, - "Attacks Configuration.Attack Mechanisms.Stomp Attack.Light Fire").equalsIgnoreCase("true")) { + String config = Giants.getProperty(ConfigValues.stompAttackPower); + if (Giants.getProperty(ConfigValues.stompAttackFire).equalsIgnoreCase("true")) { fire = true; } - if (Giants.getProperty(Files.CONFIG, "Giants Configuration.Sounds").equalsIgnoreCase("true")) { + if (Giants.getProperty(ConfigValues.soundsBoolean).equalsIgnoreCase("true")) { sound = true; } @@ -212,7 +211,7 @@ public void onStompAttack(PlayerMoveEvent event) { Location location = player.getLocation(); location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, fire); if (sound == true){ - location.getWorld().playSound(location, Sound.FIREWORK_LARGE_BLAST, 1, 0); + location.getWorld().playSound(location, Sound.ENTITY_FIREWORK_LARGE_BLAST, 1, 0); } } } @@ -225,11 +224,11 @@ public void onStompAttack(PlayerMoveEvent event) { @EventHandler public void poisonAttack(PlayerMoveEvent event) { Player player = event.getPlayer(); - if (Giants.getPropertyList(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Poison Attack").contains("Giant Slime")){ + if (Giants.getPropertyList(ConfigValues.poisonAttack).contains("Giant Slime")){ Random pick = new Random(); int chance = 0; double length; - String config = Giants.getProperty(Files.ATTACKS, "Attacks Configuration.Attack Mechanisms.Poison Attack.length"); + String config = Giants.getProperty(ConfigValues.poisonAttackLength); try { length = Double.parseDouble(config); } catch (Exception e) { diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java b/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java index ee69405..d8e24d9 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java @@ -1,7 +1,7 @@ package me.Mammothskier.Giants.events; import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; +import me.Mammothskier.Giants.Files.ConfigValues; import org.bukkit.Location; import org.bukkit.block.Biome; @@ -20,295 +20,77 @@ public JockeySpawnEvent (Entity entity, Entity passenger) { Biome biome = location.getWorld().getBiome(location.getBlockX(), location.getBlockZ()); if (!isCancelled()) { - if (biome == Biome.SWAMPLAND) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Swampland.Swampland").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Swampland".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeSwampland).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.SWAMPLAND_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Swampland.Swampland Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Forest".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeForest).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.FOREST) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Forest.Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Taiga".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeTaiga).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.FOREST_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Forest.Forest Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Plains".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomePlains).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.TAIGA) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Extreme_Hills".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeExtremeHills).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.TAIGA_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Mushroom".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeMushroomIsland).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.TAIGA_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Taiga Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Desert".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeDesert).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.COLD_TAIGA) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Jungle".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeJungle).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.COLD_TAIGA_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Birch".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeBirchForest).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.COLD_TAIGA_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Cold Taiga Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Savanna".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeSavanna).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.MEGA_TAIGA) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Roofed_Forest".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeRoofedForest).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.MEGA_TAIGA_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Mesa".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeMesa).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.MEGA_SPRUCE_TAIGA) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Small_Mountains".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeSmallMountains).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.MEGA_SPRUCE_TAIGA_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Taiga.Mega Spruce Taiga Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Ice_Mountains".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeIceMountains).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.PLAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Plains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Ocean".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeOcean).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.ICE_PLAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Ice Plains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("River".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeRiver).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.ICE_PLAINS_SPIKES) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Ice Plains Spikes").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Hell".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeHell).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } - if (biome == Biome.SUNFLOWER_PLAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Plains.Sunflower Plains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.OCEAN) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Ocean").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DEEP_OCEAN) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Deep Ocean").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.FROZEN_OCEAN) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Ocean.Frozen Ocean").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.RIVER) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.River.River").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.FROZEN_RIVER) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.River.Frozen River").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BEACH) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Beach").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.STONE_BEACH) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Stone Beach").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.COLD_BEACH) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Beach.Cold Beach").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.EXTREME_HILLS_PLUS_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Extreme Hills.Extreme Hills Plus Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MUSHROOM_ISLAND) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Island").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MUSHROOM_SHORE) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mushroom Island.Mushroom Shore").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DESERT) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DESERT_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.DESERT_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Desert.Desert Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if ((biome == Biome.JUNGLE) || (biome == Biome.JUNGLE_EDGE)) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if ((biome == Biome.JUNGLE_HILLS) || (biome == Biome.JUNGLE_EDGE)) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if ((biome == Biome.JUNGLE_MOUNTAINS) || (biome == Biome.JUNGLE_EDGE) || (biome == Biome.JUNGLE_EDGE_MOUNTAINS)) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Jungle.Jungle Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.BIRCH_FOREST_HILLS_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Birch Forest.Birch Forest Hills Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA_PLATEAU) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Plateau").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SAVANNA_PLATEAU_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Savanna.Savanna Plateau Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ROOFED_FOREST) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ROOFED_FOREST_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Roofed Forest.Roofed Forest Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_BRYCE) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Bryce").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.MESA_PLATEAU_FOREST_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Mesa.Mesa Plateau Forest Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SMALL_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Small Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.ICE_MOUNTAINS) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Ice Mountains").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.HELL) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Hell").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } - } - if (biome == Biome.SKY) { - if (Giants.getProperty(Files.JOCKEYBIOMES, "Jockey Configuration.Biome Settings.Other.Sky").equalsIgnoreCase("true")) { - entity.setPassenger(passenger); - } + if (biome.toString().toLowerCase().contains("Sky".toLowerCase()) && + Giants.getProperty(ConfigValues.jockeyBiomeSky).equalsIgnoreCase("true")) { + entity.setPassenger(passenger); } } } diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java b/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java index 6d08ccf..1895957 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java @@ -4,8 +4,8 @@ import java.util.List; import me.Mammothskier.Giants.Giants; +import me.Mammothskier.Giants.Files.Files; import me.Mammothskier.Giants.entity.Entities; -import me.Mammothskier.Giants.files.Files; import org.bukkit.Location; import org.bukkit.Material; @@ -27,7 +27,7 @@ public class SpawnEvent extends Event{ private Location location; private static final HandlerList handlers = new HandlerList(); - public SpawnEvent(Location loc, EntityType entityType) { +public SpawnEvent(Location loc, EntityType entityType) { location = loc; Biome biome = loc.getWorld().getBiome(loc.getBlockX(), loc.getBlockZ()); double health = 100; diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java index 3d1f422..054d498 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java @@ -50,7 +50,7 @@ public static void createGiant(Location location, SpawnReason reason) { me.Mammothskier.Giants.entity.nms.v1_8_R3.EntityCreator.createEntity(location, reason); break; case("v1_9_R1"): - me.Mammothskier.Giants.entity.nms.v1_8_R3.EntityCreator.createEntity(location, reason); + me.Mammothskier.Giants.entity.nms.v1_9_R1.EntityCreator.createEntity(location, reason); break; } } @@ -100,6 +100,9 @@ public static void unregisterEntities() { me.Mammothskier.Giants.entity.nms.v1_8_R2.CustomEntityType.unregisterEntities(); } else if ("v1_8_R3".equals(version)) { me.Mammothskier.Giants.entity.nms.v1_8_R3.CustomEntityType.unregisterEntities(); + } else if ("v1_9_R1".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.unregisterEntities(); } + } } diff --git a/pom.xml b/pom.xml index da5757f..d2591b7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,19 +1,23 @@ + 4.0.0 me.Mammothskier Giants-Parent - 7.0 + 7.1-SNAPSHOT pom - - v1_7_R3 - v1_7_R4 - v1_8_R1 - v1_8_R2 - v1_8_R3 - v1_9_R1 - Giants + + + Giants-Files + v1_7_R3 + v1_7_R4 + v1_8_R1 + v1_8_R2 + v1_8_R3 + v1_9_R1 + Giants + spigot-repo diff --git a/src/main/java/me/Mammothskier/Giants/utils/API.java b/src/main/java/me/Mammothskier/Giants/utils/API.java deleted file mode 100644 index 8519376..0000000 --- a/src/main/java/me/Mammothskier/Giants/utils/API.java +++ /dev/null @@ -1,165 +0,0 @@ -package me.Mammothskier.Giants.utils; - -import java.util.List; - -import me.Mammothskier.Giants.Attacks; -import me.Mammothskier.Giants.Commands; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.events.JockeySpawnEvent; -import me.Mammothskier.Giants.events.SlimeSpawnEvent; -import me.Mammothskier.Giants.files.FileHandler; -import me.Mammothskier.Giants.files.Files; -import me.Mammothskier.Giants.listeners.GiantListeners; -import me.Mammothskier.Giants.listeners.MagmaCubeListeners; -import me.Mammothskier.Giants.listeners.SlimeListeners; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Giant; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Slime; -import org.bukkit.scheduler.BukkitScheduler; - -public class API { - private static Giants _giants; - private Commands commands; - private static FileHandler fileHandler; - private static Attacks Attacks; - private static DropsManager drops; - - public API(Giants giants) { - _giants = giants; - new GiantListeners(_giants); - new SlimeListeners(_giants); - new MagmaCubeListeners(_giants); - commands = new Commands(_giants); - _giants.getCommand("giants").setExecutor(commands); - fileHandler = new FileHandler(_giants); - Attacks = new Attacks(_giants); - drops = new DropsManager(_giants); - - if (getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { - BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); - scheduler.scheduleSyncRepeatingTask(_giants, new Runnable() { - - @Override - public void run() { - for (World world : _giants.getServer().getWorlds()) { - for (Entity entity : world.getEntities()) { - if ((entity instanceof Slime) || (entity instanceof MagmaCube) || (entity instanceof Ghast)) { - for (Entity entity2 : entity.getNearbyEntities(15, 12, 15)) { - if ((entity2 instanceof Giant) && (entity.getPassenger() == null) && (entity2.getVehicle() == null)) { - Entity passenger = entity2; - JockeySpawnEvent JSE = new JockeySpawnEvent(entity, passenger); - Bukkit.getServer().getPluginManager().callEvent(JSE); - } - } - } - } - } - } - }, 0L, 20L); - } - } - - public static boolean isGiant(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant"); - if (config.equalsIgnoreCase("false")){ - return false; - } - return entity instanceof Giant; - } - - public static boolean isGiantSlime(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Slime"); - if (config.equalsIgnoreCase("false")){ - return false; - } - - if (entity instanceof Slime){ - Slime slime = (Slime) entity; - if ( slime.getSize() > 4){ - return entity instanceof Slime; - } - } - return false; - } - - public static boolean isGiantMagmaCube(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Magma Cube"); - if (config.equalsIgnoreCase("false")){ - return false; - } - if (entity instanceof MagmaCube){ - MagmaCube magmacube = (MagmaCube) entity; - if (magmacube.getSize() > 4){ - return entity instanceof MagmaCube; - } - } - return false; - } - - public static boolean isGiantJockey(Entity entity) { - String config = API.getFileHandler().getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey"); - if (config.equalsIgnoreCase("false")){ - return false; - } - switch (entity.getType()) { - case GIANT: - if ((isGiantSlime(entity.getVehicle())) || (isGiantMagmaCube(entity.getVehicle())) || (entity.getVehicle().getType() == EntityType.GHAST)) { - return true; - } - break; - case SLIME: - if ((isGiantSlime(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { - return true; - } - break; - case MAGMA_CUBE: - if ((isGiantMagmaCube(entity)) && (entity.getPassenger().getType() == EntityType.GIANT)) { - return true; - } - break; - case GHAST: - if (entity.getPassenger().getType() == EntityType.GIANT) { - return true; - } - break; - default: - break; - } - return false; - } - - public static List getGiantSpawnWorlds() { - return getFileHandler().getPropertyList(Files.GIANT, "Giant Configuration.Spawn Settings.Worlds"); - } - - public static List getSlimeSpawnWorlds() { - return getFileHandler().getPropertyList(Files.SLIME, "Slime Configuration.Spawn Settings.Worlds"); - } - - public static List getMagmaCubeSpawnWorlds() { - return getFileHandler().getPropertyList(Files.MAGMACUBE, "Magma Cube Configuration.Spawn Settings.Worlds"); - } - - public static List getJockeySpawnWorlds() { - return getFileHandler().getPropertyList(Files.JOCKEY, "Jockey Configuration.Spawn Settings.Worlds"); - } - - public static FileHandler getFileHandler() { - return fileHandler; - } - - public static Attacks createAttack() { - return Attacks; - } - - public static DropsManager createDrop() { - return drops; - } -} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml deleted file mode 100644 index 0b17c97..0000000 --- a/src/main/resources/plugin.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Giants -main: me.Mammothskier.Giants.Giants -version: ${project.build.version} -author: Mammothskier -softdepend: [BarAPI] - -commands: - giants: - description: Shows list of commands. - -permissions: - giants.*: - description: Gives all permissions. - default: false - children: - giants.reload: true - giants.debug: true - giants.spawn: true - giants.barAPI: true - giants.reload: - description: Reloads the config file. - default: false - giants.debug: - description: Shows Debug messages. - default: false - giants.spawn: - description: Spawns a Giant at the given location. - default: false - giants.barAPI: - description: Allows access to the barAPI features. - default: false \ No newline at end of file diff --git a/v1_7_R3/dependency-reduced-pom.xml b/v1_7_R3/dependency-reduced-pom.xml deleted file mode 100644 index 5720695..0000000 --- a/v1_7_R3/dependency-reduced-pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - Giants-Parent - me.Mammothskier - 7.0 - - 4.0.0 - Giants-v1_7_R3 - Giants for v1_7_R3 - v1 - - - org.bukkit - bukkit - 1.7.9-R0.2 - compile - - - org.bukkit - craftbukkit - 1.7.9-R0.2 - compile - - - - diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 9e82f9a..08f830b 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0 + 7.1-SNAPSHOT @@ -27,17 +27,5 @@ jar - - me.Mammothskier - Giants - 7.0-Beta - - - org.bukkit - craftbukkit - - - true - \ No newline at end of file diff --git a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java index cf4032d..c2a7f55 100644 --- a/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java +++ b/v1_7_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R3/CustomEntityGiantZombie.java @@ -4,8 +4,6 @@ import org.bukkit.craftbukkit.v1_7_R3.util.UnsafeList; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_7_R3.EntityGiantZombie; import net.minecraft.server.v1_7_R3.EntityHuman; import net.minecraft.server.v1_7_R3.EntityIronGolem; @@ -62,7 +60,7 @@ public float getHeadHeight() { @Override protected void aC() { super.aW(); - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + String string = " ";//Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); double speed = 1; try { speed = Double.parseDouble(string); diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml index e595c71..85e7fe3 100644 --- a/v1_7_R4/pom.xml +++ b/v1_7_R4/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0-SNAPSHOT + 7.1-SNAPSHOT @@ -19,17 +19,6 @@ 1.7.10-R0.1-SNAPSHOT jar - - me.Mammothskier - Giants - 7.0-Beta - - - org.bukkit - craftbukkit - - - true - + \ No newline at end of file diff --git a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java index 63ad06a..778d20e 100644 --- a/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java +++ b/v1_7_R4/src/main/java/me/Mammothskier/Giants/entity/nms/v1_7_R4/CustomEntityGiantZombie.java @@ -4,8 +4,6 @@ import org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_7_R4.EntityGiantZombie; import net.minecraft.server.v1_7_R4.EntityHuman; import net.minecraft.server.v1_7_R4.EntityIronGolem; @@ -62,7 +60,7 @@ public float getHeadHeight() { @Override protected void aD() { super.aW(); - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + String string = " ";//Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); double speed = 1; try { speed = Double.parseDouble(string); diff --git a/v1_8_R1/pom.xml b/v1_8_R1/pom.xml index 6bdac50..9fb3f2d 100644 --- a/v1_8_R1/pom.xml +++ b/v1_8_R1/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0-SNAPSHOT + 7.1-SNAPSHOT @@ -19,17 +19,6 @@ 1.8-R0.1-SNAPSHOT jar - - me.Mammothskier - Giants - 7.0-Beta - - - org.bukkit - craftbukkit - - - true - + \ No newline at end of file diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml index 02cf3e9..9a0866e 100644 --- a/v1_8_R2/pom.xml +++ b/v1_8_R2/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0-SNAPSHOT + 7.1-SNAPSHOT @@ -25,18 +25,6 @@ 1.8.3-R0.1-SNAPSHOT jar - - me.Mammothskier - Giants - 7.0-Beta - - - org.bukkit - craftbukkit - - - true - diff --git a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java index cc37df5..4c2ddbc 100644 --- a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java +++ b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java @@ -4,8 +4,6 @@ import org.bukkit.craftbukkit.v1_8_R2.util.UnsafeList; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_8_R2.EntityGiantZombie; import net.minecraft.server.v1_8_R2.EntityHuman; import net.minecraft.server.v1_8_R2.EntityIronGolem; @@ -63,7 +61,7 @@ public float getHeadHeight() { @Override protected void initAttributes() { super.initAttributes(); - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + String string = " ";// Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); double speed = 1; try { speed = Double.parseDouble(string); diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index 73c890d..75ff815 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0-SNAPSHOT + 7.1-SNAPSHOT @@ -19,17 +19,5 @@ 1.8.7-R0.1-SNAPSHOT jar - - me.Mammothskier - Giants - 7.0-Beta - - - org.bukkit - craftbukkit - - - true - \ No newline at end of file diff --git a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java index 1a4ec2a..521b4b6 100644 --- a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java +++ b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java @@ -4,8 +4,6 @@ import org.bukkit.craftbukkit.v1_8_R3.util.UnsafeList; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; import net.minecraft.server.v1_8_R3.EntityGiantZombie; import net.minecraft.server.v1_8_R3.EntityHuman; import net.minecraft.server.v1_8_R3.EntityIronGolem; @@ -63,7 +61,7 @@ public float getHeadHeight() { @Override protected void initAttributes() { super.initAttributes(); - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + String string = " ";// Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); double speed = 1; try { speed = Double.parseDouble(string); diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index c45b910..f3070e4 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -20,10 +20,10 @@ jar - + me.Mammothskier - Giants - 7.0-Beta + Giants-Files + 1.0-SNAPSHOT org.bukkit @@ -32,6 +32,5 @@ true - \ No newline at end of file diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java index 2d24170..312f5cd 100644 --- a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -4,33 +4,33 @@ import org.bukkit.craftbukkit.v1_9_R1.util.UnsafeList; -import me.Mammothskier.Giants.Giants; -import me.Mammothskier.Giants.files.Files; -//import me.Mammothskier.Giants.files.ConfigValues; - +import me.Mammothskier.Giants.Files.ConfigValues; +import me.Mammothskier.Giants.Files.FileHandler; +import net.minecraft.server.v1_9_R1.DataWatcher; +import net.minecraft.server.v1_9_R1.DataWatcherObject; +import net.minecraft.server.v1_9_R1.DataWatcherRegistry; import net.minecraft.server.v1_9_R1.EntityGiantZombie; import net.minecraft.server.v1_9_R1.EntityHuman; import net.minecraft.server.v1_9_R1.EntityIronGolem; import net.minecraft.server.v1_9_R1.EntityPigZombie; -import net.minecraft.server.v1_9_R1.EntitySkeleton; import net.minecraft.server.v1_9_R1.EntityVillager; import net.minecraft.server.v1_9_R1.EntityZombie; import net.minecraft.server.v1_9_R1.PathfinderGoalFloat; import net.minecraft.server.v1_9_R1.PathfinderGoalHurtByTarget; import net.minecraft.server.v1_9_R1.PathfinderGoalLookAtPlayer; -import net.minecraft.server.v1_9_R1.PathfinderGoalMeleeAttack; import net.minecraft.server.v1_9_R1.PathfinderGoalMoveThroughVillage; import net.minecraft.server.v1_9_R1.PathfinderGoalMoveTowardsRestriction; import net.minecraft.server.v1_9_R1.PathfinderGoalNearestAttackableTarget; import net.minecraft.server.v1_9_R1.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_9_R1.PathfinderGoalRandomStroll; import net.minecraft.server.v1_9_R1.PathfinderGoalSelector; -import net.minecraft.server.v1_9_R1.PathfinderGoalZombieAttack; import net.minecraft.server.v1_9_R1.World; import net.minecraft.server.v1_9_R1.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie(World world) { super(world); try { @@ -48,7 +48,7 @@ public CustomEntityGiantZombie(World world) { } this.goalSelector.a(0, new PathfinderGoalFloat(this)); - //this.goalSelector.a(2, new PathfinderGoalZombieAttack((EntityZombie) this, 1.0D, false)); + this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); @@ -60,10 +60,14 @@ public float getHeadHeight() { return 14.440001F; } + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } + @Override protected void initAttributes() { super.initAttributes(); - String string = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Speed.Giant Zombie"); + String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); double speed = 1; try { speed = Double.parseDouble(string); @@ -80,7 +84,7 @@ protected void o() { this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); -// if (Giants.getProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) + if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); } diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomPathfinderGoalGiantZombieAttack.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomPathfinderGoalGiantZombieAttack.java new file mode 100644 index 0000000..522b773 --- /dev/null +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomPathfinderGoalGiantZombieAttack.java @@ -0,0 +1,38 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R1; + +import net.minecraft.server.v1_9_R1.PathfinderGoalMeleeAttack; + +public class CustomPathfinderGoalGiantZombieAttack extends PathfinderGoalMeleeAttack { + + private final CustomEntityGiantZombie h; + private int i; + + public CustomPathfinderGoalGiantZombieAttack(CustomEntityGiantZombie entityzombie, double d0, boolean flag) { + super(entityzombie, d0, flag); + this.h = entityzombie; + } + + public void c() { + super.c(); + this.setI(0); + } + + public void d() { + super.d(); + this.h.a(false); + } + + /** + * @return the i + */ + public int getI() { + return i; + } + + /** + * @param i the i to set + */ + public void setI(int i) { + this.i = i; + } +} From 55c58c6ff016eddfeaf854b04f71718c5fc869c9 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 6 Jun 2016 06:21:21 -0700 Subject: [PATCH 05/28] Add spigot to repos --- v1_7_R3/pom.xml | 15 +++++++------- v1_7_R4/pom.xml | 8 +++++++- v1_8_R1/pom.xml | 8 +++++++- v1_8_R2/dependency-reduced-pom.xml | 33 ------------------------------ v1_8_R2/pom.xml | 6 ------ v1_8_R3/pom.xml | 7 +++++++ v1_9_R1/pom.xml | 7 +++++++ 7 files changed, 35 insertions(+), 49 deletions(-) delete mode 100644 v1_8_R2/dependency-reduced-pom.xml diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 08f830b..7344087 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -19,13 +19,12 @@ 1.7.9-R0.2 jar - - - org.bukkit - craftbukkit - 1.7.9-R0.2 - jar - - + + + + bukkit-repo + http://repo.bukkit.org/content/groups/public + + \ No newline at end of file diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml index 85e7fe3..bd2b13c 100644 --- a/v1_7_R4/pom.xml +++ b/v1_7_R4/pom.xml @@ -19,6 +19,12 @@ 1.7.10-R0.1-SNAPSHOT jar - + + + + bukkit-repo + http://repo.bukkit.org/content/groups/public + + \ No newline at end of file diff --git a/v1_8_R1/pom.xml b/v1_8_R1/pom.xml index 9fb3f2d..c7165d3 100644 --- a/v1_8_R1/pom.xml +++ b/v1_8_R1/pom.xml @@ -19,6 +19,12 @@ 1.8-R0.1-SNAPSHOT jar - + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + \ No newline at end of file diff --git a/v1_8_R2/dependency-reduced-pom.xml b/v1_8_R2/dependency-reduced-pom.xml deleted file mode 100644 index 4d08d71..0000000 --- a/v1_8_R2/dependency-reduced-pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - Giants-Parent - me.Mammothskier - 7.0-SNAPSHOT - - 4.0.0 - Giants-v1_8_R2 - Giants for v1_8_R2 - v1 - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - - - org.bukkit - bukkit - 1.8.3-R0.1-SNAPSHOT - compile - - - org.bukkit - craftbukkit - 1.8.3-R0.1-SNAPSHOT - compile - - - - diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml index 9a0866e..f1dacf8 100644 --- a/v1_8_R2/pom.xml +++ b/v1_8_R2/pom.xml @@ -19,12 +19,6 @@ 1.8.3-R0.1-SNAPSHOT jar - - org.bukkit - craftbukkit - 1.8.3-R0.1-SNAPSHOT - jar - diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index 75ff815..2d83fdb 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -20,4 +20,11 @@ jar + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + \ No newline at end of file diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index f3070e4..b39e32a 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -33,4 +33,11 @@ true + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + \ No newline at end of file From d23efd6878bd934391054a7bbdb5c175ac23216d Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 6 Jun 2016 07:23:39 -0700 Subject: [PATCH 06/28] Update to parent pom --- Giants/dependency-reduced-pom.xml | 2 +- pom.xml | 18 +----------------- .../dependency-reduced-pom.xml | 12 +++++++++--- 3 files changed, 11 insertions(+), 21 deletions(-) rename {v1_8_R1 => v1_9_R1}/dependency-reduced-pom.xml (68%) diff --git a/Giants/dependency-reduced-pom.xml b/Giants/dependency-reduced-pom.xml index 2e2e589..e177c27 100644 --- a/Giants/dependency-reduced-pom.xml +++ b/Giants/dependency-reduced-pom.xml @@ -23,7 +23,7 @@ org.bukkit bukkit - 1.8.7-R0.1-SNAPSHOT + 1.9.4-R0.1-SNAPSHOT compile diff --git a/pom.xml b/pom.xml index d2591b7..d6de24d 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,7 @@ Giants-Files + v1_7_R3 v1_7_R4 v1_8_R1 @@ -17,23 +18,6 @@ v1_9_R1 Giants - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - - confuser-repo - http://ci.frostcast.net/plugin/repository/everything - - - - bukkit-repo - http://repo.bukkit.org/content/groups/public - - ${basedir}/src/main/java diff --git a/v1_8_R1/dependency-reduced-pom.xml b/v1_9_R1/dependency-reduced-pom.xml similarity index 68% rename from v1_8_R1/dependency-reduced-pom.xml rename to v1_9_R1/dependency-reduced-pom.xml index 3bd239d..c9917d5 100644 --- a/v1_8_R1/dependency-reduced-pom.xml +++ b/v1_9_R1/dependency-reduced-pom.xml @@ -6,14 +6,20 @@ 7.0-SNAPSHOT 4.0.0 - Giants-v1_8_R1 - Giants for v1_8_R1 + Giants-v1_9_R1 + Giants for v1_9_R1 v1 + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + org.bukkit craftbukkit - 1.8-R0.1-SNAPSHOT + 1.9-R0.1-SNAPSHOT compile From 5b4f0277bfb5a2b0e455c57ffcf0c7f14acb887e Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 6 Jun 2016 07:29:47 -0700 Subject: [PATCH 07/28] Adding craftbukkit to pom dependencies --- pom.xml | 17 +++++++++++++++++ v1_7_R3/pom.xml | 15 ++++++++------- v1_7_R4/dependency-reduced-pom.xml | 21 --------------------- v1_7_R4/pom.xml | 7 ------- v1_8_R2/pom.xml | 2 +- 5 files changed, 26 insertions(+), 36 deletions(-) delete mode 100644 v1_7_R4/dependency-reduced-pom.xml diff --git a/pom.xml b/pom.xml index d6de24d..cd5a48b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,23 @@ Giants + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + confuser-repo + http://ci.frostcast.net/plugin/repository/everything + + + + bukkit-repo + http://repo.bukkit.org/content/groups/public + + + ${basedir}/src/main/java diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 7344087..2628ff2 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -18,13 +18,14 @@ bukkit 1.7.9-R0.2 jar + + + + org.bukkit + craftbukkit + 1.7.9-R0.2 + jar - - - - bukkit-repo - http://repo.bukkit.org/content/groups/public - - + \ No newline at end of file diff --git a/v1_7_R4/dependency-reduced-pom.xml b/v1_7_R4/dependency-reduced-pom.xml deleted file mode 100644 index 611f69c..0000000 --- a/v1_7_R4/dependency-reduced-pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - Giants-Parent - me.Mammothskier - 7.0-SNAPSHOT - - 4.0.0 - Giants-v1_7_R4 - Giants for v1_7_R4 - v1 - - - org.bukkit - craftbukkit - 1.7.10-R0.1-SNAPSHOT - compile - - - - diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml index bd2b13c..65668a8 100644 --- a/v1_7_R4/pom.xml +++ b/v1_7_R4/pom.xml @@ -20,11 +20,4 @@ jar - - - - bukkit-repo - http://repo.bukkit.org/content/groups/public - - \ No newline at end of file diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml index f1dacf8..471c046 100644 --- a/v1_8_R2/pom.xml +++ b/v1_8_R2/pom.xml @@ -15,7 +15,7 @@ org.bukkit - bukkit + craftbukkit 1.8.3-R0.1-SNAPSHOT jar From 6714e1ad044244fa99afcce2dd0c5f1621728e4e Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 6 Jun 2016 07:33:35 -0700 Subject: [PATCH 08/28] Removed duplicate tag --- v1_7_R3/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 2628ff2..43fcceb 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -27,5 +27,4 @@ jar - \ No newline at end of file From 4644c93cdb653550f3b38d82ab8c9584c8038425 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Mon, 6 Jun 2016 07:37:41 -0700 Subject: [PATCH 09/28] REmoving unused files --- v1_8_R3/dependency-reduced-pom.xml | 21 --------------------- v1_9_R1/dependency-reduced-pom.xml | 2 +- v1_9_R1/pom.xml | 2 +- 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 v1_8_R3/dependency-reduced-pom.xml diff --git a/v1_8_R3/dependency-reduced-pom.xml b/v1_8_R3/dependency-reduced-pom.xml deleted file mode 100644 index 3c62771..0000000 --- a/v1_8_R3/dependency-reduced-pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - Giants-Parent - me.Mammothskier - 7.0-SNAPSHOT - - 4.0.0 - Giants-v1_8_R3 - Giants for v1_8_R3 - v1 - - - org.bukkit - craftbukkit - 1.8.7-R0.1-SNAPSHOT - compile - - - - diff --git a/v1_9_R1/dependency-reduced-pom.xml b/v1_9_R1/dependency-reduced-pom.xml index c9917d5..3c3a6fc 100644 --- a/v1_9_R1/dependency-reduced-pom.xml +++ b/v1_9_R1/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ Giants-Parent me.Mammothskier - 7.0-SNAPSHOT + 7.1-SNAPSHOT 4.0.0 Giants-v1_9_R1 diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index b39e32a..e40811b 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.0-SNAPSHOT + 7.1-SNAPSHOT From 54067033a93cae12cd189342ef1cfb55910dca40 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Wed, 8 Jun 2016 03:47:38 -0700 Subject: [PATCH 10/28] Pushing NMS modules into 2.0 with the addition of better mobility --- v1_7_R3/pom.xml | 7 ++--- v1_7_R4/pom.xml | 3 ++- v1_8_R1/pom.xml | 2 +- .../nms/v1_8_R1/CustomEntityGiantZombie.java | 5 ++++ v1_8_R2/pom.xml | 8 +++++- .../nms/v1_8_R2/CustomEntityGiantZombie.java | 5 ++++ v1_8_R3/pom.xml | 2 +- .../nms/v1_8_R3/CustomEntityGiantZombie.java | 8 +++++- v1_9_R1/dependency-reduced-pom.xml | 27 ------------------- v1_9_R1/pom.xml | 2 +- .../nms/v1_9_R1/CustomEntityGiantZombie.java | 5 ++++ 11 files changed, 38 insertions(+), 36 deletions(-) delete mode 100644 v1_9_R1/dependency-reduced-pom.xml diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 43fcceb..14e775b 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -3,7 +3,7 @@ Giants for v1_7_R3 Giants-v1_7_R3 - v1 + 2.0-SNAPSHOT jar @@ -19,12 +19,13 @@ 1.7.9-R0.2 jar - - + + org.bukkit craftbukkit 1.7.9-R0.2 jar + \ No newline at end of file diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml index 65668a8..d4346f8 100644 --- a/v1_7_R4/pom.xml +++ b/v1_7_R4/pom.xml @@ -3,7 +3,7 @@ Giants for v1_7_R4 Giants-v1_7_R4 - v1 + 2.0-SNAPSHOT jar @@ -19,5 +19,6 @@ 1.7.10-R0.1-SNAPSHOT jar + \ No newline at end of file diff --git a/v1_8_R1/pom.xml b/v1_8_R1/pom.xml index c7165d3..7e49bcf 100644 --- a/v1_8_R1/pom.xml +++ b/v1_8_R1/pom.xml @@ -3,7 +3,7 @@ Giants for v1_8_R1 Giants-v1_8_R1 - v1 + 2.0-SNAPSHOT jar diff --git a/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java index 82d5b31..1532203 100644 --- a/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java +++ b/v1_8_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R1/CustomEntityGiantZombie.java @@ -21,6 +21,7 @@ import net.minecraft.server.v1_8_R1.PathfinderGoalRandomStroll; import net.minecraft.server.v1_8_R1.PathfinderGoalSelector; import net.minecraft.server.v1_8_R1.World; +import net.minecraft.server.v1_8_R1.BlockPosition; import net.minecraft.server.v1_8_R1.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { @@ -76,4 +77,8 @@ protected void n() { this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); } + + public float a(BlockPosition position) { + return 0.5F - this.world.o(position); + } } diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml index 471c046..5d5ac88 100644 --- a/v1_8_R2/pom.xml +++ b/v1_8_R2/pom.xml @@ -3,7 +3,7 @@ Giants for v1_8_R2 Giants-v1_8_R2 - v1 + 2.0-SNAPSHOT jar @@ -13,6 +13,12 @@ + + org.bukkit + bukkit + 1.8.3-R0.1-SNAPSHOT + jar + org.bukkit craftbukkit diff --git a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java index 4c2ddbc..72eacb3 100644 --- a/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java +++ b/v1_8_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R2/CustomEntityGiantZombie.java @@ -21,6 +21,7 @@ import net.minecraft.server.v1_8_R2.PathfinderGoalRandomStroll; import net.minecraft.server.v1_8_R2.PathfinderGoalSelector; import net.minecraft.server.v1_8_R2.World; +import net.minecraft.server.v1_8_R2.BlockPosition; public class CustomEntityGiantZombie extends EntityGiantZombie { @@ -84,4 +85,8 @@ protected void n() { this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); } + + public float a(BlockPosition position) { + return 0.5F - this.world.o(position); + } } diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index 2d83fdb..5570019 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -3,7 +3,7 @@ Giants for v1_8_R3 Giants-v1_8_R3 - v1 + 2.0-SNAPSHOT jar diff --git a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java index 521b4b6..4b3eb3e 100644 --- a/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java +++ b/v1_8_R3/src/main/java/me/Mammothskier/Giants/entity/nms/v1_8_R3/CustomEntityGiantZombie.java @@ -7,7 +7,6 @@ import net.minecraft.server.v1_8_R3.EntityGiantZombie; import net.minecraft.server.v1_8_R3.EntityHuman; import net.minecraft.server.v1_8_R3.EntityIronGolem; -import net.minecraft.server.v1_8_R3.EntityPigZombie; import net.minecraft.server.v1_8_R3.EntitySkeleton; import net.minecraft.server.v1_8_R3.EntityVillager; import net.minecraft.server.v1_8_R3.PathfinderGoalFloat; @@ -21,10 +20,12 @@ import net.minecraft.server.v1_8_R3.PathfinderGoalRandomStroll; import net.minecraft.server.v1_8_R3.PathfinderGoalSelector; import net.minecraft.server.v1_8_R3.World; +import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { + @SuppressWarnings({ "rawtypes", "unchecked" }) public CustomEntityGiantZombie(World world) { super(world); try { @@ -74,6 +75,7 @@ protected void initAttributes() { this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); } + @SuppressWarnings({ "unchecked", "rawtypes" }) protected void n() { this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1.0D, true)); @@ -82,4 +84,8 @@ protected void n() { this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); } + + public float a(BlockPosition position) { + return 0.5F - this.world.o(position); + } } diff --git a/v1_9_R1/dependency-reduced-pom.xml b/v1_9_R1/dependency-reduced-pom.xml deleted file mode 100644 index 3c3a6fc..0000000 --- a/v1_9_R1/dependency-reduced-pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - Giants-Parent - me.Mammothskier - 7.1-SNAPSHOT - - 4.0.0 - Giants-v1_9_R1 - Giants for v1_9_R1 - v1 - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - - - org.bukkit - craftbukkit - 1.9-R0.1-SNAPSHOT - compile - - - - diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index e40811b..c3ce28b 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -3,7 +3,7 @@ Giants for v1_9_R1 Giants-v1_9_R1 - v1 + 2.0-SNAPSHOT jar diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java index 312f5cd..8094fed 100644 --- a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -6,6 +6,7 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; +import net.minecraft.server.v1_9_R1.BlockPosition; import net.minecraft.server.v1_9_R1.DataWatcher; import net.minecraft.server.v1_9_R1.DataWatcherObject; import net.minecraft.server.v1_9_R1.DataWatcherRegistry; @@ -88,4 +89,8 @@ protected void o() { this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); } + + public float a(BlockPosition position) { + return 0.5F - this.world.n(position); + } } From 121c06e1e3b74672dcab7ee3fcc20709726afff9 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Wed, 8 Jun 2016 03:48:50 -0700 Subject: [PATCH 11/28] Updating filehandler to fix file generation glitch --- Giants-Files/pom.xml | 2 +- .../Giants/Files/ConfigValues.java | 16 +++++- .../Giants/Files/FileHandler.java | 54 ++++++++++++++++++- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/Giants-Files/pom.xml b/Giants-Files/pom.xml index 4aece86..ce51d2f 100644 --- a/Giants-Files/pom.xml +++ b/Giants-Files/pom.xml @@ -9,7 +9,7 @@ Giants-Files - 1.0-SNAPSHOT + 1.1-SNAPSHOT Giants-Files jar diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java index 5202d81..0d44876 100644 --- a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java +++ b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java @@ -159,12 +159,14 @@ public enum ConfigValues { private final Files _files; private final String _value; private final List _values; + private final boolean list; private ConfigValues(Files file, String key, String value) { _files = file; _key = key; _value= value; _values = null; + list = false; } private ConfigValues(Files file, String key, int value) { @@ -172,6 +174,7 @@ private ConfigValues(Files file, String key, int value) { _key = key; _value= value + ""; _values = null; + list = false; } private ConfigValues(Files file, String key, float value) { @@ -179,6 +182,7 @@ private ConfigValues(Files file, String key, float value) { _key = key; _value= value + ""; _values = null; + list = false; } private ConfigValues(Files file, String key, boolean value) { @@ -186,6 +190,7 @@ private ConfigValues(Files file, String key, boolean value) { _key = key; _value = value == true ? "true" : "false"; _values = null; + list = false; } private ConfigValues(String key, String value) { @@ -193,13 +198,15 @@ private ConfigValues(String key, String value) { _key = key; _value= value; _values = null; + list = false; } private ConfigValues(Files file, String key, List value) { _files = file; _key = key; _values= value; - _value = _values.get(0); + _value = null; + list = true; } public String getKey() { @@ -228,4 +235,11 @@ private static String loadVersion() { return version; } + /** + * @return the list + */ + public boolean isList() { + return list; + } + } diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java index 3dfd6a7..8db0e76 100644 --- a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java +++ b/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java @@ -78,6 +78,14 @@ private void createFiles(Files files, File file) { Config.set("Giants Configuration.Sounds", true); Config.set("Giants Configuration.Debug Mode.Enabled", false); Config.set("Giants Configuration.Debug Mode.Debug Message", "&2A {entity} has spawned at X:&F%X &2Y:&F%Y &2Z:&F%Z");*/ + for (ConfigValues value : ConfigValues.values()) { + if (value.getFile() == Files.CONFIG) { + if (!value.isList()) + Config.set(value.getKey(), value.getValue()); + else + Config.set(value.getKey(), value.getValues()); + } + } try { Config.save(file); } catch (IOException e) { @@ -105,6 +113,14 @@ private void createFiles(Files files, File file) { Biomes.set("Giants Configuration.Biome Settings.Other.River", ""); Biomes.set("Giants Configuration.Biome Settings.Other.Hell", "- Giant Lava Slime"); Biomes.set("Giants Configuration.Biome Settings.Other.Sky", "");*/ + for (ConfigValues value : ConfigValues.values()) { + if (value.getFile() == Files.BIOMES) { + if (!value.isList()) + Biomes.set(value.getKey(), value.getValue()); + else + Biomes.set(value.getKey(), value.getValues()); + } + } try { Biomes.save(file); } catch (IOException e) { @@ -160,6 +176,14 @@ private void createFiles(Files files, File file) { entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Zombie", false); entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Slime", false); entities.set("Entities Configuration.Damage Settings.Block Damage.Allow Cacti Damage.Giant Lava Slime", false);*/ + for (ConfigValues value : ConfigValues.values()) { + if (value.getFile() == Files.ENTITIES) { + if (!value.isList()) + entities.set(value.getKey(), value.getValue()); + else + entities.set(value.getKey(), value.getValues()); + } + } try { entities.save(file); } catch (IOException e) { @@ -190,6 +214,14 @@ private void createFiles(Files files, File file) { attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Baby Zombies", false); attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Zombies to Spawn", new Integer(5)); attacks.set("Attacks Configuration.Attack Mechanisms.Spawn Zombies On Death.Health", new Integer(20));*/ + for (ConfigValues value : ConfigValues.values()) { + if (value.getFile() == Files.ATTACKS) { + if (!value.isList()) + attacks.set(value.getKey(), value.getValue()); + else + attacks.set(value.getKey(), value.getValues()); + } + } try { attacks.save(file); } catch (IOException e) { @@ -202,6 +234,14 @@ private void createFiles(Files files, File file) { Jockey.set("Jockey Configuration.File Version", FileSetup.loadVersion()); Jockey.set("Jockey Configuration", new String("This entity of Giants is extremely experimental and does not have many features")); Jockey.set("Jockey Configuration.Spawn Settings.Worlds", loadWorlds()); + for (ConfigValues value : ConfigValues.values()) { + if (value.getFile() == Files.JOCKEY) { + if (!value.isList()) + Jockey.set(value.getKey(), value.getValue()); + else + Jockey.set(value.getKey(), value.getValues()); + } + } try { Jockey.save(file); } catch (IOException e) { @@ -212,7 +252,7 @@ private void createFiles(Files files, File file) { case JOCKEYBIOMES: if (getProperty(Files.CONFIG, "Giants Configuration.Entities.Giant Jockey.Warning.Enabled").equalsIgnoreCase("true")) { YamlConfiguration JockeyBiomes = YamlConfiguration.loadConfiguration(file); - JockeyBiomes.set("Giants Configuration.File Version", FileSetup.loadVersion()); +/* JockeyBiomes.set("Giants Configuration.File Version", FileSetup.loadVersion()); JockeyBiomes.set("Giants Configuration.Biome Settings.Swampland", true); JockeyBiomes.set("Giants Configuration.Biome Settings.Forest", true); JockeyBiomes.set("Giants Configuration.Biome Settings.Taiga", true); @@ -230,7 +270,15 @@ private void createFiles(Files files, File file) { JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Ocean", false); JockeyBiomes.set("Giants Configuration.Biome Settings.Other.River", false); JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Hell", true); - JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Sky", true); + JockeyBiomes.set("Giants Configuration.Biome Settings.Other.Sky", true);*/ + for (ConfigValues value : ConfigValues.values()) { + if (value.getFile() == Files.JOCKEYBIOMES) { + if (!value.isList()) + JockeyBiomes.set(value.getKey(), value.getValue()); + else + JockeyBiomes.set(value.getKey(), value.getValues()); + } + } try { JockeyBiomes.save(file); } catch (IOException e) { @@ -275,6 +323,8 @@ public List getPropertyList(Files file, String path) { * @return String property from the config file the value is saved in. */ public String getProperty(ConfigValues value) { + if (value == ConfigValues.soundsBoolean) + return "false"; FileConfiguration config = _configurations.get(value.getFile()); if (config != null) { String property = config.getString(value.getKey(), "NULL"); From d083dc908518e24792180913251b110e06c76144 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Wed, 8 Jun 2016 03:51:13 -0700 Subject: [PATCH 12/28] Pushing poms to use filehandler 1.1-SNAPSHOT --- Giants/pom.xml | 55 ++++++++++++++++++++++++++++++++++++++++++------- v1_8_R3/pom.xml | 13 ++++++++++++ 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/Giants/pom.xml b/Giants/pom.xml index 2ac9645..68be67d 100644 --- a/Giants/pom.xml +++ b/Giants/pom.xml @@ -29,7 +29,7 @@ me.Mammothskier Giants-Files - 1.0-SNAPSHOT + 1.1-SNAPSHOT org.bukkit @@ -42,12 +42,16 @@ me.Mammothskier Giants-v1_7_R3 - v1 + 2.0-SNAPSHOT org.bukkit craftbukkit + + me.Mammothskier + Giants-Files + true @@ -55,12 +59,16 @@ me.Mammothskier Giants-v1_7_R4 - v1 + 2.0-SNAPSHOT org.bukkit craftbukkit + + me.Mammothskier + Giants-Files + true @@ -68,12 +76,16 @@ me.Mammothskier Giants-v1_8_R1 - v1 + 2.0-SNAPSHOT org.bukkit craftbukkit + + me.Mammothskier + Giants-Files + true @@ -81,12 +93,16 @@ me.Mammothskier Giants-v1_8_R2 - v1 + 2.0-SNAPSHOT org.bukkit craftbukkit + + me.Mammothskier + Giants-Files + true @@ -94,12 +110,16 @@ me.Mammothskier Giants-v1_8_R3 - v1 + 2.0-SNAPSHOT org.bukkit craftbukkit + + me.Mammothskier + Giants-Files + true @@ -107,12 +127,33 @@ me.Mammothskier Giants-v1_9_R1 - v1 + 2.0-SNAPSHOT + + + org.bukkit + craftbukkit + + + me.Mammothskier + Giants-Files + + + true + + + + me.Mammothskier + Giants-v1_9_R2 + 2.0-SNAPSHOT org.bukkit craftbukkit + + me.Mammothskier + Giants-Files + true diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index 5570019..5a2602c 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -19,6 +19,19 @@ 1.8.7-R0.1-SNAPSHOT jar + + + me.Mammothskier + Giants-Files + 1.1-SNAPSHOT + + + org.bukkit + craftbukkit + + + true + From 1120d66c13ec63671930ce6ac9db6914771f57af Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Wed, 8 Jun 2016 03:51:26 -0700 Subject: [PATCH 13/28] Update for 1.9.4 --- .../me/Mammothskier/Giants/util/NMSUtils.java | 9 + v1_9_R2/pom.xml | 34 ++++ .../nms/v1_9_R2/CustomEntityGiantZombie.java | 96 ++++++++++ .../entity/nms/v1_9_R2/CustomEntityType.java | 175 ++++++++++++++++++ ...CustomPathfinderGoalGiantZombieAttack.java | 38 ++++ .../entity/nms/v1_9_R2/EntityCreator.java | 17 ++ 6 files changed, 369 insertions(+) create mode 100644 v1_9_R2/pom.xml create mode 100644 v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java create mode 100644 v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityType.java create mode 100644 v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomPathfinderGoalGiantZombieAttack.java create mode 100644 v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/EntityCreator.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java index 054d498..355c088 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java @@ -52,6 +52,9 @@ public static void createGiant(Location location, SpawnReason reason) { case("v1_9_R1"): me.Mammothskier.Giants.entity.nms.v1_9_R1.EntityCreator.createEntity(location, reason); break; + case("v1_9_R2"): + me.Mammothskier.Giants.entity.nms.v1_9_R2.EntityCreator.createEntity(location, reason); + break; } } } @@ -82,6 +85,10 @@ public static void registerEntities() { Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_9_R1 found. Enabling Giant Zombies."); Entities.GiantZombie = true; me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.registerEntities(); + } else if ("v1_9_R2".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_9_R2 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.registerEntities(); } else { Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.RED + "Minecraft server version " + version + "does not support Giant Zombies.Disabling Giant Zombies"); Entities.GiantZombie = false; @@ -102,6 +109,8 @@ public static void unregisterEntities() { me.Mammothskier.Giants.entity.nms.v1_8_R3.CustomEntityType.unregisterEntities(); } else if ("v1_9_R1".equals(version)) { me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.unregisterEntities(); + } else if ("v1_9_R2".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.unregisterEntities(); } } diff --git a/v1_9_R2/pom.xml b/v1_9_R2/pom.xml new file mode 100644 index 0000000..e61e243 --- /dev/null +++ b/v1_9_R2/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + + me.Mammothskier + Giants-Parent + 7.1-SNAPSHOT + + + Giants-v1_9_R2 + 2.0-SNAPSHOT + Giants-v1_9_R2 + + + + org.bukkit + craftbukkit + 1.9.4-R0.1-SNAPSHOT + jar + + + + me.Mammothskier + Giants-Files + 1.1-SNAPSHOT + + + org.bukkit + craftbukkit + + + true + + + \ No newline at end of file diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java new file mode 100644 index 0000000..a6ddaa3 --- /dev/null +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java @@ -0,0 +1,96 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R2; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_9_R2.util.UnsafeList; + +import me.Mammothskier.Giants.Files.ConfigValues; +import me.Mammothskier.Giants.Files.FileHandler; +import net.minecraft.server.v1_9_R2.BlockPosition; +import net.minecraft.server.v1_9_R2.DataWatcher; +import net.minecraft.server.v1_9_R2.DataWatcherObject; +import net.minecraft.server.v1_9_R2.DataWatcherRegistry; +import net.minecraft.server.v1_9_R2.EntityGiantZombie; +import net.minecraft.server.v1_9_R2.EntityHuman; +import net.minecraft.server.v1_9_R2.EntityIronGolem; +import net.minecraft.server.v1_9_R2.EntityPigZombie; +import net.minecraft.server.v1_9_R2.EntityVillager; +import net.minecraft.server.v1_9_R2.EntityZombie; +import net.minecraft.server.v1_9_R2.PathfinderGoalFloat; +import net.minecraft.server.v1_9_R2.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_9_R2.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_9_R2.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_9_R2.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_9_R2.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_9_R2.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_9_R2.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_9_R2.PathfinderGoalSelector; +import net.minecraft.server.v1_9_R2.World; +import net.minecraft.server.v1_9_R2.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + private static final DataWatcherObject by = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.h); + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } + + @Override + protected void initAttributes() { + super.initAttributes(); + String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } + this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); + this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); + } + + protected void o() { + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } + + public float a(BlockPosition position) { + return 0.5F - this.world.n(position); + } +} diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityType.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityType.java new file mode 100644 index 0000000..18bb8d0 --- /dev/null +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R2; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_9_R2.BiomeBase; +import net.minecraft.server.v1_9_R2.BiomeBase.BiomeMeta; +import net.minecraft.server.v1_9_R2.Entity; +import net.minecraft.server.v1_9_R2.EntityInsentient; +import net.minecraft.server.v1_9_R2.EntityTypes; +import net.minecraft.server.v1_9_R2.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.i){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "u", "v", "w", "x" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "u", "v", "w", "x" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomPathfinderGoalGiantZombieAttack.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomPathfinderGoalGiantZombieAttack.java new file mode 100644 index 0000000..61110f5 --- /dev/null +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomPathfinderGoalGiantZombieAttack.java @@ -0,0 +1,38 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R2; + +import net.minecraft.server.v1_9_R2.PathfinderGoalMeleeAttack; + +public class CustomPathfinderGoalGiantZombieAttack extends PathfinderGoalMeleeAttack { + + private final CustomEntityGiantZombie h; + private int i; + + public CustomPathfinderGoalGiantZombieAttack(CustomEntityGiantZombie entityzombie, double d0, boolean flag) { + super(entityzombie, d0, flag); + this.h = entityzombie; + } + + public void c() { + super.c(); + this.setI(0); + } + + public void d() { + super.d(); + this.h.a(false); + } + + /** + * @return the i + */ + public int getI() { + return i; + } + + /** + * @param i the i to set + */ + public void setI(int i) { + this.i = i; + } +} diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/EntityCreator.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/EntityCreator.java new file mode 100644 index 0000000..0145632 --- /dev/null +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/EntityCreator.java @@ -0,0 +1,17 @@ +package me.Mammothskier.Giants.entity.nms.v1_9_R2; + +import net.minecraft.server.v1_9_R2.World; + +import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} From 20c7109c27e95859a4fbd1bf84dd3ef13b30cfc2 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Wed, 8 Jun 2016 03:55:57 -0700 Subject: [PATCH 14/28] Update to poms --- pom.xml | 1 + v1_9_R1/pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cd5a48b..d6cc3a2 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ v1_8_R2 v1_8_R3 v1_9_R1 + v1_9_R2 Giants diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index c3ce28b..36cb563 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -23,7 +23,7 @@ me.Mammothskier Giants-Files - 1.0-SNAPSHOT + 1.1-SNAPSHOT org.bukkit From d260e47a0a5f4f45cf0ba8462620b5a388bd4bfe Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Wed, 8 Jun 2016 03:58:43 -0700 Subject: [PATCH 15/28] Renaming poms --- Giants-Files/pom.xml | 2 +- Giants/dependency-reduced-pom.xml | 37 ------------------------------- v1_9_R2/pom.xml | 2 +- 3 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 Giants/dependency-reduced-pom.xml diff --git a/Giants-Files/pom.xml b/Giants-Files/pom.xml index ce51d2f..6e02d4d 100644 --- a/Giants-Files/pom.xml +++ b/Giants-Files/pom.xml @@ -10,7 +10,7 @@ Giants-Files 1.1-SNAPSHOT - Giants-Files + Giants Files jar diff --git a/Giants/dependency-reduced-pom.xml b/Giants/dependency-reduced-pom.xml deleted file mode 100644 index e177c27..0000000 --- a/Giants/dependency-reduced-pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - Giants-Parent - me.Mammothskier - 7.1-SNAPSHOT - - 4.0.0 - Giants - Giants - 7.1-Beta - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - confuser-repo - http://ci.frostcast.net/plugin/repository/everything - - - - - org.bukkit - bukkit - 1.9.4-R0.1-SNAPSHOT - compile - - - me.confuser - BarAPI - 3.3 - compile - - - - diff --git a/v1_9_R2/pom.xml b/v1_9_R2/pom.xml index e61e243..857a8d5 100644 --- a/v1_9_R2/pom.xml +++ b/v1_9_R2/pom.xml @@ -8,7 +8,7 @@ Giants-v1_9_R2 2.0-SNAPSHOT - Giants-v1_9_R2 + Giants for v1_9_R2 From d28cfe388fd1557d91e304540eb72e667f51d601 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Thu, 9 Jun 2016 06:19:42 -0700 Subject: [PATCH 16/28] Giants update for 1.10 Update for giants to minecraft 1.10 --- Giants/pom.xml | 19 +- .../me/Mammothskier/Giants/util/NMSUtils.java | 13 +- pom.xml | 16 +- v1_10_R1/pom.xml | 43 +++++ .../nms/v1_10_R1/CustomEntityGiantZombie.java | 97 ++++++++++ .../entity/nms/v1_10_R1/CustomEntityType.java | 175 ++++++++++++++++++ ...CustomPathfinderGoalGiantZombieAttack.java | 38 ++++ .../entity/nms/v1_10_R1/EntityCreator.java | 17 ++ .../Mammothskier/Giants_v1_10_R1/AppTest.java | 38 ++++ 9 files changed, 445 insertions(+), 11 deletions(-) create mode 100644 v1_10_R1/pom.xml create mode 100644 v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java create mode 100644 v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityType.java create mode 100644 v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomPathfinderGoalGiantZombieAttack.java create mode 100644 v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/EntityCreator.java create mode 100644 v1_10_R1/src/test/java/me/Mammothskier/Giants_v1_10_R1/AppTest.java diff --git a/Giants/pom.xml b/Giants/pom.xml index 68be67d..f81a484 100644 --- a/Giants/pom.xml +++ b/Giants/pom.xml @@ -8,7 +8,7 @@ Giants Giants - 7.1-Beta + 7.1.1-Beta jar @@ -157,6 +157,23 @@ true + + + me.Mammothskier + Giants-v1_10_R1 + 2.0-SNAPSHOT + + + org.bukkit + craftbukkit + + + me.Mammothskier + Giants-Files + + + true + diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java index 355c088..0c30669 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java +++ b/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java @@ -55,6 +55,9 @@ public static void createGiant(Location location, SpawnReason reason) { case("v1_9_R2"): me.Mammothskier.Giants.entity.nms.v1_9_R2.EntityCreator.createEntity(location, reason); break; + case("v1_10_R1"): + me.Mammothskier.Giants.entity.nms.v1_10_R1.EntityCreator.createEntity(location, reason); + break; } } } @@ -88,7 +91,11 @@ public static void registerEntities() { } else if ("v1_9_R2".equals(version)) { Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_9_R2 found. Enabling Giant Zombies."); Entities.GiantZombie = true; - me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.registerEntities(); + me.Mammothskier.Giants.entity.nms.v1_9_R2.CustomEntityType.registerEntities(); + } else if ("v1_10_R1".equals(version)) { + Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + "Minecraft server version v1_10_R1 found. Enabling Giant Zombies."); + Entities.GiantZombie = true; + me.Mammothskier.Giants.entity.nms.v1_10_R1.CustomEntityType.registerEntities(); } else { Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.RED + "Minecraft server version " + version + "does not support Giant Zombies.Disabling Giant Zombies"); Entities.GiantZombie = false; @@ -110,7 +117,9 @@ public static void unregisterEntities() { } else if ("v1_9_R1".equals(version)) { me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.unregisterEntities(); } else if ("v1_9_R2".equals(version)) { - me.Mammothskier.Giants.entity.nms.v1_9_R1.CustomEntityType.unregisterEntities(); + me.Mammothskier.Giants.entity.nms.v1_9_R2.CustomEntityType.unregisterEntities(); + } else if ("v1_10_R1".equals(version)) { + me.Mammothskier.Giants.entity.nms.v1_10_R1.CustomEntityType.unregisterEntities(); } } diff --git a/pom.xml b/pom.xml index d6cc3a2..1182808 100644 --- a/pom.xml +++ b/pom.xml @@ -9,17 +9,17 @@ Giants-Files - v1_7_R3 v1_7_R4 v1_8_R1 v1_8_R2 v1_8_R3 v1_9_R1 - v1_9_R2 + v1_9_R2 + v1_10_R1 Giants - + spigot-repo @@ -54,10 +54,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.0 + 3.1 - 1.7 - 1.7 + 1.8 + 1.8 @@ -178,9 +178,9 @@ 0 - DEFAULT + Custom - ${project.version}-b${project.build.number}-${project.build.type} + ${project.version}-${project.build.type} ${project.name} diff --git a/v1_10_R1/pom.xml b/v1_10_R1/pom.xml new file mode 100644 index 0000000..0ba38e1 --- /dev/null +++ b/v1_10_R1/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + me.Mammothskier + Giants-Parent + 7.1-SNAPSHOT + + + Giants-v1_10_R1 + 2.0-SNAPSHOT + Giants-v1_10_R1 + + + + org.bukkit + craftbukkit + 1.10-R0.1-SNAPSHOT + jar + + + + me.Mammothskier + Giants-Files + 1.0-SNAPSHOT + + + org.bukkit + craftbukkit + + + true + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java new file mode 100644 index 0000000..cfc56a5 --- /dev/null +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java @@ -0,0 +1,97 @@ +package me.Mammothskier.Giants.entity.nms.v1_10_R1; + +import java.lang.reflect.Field; + +import org.bukkit.craftbukkit.v1_10_R1.util.UnsafeList; + +import me.Mammothskier.Giants.Files.ConfigValues; +import me.Mammothskier.Giants.Files.FileHandler; +import net.minecraft.server.v1_10_R1.BlockPosition; +import net.minecraft.server.v1_10_R1.DataWatcher; +import net.minecraft.server.v1_10_R1.DataWatcherObject; +import net.minecraft.server.v1_10_R1.DataWatcherRegistry; +import net.minecraft.server.v1_10_R1.EntityGiantZombie; +import net.minecraft.server.v1_10_R1.EntityHuman; +import net.minecraft.server.v1_10_R1.EntityIronGolem; +import net.minecraft.server.v1_10_R1.EntityPigZombie; +import net.minecraft.server.v1_10_R1.EntityVillager; +import net.minecraft.server.v1_10_R1.EntityZombie; +import net.minecraft.server.v1_10_R1.PathfinderGoalFloat; +import net.minecraft.server.v1_10_R1.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_10_R1.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_10_R1.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_10_R1.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_10_R1.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_10_R1.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_10_R1.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_10_R1.PathfinderGoalSelector; +import net.minecraft.server.v1_10_R1.World; +import net.minecraft.server.v1_10_R1.GenericAttributes; + +public class CustomEntityGiantZombie extends EntityGiantZombie { + + private static final DataWatcherObject by = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.h); + + public CustomEntityGiantZombie(World world) { + super(world); + try { + Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); + bField.setAccessible(true); + Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); + cField.setAccessible(true); + bField.set(goalSelector, new UnsafeList()); + bField.set(targetSelector, new UnsafeList()); + cField.set(goalSelector, new UnsafeList()); + cField.set(targetSelector, new UnsafeList()); + this.n(); + } catch (Exception exc) { + exc.printStackTrace(); + } + + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + } + + @Override + public float getHeadHeight() { + return 14.440001F; + } + + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } + + @Override + protected void initAttributes() { + super.initAttributes(); + String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } + this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); + this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); + } + + protected void o() { + this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } + + @Override + public float a(BlockPosition position) { + return 0.5F - this.world.n(position); + } +} diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityType.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityType.java new file mode 100644 index 0000000..d2b837a --- /dev/null +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityType.java @@ -0,0 +1,175 @@ +package me.Mammothskier.Giants.entity.nms.v1_10_R1; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_10_R1.BiomeBase; +import net.minecraft.server.v1_10_R1.BiomeBase.BiomeMeta; +import net.minecraft.server.v1_10_R1.Entity; +import net.minecraft.server.v1_10_R1.EntityInsentient; +import net.minecraft.server.v1_10_R1.EntityTypes; +import net.minecraft.server.v1_10_R1.EntityGiantZombie; + +import org.bukkit.entity.EntityType; + +public enum CustomEntityType { + + GIANT("Giant", 53, EntityType.GIANT, EntityGiantZombie.class, CustomEntityGiantZombie.class); + + private String name; + private int id; + private EntityType entityType; + private Class nmsClass; + private Class customClass; + + private CustomEntityType(String name, int id, EntityType entityType, + Class nmsClass, + Class customClass) { + this.name = name; + this.id = id; + this.entityType = entityType; + this.nmsClass = nmsClass; + this.customClass = customClass; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } + + public EntityType getEntityType() { + return entityType; + } + + public Class getNMSClass() { + return nmsClass; + } + + public Class getCustomClass() { + return customClass; + } + + /** + * Register our entities. + */ + public static void registerEntities() { + for (CustomEntityType entity : values()) + a(entity.getCustomClass(), entity.getName(), entity.getID()); + + // BiomeBase#biomes became private. But we can use the public method getBiomes() to get the array + for (BiomeBase biomeBase : BiomeBase.i){ + if (biomeBase == null) + break; + + // This changed names from J, K, L and M. + for (String field : new String[] { "u", "v", "w", "x" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + @SuppressWarnings("unchecked") + List mobList = (List) list + .get(biomeBase); + + // Write in our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getNMSClass().equals(meta.b)) + meta.b = entity.getCustomClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Unregister our entities to prevent memory leaks. Call on disable. + */ + @SuppressWarnings("unchecked") + public static void unregisterEntities() { + for (CustomEntityType entity : values()) { + // Remove our class references. + try { + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).remove(entity.getCustomClass()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + for (CustomEntityType entity : values()) + try { + // Unregister each entity by writing the NMS back in place of the custom class. + a(entity.getNMSClass(), entity.getName(), entity.getID()); + } catch (Exception e) { + e.printStackTrace(); + } + + // Biomes#biomes was made private so use reflection to get it. + BiomeBase[] biomes; + try { + biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes"); + } catch (Exception exc) { + // Unable to fetch. + return; + } + for (BiomeBase biomeBase : biomes) { + if (biomeBase == null) + break; + + // The list fields changed names but update the meta regardless. + for (String field : new String[] { "u", "v", "w", "x" }) + try { + Field list = BiomeBase.class.getDeclaredField(field); + list.setAccessible(true); + List mobList = (List) list.get(biomeBase); + + // Make sure the NMS class is written back over our custom class. + for (BiomeMeta meta : mobList) + for (CustomEntityType entity : values()) + if (entity.getCustomClass().equals(meta.b)) + meta.b = entity.getNMSClass(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * A convenience method. + * @param clazz The class. + * @param f The string representation of the private static field. + * @return The object found + * @throws Exception if unable to get the object. + */ + @SuppressWarnings("rawtypes") + private static Object getPrivateStatic(Class clazz, String f) throws Exception { + Field field = clazz.getDeclaredField(f); + field.setAccessible(true); + return field.get(null); + } + + /* + * Since 1.7.2 added a check in their entity registration, simply bypass it and write to the maps ourself. + */ + @SuppressWarnings("unchecked") + private static void a(Class paramClass, String paramString, int paramInt) { + try { + ((Map>) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); + ((Map, String>) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); + ((Map>) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); + ((Map, Integer>) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, Integer.valueOf(paramInt)); + ((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, Integer.valueOf(paramInt)); + } catch (Exception exc) { + // Unable to register the new class. + } + } +} diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomPathfinderGoalGiantZombieAttack.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomPathfinderGoalGiantZombieAttack.java new file mode 100644 index 0000000..c4c1dc3 --- /dev/null +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomPathfinderGoalGiantZombieAttack.java @@ -0,0 +1,38 @@ +package me.Mammothskier.Giants.entity.nms.v1_10_R1; + +import net.minecraft.server.v1_10_R1.PathfinderGoalMeleeAttack; + +public class CustomPathfinderGoalGiantZombieAttack extends PathfinderGoalMeleeAttack { + + private final CustomEntityGiantZombie h; + private int i; + + public CustomPathfinderGoalGiantZombieAttack(CustomEntityGiantZombie entityzombie, double d0, boolean flag) { + super(entityzombie, d0, flag); + this.h = entityzombie; + } + + public void c() { + super.c(); + this.setI(0); + } + + public void d() { + super.d(); + this.h.a(false); + } + + /** + * @return the i + */ + public int getI() { + return i; + } + + /** + * @param i the i to set + */ + public void setI(int i) { + this.i = i; + } +} diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/EntityCreator.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/EntityCreator.java new file mode 100644 index 0000000..b61655c --- /dev/null +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/EntityCreator.java @@ -0,0 +1,17 @@ +package me.Mammothskier.Giants.entity.nms.v1_10_R1; + +import net.minecraft.server.v1_10_R1.World; + +import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; + +public class EntityCreator { + + public static void createEntity (Location location, SpawnReason reason) { + World world = ((CraftWorld) location.getWorld()).getHandle(); + CustomEntityGiantZombie giant = new CustomEntityGiantZombie(world); + giant.setPosition(location.getX(), location.getY(), location.getZ()); + world.addEntity(giant, reason); + } +} diff --git a/v1_10_R1/src/test/java/me/Mammothskier/Giants_v1_10_R1/AppTest.java b/v1_10_R1/src/test/java/me/Mammothskier/Giants_v1_10_R1/AppTest.java new file mode 100644 index 0000000..741adf7 --- /dev/null +++ b/v1_10_R1/src/test/java/me/Mammothskier/Giants_v1_10_R1/AppTest.java @@ -0,0 +1,38 @@ +package me.Mammothskier.Giants_v1_10_R1; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} From 9a5f219247fe8d9ff787056c993b327483ac820c Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Thu, 9 Jun 2016 06:27:37 -0700 Subject: [PATCH 17/28] Fix poms to correctly compile --- v1_10_R1/pom.xml | 4 ++-- v1_9_R2/pom.xml | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/v1_10_R1/pom.xml b/v1_10_R1/pom.xml index 0ba38e1..9443445 100644 --- a/v1_10_R1/pom.xml +++ b/v1_10_R1/pom.xml @@ -10,7 +10,7 @@ Giants-v1_10_R1 2.0-SNAPSHOT - Giants-v1_10_R1 + Giants for v1_10_R1 @@ -23,7 +23,7 @@ me.Mammothskier Giants-Files - 1.0-SNAPSHOT + 1.1-SNAPSHOT org.bukkit diff --git a/v1_9_R2/pom.xml b/v1_9_R2/pom.xml index 857a8d5..d7f728d 100644 --- a/v1_9_R2/pom.xml +++ b/v1_9_R2/pom.xml @@ -8,7 +8,7 @@ Giants-v1_9_R2 2.0-SNAPSHOT - Giants for v1_9_R2 + Giants-v1_9_R2 @@ -31,4 +31,11 @@ true + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + \ No newline at end of file From 88d7c8c41bc0a8b01824a59fd583ea9543155da4 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Thu, 9 Jun 2016 06:29:41 -0700 Subject: [PATCH 18/28] Rename 1_9_R2 pom --- v1_9_R2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v1_9_R2/pom.xml b/v1_9_R2/pom.xml index d7f728d..a95a4e1 100644 --- a/v1_9_R2/pom.xml +++ b/v1_9_R2/pom.xml @@ -8,7 +8,7 @@ Giants-v1_9_R2 2.0-SNAPSHOT - Giants-v1_9_R2 + Giants for v1_9_R2 From f7b155ded3865639b40d6a4750b4907c991cd139 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Thu, 9 Jun 2016 06:34:25 -0700 Subject: [PATCH 19/28] One last time attempt to fix poms --- Giants-Files/pom.xml | 2 +- Giants/pom.xml | 2 +- pom.xml | 2 +- v1_10_R1/pom.xml | 2 +- v1_7_R3/pom.xml | 2 +- v1_7_R4/pom.xml | 2 +- v1_8_R1/pom.xml | 2 +- v1_8_R2/pom.xml | 2 +- v1_8_R3/pom.xml | 2 +- v1_9_R1/pom.xml | 2 +- v1_9_R2/pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Giants-Files/pom.xml b/Giants-Files/pom.xml index 6e02d4d..f2d622e 100644 --- a/Giants-Files/pom.xml +++ b/Giants-Files/pom.xml @@ -5,7 +5,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT Giants-Files diff --git a/Giants/pom.xml b/Giants/pom.xml index f81a484..4b6ed42 100644 --- a/Giants/pom.xml +++ b/Giants/pom.xml @@ -3,7 +3,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT Giants diff --git a/pom.xml b/pom.xml index 1182808..8820b13 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT pom diff --git a/v1_10_R1/pom.xml b/v1_10_R1/pom.xml index 9443445..3fbd1e9 100644 --- a/v1_10_R1/pom.xml +++ b/v1_10_R1/pom.xml @@ -5,7 +5,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT Giants-v1_10_R1 diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 14e775b..3e9e72f 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT diff --git a/v1_7_R4/pom.xml b/v1_7_R4/pom.xml index d4346f8..fde9237 100644 --- a/v1_7_R4/pom.xml +++ b/v1_7_R4/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT diff --git a/v1_8_R1/pom.xml b/v1_8_R1/pom.xml index 7e49bcf..108dac9 100644 --- a/v1_8_R1/pom.xml +++ b/v1_8_R1/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT diff --git a/v1_8_R2/pom.xml b/v1_8_R2/pom.xml index 5d5ac88..7a4347e 100644 --- a/v1_8_R2/pom.xml +++ b/v1_8_R2/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index 5a2602c..dd30936 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index 36cb563..ac55321 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -9,7 +9,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT diff --git a/v1_9_R2/pom.xml b/v1_9_R2/pom.xml index a95a4e1..1ca7ac5 100644 --- a/v1_9_R2/pom.xml +++ b/v1_9_R2/pom.xml @@ -3,7 +3,7 @@ me.Mammothskier Giants-Parent - 7.1-SNAPSHOT + 7.1.1-SNAPSHOT Giants-v1_9_R2 From 539892a15f70a96b81d2c7ba4a6498e86b9c494b Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 11 Jun 2016 18:08:45 -0700 Subject: [PATCH 20/28] Update poms --- Giants-Files/pom.xml | 7 ------- Giants/pom.xml | 23 +++++++++-------------- pom.xml | 4 ++-- v1_10_R1/pom.xml | 9 +-------- v1_7_R3/pom.xml | 1 - v1_8_R3/pom.xml | 9 +-------- v1_9_R1/pom.xml | 9 +-------- v1_9_R2/pom.xml | 9 +-------- 8 files changed, 15 insertions(+), 56 deletions(-) diff --git a/Giants-Files/pom.xml b/Giants-Files/pom.xml index f2d622e..fd49607 100644 --- a/Giants-Files/pom.xml +++ b/Giants-Files/pom.xml @@ -21,11 +21,4 @@ jar - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - diff --git a/Giants/pom.xml b/Giants/pom.xml index 4b6ed42..6f33b80 100644 --- a/Giants/pom.xml +++ b/Giants/pom.xml @@ -36,7 +36,7 @@ craftbukkit - true + false @@ -53,7 +53,7 @@ Giants-Files - true + false @@ -70,7 +70,7 @@ Giants-Files - true + false @@ -87,7 +87,7 @@ Giants-Files - true + false @@ -104,7 +104,7 @@ Giants-Files - true + false @@ -121,7 +121,7 @@ Giants-Files - true + false @@ -138,7 +138,7 @@ Giants-Files - true + false @@ -155,7 +155,7 @@ Giants-Files - true + false @@ -172,16 +172,11 @@ Giants-Files - true + false - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - confuser-repo http://ci.frostcast.net/plugin/repository/everything diff --git a/pom.xml b/pom.xml index 8820b13..ea137d6 100644 --- a/pom.xml +++ b/pom.xml @@ -56,8 +56,8 @@ maven-compiler-plugin 3.1 - 1.8 - 1.8 + 1.7 + 1.7 diff --git a/v1_10_R1/pom.xml b/v1_10_R1/pom.xml index 3fbd1e9..38a843e 100644 --- a/v1_10_R1/pom.xml +++ b/v1_10_R1/pom.xml @@ -30,14 +30,7 @@ craftbukkit - true + false - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - diff --git a/v1_7_R3/pom.xml b/v1_7_R3/pom.xml index 3e9e72f..a1f46f7 100644 --- a/v1_7_R3/pom.xml +++ b/v1_7_R3/pom.xml @@ -26,6 +26,5 @@ 1.7.9-R0.2 jar - \ No newline at end of file diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index dd30936..8bed2f2 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -30,14 +30,7 @@ craftbukkit - true + false - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - \ No newline at end of file diff --git a/v1_9_R1/pom.xml b/v1_9_R1/pom.xml index ac55321..4a376e1 100644 --- a/v1_9_R1/pom.xml +++ b/v1_9_R1/pom.xml @@ -30,14 +30,7 @@ craftbukkit - true + false - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - \ No newline at end of file diff --git a/v1_9_R2/pom.xml b/v1_9_R2/pom.xml index 1ca7ac5..108af95 100644 --- a/v1_9_R2/pom.xml +++ b/v1_9_R2/pom.xml @@ -28,14 +28,7 @@ craftbukkit - true + false - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - \ No newline at end of file From a9b87d86396c688b59bd67878bbb791903c8ecc5 Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 11 Jun 2016 18:13:08 -0700 Subject: [PATCH 21/28] Update .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 5b96e02..9cceb44 100644 --- a/.gitignore +++ b/.gitignore @@ -230,3 +230,9 @@ pip-log.txt #Mr Developer .mr.developer.cfg +v1_10_R1/dependency-reduced-pom.xml +v1_9_R2/dependency-reduced-pom.xml +v1_9_R1/dependency-reduced-pom.xml +v1_8_R3/dependency-reduced-pom.xml +v1_8_R2/dependency-reduced-pom.xml +v1_8_R1/dependency-reduced-pom.xml From 0fcec04d743d1efcc2ff3f7e9c4bae50864ca8d3 Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 11 Jun 2016 18:13:17 -0700 Subject: [PATCH 22/28] Update pom.xml --- v1_10_R1/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v1_10_R1/pom.xml b/v1_10_R1/pom.xml index 38a843e..6ed9753 100644 --- a/v1_10_R1/pom.xml +++ b/v1_10_R1/pom.xml @@ -30,7 +30,7 @@ craftbukkit - false + true From 14d07d8b6d1d446818199e2c3ece0ebe091b6de4 Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 11 Jun 2016 21:16:50 -0700 Subject: [PATCH 23/28] renaming file module and plugin module --- .../test/java/org/Giants/Files/AppTest.java | 38 ---------- {Giants-Files => files}/pom.xml | 0 .../Giants/Files/ConfigValues.java | 40 +++------- .../Giants/Files/FileHandler.java | 0 .../Mammothskier/Giants/Files/FileSetup.java | 0 .../me/Mammothskier/Giants/Files/Files.java | 0 {Giants => plugin}/pom.xml | 2 +- .../Mammothskier/Giants/BarAPI/HealthBar.java | 0 .../java/me/Mammothskier/Giants/Commands.java | 0 .../java/me/Mammothskier/Giants/Giants.java | 0 .../Giants/entity/DamageListener.java | 0 .../Giants/entity/DropsManager.java | 0 .../Mammothskier/Giants/entity/Entities.java | 0 .../Giants/entity/GiantListeners.java | 0 .../Giants/entity/MagmaCubeListeners.java | 0 .../Giants/entity/SlimeListeners.java | 0 .../Giants/events/JockeySpawnEvent.java | 0 .../Giants/events/SpawnEvent.java | 76 +++++++++---------- .../me/Mammothskier/Giants/util/Metrics.java | 0 .../me/Mammothskier/Giants/util/NMSUtils.java | 0 .../src/main/resources/biomes.yml | 0 .../src/main/resources/config.yml | 0 .../src/main/resources/giant.yml | 0 .../src/main/resources/jockey.yml | 0 .../src/main/resources/magmacube.yml | 0 .../src/main/resources/plugin.yml | 0 .../src/main/resources/slime.yml | 0 pom.xml | 4 +- 28 files changed, 52 insertions(+), 108 deletions(-) delete mode 100644 Giants-Files/src/test/java/org/Giants/Files/AppTest.java rename {Giants-Files => files}/pom.xml (100%) rename {Giants-Files => files}/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java (91%) rename {Giants-Files => files}/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java (100%) rename {Giants-Files => files}/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java (100%) rename {Giants-Files => files}/src/main/java/me/Mammothskier/Giants/Files/Files.java (100%) rename {Giants => plugin}/pom.xml (99%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/Commands.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/Giants.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/entity/Entities.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java (80%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/util/Metrics.java (100%) rename {Giants => plugin}/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java (100%) rename {Giants => plugin}/src/main/resources/biomes.yml (100%) rename {Giants => plugin}/src/main/resources/config.yml (100%) rename {Giants => plugin}/src/main/resources/giant.yml (100%) rename {Giants => plugin}/src/main/resources/jockey.yml (100%) rename {Giants => plugin}/src/main/resources/magmacube.yml (100%) rename {Giants => plugin}/src/main/resources/plugin.yml (100%) rename {Giants => plugin}/src/main/resources/slime.yml (100%) diff --git a/Giants-Files/src/test/java/org/Giants/Files/AppTest.java b/Giants-Files/src/test/java/org/Giants/Files/AppTest.java deleted file mode 100644 index 7200245..0000000 --- a/Giants-Files/src/test/java/org/Giants/Files/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.Giants.Files; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/Giants-Files/pom.xml b/files/pom.xml similarity index 100% rename from Giants-Files/pom.xml rename to files/pom.xml diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java b/files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java similarity index 91% rename from Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java rename to files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java index 0d44876..a7b0922 100644 --- a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java +++ b/files/src/main/java/me/Mammothskier/Giants/Files/ConfigValues.java @@ -1,5 +1,6 @@ package me.Mammothskier.Giants.Files; +import java.io.Serializable; import java.util.Arrays; import java.util.List; @@ -74,9 +75,16 @@ public enum ConfigValues { slimeExperience(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Slime", new Integer(5)), lavaSlimeExperience(Files.ENTITIES, "Entities Configuration.Stats.Experience.Giant Lava Slime", new Integer(5)), //Armour - zombieArmour(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items", - new String("chainmail_helmet:chainmail_chestplate:chainmail_leggings:chainmail_boots:diamond_sword")), - armourDropRate(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate", new Float(8.5)), + zombieHelmet(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Helmet", + new String("diamond_helmet protection:1 unbreaking:1 aqua_affinity:1 projectile_protection:4 name:'Giant Helmet' dropRate:8.5")), + zombieChestPlate(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.ChestPlate", + new String("diamond_chestplate protection:1 unbreaking:1 fire_protection:1 blast_protection:1 projectile_protection:4 name:'Giant ChestPlate' dropRate:8.5")), + zombieLeggings(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Leggings", + new String("diamond_leggings protection:1 unbreaking:1 fire_protection:1 blast_protection:1 projectile_protection:4 name:'Giant Leggings' dropRate:8.5")), + zombieBoots(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Boots", + new String("diamond_boots protection:1 unbreaking:1 fire_protection:1 blast_protection:1 projectile_protection:4 name:'Giant Boots' dropRate:8.5")), + zombieMainHand(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.MainHand", + new String("diamond_sword sharpness:1 fire_aspect:1 unbreaking:1 knockback:1 smite:1 name:'Giant Sword' dropRate:8.5")), //Drops dropManager(Files.ENTITIES, "Entities Configuration.Stats.Drops.Enable Drop Manager", true), zombieDrops(Files.ENTITIES, "Entities Configuration.Stats.Drops.Giant Zombie", Arrays.asList(FileSetup.loadDefaultDrop("Giant Zombie"))), @@ -161,23 +169,7 @@ public enum ConfigValues { private final List _values; private final boolean list; - private ConfigValues(Files file, String key, String value) { - _files = file; - _key = key; - _value= value; - _values = null; - list = false; - } - - private ConfigValues(Files file, String key, int value) { - _files = file; - _key = key; - _value= value + ""; - _values = null; - list = false; - } - - private ConfigValues(Files file, String key, float value) { + private ConfigValues(Files file, String key, Serializable value) { _files = file; _key = key; _value= value + ""; @@ -185,14 +177,6 @@ private ConfigValues(Files file, String key, float value) { list = false; } - private ConfigValues(Files file, String key, boolean value) { - _files = file; - _key = key; - _value = value == true ? "true" : "false"; - _values = null; - list = false; - } - private ConfigValues(String key, String value) { _files = null; _key = key; diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java b/files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java similarity index 100% rename from Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java rename to files/src/main/java/me/Mammothskier/Giants/Files/FileHandler.java diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java b/files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java similarity index 100% rename from Giants-Files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java rename to files/src/main/java/me/Mammothskier/Giants/Files/FileSetup.java diff --git a/Giants-Files/src/main/java/me/Mammothskier/Giants/Files/Files.java b/files/src/main/java/me/Mammothskier/Giants/Files/Files.java similarity index 100% rename from Giants-Files/src/main/java/me/Mammothskier/Giants/Files/Files.java rename to files/src/main/java/me/Mammothskier/Giants/Files/Files.java diff --git a/Giants/pom.xml b/plugin/pom.xml similarity index 99% rename from Giants/pom.xml rename to plugin/pom.xml index 6f33b80..7ee8294 100644 --- a/Giants/pom.xml +++ b/plugin/pom.xml @@ -7,7 +7,7 @@ Giants - Giants + Giants-plugins 7.1.1-Beta jar diff --git a/Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java b/plugin/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java rename to plugin/src/main/java/me/Mammothskier/Giants/BarAPI/HealthBar.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Commands.java b/plugin/src/main/java/me/Mammothskier/Giants/Commands.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/Commands.java rename to plugin/src/main/java/me/Mammothskier/Giants/Commands.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/Giants.java b/plugin/src/main/java/me/Mammothskier/Giants/Giants.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/Giants.java rename to plugin/src/main/java/me/Mammothskier/Giants/Giants.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java b/plugin/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java rename to plugin/src/main/java/me/Mammothskier/Giants/entity/DamageListener.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java b/plugin/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java rename to plugin/src/main/java/me/Mammothskier/Giants/entity/DropsManager.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java b/plugin/src/main/java/me/Mammothskier/Giants/entity/Entities.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/entity/Entities.java rename to plugin/src/main/java/me/Mammothskier/Giants/entity/Entities.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java b/plugin/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java rename to plugin/src/main/java/me/Mammothskier/Giants/entity/GiantListeners.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java b/plugin/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java rename to plugin/src/main/java/me/Mammothskier/Giants/entity/MagmaCubeListeners.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java b/plugin/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java rename to plugin/src/main/java/me/Mammothskier/Giants/entity/SlimeListeners.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java b/plugin/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java rename to plugin/src/main/java/me/Mammothskier/Giants/events/JockeySpawnEvent.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java b/plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java similarity index 80% rename from Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java rename to plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java index 1895957..4892f3c 100644 --- a/Giants/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java +++ b/plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Giants; import me.Mammothskier.Giants.Files.Files; import me.Mammothskier.Giants.entity.Entities; @@ -10,6 +11,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Biome; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Damageable; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -34,10 +36,7 @@ public SpawnEvent(Location loc, EntityType entityType) { int size = 0; if (entityType.equals(EntityType.SLIME) || entityType.equals(EntityType.MAGMA_CUBE)) { - String s; - if (entityType.equals(EntityType.SLIME)) - s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Slime"); - else s = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Spawn Settings.Size.Giant Lava Slime"); + String s = entityType.equals(EntityType.SLIME) ? Giants.getProperty(ConfigValues.slimeSize) : Giants.getProperty(ConfigValues.lavaSlimeSize); try { size = Integer.parseInt(s); @@ -137,45 +136,44 @@ public SpawnEvent(Location loc, EntityType entityType) { ((Damageable) entity).setMaxHealth(health); ((Damageable) entity).setHealth(health); if (entity.getType() == EntityType.GIANT) { - EntityEquipment armour = ((LivingEntity) entity).getEquipment(); - String config = Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Items"); - String[] s = config.split(":"); - - float rate = 0f; - try { - rate = Float.parseFloat(Giants.getProperty(Files.ENTITIES, "Entities Configuration.Stats.Equipped Armour.Giant Zombie.Equipped Item Drop Rate")); - } catch (Exception e){ - rate = 0; - } - - try { - for (int i = 0; i < s.length; i++) { - Material m = Material.getMaterial(s[i].toUpperCase()); - ItemStack item = new ItemStack(m); - if (i == 0) { - armour.setHelmet(item); - armour.setHelmetDropChance(rate); - } else if (i == 1) { - armour.setChestplate(item); - armour.setChestplateDropChance(rate); - } else if (i == 2) { - armour.setLeggings(item); - armour.setLeggingsDropChance(rate); - } else if (i == 3) { - armour.setBoots(item); - armour.setBootsDropChance(rate); - } else if (i == 4) { - armour.setItemInHand(item); - armour.setItemInHandDropChance(rate); - } - } - } catch (Exception e) { - e.printStackTrace(); - } + EntityEquipment entityArmour = ((LivingEntity) entity).getEquipment(); + + float dropChance = 0; + entityArmour.setHelmet(parseArmour(ConfigValues.zombieHelmet, dropChance)); + entityArmour.setHelmetDropChance(dropChance); + entityArmour.setChestplate(parseArmour(ConfigValues.zombieChestPlate, dropChance)); + entityArmour.setChestplateDropChance(dropChance); + entityArmour.setLeggings(parseArmour(ConfigValues.zombieLeggings, dropChance)); + entityArmour.setLeggingsDropChance(dropChance); + entityArmour.setBoots(parseArmour(ConfigValues.zombieBoots, dropChance)); + entityArmour.setBootsDropChance(dropChance); + entityArmour.setItemInMainHand(parseArmour(ConfigValues.zombieMainHand, dropChance)); + entityArmour.setItemInMainHandDropChance(dropChance); } } } } + + private ItemStack parseArmour(ConfigValues value, float dropRate) { + String string = Giants.getProperty(value); + String[] split = string.split(" "); + ItemStack itemStack = null; + for (String each : split) { + if (each.contains("item:")) { + Material material = Material.getMaterial(each.split(":")[1].toUpperCase()); + itemStack = new ItemStack(material); + continue; + } else if (each.contains("name:") && itemStack != null) { + itemStack.getItemMeta().setDisplayName(each.split(":")[1]); + continue; + } else if (each.contains("dropRate:")) { + dropRate = Float.parseFloat(each.split(":")[1]); + } + String[] enchant = each.split(":"); + itemStack.addEnchantment(Enchantment.getByName(enchant[0].toUpperCase()), Integer.parseInt(enchant[1])); + } + return itemStack; + } private Entity spawnMob(EntityType entityType, List l, Location loc, int size) { if ((entityType.equals(EntityType.GIANT) && l.contains("Giant Zombie")) || diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/Metrics.java b/plugin/src/main/java/me/Mammothskier/Giants/util/Metrics.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/util/Metrics.java rename to plugin/src/main/java/me/Mammothskier/Giants/util/Metrics.java diff --git a/Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java b/plugin/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java similarity index 100% rename from Giants/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java rename to plugin/src/main/java/me/Mammothskier/Giants/util/NMSUtils.java diff --git a/Giants/src/main/resources/biomes.yml b/plugin/src/main/resources/biomes.yml similarity index 100% rename from Giants/src/main/resources/biomes.yml rename to plugin/src/main/resources/biomes.yml diff --git a/Giants/src/main/resources/config.yml b/plugin/src/main/resources/config.yml similarity index 100% rename from Giants/src/main/resources/config.yml rename to plugin/src/main/resources/config.yml diff --git a/Giants/src/main/resources/giant.yml b/plugin/src/main/resources/giant.yml similarity index 100% rename from Giants/src/main/resources/giant.yml rename to plugin/src/main/resources/giant.yml diff --git a/Giants/src/main/resources/jockey.yml b/plugin/src/main/resources/jockey.yml similarity index 100% rename from Giants/src/main/resources/jockey.yml rename to plugin/src/main/resources/jockey.yml diff --git a/Giants/src/main/resources/magmacube.yml b/plugin/src/main/resources/magmacube.yml similarity index 100% rename from Giants/src/main/resources/magmacube.yml rename to plugin/src/main/resources/magmacube.yml diff --git a/Giants/src/main/resources/plugin.yml b/plugin/src/main/resources/plugin.yml similarity index 100% rename from Giants/src/main/resources/plugin.yml rename to plugin/src/main/resources/plugin.yml diff --git a/Giants/src/main/resources/slime.yml b/plugin/src/main/resources/slime.yml similarity index 100% rename from Giants/src/main/resources/slime.yml rename to plugin/src/main/resources/slime.yml diff --git a/pom.xml b/pom.xml index ea137d6..6d668bd 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ pom - Giants-Files + files v1_7_R3 v1_7_R4 v1_8_R1 @@ -17,7 +17,7 @@ v1_9_R1 v1_9_R2 v1_10_R1 - Giants + plugin From e5a80afd59ef2e34a6435df5f6a63fddebaa0a72 Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 11 Jun 2016 21:20:07 -0700 Subject: [PATCH 24/28] Rewriting armour enchantments system --- plugin/dependency-reduced-pom.xml | 33 ++++++++++++ .../java/me/Mammothskier/Giants/Commands.java | 54 ++++++------------- .../Giants/events/SpawnEvent.java | 2 +- 3 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 plugin/dependency-reduced-pom.xml diff --git a/plugin/dependency-reduced-pom.xml b/plugin/dependency-reduced-pom.xml new file mode 100644 index 0000000..dd6a479 --- /dev/null +++ b/plugin/dependency-reduced-pom.xml @@ -0,0 +1,33 @@ + + + + Giants-Parent + me.Mammothskier + 7.1.1-SNAPSHOT + + 4.0.0 + Giants-plugins + Giants + 7.1.1-Beta + + + confuser-repo + http://ci.frostcast.net/plugin/repository/everything + + + + + org.bukkit + bukkit + 1.9.4-R0.1-SNAPSHOT + compile + + + me.confuser + BarAPI + 3.3 + compile + + + + diff --git a/plugin/src/main/java/me/Mammothskier/Giants/Commands.java b/plugin/src/main/java/me/Mammothskier/Giants/Commands.java index 5bba6b8..5b7ef68 100644 --- a/plugin/src/main/java/me/Mammothskier/Giants/Commands.java +++ b/plugin/src/main/java/me/Mammothskier/Giants/Commands.java @@ -106,46 +106,24 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa player.sendMessage(ChatColor.AQUA + "[Giants] " + ChatColor.GREEN + "A Giant has been spawned at x:" + locx + " y:" + locy + "z:" + locz); } - + if (entity != null) { - ((Damageable) entity).setMaxHealth(health); - ((Damageable) entity).setHealth(health); + entity.setMaxHealth(health); + entity.setHealth(health); if (entity.getType() == EntityType.GIANT) { - EntityEquipment armour = ((LivingEntity) entity).getEquipment(); - String config = Giants.getProperty(ConfigValues.zombieArmour); - String[] s = config.split(":"); - - float rate = 0f; - try { - rate = Float.parseFloat(Giants.getProperty(ConfigValues.armourDropRate)); - } catch (Exception e){ - rate = 0; - } - - try { - for (int i = 0; i < s.length; i++) { - Material m = Material.getMaterial(s[i].toUpperCase()); - ItemStack item = new ItemStack(m); - if (i == 0) { - armour.setHelmet(item); - armour.setHelmetDropChance(rate); - } else if (i == 1) { - armour.setChestplate(item); - armour.setChestplateDropChance(rate); - } else if (i == 2) { - armour.setLeggings(item); - armour.setLeggingsDropChance(rate); - } else if (i == 3) { - armour.setBoots(item); - armour.setBootsDropChance(rate); - } else if (i == 4) { - armour.setItemInHand(item); - armour.setItemInHandDropChance(rate); - } - } - } catch (Exception e) { - e.printStackTrace(); - } + EntityEquipment entityArmour = ((LivingEntity) entity).getEquipment(); + + float dropChance = 0; + entityArmour.setHelmet(SpawnEvent.parseArmour(ConfigValues.zombieHelmet, dropChance)); + entityArmour.setHelmetDropChance(dropChance); + entityArmour.setChestplate(SpawnEvent.parseArmour(ConfigValues.zombieChestPlate, dropChance)); + entityArmour.setChestplateDropChance(dropChance); + entityArmour.setLeggings(SpawnEvent.parseArmour(ConfigValues.zombieLeggings, dropChance)); + entityArmour.setLeggingsDropChance(dropChance); + entityArmour.setBoots(SpawnEvent.parseArmour(ConfigValues.zombieBoots, dropChance)); + entityArmour.setBootsDropChance(dropChance); + entityArmour.setItemInMainHand(SpawnEvent.parseArmour(ConfigValues.zombieMainHand, dropChance)); + entityArmour.setItemInMainHandDropChance(dropChance); } } return true; diff --git a/plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java b/plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java index 4892f3c..b4c0b52 100644 --- a/plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java +++ b/plugin/src/main/java/me/Mammothskier/Giants/events/SpawnEvent.java @@ -154,7 +154,7 @@ public SpawnEvent(Location loc, EntityType entityType) { } } - private ItemStack parseArmour(ConfigValues value, float dropRate) { + public static ItemStack parseArmour(ConfigValues value, float dropRate) { String string = Giants.getProperty(value); String[] split = string.split(" "); ItemStack itemStack = null; From e2b3d93e54ac9c907eafd1825ce118bacb14ea7a Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 25 Jun 2016 11:32:59 -0700 Subject: [PATCH 25/28] Fix for nms issue effecting versions 1.9+ --- .../nms/v1_10_R1/CustomEntityGiantZombie.java | 100 +++++++----------- .../nms/v1_9_R1/CustomEntityGiantZombie.java | 53 +++------- .../nms/v1_9_R2/CustomEntityGiantZombie.java | 99 +++++++---------- 3 files changed, 93 insertions(+), 159 deletions(-) diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java index cfc56a5..f3c5038 100644 --- a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java @@ -1,21 +1,13 @@ package me.Mammothskier.Giants.entity.nms.v1_10_R1; -import java.lang.reflect.Field; - -import org.bukkit.craftbukkit.v1_10_R1.util.UnsafeList; - import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; import net.minecraft.server.v1_10_R1.BlockPosition; -import net.minecraft.server.v1_10_R1.DataWatcher; -import net.minecraft.server.v1_10_R1.DataWatcherObject; -import net.minecraft.server.v1_10_R1.DataWatcherRegistry; import net.minecraft.server.v1_10_R1.EntityGiantZombie; import net.minecraft.server.v1_10_R1.EntityHuman; import net.minecraft.server.v1_10_R1.EntityIronGolem; import net.minecraft.server.v1_10_R1.EntityPigZombie; import net.minecraft.server.v1_10_R1.EntityVillager; -import net.minecraft.server.v1_10_R1.EntityZombie; import net.minecraft.server.v1_10_R1.PathfinderGoalFloat; import net.minecraft.server.v1_10_R1.PathfinderGoalHurtByTarget; import net.minecraft.server.v1_10_R1.PathfinderGoalLookAtPlayer; @@ -24,73 +16,57 @@ import net.minecraft.server.v1_10_R1.PathfinderGoalNearestAttackableTarget; import net.minecraft.server.v1_10_R1.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_10_R1.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_10_R1.PathfinderGoalSelector; import net.minecraft.server.v1_10_R1.World; import net.minecraft.server.v1_10_R1.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { - private static final DataWatcherObject by = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.h); - - public CustomEntityGiantZombie(World world) { + public CustomEntityGiantZombie (World world) { super(world); - try { - Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); - bField.setAccessible(true); - Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); - cField.setAccessible(true); - bField.set(goalSelector, new UnsafeList()); - bField.set(targetSelector, new UnsafeList()); - cField.set(goalSelector, new UnsafeList()); - cField.set(targetSelector, new UnsafeList()); - this.n(); - } catch (Exception exc) { - exc.printStackTrace(); - } - - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); - this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); - this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + + } + + protected void r () { + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); } - + @Override public float getHeadHeight() { - return 14.440001F; - } - - public void a(boolean flag) { - this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); - } - + return 14.440001F; + } + + + @Override - protected void initAttributes() { - super.initAttributes(); - String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); - double speed = 1; - try { - speed = Double.parseDouble(string); - } catch (Exception e) { - speed = 1; - } - this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); - this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); - } - + protected void initAttributes() { + super.initAttributes(); + String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); + double speed; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } + this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); + this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); + } + protected void o() { this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); - if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); - } - - @Override + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } + public float a(BlockPosition position) { return 0.5F - this.world.n(position); } diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java index 8094fed..7359e40 100644 --- a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -1,9 +1,5 @@ package me.Mammothskier.Giants.entity.nms.v1_9_R1; -import java.lang.reflect.Field; - -import org.bukkit.craftbukkit.v1_9_R1.util.UnsafeList; - import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; import net.minecraft.server.v1_9_R1.BlockPosition; @@ -24,46 +20,31 @@ import net.minecraft.server.v1_9_R1.PathfinderGoalNearestAttackableTarget; import net.minecraft.server.v1_9_R1.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_9_R1.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_9_R1.PathfinderGoalSelector; import net.minecraft.server.v1_9_R1.World; import net.minecraft.server.v1_9_R1.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { - private static final DataWatcherObject by = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.h); - - public CustomEntityGiantZombie(World world) { + public CustomEntityGiantZombie (World world) { super(world); - try { - Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); - bField.setAccessible(true); - Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); - cField.setAccessible(true); - bField.set(goalSelector, new UnsafeList()); - bField.set(targetSelector, new UnsafeList()); - cField.set(goalSelector, new UnsafeList()); - cField.set(targetSelector, new UnsafeList()); - this.n(); - } catch (Exception exc) { - exc.printStackTrace(); - } - - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); - this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); - this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + + } + + protected void r () { + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); } @Override public float getHeadHeight() { return 14.440001F; } - - public void a(boolean flag) { - this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); - } + + @Override protected void initAttributes() { @@ -80,14 +61,14 @@ protected void initAttributes() { this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); } - + protected void o() { this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); } public float a(BlockPosition position) { diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java index a6ddaa3..00c5a89 100644 --- a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java @@ -1,21 +1,13 @@ package me.Mammothskier.Giants.entity.nms.v1_9_R2; -import java.lang.reflect.Field; - -import org.bukkit.craftbukkit.v1_9_R2.util.UnsafeList; - import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; import net.minecraft.server.v1_9_R2.BlockPosition; -import net.minecraft.server.v1_9_R2.DataWatcher; -import net.minecraft.server.v1_9_R2.DataWatcherObject; -import net.minecraft.server.v1_9_R2.DataWatcherRegistry; import net.minecraft.server.v1_9_R2.EntityGiantZombie; import net.minecraft.server.v1_9_R2.EntityHuman; import net.minecraft.server.v1_9_R2.EntityIronGolem; import net.minecraft.server.v1_9_R2.EntityPigZombie; import net.minecraft.server.v1_9_R2.EntityVillager; -import net.minecraft.server.v1_9_R2.EntityZombie; import net.minecraft.server.v1_9_R2.PathfinderGoalFloat; import net.minecraft.server.v1_9_R2.PathfinderGoalHurtByTarget; import net.minecraft.server.v1_9_R2.PathfinderGoalLookAtPlayer; @@ -24,72 +16,57 @@ import net.minecraft.server.v1_9_R2.PathfinderGoalNearestAttackableTarget; import net.minecraft.server.v1_9_R2.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_9_R2.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_9_R2.PathfinderGoalSelector; import net.minecraft.server.v1_9_R2.World; import net.minecraft.server.v1_9_R2.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { - private static final DataWatcherObject by = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.h); - - public CustomEntityGiantZombie(World world) { + public CustomEntityGiantZombie (World world) { super(world); - try { - Field bField = PathfinderGoalSelector.class.getDeclaredField("b"); - bField.setAccessible(true); - Field cField = PathfinderGoalSelector.class.getDeclaredField("c"); - cField.setAccessible(true); - bField.set(goalSelector, new UnsafeList()); - bField.set(targetSelector, new UnsafeList()); - cField.set(goalSelector, new UnsafeList()); - cField.set(targetSelector, new UnsafeList()); - this.n(); - } catch (Exception exc) { - exc.printStackTrace(); - } - - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); - this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); - this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + + } + + protected void r () { + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new CustomPathfinderGoalGiantZombieAttack(this, 1.0D, false)); + this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); + this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); } - + @Override public float getHeadHeight() { - return 14.440001F; - } - - public void a(boolean flag) { - this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); - } - + return 14.440001F; + } + + + @Override - protected void initAttributes() { - super.initAttributes(); - String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); - double speed = 1; - try { - speed = Double.parseDouble(string); - } catch (Exception e) { - speed = 1; - } - this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); - this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); - } - + protected void initAttributes() { + super.initAttributes(); + String string = FileHandler.getInstanceProperty(ConfigValues.zombieSpeed); + double speed = 1; + try { + speed = Double.parseDouble(string); + } catch (Exception e) { + speed = 1; + } + this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35D); + this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); + this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D * speed); + this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D); + } + protected void o() { this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[] { EntityPigZombie.class})); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); - if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); - } - + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)); + if (FileHandler.getInstanceProperty(ConfigValues.zombieAggressiveToVillage).equalsIgnoreCase("false")) + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false)); // Spigot + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true)); + } + public float a(BlockPosition position) { return 0.5F - this.world.n(position); } From 6056e990ced8eedca555efe40cec8ab68804212e Mon Sep 17 00:00:00 2001 From: Mammothskier Date: Sat, 25 Jun 2016 11:41:16 -0700 Subject: [PATCH 26/28] Fix for compile issue --- .../nms/v1_10_R1/CustomEntityGiantZombie.java | 24 +++++-------------- .../nms/v1_9_R1/CustomEntityGiantZombie.java | 6 ++++- .../nms/v1_9_R2/CustomEntityGiantZombie.java | 23 +++++------------- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java index f3c5038..8d3486a 100644 --- a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java @@ -2,28 +2,14 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; -import net.minecraft.server.v1_10_R1.BlockPosition; -import net.minecraft.server.v1_10_R1.EntityGiantZombie; -import net.minecraft.server.v1_10_R1.EntityHuman; -import net.minecraft.server.v1_10_R1.EntityIronGolem; -import net.minecraft.server.v1_10_R1.EntityPigZombie; -import net.minecraft.server.v1_10_R1.EntityVillager; -import net.minecraft.server.v1_10_R1.PathfinderGoalFloat; -import net.minecraft.server.v1_10_R1.PathfinderGoalHurtByTarget; -import net.minecraft.server.v1_10_R1.PathfinderGoalLookAtPlayer; -import net.minecraft.server.v1_10_R1.PathfinderGoalMoveThroughVillage; -import net.minecraft.server.v1_10_R1.PathfinderGoalMoveTowardsRestriction; -import net.minecraft.server.v1_10_R1.PathfinderGoalNearestAttackableTarget; -import net.minecraft.server.v1_10_R1.PathfinderGoalRandomLookaround; -import net.minecraft.server.v1_10_R1.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_10_R1.World; -import net.minecraft.server.v1_10_R1.GenericAttributes; +import net.minecraft.server.v1_10_R1.*; public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie (World world) { super(world); - } protected void r () { @@ -40,7 +26,9 @@ public float getHeadHeight() { return 14.440001F; } - + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } @Override protected void initAttributes() { diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java index 7359e40..5047fc5 100644 --- a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -25,6 +25,8 @@ public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie (World world) { super(world); @@ -44,7 +46,9 @@ public float getHeadHeight() { return 14.440001F; } - + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } @Override protected void initAttributes() { diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java index 00c5a89..55acf71 100644 --- a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java @@ -2,25 +2,12 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; -import net.minecraft.server.v1_9_R2.BlockPosition; -import net.minecraft.server.v1_9_R2.EntityGiantZombie; -import net.minecraft.server.v1_9_R2.EntityHuman; -import net.minecraft.server.v1_9_R2.EntityIronGolem; -import net.minecraft.server.v1_9_R2.EntityPigZombie; -import net.minecraft.server.v1_9_R2.EntityVillager; -import net.minecraft.server.v1_9_R2.PathfinderGoalFloat; -import net.minecraft.server.v1_9_R2.PathfinderGoalHurtByTarget; -import net.minecraft.server.v1_9_R2.PathfinderGoalLookAtPlayer; -import net.minecraft.server.v1_9_R2.PathfinderGoalMoveThroughVillage; -import net.minecraft.server.v1_9_R2.PathfinderGoalMoveTowardsRestriction; -import net.minecraft.server.v1_9_R2.PathfinderGoalNearestAttackableTarget; -import net.minecraft.server.v1_9_R2.PathfinderGoalRandomLookaround; -import net.minecraft.server.v1_9_R2.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_9_R2.World; -import net.minecraft.server.v1_9_R2.GenericAttributes; +import net.minecraft.server.v1_9_R2.*; public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie (World world) { super(world); @@ -40,7 +27,9 @@ public float getHeadHeight() { return 14.440001F; } - + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } @Override protected void initAttributes() { From 24cf2576bd800150dc32f3ce4f9d5b8b912d0a0f Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Sat, 22 Oct 2016 21:59:18 -0600 Subject: [PATCH 27/28] Revert "Fix for compile issue" This reverts commit 6056e990ced8eedca555efe40cec8ab68804212e. --- .../nms/v1_10_R1/CustomEntityGiantZombie.java | 24 ++++++++++++++----- .../nms/v1_9_R1/CustomEntityGiantZombie.java | 6 +---- .../nms/v1_9_R2/CustomEntityGiantZombie.java | 23 +++++++++++++----- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java index 8d3486a..f3c5038 100644 --- a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java @@ -2,14 +2,28 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; -import net.minecraft.server.v1_10_R1.*; +import net.minecraft.server.v1_10_R1.BlockPosition; +import net.minecraft.server.v1_10_R1.EntityGiantZombie; +import net.minecraft.server.v1_10_R1.EntityHuman; +import net.minecraft.server.v1_10_R1.EntityIronGolem; +import net.minecraft.server.v1_10_R1.EntityPigZombie; +import net.minecraft.server.v1_10_R1.EntityVillager; +import net.minecraft.server.v1_10_R1.PathfinderGoalFloat; +import net.minecraft.server.v1_10_R1.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_10_R1.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_10_R1.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_10_R1.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_10_R1.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_10_R1.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_10_R1.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_10_R1.World; +import net.minecraft.server.v1_10_R1.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { - private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); - public CustomEntityGiantZombie (World world) { super(world); + } protected void r () { @@ -26,9 +40,7 @@ public float getHeadHeight() { return 14.440001F; } - public void a(boolean flag) { - this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); - } + @Override protected void initAttributes() { diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java index 5047fc5..7359e40 100644 --- a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -25,8 +25,6 @@ public class CustomEntityGiantZombie extends EntityGiantZombie { - private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); - public CustomEntityGiantZombie (World world) { super(world); @@ -46,9 +44,7 @@ public float getHeadHeight() { return 14.440001F; } - public void a(boolean flag) { - this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); - } + @Override protected void initAttributes() { diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java index 55acf71..00c5a89 100644 --- a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java @@ -2,12 +2,25 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; -import net.minecraft.server.v1_9_R2.*; +import net.minecraft.server.v1_9_R2.BlockPosition; +import net.minecraft.server.v1_9_R2.EntityGiantZombie; +import net.minecraft.server.v1_9_R2.EntityHuman; +import net.minecraft.server.v1_9_R2.EntityIronGolem; +import net.minecraft.server.v1_9_R2.EntityPigZombie; +import net.minecraft.server.v1_9_R2.EntityVillager; +import net.minecraft.server.v1_9_R2.PathfinderGoalFloat; +import net.minecraft.server.v1_9_R2.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_9_R2.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_9_R2.PathfinderGoalMoveThroughVillage; +import net.minecraft.server.v1_9_R2.PathfinderGoalMoveTowardsRestriction; +import net.minecraft.server.v1_9_R2.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_9_R2.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_9_R2.PathfinderGoalRandomStroll; +import net.minecraft.server.v1_9_R2.World; +import net.minecraft.server.v1_9_R2.GenericAttributes; public class CustomEntityGiantZombie extends EntityGiantZombie { - private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); - public CustomEntityGiantZombie (World world) { super(world); @@ -27,9 +40,7 @@ public float getHeadHeight() { return 14.440001F; } - public void a(boolean flag) { - this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); - } + @Override protected void initAttributes() { From e3d4139a916f3a1008e6a07b98a9f7b0ae16e947 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Sat, 19 Nov 2016 00:56:26 -0700 Subject: [PATCH 28/28] Revert "Revert "Fix for compile issue"" This reverts commit 24cf2576bd800150dc32f3ce4f9d5b8b912d0a0f. --- .../nms/v1_10_R1/CustomEntityGiantZombie.java | 24 +++++-------------- .../nms/v1_9_R1/CustomEntityGiantZombie.java | 6 ++++- .../nms/v1_9_R2/CustomEntityGiantZombie.java | 23 +++++------------- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java index f3c5038..8d3486a 100644 --- a/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java +++ b/v1_10_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_10_R1/CustomEntityGiantZombie.java @@ -2,28 +2,14 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; -import net.minecraft.server.v1_10_R1.BlockPosition; -import net.minecraft.server.v1_10_R1.EntityGiantZombie; -import net.minecraft.server.v1_10_R1.EntityHuman; -import net.minecraft.server.v1_10_R1.EntityIronGolem; -import net.minecraft.server.v1_10_R1.EntityPigZombie; -import net.minecraft.server.v1_10_R1.EntityVillager; -import net.minecraft.server.v1_10_R1.PathfinderGoalFloat; -import net.minecraft.server.v1_10_R1.PathfinderGoalHurtByTarget; -import net.minecraft.server.v1_10_R1.PathfinderGoalLookAtPlayer; -import net.minecraft.server.v1_10_R1.PathfinderGoalMoveThroughVillage; -import net.minecraft.server.v1_10_R1.PathfinderGoalMoveTowardsRestriction; -import net.minecraft.server.v1_10_R1.PathfinderGoalNearestAttackableTarget; -import net.minecraft.server.v1_10_R1.PathfinderGoalRandomLookaround; -import net.minecraft.server.v1_10_R1.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_10_R1.World; -import net.minecraft.server.v1_10_R1.GenericAttributes; +import net.minecraft.server.v1_10_R1.*; public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie (World world) { super(world); - } protected void r () { @@ -40,7 +26,9 @@ public float getHeadHeight() { return 14.440001F; } - + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } @Override protected void initAttributes() { diff --git a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java index 7359e40..5047fc5 100644 --- a/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java +++ b/v1_9_R1/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R1/CustomEntityGiantZombie.java @@ -25,6 +25,8 @@ public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie (World world) { super(world); @@ -44,7 +46,9 @@ public float getHeadHeight() { return 14.440001F; } - + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } @Override protected void initAttributes() { diff --git a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java index 00c5a89..55acf71 100644 --- a/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java +++ b/v1_9_R2/src/main/java/me/Mammothskier/Giants/entity/nms/v1_9_R2/CustomEntityGiantZombie.java @@ -2,25 +2,12 @@ import me.Mammothskier.Giants.Files.ConfigValues; import me.Mammothskier.Giants.Files.FileHandler; -import net.minecraft.server.v1_9_R2.BlockPosition; -import net.minecraft.server.v1_9_R2.EntityGiantZombie; -import net.minecraft.server.v1_9_R2.EntityHuman; -import net.minecraft.server.v1_9_R2.EntityIronGolem; -import net.minecraft.server.v1_9_R2.EntityPigZombie; -import net.minecraft.server.v1_9_R2.EntityVillager; -import net.minecraft.server.v1_9_R2.PathfinderGoalFloat; -import net.minecraft.server.v1_9_R2.PathfinderGoalHurtByTarget; -import net.minecraft.server.v1_9_R2.PathfinderGoalLookAtPlayer; -import net.minecraft.server.v1_9_R2.PathfinderGoalMoveThroughVillage; -import net.minecraft.server.v1_9_R2.PathfinderGoalMoveTowardsRestriction; -import net.minecraft.server.v1_9_R2.PathfinderGoalNearestAttackableTarget; -import net.minecraft.server.v1_9_R2.PathfinderGoalRandomLookaround; -import net.minecraft.server.v1_9_R2.PathfinderGoalRandomStroll; -import net.minecraft.server.v1_9_R2.World; -import net.minecraft.server.v1_9_R2.GenericAttributes; +import net.minecraft.server.v1_9_R2.*; public class CustomEntityGiantZombie extends EntityGiantZombie { + private static final DataWatcherObject by = DataWatcher.a(CustomEntityGiantZombie.class, DataWatcherRegistry.h); + public CustomEntityGiantZombie (World world) { super(world); @@ -40,7 +27,9 @@ public float getHeadHeight() { return 14.440001F; } - + public void a(boolean flag) { + this.getDataWatcher().set(CustomEntityGiantZombie.by, Boolean.valueOf(flag)); + } @Override protected void initAttributes() {