From d1f9d1a919b061271f67ba6f9f69bc0f205d7f60 Mon Sep 17 00:00:00 2001 From: xGinko Date: Fri, 29 Sep 2023 13:26:36 +0200 Subject: [PATCH] minor adjustments --- .../villageroptimizer/WrappedVillager.java | 4 ++-- .../xginko/villageroptimizer/config/Config.java | 13 ++++++------- .../modules/extras/PreventVillagerDamage.java | 16 ++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/xginko/villageroptimizer/WrappedVillager.java b/src/main/java/me/xginko/villageroptimizer/WrappedVillager.java index b685dec..7700dd9 100644 --- a/src/main/java/me/xginko/villageroptimizer/WrappedVillager.java +++ b/src/main/java/me/xginko/villageroptimizer/WrappedVillager.java @@ -25,10 +25,10 @@ public final class WrappedVillager { } /** - * @return True if the villager is optimized by the plugin, otherwise false. + * @return True if the villager is optimized by this or another plugin, otherwise false. */ public boolean isOptimized() { - return dataContainer.has(Keys.OPTIMIZATION_TYPE.key()); + return dataContainer.has(Keys.OPTIMIZATION_TYPE.key()) || !villager.isAware() || !villager.hasAI(); } /** diff --git a/src/main/java/me/xginko/villageroptimizer/config/Config.java b/src/main/java/me/xginko/villageroptimizer/config/Config.java index 4106a54..4bc4df5 100644 --- a/src/main/java/me/xginko/villageroptimizer/config/Config.java +++ b/src/main/java/me/xginko/villageroptimizer/config/Config.java @@ -28,7 +28,6 @@ public class Config { "If set to true, will display messages based on client language"); this.cache_keep_time_seconds = getInt("general.cache-keep-time-seconds", 30, "The amount of time in seconds a villager will be kept in the plugin's cache."); - this.addComment("", ""); } private ConfigFile loadConfig(File ymlFile) throws Exception { @@ -51,14 +50,14 @@ public class Config { private void structureConfig() { config.addDefault("config-version", 1.00); createTitledSection("General", "general"); - createTitledSection("Optimization Methods", "optimization-methods"); - addComment("optimization-methods", """ - BE AWARE:\s - It is recommended to choose preferably one (no more than 2) of the below methods, as this can\s - get confusing and depending on your config exploitable otherwise. - """); + createTitledSection("Optimization", "optimization-methods"); config.addDefault("optimization-methods.commands.unoptimizevillagers", null); config.addDefault("optimization-methods.nametag-optimization.enable", true); + addComment("optimization-methods", """ + BE AWARE:\s + It is recommended to choose preferably ONE, no more than TWO of the below methods, as it can\s + become confusing and - depending on your config - exploitable otherwise. + """); createTitledSection("Villager Chunk Limit", "villager-chunk-limit"); createTitledSection("Gameplay", "gameplay"); config.addDefault("gameplay.villagers-spawn-as-adults.enable", false); diff --git a/src/main/java/me/xginko/villageroptimizer/modules/extras/PreventVillagerDamage.java b/src/main/java/me/xginko/villageroptimizer/modules/extras/PreventVillagerDamage.java index 362535e..75dd232 100644 --- a/src/main/java/me/xginko/villageroptimizer/modules/extras/PreventVillagerDamage.java +++ b/src/main/java/me/xginko/villageroptimizer/modules/extras/PreventVillagerDamage.java @@ -27,16 +27,16 @@ public class PreventVillagerDamage implements VillagerOptimizerModule, Listener Config config = VillagerOptimizer.getConfiguration(); config.addComment("gameplay.prevent-damage.enable", "Configure what kind of damage you want to cancel for optimized villagers here."); - this.block = config.getBoolean("gameplay.prevent-damage.block", false, - "Prevents damage from blocks like lava, tnt, respawn anchors, etc."); - this.player = config.getBoolean("gameplay.prevent-damage.player", false, - "Prevents damage from getting hit by players."); - this.mob = config.getBoolean("gameplay.prevent-damage.mob", true, - "Prevents damage from hostile mobs."); - this.other = config.getBoolean("gameplay.prevent-damage.other", true, - "Prevents damage from all other entities."); this.push = config.getBoolean("gameplay.prevent-damage.prevent-push-from-attack", true, "Prevents optimized villagers from getting pushed by an attacking entity"); + this.block = config.getBoolean("gameplay.prevent-damage.damagers.block", false, + "Prevents damage from blocks like lava, tnt, respawn anchors, etc."); + this.player = config.getBoolean("gameplay.prevent-damage.damagers.player", false, + "Prevents damage from getting hit by players."); + this.mob = config.getBoolean("gameplay.prevent-damage.damagers.mob", true, + "Prevents damage from hostile mobs."); + this.other = config.getBoolean("gameplay.prevent-damage.damagers.other", true, + "Prevents damage from all other entities."); } @Override