fixes from first testrun
This commit is contained in:
parent
64c0ce3a0a
commit
e47794ab07
1
pom.xml
1
pom.xml
@ -40,7 +40,6 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -10,7 +10,6 @@ import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -38,25 +37,25 @@ public final class VillagerOptimizer extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
logger = getLogger();
|
||||
ConsoleCommandSender console = getServer().getConsoleSender();
|
||||
console.sendMessage(Component.text(
|
||||
getServer().getConsoleSender().sendMessage(Component.text(
|
||||
"""
|
||||
\s
|
||||
_ __ _ __ __ ____ __ _ _ \s
|
||||
| | / /(_)/ // /____ _ ____ _ ___ _____ / __ \\ ____ / /_ (_)____ ___ (_)____ ___ _____
|
||||
| | / // // // // __ `// __ `// _ \\ / ___// / / // __ \\ / __// // __ `__ \\ / //_ / / _ \\ / ___/
|
||||
| |/ // // // // /_/ // /_/ // __// / / /_/ // /_/ // /_ / // / / / / // / / /_/ __// / \s
|
||||
|___//_//_//_/ \\__,_/ \\__, / \\___//_/ \\____// .___/ \\__//_//_/ /_/ /_//_/ /___/\\___//_/ \s
|
||||
/____/ /_/ by xGinko \s
|
||||
"""
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ _ __ _ __ __ ____ __ _ _ ┃\s
|
||||
┃ | | / /(_)/ // /____ _ ____ _ ___ _____ / __ \\ ____ / /_ (_)____ ___ (_)____ ___ _____ ┃\s
|
||||
┃ | | / // // // // __ `// __ `// _ \\ / ___// / / // __ \\ / __// // __ `__ \\ / //_ / / _ \\ / ___/ ┃\s
|
||||
┃ | |/ // // // // /_/ // /_/ // __// / / /_/ // /_/ // /_ / // / / / / // / / /_/ __// / ┃\s
|
||||
┃ |___//_//_//_/ \\__,_/ \\__, / \\___//_/ \\____// .___/ \\__//_//_/ /_/ /_//_/ /___/\\___//_/ ┃\s
|
||||
┃ /____/ /_/ by xGinko ┃\s
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"""
|
||||
).color(TextColor.color(102,255,230)).decorate(TextDecoration.BOLD));
|
||||
console.sendMessage(Component.text("Loading Translations...").color(TextColor.color(102,255,230)));
|
||||
logger.info("Loading Translations...");
|
||||
reloadLang();
|
||||
console.sendMessage(Component.text("Loading Config...").color(TextColor.color(102,255,230)));
|
||||
logger.info("Loading Config...");
|
||||
reloadConfiguration();
|
||||
console.sendMessage(Component.text("Registering Commands...").color(TextColor.color(102,255,230)));
|
||||
logger.info("Registering Commands...");
|
||||
VillagerOptimizerCommand.reloadCommands();
|
||||
console.sendMessage(Component.text("Done.").color(TextColor.color(102,255,230)));
|
||||
logger.info("Done.");
|
||||
}
|
||||
|
||||
public static VillagerOptimizer getInstance() {
|
||||
|
@ -43,7 +43,7 @@ public class OptVillagersRadius implements VillagerOptimizerCommand, TabComplete
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (sender.hasPermission(Permissions.Commands.OPTIMIZE_RADIUS.get())) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Component.text("This command can only be executed as a player.")
|
||||
sender.sendMessage(Component.text("This command can only be executed by a player.")
|
||||
.color(NamedTextColor.RED).decorate(TextDecoration.BOLD));
|
||||
return true;
|
||||
}
|
||||
@ -77,12 +77,14 @@ public class OptVillagersRadius implements VillagerOptimizerCommand, TabComplete
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0) {
|
||||
final String success = Integer.toString(successCount);
|
||||
final String radius = Integer.toString(specifiedRadius);
|
||||
VillagerOptimizer.getLang(player.locale()).command_optimize_success.forEach(line -> player.sendMessage(line
|
||||
.replaceText(TextReplacementConfig.builder().matchLiteral("%amount%").replacement(success).build())
|
||||
.replaceText(TextReplacementConfig.builder().matchLiteral("%radius%").replacement(radius).build())
|
||||
));
|
||||
}
|
||||
if (failCount > 0) {
|
||||
final String alreadyOptimized = Integer.toString(failCount);
|
||||
VillagerOptimizer.getLang(player.locale()).command_optimize_fail.forEach(line -> player.sendMessage(line
|
||||
|
@ -34,7 +34,7 @@ public class UnOptVillagersRadius implements VillagerOptimizerCommand {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (sender.hasPermission(Permissions.Commands.UNOPTIMIZE_RADIUS.get())) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Component.text("This command can only be executed as a player.")
|
||||
sender.sendMessage(Component.text("This command can only be executed by a player.")
|
||||
.color(NamedTextColor.RED).decorate(TextDecoration.BOLD));
|
||||
return true;
|
||||
}
|
||||
|
@ -63,12 +63,12 @@ public class VillagerOptimizerCmd implements TabCompleter, VillagerOptimizerComm
|
||||
subCommands.forEach(subCommand -> sender.sendMessage(
|
||||
subCommand.getSyntax().append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)).append(subCommand.getDescription())));
|
||||
sender.sendMessage(
|
||||
Component.text("/optimizevillagers <message>").color(NamedTextColor.BLUE)
|
||||
Component.text("/optimizevillagers <blockradius>").color(NamedTextColor.BLUE)
|
||||
.append(Component.text(" - ").color(NamedTextColor.DARK_GRAY))
|
||||
.append(Component.text("Optimize villagers in a radius").color(NamedTextColor.GRAY))
|
||||
);
|
||||
sender.sendMessage(
|
||||
Component.text("/unoptmizevillagers").color(NamedTextColor.BLUE)
|
||||
Component.text("/unoptmizevillagers <blockradius>").color(NamedTextColor.BLUE)
|
||||
.append(Component.text(" - ").color(NamedTextColor.DARK_GRAY))
|
||||
.append(Component.text("Unoptimize villagers in a radius").color(NamedTextColor.GRAY))
|
||||
);
|
||||
|
@ -22,19 +22,23 @@ public class VersionSubCmd extends SubCommand {
|
||||
}
|
||||
@Override
|
||||
public TextComponent getSyntax() {
|
||||
return Component.text("/villageroptimizer version").color(NamedTextColor.GOLD);
|
||||
return Component.text("/villageroptimizer version").color(NamedTextColor.BLUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender sender, String[] args) {
|
||||
if (sender.hasPermission(Permissions.Commands.VERSION.get())) {
|
||||
PluginMeta pluginMeta = VillagerOptimizer.getInstance().getPluginMeta();
|
||||
final PluginMeta pluginMeta = VillagerOptimizer.getInstance().getPluginMeta();
|
||||
sender.sendMessage(
|
||||
Component.newline()
|
||||
.append(Component.text(pluginMeta.getName()+" "+pluginMeta.getVersion()).color(NamedTextColor.BLUE).decorate(TextDecoration.BOLD)
|
||||
.append(Component.text(" by ").color(NamedTextColor.GRAY))
|
||||
.append(Component.text(pluginMeta.getAuthors().get(0)).color(NamedTextColor.WHITE))
|
||||
.append(Component.text(pluginMeta.getName()+" "+pluginMeta.getVersion())
|
||||
.color(NamedTextColor.BLUE).decorate(TextDecoration.BOLD)
|
||||
.clickEvent(ClickEvent.openUrl(pluginMeta.getWebsite())))
|
||||
.append(Component.text(" by ")
|
||||
.color(NamedTextColor.GRAY))
|
||||
.append(Component.text(pluginMeta.getAuthors().get(0))
|
||||
.color(NamedTextColor.WHITE)
|
||||
.clickEvent(ClickEvent.openUrl("https://github.com/xGinko")))
|
||||
.append(Component.newline())
|
||||
);
|
||||
} else {
|
||||
|
@ -50,6 +50,13 @@ public class Config {
|
||||
config.addDefault("config-version", 1.00);
|
||||
createTitledSection("General", "general");
|
||||
createTitledSection("Optimization", "optimization");
|
||||
config.addDefault("optimization.villager-chunk-limit.enable", false);
|
||||
config.addDefault("optimization.prevent-trading-with-unoptimized.enable", false);
|
||||
config.addDefault("optimization.methods.by-nametag.enable", true);
|
||||
config.addDefault("optimization.behavior.villager-leveling.enable", true);
|
||||
config.addDefault("optimization.behavior.trade-restocking.enable", true);
|
||||
config.addDefault("optimization.behavior.prevent-targeting.enable", true);
|
||||
config.addDefault("optimization.behavior.prevent-damage.enable", true);
|
||||
}
|
||||
|
||||
public void createTitledSection(String title, String path) {
|
||||
|
@ -37,6 +37,7 @@ public class BlockOptimization implements VillagerOptimizerModule, Listener {
|
||||
private final long cooldown;
|
||||
|
||||
protected BlockOptimization() {
|
||||
shouldEnable();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.methods.by-specific-block.enable", """
|
||||
@ -61,7 +62,8 @@ public class BlockOptimization implements VillagerOptimizerModule, Listener {
|
||||
""") * 1000L;
|
||||
this.maxVillagers = config.getInt("optimization.methods.by-specific-block.max-villagers-per-block", 3,
|
||||
"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.by-specific-block.notify-player", true,
|
||||
"Sends players a message when they successfully optimized a villager.");
|
||||
this.shouldLog = config.getBoolean("optimization.methods.by-specific-block.log", false);
|
||||
}
|
||||
|
||||
|
@ -25,18 +25,17 @@ public class LevelVillagers implements VillagerOptimizerModule, Listener {
|
||||
private final long cooldown;
|
||||
|
||||
public LevelVillagers() {
|
||||
shouldEnable();
|
||||
this.plugin = VillagerOptimizer.getInstance();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.villager-leveling.enable", """
|
||||
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.
|
||||
""");
|
||||
this.cooldown = config.getInt("optimization.villager-leveling.level-check-cooldown-seconds", 5, """
|
||||
Cooldown in seconds until the level of a villager will be checked and updated again. \s
|
||||
Recommended to leave as is.
|
||||
""") * 1000L;
|
||||
this.shouldNotify = config.getBoolean("optimization.villager-leveling.notify-player", true,
|
||||
config.addComment("optimization.behavior.villager-leveling.enable", """
|
||||
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.""");
|
||||
this.cooldown = config.getInt("optimization.behavior.villager-leveling.level-check-cooldown-seconds", 5, """
|
||||
Cooldown in seconds until the level of a villager will be checked and updated again.\s
|
||||
Recommended to leave as is.""") * 1000L;
|
||||
this.shouldNotify = config.getBoolean("optimization.behavior.villager-leveling.notify-player", true,
|
||||
"Tell players to wait when a villager is leveling up.");
|
||||
}
|
||||
|
||||
@ -53,7 +52,7 @@ public class LevelVillagers implements VillagerOptimizerModule, Listener {
|
||||
|
||||
@Override
|
||||
public boolean shouldEnable() {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.villager-leveling.enable", true);
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.villager-leveling.enable", true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
|
@ -32,21 +32,21 @@ public class NametagOptimization implements VillagerOptimizerModule, Listener {
|
||||
private final long cooldown;
|
||||
|
||||
protected NametagOptimization() {
|
||||
shouldEnable();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.methods.by-nametag.enable", """
|
||||
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"),
|
||||
"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,
|
||||
"Enable or disable consumption of the used nametag item.");
|
||||
this.cooldown = config.getInt("optimization.methods.by-workstation.optimize-cooldown-seconds", 600, """
|
||||
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;
|
||||
this.shouldNotifyPlayer = config.getBoolean("optimization.methods.by-nametag.notify-player", true);
|
||||
this.cooldown = config.getInt("optimization.methods.by-nametag.optimize-cooldown-seconds", 600, """
|
||||
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;
|
||||
this.shouldNotifyPlayer = config.getBoolean("optimization.methods.by-nametag.notify-player", true,
|
||||
"Sends players a message when they successfully optimized a villager.");
|
||||
this.shouldLog = config.getBoolean("optimization.methods.by-nametag.log", false);
|
||||
}
|
||||
|
||||
|
@ -20,14 +20,15 @@ public class PreventUnoptimizedTrading implements VillagerOptimizerModule, Liste
|
||||
private final boolean notifyPlayer;
|
||||
|
||||
protected PreventUnoptimizedTrading() {
|
||||
shouldEnable();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.prevent-trading-with-unoptimized-villagers.enable", """
|
||||
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\
|
||||
Inventories can still be opened so players can move villagers around.
|
||||
""");
|
||||
this.notifyPlayer = config.getBoolean("optimization.prevent-trading-with-unoptimized-villagers.notify-player", true);
|
||||
config.addComment("optimization.prevent-trading-with-unoptimized.enable", """
|
||||
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
|
||||
Inventories can still be opened so players can move villagers around.""");
|
||||
this.notifyPlayer = config.getBoolean("optimization.prevent-trading-with-unoptimized.notify-player", true,
|
||||
"Sends players a message when they try to trade with an unoptimized villager.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,7 +44,7 @@ public class PreventUnoptimizedTrading implements VillagerOptimizerModule, Liste
|
||||
|
||||
@Override
|
||||
public boolean shouldEnable() {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.prevent-trading-with-unoptimized-villagers.enable", false);
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.prevent-trading-with-unoptimized.enable", false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
|
@ -3,20 +3,39 @@ package me.xginko.villageroptimizer.modules;
|
||||
import io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent;
|
||||
import me.xginko.villageroptimizer.VillagerOptimizer;
|
||||
import me.xginko.villageroptimizer.cache.VillagerManager;
|
||||
import me.xginko.villageroptimizer.config.Config;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Mob;
|
||||
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.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class PreventVillagerDamage implements VillagerOptimizerModule, Listener {
|
||||
|
||||
private final VillagerManager villagerManager;
|
||||
private final boolean block, player, mob, other, push;
|
||||
|
||||
protected PreventVillagerDamage() {
|
||||
shouldEnable();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.behavior.prevent-damage.enable",
|
||||
"Configure what kind of damage you want to cancel for optimized villagers here.");
|
||||
this.block = config.getBoolean("optimization.behavior.prevent-damage.block", false,
|
||||
"Prevents damage from blocks like lava, tnt, respawn anchors, etc.");
|
||||
this.player = config.getBoolean("optimization.behavior.prevent-damage.player", false,
|
||||
"Prevents damage from getting hit by players.");
|
||||
this.mob = config.getBoolean("optimization.behavior.prevent-damage.mob", true,
|
||||
"Prevents damage from hostile mobs.");
|
||||
this.other = config.getBoolean("optimization.behavior.prevent-damage.other", true,
|
||||
"Prevents damage from all other entities.");
|
||||
this.push = config.getBoolean("optimization.behavior.prevent-damage.prevent-push-from-attack", true,
|
||||
"Prevents optimized villagers from getting pushed by an attacking entity");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,13 +51,37 @@ public class PreventVillagerDamage implements VillagerOptimizerModule, Listener
|
||||
|
||||
@Override
|
||||
public boolean shouldEnable() {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.optimized-villagers-dont-take-damage", true);
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.prevent-damage.enable", true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onDamageReceive(EntityDamageEvent event) {
|
||||
private void onDamageReceive(EntityDamageByEntityEvent event) {
|
||||
if (
|
||||
!event.getEntityType().equals(EntityType.VILLAGER)
|
||||
event.getEntityType().equals(EntityType.VILLAGER)
|
||||
&& villagerManager.getOrAdd((Villager) event.getEntity()).isOptimized()
|
||||
) {
|
||||
Entity damager = event.getDamager();
|
||||
if (damager.getType().equals(EntityType.PLAYER)) {
|
||||
if (player) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (damager instanceof Mob) {
|
||||
if (mob) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (other) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onDamageReceive(EntityDamageByBlockEvent event) {
|
||||
if (
|
||||
block
|
||||
&& event.getEntityType().equals(EntityType.VILLAGER)
|
||||
&& villagerManager.getOrAdd((Villager) event.getEntity()).isOptimized()
|
||||
) {
|
||||
event.setCancelled(true);
|
||||
@ -48,7 +91,8 @@ public class PreventVillagerDamage implements VillagerOptimizerModule, Listener
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onPushByEntityAttack(EntityPushedByEntityAttackEvent event) {
|
||||
if (
|
||||
!event.getEntityType().equals(EntityType.VILLAGER)
|
||||
push
|
||||
&& event.getEntityType().equals(EntityType.VILLAGER)
|
||||
&& villagerManager.getOrAdd((Villager) event.getEntity()).isOptimized()
|
||||
) {
|
||||
event.setCancelled(true);
|
||||
|
@ -35,7 +35,8 @@ public class PreventVillagerTargetting implements VillagerOptimizerModule, Liste
|
||||
|
||||
@Override
|
||||
public boolean shouldEnable() {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.optimized-villagers-dont-get-targeted", true);
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.prevent-targeting.enable", true,
|
||||
"Prevents hostile entities from targeting optimized villagers.");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
@ -23,17 +23,17 @@ public class RestockTrades implements VillagerOptimizerModule, Listener {
|
||||
private final boolean shouldLog, notifyPlayer;
|
||||
|
||||
protected RestockTrades() {
|
||||
shouldEnable();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.trade-restocking.enable", """
|
||||
config.addComment("optimization.behavior.trade-restocking.enable", """
|
||||
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.
|
||||
""");
|
||||
this.restock_delay_millis = config.getInt("optimization.trade-restocking.delay-in-ticks", 1000,
|
||||
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,
|
||||
"1 second = 20 ticks. There are 24.000 ticks in a single minecraft day.") * 50L;
|
||||
this.shouldLog = config.getBoolean("optimization.trade-restocking.log", false);
|
||||
this.notifyPlayer = config.getBoolean("optimization.trade-restocking.notify-player", true,
|
||||
this.notifyPlayer = config.getBoolean("optimization.behavior.trade-restocking.notify-player", true,
|
||||
"Sends the player a message when the trades were restocked on a clicked villager.");
|
||||
this.shouldLog = config.getBoolean("optimization.behavior.trade-restocking.log", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,7 +49,7 @@ public class RestockTrades implements VillagerOptimizerModule, Listener {
|
||||
|
||||
@Override
|
||||
public boolean shouldEnable() {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.trade-restocking.enable", true);
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.behavior.trade-restocking.enable", true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
|
@ -36,10 +36,11 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
||||
this.plugin = VillagerOptimizer.getInstance();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
this.maxVillagersPerChunk = config.getInt("villager-chunk-limit.max-villagers-per-chunk", 25);
|
||||
this.logIsEnabled = config.getBoolean("villager-chunk-limit.log-removals", false);
|
||||
this.checkPeriod = config.getInt("villager-chunk-limit.check-period-in-ticks", 600, "check all chunks every x ticks.");
|
||||
config.getList("villager-chunk-limit.removal-priority", List.of(
|
||||
this.maxVillagersPerChunk = config.getInt("optimization.villager-chunk-limit.max-villagers-per-chunk", 25);
|
||||
this.logIsEnabled = config.getBoolean("optimization.villager-chunk-limit.log-removals", false);
|
||||
this.checkPeriod = config.getInt("optimization.villager-chunk-limit.check-period-in-ticks", 600,
|
||||
"Check all loaded chunks every X ticks. 1 second = 20 ticks");
|
||||
config.getList("optimization.villager-chunk-limit.removal-priority", List.of(
|
||||
"NONE", "NITWIT", "SHEPHERD", "FISHERMAN", "BUTCHER", "CARTOGRAPHER", "LEATHERWORKER",
|
||||
"FLETCHER", "MASON", "FARMER", "ARMORER", "TOOLSMITH", "WEAPONSMITH", "CLERIC", "LIBRARIAN"
|
||||
),
|
||||
@ -50,7 +51,8 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
||||
Villager.Profession profession = Villager.Profession.valueOf(configuredProfession);
|
||||
this.removalPriority.add(profession);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LogUtils.moduleLog(Level.WARNING, "villager-chunk-limit", "Villager profession '"+configuredProfession+"' not recognized. Make sure you're using the correct profession enums.");
|
||||
LogUtils.moduleLog(Level.WARNING, "optimization.villager-chunk-limit",
|
||||
"Villager profession '"+configuredProfession+"' not recognized. Make sure you're using the correct profession enums.");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -63,7 +65,7 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
||||
|
||||
@Override
|
||||
public boolean shouldEnable() {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("villager-chunk-limit.enable", false);
|
||||
return VillagerOptimizer.getConfiguration().getBoolean("optimization.villager-chunk-limit.enable", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,7 +118,7 @@ public class VillagerChunkLimit implements VillagerOptimizerModule, Listener {
|
||||
for (int i = 0; i < amount_over_the_limit; i++) {
|
||||
Villager villager = villagers_in_chunk.get(i);
|
||||
villager.remove();
|
||||
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, "villager-chunk-limit",
|
||||
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, "optimization.villager-chunk-limit",
|
||||
"Removed villager of profession type '"+villager.getProfession()+"' at "+villager.getLocation());
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
||||
private final double search_radius;
|
||||
|
||||
protected WorkstationOptimization() {
|
||||
shouldEnable();
|
||||
this.villagerManager = VillagerOptimizer.getVillagerManager();
|
||||
Config config = VillagerOptimizer.getConfiguration();
|
||||
config.addComment("optimization.methods.by-workstation.enable", """
|
||||
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(
|
||||
"COMPOSTER", "SMOKER", "BARREL", "LOOM", "BLAST_FURNACE", "BREWING_STAND", "CAULDRON",
|
||||
"FLETCHING_TABLE", "CARTOGRAPHY_TABLE", "LECTERN", "SMITHING_TABLE", "STONECUTTER", "GRINDSTONE"
|
||||
@ -55,13 +55,12 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
||||
});
|
||||
this.search_radius = config.getDouble("optimization.methods.by-workstation.search-radius-in-blocks", 4.0, """
|
||||
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.
|
||||
""");
|
||||
The closest unoptimized villager to the player will be optimized.""");
|
||||
this.cooldown = config.getInt("optimization.methods.by-workstation.optimize-cooldown-seconds", 600, """
|
||||
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;
|
||||
this.shouldNotifyPlayer = config.getBoolean("optimization.methods.by-workstation.notify-player", true);
|
||||
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,
|
||||
"Sends players a message when they successfully optimized a villager.");
|
||||
this.shouldLog = config.getBoolean("optimization.methods.by-workstation.log", false);
|
||||
}
|
||||
|
||||
@ -115,7 +114,7 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
||||
if (shouldNotifyPlayer) {
|
||||
final String villagerType = closestOptimizableVillager.villager().getProfession().toString().toLowerCase();
|
||||
final String workstation = placed.getType().toString().toLowerCase();
|
||||
VillagerOptimizer.getLang(player.locale()).workstation_unoptimize_success.forEach(line -> player.sendMessage(line
|
||||
VillagerOptimizer.getLang(player.locale()).workstation_optimize_success.forEach(line -> player.sendMessage(line
|
||||
.replaceText(TextReplacementConfig.builder().matchLiteral("%villagertype%").replacement(villagerType).build())
|
||||
.replaceText(TextReplacementConfig.builder().matchLiteral("%workstation%").replacement(workstation).build())
|
||||
));
|
||||
@ -147,8 +146,6 @@ public class WorkstationOptimization implements VillagerOptimizerModule, Listene
|
||||
for (Entity entity : workstationLoc.getNearbyEntities(search_radius, search_radius, search_radius)) {
|
||||
if (!entity.getType().equals(EntityType.VILLAGER)) continue;
|
||||
Villager villager = (Villager) entity;
|
||||
final Villager.Profession profession = villager.getProfession();
|
||||
if (profession.equals(Villager.Profession.NONE) || profession.equals(Villager.Profession.NITWIT)) continue;
|
||||
|
||||
WrappedVillager wVillager = villagerManager.getOrAdd(villager);
|
||||
final double distance = entity.getLocation().distance(workstationLoc);
|
||||
|
@ -18,7 +18,7 @@ commands:
|
||||
description: Optmize villagers in a radius around you
|
||||
aliases:
|
||||
- optvils
|
||||
unoptmizevillagers:
|
||||
unoptimizevillagers:
|
||||
usage: /unoptimizevillagers <blockradius>
|
||||
description: Unoptmize villagers in a radius around you
|
||||
aliases:
|
||||
|
Loading…
x
Reference in New Issue
Block a user