Add world blacklist, refactor config.yml

This commit is contained in:
Minecon724 2024-09-20 17:47:19 +02:00
parent aa151f6c9a
commit 022f9754e7
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
3 changed files with 24 additions and 13 deletions

View file

@ -10,6 +10,7 @@ import org.bukkit.util.Vector;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -26,6 +27,7 @@ public class Configuration {
Vector attackReach; Vector attackReach;
List<String> worldBlacklist;
Set<PotionEffect> effects = new HashSet<>(); Set<PotionEffect> effects = new HashSet<>();
Set<Drop> drops = new HashSet<>(); Set<Drop> drops = new HashSet<>();
@ -48,6 +50,8 @@ public class Configuration {
double _expandUp = config.getDouble("expandUp"); double _expandUp = config.getDouble("expandUp");
attackReach = new Vector(_attackReach, _expandUp, _attackReach); attackReach = new Vector(_attackReach, _expandUp, _attackReach);
worldBlacklist = config.getStringList("blacklist");
for (String line : config.getStringList("effects")) { for (String line : config.getStringList("effects")) {
String[] parts = line.split(":"); String[] parts = line.split(":");

View file

@ -132,6 +132,9 @@ public class GiantProcessor implements Listener {
@EventHandler @EventHandler
public void entitySpawn(EntitySpawnEvent e) { public void entitySpawn(EntitySpawnEvent e) {
if (configuration.worldBlacklist.contains(e.getLocation().getWorld().getName()))
return;
if (e.getEntityType() == EntityType.ZOMBIE) { if (e.getEntityType() == EntityType.ZOMBIE) {
if (configuration.chance > random.nextFloat()) { if (configuration.chance > random.nextFloat()) {
e.setCancelled(true); e.setCancelled(true);

View file

@ -1,5 +1,5 @@
# Do as it says # Notes:
remove_this_line_after_editing: true # To have no values in a list, remove every value below it and change to [] like `effects: []`
# If disabled, the giant won't move (but it will still attack) # If disabled, the giant won't move (but it will still attack)
ai: true ai: true
@ -18,30 +18,34 @@ attackDelay: 20
# There's no wall check yet, so it will hit through walls # There's no wall check yet, so it will hit through walls
attackReach: 2 attackReach: 2
# The value above does not modify vertical reach, this value extends it upwards
expandUp: 0
### ###
# Chance of a zombie becoming a giant. This is per each zombie spawn, natural or not. # Chance of a zombie becoming a giant. This is per each zombie spawn, natural or not.
chance: 0.02 # 0 is 0% (no zombie becomes a giant), 1 is 100% (every zombie becomes a giant), so the default 0.005 is 0.5%
chance: 0.005
# Which worlds not to spawn Giants in
blacklist:
- "world_nether"
- "world_the_end"
# Potion effects applied to a giant # Potion effects applied to a giant
# type:amplifier # type:amplifier
# types: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html # types: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
# amplifier: just like you know it, max 255 # amplifier: just like you know it, max 255
# Set to [] to disable
effects: effects:
- "JUMP:1" - "JUMP:1"
- "REGENERATION:2" - "REGENERATION:2"
- "HEALTH_BOOST:10" - "HEALTH_BOOST:10"
# Custom drops # Custom drops
# material:min quantity:max quantity:chance # material:min quantity:max quantity:chance
# material: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html # material: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
# min and max are inclusive # min and max are inclusive
# chance is 0 - 100 # unlike above, chance is an integer from 0 to 100
# metadata can't be set yet # metadata can't be set yet
# Set to [] to disable
drops: drops:
- "APPLE:1:3:25" # 25% of the time, drop 1 to 3 apples - "APPLE:1:3:25" # 25% of the time, drop 1 to 3 apples
### Advanced
expandUp: 0