clean config
This commit is contained in:
parent
1312904176
commit
bf66f6a044
@ -49,14 +49,16 @@ public class Config {
|
|||||||
private void structureConfig() {
|
private void structureConfig() {
|
||||||
config.addDefault("config-version", 1.00);
|
config.addDefault("config-version", 1.00);
|
||||||
createTitledSection("General", "general");
|
createTitledSection("General", "general");
|
||||||
createTitledSection("Optimization", "optimization");
|
createTitledSection("Optimization Methods", "optimization-methods");
|
||||||
config.addDefault("optimization.villager-chunk-limit.enable", false);
|
config.addDefault("optimization-methods.nametag-optimization.enable", true);
|
||||||
config.addDefault("optimization.prevent-trading-with-unoptimized.enable", false);
|
createTitledSection("Villager Chunk Limit", "villager-chunk-limit");
|
||||||
config.addDefault("optimization.methods.by-nametag.enable", true);
|
createTitledSection("Gameplay", "gameplay");
|
||||||
config.addDefault("optimization.behavior.villager-leveling.enable", true);
|
config.addDefault("gameplay.villagers-spawn-as-adults", false);
|
||||||
config.addDefault("optimization.behavior.trade-restocking.enable", true);
|
config.addDefault("gameplay.prevent-trading-with-unoptimized.enable", false);
|
||||||
config.addDefault("optimization.behavior.prevent-targeting.enable", true);
|
config.addDefault("gameplay.villager-leveling.enable", true);
|
||||||
config.addDefault("optimization.behavior.prevent-damage.enable", true);
|
config.addDefault("gameplay.trade-restocking.enable", true);
|
||||||
|
config.addDefault("gameplay.prevent-targeting.enable", true);
|
||||||
|
config.addDefault("gameplay.prevent-damage.enable", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTitledSection(String title, String path) {
|
public void createTitledSection(String title, String path) {
|
||||||
|
@ -40,12 +40,12 @@ public class BlockOptimization implements VillagerOptimizerModule, Listener {
|
|||||||
shouldEnable();
|
shouldEnable();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.methods.by-specific-block.enable", """
|
config.addComment("optimization-methods.block-optimization.enable", """
|
||||||
When enabled, villagers standing on the configured specific blocks will become optimized once a\s
|
When enabled, villagers standing on the configured specific blocks will become optimized once a\s
|
||||||
player interacts with them. If the block is broken or moved, the villager will become unoptimized\s
|
player interacts with them. If the block is broken or moved, the villager will become unoptimized\s
|
||||||
again once a player interacts with the villager afterwards.
|
again once a player interacts with the villager afterwards.
|
||||||
""");
|
""");
|
||||||
config.getList("optimization.methods.by-specific-block.materials", List.of(
|
config.getList("optimization-methods.block-optimization.materials", List.of(
|
||||||
"LAPIS_BLOCK", "GLOWSTONE", "IRON_BLOCK"
|
"LAPIS_BLOCK", "GLOWSTONE", "IRON_BLOCK"
|
||||||
), "Values here need to be valid bukkit Material enums for your server version."
|
), "Values here need to be valid bukkit Material enums for your server version."
|
||||||
).forEach(configuredMaterial -> {
|
).forEach(configuredMaterial -> {
|
||||||
@ -53,18 +53,18 @@ public class BlockOptimization implements VillagerOptimizerModule, Listener {
|
|||||||
Material disableBlock = Material.valueOf(configuredMaterial);
|
Material disableBlock = Material.valueOf(configuredMaterial);
|
||||||
this.blocks_that_disable.add(disableBlock);
|
this.blocks_that_disable.add(disableBlock);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
LogUtils.materialNotRecognized("optimization.methods.by-specific-block", configuredMaterial);
|
LogUtils.materialNotRecognized("optimization-methods.block-optimization", configuredMaterial);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.cooldown = config.getInt("optimization.methods.by-specific-block.optimize-cooldown-seconds", 600, """
|
this.cooldown = config.getInt("optimization-methods.block-optimization.optimize-cooldown-seconds", 600, """
|
||||||
Cooldown in seconds until a villager can be optimized again by using this method. \s
|
Cooldown in seconds until a villager can be optimized again by using this method. \s
|
||||||
Here for configuration freedom. Recommended to leave as is to not enable any exploitable behavior.
|
Here for configuration freedom. Recommended to leave as is to not enable any exploitable behavior.
|
||||||
""") * 1000L;
|
""") * 1000L;
|
||||||
this.maxVillagers = config.getInt("optimization.methods.by-specific-block.max-villagers-per-block", 3,
|
this.maxVillagers = config.getInt("optimization-methods.block-optimization.max-villagers-per-block", 3,
|
||||||
"How many villagers can be optimized at once by placing a block under them.");
|
"How many villagers can be optimized at once by placing a block under them.");
|
||||||
this.shouldNotifyPlayer = config.getBoolean("optimization.methods.by-specific-block.notify-player", true,
|
this.shouldNotifyPlayer = config.getBoolean("optimization-methods.block-optimization.notify-player", true,
|
||||||
"Sends players a message when they successfully optimized a villager.");
|
"Sends players a message when they successfully optimized a villager.");
|
||||||
this.shouldLog = config.getBoolean("optimization.methods.by-specific-block.log", false);
|
this.shouldLog = config.getBoolean("optimization-methods.block-optimization.log", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +80,7 @@ public class BlockOptimization implements VillagerOptimizerModule, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.methods.by-specific-block.enable", true);
|
return VillagerOptimizer.getConfiguration().getBoolean("optimization-methods.block-optimization.enable", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
@ -29,13 +29,13 @@ public class LevelVillagers implements VillagerOptimizerModule, Listener {
|
|||||||
this.plugin = VillagerOptimizer.getInstance();
|
this.plugin = VillagerOptimizer.getInstance();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.behavior.villager-leveling.enable", """
|
config.addComment("gameplay.villager-leveling.enable", """
|
||||||
This is needed to allow optimized villagers to level up.\s
|
This is needed to allow optimized villagers to level up.\s
|
||||||
Temporarily enables the villagers AI to allow it to level up and then disables it again.""");
|
Temporarily enables the villagers AI to allow it to level up and then disables it again.""");
|
||||||
this.cooldown = config.getInt("optimization.behavior.villager-leveling.level-check-cooldown-seconds", 5, """
|
this.cooldown = config.getInt("gameplay.villager-leveling.level-check-cooldown-seconds", 5, """
|
||||||
Cooldown in seconds until the level of a villager will be checked and updated again.\s
|
Cooldown in seconds until the level of a villager will be checked and updated again.\s
|
||||||
Recommended to leave as is.""") * 1000L;
|
Recommended to leave as is.""") * 1000L;
|
||||||
this.shouldNotify = config.getBoolean("optimization.behavior.villager-leveling.notify-player", true,
|
this.shouldNotify = config.getBoolean("gameplay.villager-leveling.notify-player", true,
|
||||||
"Tell players to wait when a villager is leveling up.");
|
"Tell players to wait when a villager is leveling up.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class LevelVillagers implements VillagerOptimizerModule, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.villager-leveling.enable", true);
|
return VillagerOptimizer.getConfiguration().getBoolean("gameplay.villager-leveling.enable", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
@ -35,19 +35,19 @@ public class NametagOptimization implements VillagerOptimizerModule, Listener {
|
|||||||
shouldEnable();
|
shouldEnable();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.methods.by-nametag.enable", """
|
config.addComment("optimization-methods.nametag-optimization.enable", """
|
||||||
Enable optimization by naming villagers to one of the names configured below.\s
|
Enable optimization by naming villagers to one of the names configured below.\s
|
||||||
Nametag optimized villagers will be unoptimized again when they are renamed to something else.""");
|
Nametag optimized villagers will be unoptimized again when they are renamed to something else.""");
|
||||||
this.nametags.addAll(config.getList("optimization.methods.by-nametag.names", List.of("Optimize", "DisableAI"),
|
this.nametags.addAll(config.getList("optimization-methods.nametag-optimization.names", List.of("Optimize", "DisableAI"),
|
||||||
"Names are case insensitive, capital letters won't matter.").stream().map(String::toLowerCase).toList());
|
"Names are case insensitive, capital letters won't matter.").stream().map(String::toLowerCase).toList());
|
||||||
this.consumeNametag = config.getBoolean("optimization.methods.by-nametag.nametags-get-consumed", true,
|
this.consumeNametag = config.getBoolean("optimization-methods.nametag-optimization.nametags-get-consumed", true,
|
||||||
"Enable or disable consumption of the used nametag item.");
|
"Enable or disable consumption of the used nametag item.");
|
||||||
this.cooldown = config.getInt("optimization.methods.by-nametag.optimize-cooldown-seconds", 600, """
|
this.cooldown = config.getInt("optimization-methods.nametag-optimization.optimize-cooldown-seconds", 600, """
|
||||||
Cooldown in seconds until a villager can be optimized again using a nametag.\s
|
Cooldown in seconds until a villager can be optimized again using a nametag.\s
|
||||||
Here for configuration freedom. Recommended to leave as is to not enable any exploitable behavior.""") * 1000L;
|
Here for configuration freedom. Recommended to leave as is to not enable any exploitable behavior.""") * 1000L;
|
||||||
this.shouldNotifyPlayer = config.getBoolean("optimization.methods.by-nametag.notify-player", true,
|
this.shouldNotifyPlayer = config.getBoolean("optimization-methods.nametag-optimization.notify-player", true,
|
||||||
"Sends players a message when they successfully optimized a villager.");
|
"Sends players a message when they successfully optimized a villager.");
|
||||||
this.shouldLog = config.getBoolean("optimization.methods.by-nametag.log", false);
|
this.shouldLog = config.getBoolean("optimization-methods.nametag-optimization.log", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,7 +63,7 @@ public class NametagOptimization implements VillagerOptimizerModule, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.methods.by-nametag.enable", true);
|
return VillagerOptimizer.getConfiguration().getBoolean("optimization-methods.nametag-optimization.enable", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package me.xginko.villageroptimizer.modules;
|
||||||
|
|
||||||
|
import me.xginko.villageroptimizer.VillagerOptimizer;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Villager;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
|
||||||
|
public class NoBabyVillagers implements VillagerOptimizerModule, Listener {
|
||||||
|
|
||||||
|
protected NoBabyVillagers() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
VillagerOptimizer plugin = VillagerOptimizer.getInstance();
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldEnable() {
|
||||||
|
return VillagerOptimizer.getConfiguration().getBoolean("gameplay.villagers-spawn-as-adults", false,
|
||||||
|
"Automatically turns baby villagers into adults when spawning.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
private void onVillagerSpawn(CreatureSpawnEvent event) {
|
||||||
|
if (!event.getEntityType().equals(EntityType.VILLAGER)) return;
|
||||||
|
Villager villager = (Villager) event.getEntity();
|
||||||
|
if (!villager.isAdult()) villager.setAdult();
|
||||||
|
}
|
||||||
|
}
|
@ -23,11 +23,11 @@ public class PreventUnoptimizedTrading implements VillagerOptimizerModule, Liste
|
|||||||
shouldEnable();
|
shouldEnable();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.prevent-trading-with-unoptimized.enable", """
|
config.addComment("gameplay.prevent-trading-with-unoptimized.enable", """
|
||||||
Will prevent players from selecting and using trades of unoptimized villagers.\s
|
Will prevent players from selecting and using trades of unoptimized villagers.\s
|
||||||
Use this if you have a lot of villagers and therefore want to force your players to optimize them.\s
|
Use this if you have a lot of villagers and therefore want to force your players to optimize them.\s
|
||||||
Inventories can still be opened so players can move villagers around.""");
|
Inventories can still be opened so players can move villagers around.""");
|
||||||
this.notifyPlayer = config.getBoolean("optimization.prevent-trading-with-unoptimized.notify-player", true,
|
this.notifyPlayer = config.getBoolean("gameplay.prevent-trading-with-unoptimized.notify-player", true,
|
||||||
"Sends players a message when they try to trade with an unoptimized villager.");
|
"Sends players a message when they try to trade with an unoptimized villager.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class PreventUnoptimizedTrading implements VillagerOptimizerModule, Liste
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.prevent-trading-with-unoptimized.enable", false);
|
return VillagerOptimizer.getConfiguration().getBoolean("gameplay.prevent-trading-with-unoptimized.enable", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
@ -24,17 +24,17 @@ public class PreventVillagerDamage implements VillagerOptimizerModule, Listener
|
|||||||
shouldEnable();
|
shouldEnable();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.behavior.prevent-damage.enable",
|
config.addComment("gameplay.prevent-damage.enable",
|
||||||
"Configure what kind of damage you want to cancel for optimized villagers here.");
|
"Configure what kind of damage you want to cancel for optimized villagers here.");
|
||||||
this.block = config.getBoolean("optimization.behavior.prevent-damage.block", false,
|
this.block = config.getBoolean("gameplay.prevent-damage.block", false,
|
||||||
"Prevents damage from blocks like lava, tnt, respawn anchors, etc.");
|
"Prevents damage from blocks like lava, tnt, respawn anchors, etc.");
|
||||||
this.player = config.getBoolean("optimization.behavior.prevent-damage.player", false,
|
this.player = config.getBoolean("gameplay.prevent-damage.player", false,
|
||||||
"Prevents damage from getting hit by players.");
|
"Prevents damage from getting hit by players.");
|
||||||
this.mob = config.getBoolean("optimization.behavior.prevent-damage.mob", true,
|
this.mob = config.getBoolean("gameplay.prevent-damage.mob", true,
|
||||||
"Prevents damage from hostile mobs.");
|
"Prevents damage from hostile mobs.");
|
||||||
this.other = config.getBoolean("optimization.behavior.prevent-damage.other", true,
|
this.other = config.getBoolean("gameplay.prevent-damage.other", true,
|
||||||
"Prevents damage from all other entities.");
|
"Prevents damage from all other entities.");
|
||||||
this.push = config.getBoolean("optimization.behavior.prevent-damage.prevent-push-from-attack", true,
|
this.push = config.getBoolean("gameplay.prevent-damage.prevent-push-from-attack", true,
|
||||||
"Prevents optimized villagers from getting pushed by an attacking entity");
|
"Prevents optimized villagers from getting pushed by an attacking entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class PreventVillagerDamage implements VillagerOptimizerModule, Listener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.prevent-damage.enable", true);
|
return VillagerOptimizer.getConfiguration().getBoolean("gameplay.prevent-damage.enable", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -35,7 +35,7 @@ public class PreventVillagerTargetting implements VillagerOptimizerModule, Liste
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.prevent-targeting.enable", true,
|
return VillagerOptimizer.getConfiguration().getBoolean("gameplay.prevent-targeting.enable", true,
|
||||||
"Prevents hostile entities from targeting optimized villagers.");
|
"Prevents hostile entities from targeting optimized villagers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,14 +26,14 @@ public class RestockTrades implements VillagerOptimizerModule, Listener {
|
|||||||
shouldEnable();
|
shouldEnable();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.behavior.trade-restocking.enable", """
|
config.addComment("gameplay.trade-restocking.enable", """
|
||||||
This is for automatic restocking of trades for optimized villagers. Optimized Villagers\s
|
This is for automatic restocking of trades for optimized villagers. Optimized Villagers\s
|
||||||
Don't have enough AI to do trade restocks themselves, so this needs to always be enabled.""");
|
Don't have enough AI to do trade restocks themselves, so this needs to always be enabled.""");
|
||||||
this.restock_delay_millis = config.getInt("optimization.behavior.trade-restocking.delay-in-ticks", 1000,
|
this.restock_delay_millis = config.getInt("gameplay.trade-restocking.delay-in-ticks", 1000,
|
||||||
"1 second = 20 ticks. There are 24.000 ticks in a single minecraft day.") * 50L;
|
"1 second = 20 ticks. There are 24.000 ticks in a single minecraft day.") * 50L;
|
||||||
this.notifyPlayer = config.getBoolean("optimization.behavior.trade-restocking.notify-player", true,
|
this.notifyPlayer = config.getBoolean("gameplay.trade-restocking.notify-player", true,
|
||||||
"Sends the player a message when the trades were restocked on a clicked villager.");
|
"Sends the player a message when the trades were restocked on a clicked villager.");
|
||||||
this.shouldLog = config.getBoolean("optimization.behavior.trade-restocking.log", false);
|
this.shouldLog = config.getBoolean("gameplay.trade-restocking.log", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,7 +49,7 @@ public class RestockTrades implements VillagerOptimizerModule, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.trade-restocking.enable", true);
|
return VillagerOptimizer.getConfiguration().getBoolean("gameplay.trade-restocking.enable", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
@ -36,11 +36,11 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
|||||||
this.plugin = VillagerOptimizer.getInstance();
|
this.plugin = VillagerOptimizer.getInstance();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
this.maxVillagersPerChunk = config.getInt("optimization.villager-chunk-limit.max-villagers-per-chunk", 25);
|
this.maxVillagersPerChunk = config.getInt("villager-chunk-limit.max-villagers-per-chunk", 25);
|
||||||
this.logIsEnabled = config.getBoolean("optimization.villager-chunk-limit.log-removals", false);
|
this.logIsEnabled = config.getBoolean("villager-chunk-limit.log-removals", false);
|
||||||
this.checkPeriod = config.getInt("optimization.villager-chunk-limit.check-period-in-ticks", 600,
|
this.checkPeriod = config.getInt("villager-chunk-limit.check-period-in-ticks", 600,
|
||||||
"Check all loaded chunks every X ticks. 1 second = 20 ticks");
|
"Check all loaded chunks every X ticks. 1 second = 20 ticks");
|
||||||
config.getList("optimization.villager-chunk-limit.removal-priority", List.of(
|
config.getList("villager-chunk-limit.removal-priority", List.of(
|
||||||
"NONE", "NITWIT", "SHEPHERD", "FISHERMAN", "BUTCHER", "CARTOGRAPHER", "LEATHERWORKER",
|
"NONE", "NITWIT", "SHEPHERD", "FISHERMAN", "BUTCHER", "CARTOGRAPHER", "LEATHERWORKER",
|
||||||
"FLETCHER", "MASON", "FARMER", "ARMORER", "TOOLSMITH", "WEAPONSMITH", "CLERIC", "LIBRARIAN"
|
"FLETCHER", "MASON", "FARMER", "ARMORER", "TOOLSMITH", "WEAPONSMITH", "CLERIC", "LIBRARIAN"
|
||||||
),
|
),
|
||||||
@ -51,7 +51,7 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
|||||||
Villager.Profession profession = Villager.Profession.valueOf(configuredProfession);
|
Villager.Profession profession = Villager.Profession.valueOf(configuredProfession);
|
||||||
this.removalPriority.add(profession);
|
this.removalPriority.add(profession);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
LogUtils.moduleLog(Level.WARNING, "optimization.villager-chunk-limit",
|
LogUtils.moduleLog(Level.WARNING, "villager-chunk-limit",
|
||||||
"Villager profession '"+configuredProfession+"' not recognized. Make sure you're using the correct profession enums.");
|
"Villager profession '"+configuredProfession+"' not recognized. Make sure you're using the correct profession enums.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -65,7 +65,7 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.villager-chunk-limit.enable", false);
|
return VillagerOptimizer.getConfiguration().getBoolean("villager-chunk-limit.enable", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,7 +118,7 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
|||||||
for (int i = 0; i < amount_over_the_limit; i++) {
|
for (int i = 0; i < amount_over_the_limit; i++) {
|
||||||
Villager villager = villagers_in_chunk.get(i);
|
Villager villager = villagers_in_chunk.get(i);
|
||||||
villager.remove();
|
villager.remove();
|
||||||
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, "optimization.villager-chunk-limit",
|
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, "villager-chunk-limit",
|
||||||
"Removed villager of profession type '"+villager.getProfession()+"' at "+villager.getLocation());
|
"Removed villager of profession type '"+villager.getProfession()+"' at "+villager.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public interface VillagerOptimizerModule {
|
|||||||
modules.add(new BlockOptimization());
|
modules.add(new BlockOptimization());
|
||||||
modules.add(new LevelVillagers());
|
modules.add(new LevelVillagers());
|
||||||
modules.add(new NametagOptimization());
|
modules.add(new NametagOptimization());
|
||||||
|
modules.add(new NoBabyVillagers());
|
||||||
modules.add(new PreventUnoptimizedTrading());
|
modules.add(new PreventUnoptimizedTrading());
|
||||||
modules.add(new PreventVillagerDamage());
|
modules.add(new PreventVillagerDamage());
|
||||||
modules.add(new PreventVillagerTargetting());
|
modules.add(new PreventVillagerTargetting());
|
||||||
|
@ -38,10 +38,10 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
|||||||
shouldEnable();
|
shouldEnable();
|
||||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||||
Config config = VillagerOptimizer.getConfiguration();
|
Config config = VillagerOptimizer.getConfiguration();
|
||||||
config.addComment("optimization.methods.by-workstation.enable", """
|
config.addComment("optimization-methods.workstation-optimization.enable", """
|
||||||
When enabled, villagers near a configured radius to a workstation specific to your config\s
|
When enabled, villagers near a configured radius to a workstation specific to your config\s
|
||||||
will be optimized.""");
|
will be optimized.""");
|
||||||
config.getList("optimization.methods.by-workstation.workstation-materials", List.of(
|
config.getList("optimization-methods.workstation-optimization.workstation-materials", List.of(
|
||||||
"COMPOSTER", "SMOKER", "BARREL", "LOOM", "BLAST_FURNACE", "BREWING_STAND", "CAULDRON",
|
"COMPOSTER", "SMOKER", "BARREL", "LOOM", "BLAST_FURNACE", "BREWING_STAND", "CAULDRON",
|
||||||
"FLETCHING_TABLE", "CARTOGRAPHY_TABLE", "LECTERN", "SMITHING_TABLE", "STONECUTTER", "GRINDSTONE"
|
"FLETCHING_TABLE", "CARTOGRAPHY_TABLE", "LECTERN", "SMITHING_TABLE", "STONECUTTER", "GRINDSTONE"
|
||||||
), "Values here need to be valid bukkit Material enums for your server version."
|
), "Values here need to be valid bukkit Material enums for your server version."
|
||||||
@ -50,18 +50,18 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
|||||||
Material disableBlock = Material.valueOf(configuredMaterial);
|
Material disableBlock = Material.valueOf(configuredMaterial);
|
||||||
this.workstations_that_disable.add(disableBlock);
|
this.workstations_that_disable.add(disableBlock);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
LogUtils.materialNotRecognized("optimization.methods.by-workstation", configuredMaterial);
|
LogUtils.materialNotRecognized("optimization-methods.workstation-optimization", configuredMaterial);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.search_radius = config.getDouble("optimization.methods.by-workstation.search-radius-in-blocks", 2.0, """
|
this.search_radius = config.getDouble("optimization-methods.workstation-optimization.search-radius-in-blocks", 2.0, """
|
||||||
The radius in blocks a villager can be away from the player when he places a workstation.\s
|
The radius in blocks a villager can be away from the player when he places a workstation.\s
|
||||||
The closest unoptimized villager to the player will be optimized.""") / 2;
|
The closest unoptimized villager to the player will be optimized.""") / 2;
|
||||||
this.cooldown = config.getInt("optimization.methods.by-workstation.optimize-cooldown-seconds", 600, """
|
this.cooldown = config.getInt("optimization-methods.workstation-optimization.optimize-cooldown-seconds", 600, """
|
||||||
Cooldown in seconds until a villager can be optimized again using this method.\s
|
Cooldown in seconds until a villager can be optimized again using this method.\s
|
||||||
Here for configuration freedom. Recommended to leave as is to not enable any exploitable behavior.""") * 1000L;
|
Here for configuration freedom. Recommended to leave as is to not enable any exploitable behavior.""") * 1000L;
|
||||||
this.shouldNotifyPlayer = config.getBoolean("optimization.methods.by-workstation.notify-player", true,
|
this.shouldNotifyPlayer = config.getBoolean("optimization-methods.workstation-optimization.notify-player", true,
|
||||||
"Sends players a message when they successfully optimized a villager.");
|
"Sends players a message when they successfully optimized a villager.");
|
||||||
this.shouldLog = config.getBoolean("optimization.methods.by-workstation.log", false);
|
this.shouldLog = config.getBoolean("optimization-methods.workstation-optimization.log", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,7 +77,7 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldEnable() {
|
public boolean shouldEnable() {
|
||||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.methods.by-workstation.enable", true);
|
return VillagerOptimizer.getConfiguration().getBoolean("optimization-methods.workstation-optimization.enable", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user