diff --git a/pom.xml b/pom.xml index 15198a3..fa9c04f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 giants giants - 22.1.5 + 22.1.6 1.8 diff --git a/src/main/java/pl/minecon724/giants/Main.java b/src/main/java/pl/minecon724/giants/Main.java index 7212bd4..ca5f445 100644 --- a/src/main/java/pl/minecon724/giants/Main.java +++ b/src/main/java/pl/minecon724/giants/Main.java @@ -13,6 +13,7 @@ import org.apache.commons.lang.StringUtils; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; @@ -48,6 +49,7 @@ public class Main extends JavaPlugin implements Listener { double expandUp; long refreshDelay; Map effects = new HashMap(); + Map> drops = new HashMap>(); @Override public void onEnable() { @@ -79,7 +81,30 @@ public class Main extends JavaPlugin implements Listener { continue; } } - + for (Object s : config.getList("drops", new ArrayList())) { + try { + String[] parts = ((String) s).split(":"); + /* + TODO find a better way to do this + if (!(StringUtils.isNumeric(parts[1]))) { + throw new IllegalArgumentException(parts[1] + " is not a number"); + } + */ + Material material = Material.getMaterial(parts[0]); + if (material == null) { + throw new IllegalArgumentException(parts[0] + " is not a Material"); + } + List data = new ArrayList(); + data.add(Integer.parseInt(drops[1])); + data.add(Integer.parseInt(drops[2])); + data.add(Integer.parseInt(drops[3])); + drops.put(material, data); + } catch (Exception e) { + Bukkit.getLogger().severe("Exception while parsing " + s); + e.printStackTrace(); + continue; + } + } getServer().getPluginManager().registerEvents(this, this); new BukkitRunnable() { @Override diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a403193..0678b3d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,13 +1,18 @@ # If disabled, the giant won't move (but it will still attack) ai: true + # 0.5 is half a heart attackDamage: 1.0 + # Spawning chance, from 0 to 1 chance: 0.02 + # Attack delay in ticks, smaller values will lag the server more hitDelay: 20 + # 0 - attack only entities touching the giant, if too high the giant will hit through walls attackReach: 2 + # Additional potion effects # type:amplifier (max 255) # See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html @@ -16,6 +21,14 @@ effects: [] # - "JUMP:1" # - "REGENERATION:2" # - "HEALTH_BOOST:69" + +# Custom drops +# material:min quantity:max quantity:chance (percent, from 0 to 100) +# See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html +# Set to [] to disable +drops: [] +# - "APPLE:1:3:25" + # Head rotations, disabling can slightly improve performance headRotations: true refreshDelay: 20