improve block and workstation optimization

This commit is contained in:
xGinko 2023-09-27 11:04:58 +02:00
parent 5f0f2aa460
commit d0dc4a3346
6 changed files with 50 additions and 65 deletions

View File

@ -35,7 +35,7 @@ public final class VillagerOptimizer extends JavaPlugin {
private static Config config; private static Config config;
private static Logger logger; private static Logger logger;
private final static Style plugin_style = Style.style(TextColor.color(102,255,230), TextDecoration.BOLD); public final static Style plugin_style = Style.style(TextColor.color(102,255,230), TextDecoration.BOLD);
@Override @Override
public void onEnable() { public void onEnable() {
@ -59,9 +59,9 @@ public final class VillagerOptimizer extends JavaPlugin {
console.sendMessage(Component.text("").style(plugin_style).append(Component.text("https://github.com/xGinko/VillagerOptimizer").color(NamedTextColor.GRAY)).append(Component.text("").style(plugin_style))); console.sendMessage(Component.text("").style(plugin_style).append(Component.text("https://github.com/xGinko/VillagerOptimizer").color(NamedTextColor.GRAY)).append(Component.text("").style(plugin_style)));
console.sendMessage(Component.text("│ │").style(plugin_style)); console.sendMessage(Component.text("│ │").style(plugin_style));
console.sendMessage(Component.text("│ │").style(plugin_style)); console.sendMessage(Component.text("│ │").style(plugin_style));
console.sendMessage(Component.text("").style(plugin_style).append(Component.text(" ➤ Loading Translations...").style(plugin_style)).append(Component.text("")).decorate(TextDecoration.BOLD)); console.sendMessage(Component.text("").style(plugin_style).append(Component.text(" ➤ Loading Translations...").style(plugin_style)).append(Component.text("").style(plugin_style)));
reloadLang(true); reloadLang(true);
console.sendMessage(Component.text("").style(plugin_style).append(Component.text(" ➤ Loading Config...").style(plugin_style)).append(Component.text("")).decorate(TextDecoration.BOLD)); console.sendMessage(Component.text("").style(plugin_style).append(Component.text(" ➤ Loading Config...").style(plugin_style)).append(Component.text("").style(plugin_style)));
reloadConfiguration(); reloadConfiguration();
console.sendMessage(Component.text("").style(plugin_style).append(Component.text(" ➤ Registering Commands...").style(plugin_style)).append(Component.text("").style(plugin_style))); console.sendMessage(Component.text("").style(plugin_style).append(Component.text(" ➤ Registering Commands...").style(plugin_style)).append(Component.text("").style(plugin_style)));
VillagerOptimizerCommand.reloadCommands(); VillagerOptimizerCommand.reloadCommands();

View File

@ -1,5 +1,6 @@
package me.xginko.villageroptimizer.commands.villageroptimizer; package me.xginko.villageroptimizer.commands.villageroptimizer;
import me.xginko.villageroptimizer.VillagerOptimizer;
import me.xginko.villageroptimizer.commands.SubCommand; import me.xginko.villageroptimizer.commands.SubCommand;
import me.xginko.villageroptimizer.commands.VillagerOptimizerCommand; import me.xginko.villageroptimizer.commands.VillagerOptimizerCommand;
import me.xginko.villageroptimizer.commands.villageroptimizer.subcommands.ReloadSubCmd; import me.xginko.villageroptimizer.commands.villageroptimizer.subcommands.ReloadSubCmd;
@ -58,17 +59,17 @@ public class VillagerOptimizerCmd implements TabCompleter, VillagerOptimizerComm
private void sendCommandOverview(CommandSender sender) { private void sendCommandOverview(CommandSender sender) {
if (!sender.hasPermission(Permissions.Commands.RELOAD.get()) && !sender.hasPermission(Permissions.Commands.VERSION.get())) return; if (!sender.hasPermission(Permissions.Commands.RELOAD.get()) && !sender.hasPermission(Permissions.Commands.VERSION.get())) return;
sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY)); sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY));
sender.sendMessage(Component.text("VillagerOptimizer Commands").color(NamedTextColor.BLUE)); sender.sendMessage(Component.text("VillagerOptimizer Commands").color(VillagerOptimizer.plugin_style.color()));
sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY)); sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY));
subCommands.forEach(subCommand -> sender.sendMessage( subCommands.forEach(subCommand -> sender.sendMessage(
subCommand.getSyntax().append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)).append(subCommand.getDescription()))); subCommand.getSyntax().append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)).append(subCommand.getDescription())));
sender.sendMessage( sender.sendMessage(
Component.text("/optimizevillagers <blockradius>").color(NamedTextColor.BLUE) Component.text("/optimizevillagers <blockradius>").color(VillagerOptimizer.plugin_style.color())
.append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)) .append(Component.text(" - ").color(NamedTextColor.DARK_GRAY))
.append(Component.text("Optimize villagers in a radius").color(NamedTextColor.GRAY)) .append(Component.text("Optimize villagers in a radius").color(NamedTextColor.GRAY))
); );
sender.sendMessage( sender.sendMessage(
Component.text("/unoptmizevillagers <blockradius>").color(NamedTextColor.BLUE) Component.text("/unoptmizevillagers <blockradius>").color(VillagerOptimizer.plugin_style.color())
.append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)) .append(Component.text(" - ").color(NamedTextColor.DARK_GRAY))
.append(Component.text("Unoptimize villagers in a radius").color(NamedTextColor.GRAY)) .append(Component.text("Unoptimize villagers in a radius").color(NamedTextColor.GRAY))
); );

View File

@ -9,27 +9,30 @@ import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class ReloadSubCmd extends SubCommand { public class ReloadSubCmd extends SubCommand {
@Override @Override
public String getLabel() { public String getLabel() {
return "reload"; return "reload";
} }
@Override @Override
public TextComponent getDescription() { public TextComponent getDescription() {
return Component.text("Reload the plugin configuration.").color(NamedTextColor.GRAY); return Component.text("Reload the plugin configuration.").color(NamedTextColor.GRAY);
} }
@Override @Override
public TextComponent getSyntax() { public TextComponent getSyntax() {
return Component.text("/villageroptimizer reload").color(NamedTextColor.BLUE); return Component.text("/villageroptimizer reload").color(VillagerOptimizer.plugin_style.color());
} }
@Override @Override
public void perform(CommandSender sender, String[] args) { public void perform(CommandSender sender, String[] args) {
if (sender.hasPermission(Permissions.Commands.RELOAD.get())) { if (sender.hasPermission(Permissions.Commands.RELOAD.get())) {
sender.sendMessage(Component.text("Reloading VillagerOptimizer...").color(NamedTextColor.BLUE)); sender.sendMessage(Component.text("Reloading VillagerOptimizer...").color(NamedTextColor.WHITE));
VillagerOptimizer plugin = VillagerOptimizer.getInstance(); VillagerOptimizer plugin = VillagerOptimizer.getInstance();
plugin.getServer().getAsyncScheduler().runNow(plugin, reloadPlugin -> { plugin.getServer().getAsyncScheduler().runNow(plugin, reloadPlugin -> {
plugin.reloadPlugin(); plugin.reloadPlugin();
sender.sendMessage(Component.text("Reload complete.").color(NamedTextColor.AQUA)); sender.sendMessage(Component.text("Reload complete.").color(NamedTextColor.GREEN));
}); });
} else { } else {
sender.sendMessage(VillagerOptimizer.getLang(sender).no_permission); sender.sendMessage(VillagerOptimizer.getLang(sender).no_permission);

View File

@ -8,21 +8,23 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class VersionSubCmd extends SubCommand { public class VersionSubCmd extends SubCommand {
@Override @Override
public String getLabel() { public String getLabel() {
return "version"; return "version";
} }
@Override @Override
public TextComponent getDescription() { public TextComponent getDescription() {
return Component.text("Show the plugin version.").color(NamedTextColor.GRAY); return Component.text("Show the plugin version.").color(NamedTextColor.GRAY);
} }
@Override @Override
public TextComponent getSyntax() { public TextComponent getSyntax() {
return Component.text("/villageroptimizer version").color(NamedTextColor.BLUE); return Component.text("/villageroptimizer version").color(VillagerOptimizer.plugin_style.color());
} }
@Override @Override
@ -31,14 +33,17 @@ public class VersionSubCmd extends SubCommand {
final PluginMeta pluginMeta = VillagerOptimizer.getInstance().getPluginMeta(); final PluginMeta pluginMeta = VillagerOptimizer.getInstance().getPluginMeta();
sender.sendMessage( sender.sendMessage(
Component.newline() Component.newline()
.append(Component.text(pluginMeta.getName()+" "+pluginMeta.getVersion()) .append(
.color(NamedTextColor.BLUE).decorate(TextDecoration.BOLD) Component.text(pluginMeta.getName()+" "+pluginMeta.getVersion())
.clickEvent(ClickEvent.openUrl(pluginMeta.getWebsite()))) .style(VillagerOptimizer.plugin_style)
.append(Component.text(" by ") .clickEvent(ClickEvent.openUrl(pluginMeta.getWebsite()))
.color(NamedTextColor.GRAY)) )
.append(Component.text(pluginMeta.getAuthors().get(0)) .append(Component.text(" by ").color(NamedTextColor.GRAY))
.append(
Component.text(pluginMeta.getAuthors().get(0))
.color(NamedTextColor.WHITE) .color(NamedTextColor.WHITE)
.clickEvent(ClickEvent.openUrl("https://github.com/xGinko"))) .clickEvent(ClickEvent.openUrl("https://github.com/xGinko"))
)
.append(Component.newline()) .append(Component.newline())
); );
} else { } else {

View File

@ -40,9 +40,8 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
this.villagerCache = VillagerOptimizer.getCache(); this.villagerCache = VillagerOptimizer.getCache();
Config config = VillagerOptimizer.getConfiguration(); Config config = VillagerOptimizer.getConfiguration();
config.addComment("optimization-methods.block-optimization.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, the closest villager standing near a configured block being placed will be optimized.\s
player interacts with them. If the block is broken or moved, the villager will become unoptimized\s If a configured block is broken nearby, the closest villager will become unoptimized again.""");
again once a player interacts with the villager afterwards.""");
config.getList("optimization-methods.block-optimization.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."
@ -116,10 +115,10 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
closestOptimizableVillager.setOptimization(OptimizationType.BLOCK); closestOptimizableVillager.setOptimization(OptimizationType.BLOCK);
closestOptimizableVillager.saveOptimizeTime(); closestOptimizableVillager.saveOptimizeTime();
if (shouldNotifyPlayer) { if (shouldNotifyPlayer) {
final String villagerType = closestOptimizableVillager.villager().getProfession().toString().toLowerCase(); final String vilProfession = closestOptimizableVillager.villager().getProfession().toString().toLowerCase();
final String placedType = placed.getType().toString().toLowerCase(); final String placedType = placed.getType().toString().toLowerCase();
VillagerOptimizer.getLang(player.locale()).block_optimize_success.forEach(line -> player.sendMessage(line VillagerOptimizer.getLang(player.locale()).block_optimize_success.forEach(line -> player.sendMessage(line
.replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(villagerType).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(vilProfession).build())
.replaceText(TextReplacementConfig.builder().matchLiteral("%blocktype%").replacement(placedType).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%blocktype%").replacement(placedType).build())
)); ));
} }
@ -166,10 +165,10 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
closestOptimizedVillager.setOptimization(OptimizationType.NONE); closestOptimizedVillager.setOptimization(OptimizationType.NONE);
if (shouldNotifyPlayer) { if (shouldNotifyPlayer) {
final String villagerType = closestOptimizedVillager.villager().getProfession().toString().toLowerCase(); final String vilProfession = closestOptimizedVillager.villager().getProfession().toString().toLowerCase();
final String brokenType = broken.getType().toString().toLowerCase(); final String brokenType = broken.getType().toString().toLowerCase();
VillagerOptimizer.getLang(player.locale()).block_unoptimize_success.forEach(line -> player.sendMessage(line VillagerOptimizer.getLang(player.locale()).block_unoptimize_success.forEach(line -> player.sendMessage(line
.replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(villagerType).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(vilProfession).build())
.replaceText(TextReplacementConfig.builder().matchLiteral("%blocktype%").replacement(brokenType).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%blocktype%").replacement(brokenType).build())
)); ));
} }

View File

@ -8,7 +8,6 @@ import me.xginko.villageroptimizer.enums.OptimizationType;
import me.xginko.villageroptimizer.enums.Permissions; import me.xginko.villageroptimizer.enums.Permissions;
import me.xginko.villageroptimizer.modules.VillagerOptimizerModule; import me.xginko.villageroptimizer.modules.VillagerOptimizerModule;
import me.xginko.villageroptimizer.utils.CommonUtil; import me.xginko.villageroptimizer.utils.CommonUtil;
import me.xginko.villageroptimizer.utils.LogUtil;
import net.kyori.adventure.text.TextReplacementConfig; import net.kyori.adventure.text.TextReplacementConfig;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -24,36 +23,20 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import java.util.HashSet;
import java.util.List;
public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener { public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener {
private final VillagerCache villagerCache; private final VillagerCache villagerCache;
private final HashSet<Material> workstations_that_disable = new HashSet<>(14);
private final boolean shouldLog, shouldNotifyPlayer;
private final long cooldown; private final long cooldown;
private final double search_radius; private final double search_radius;
private final boolean shouldLog, shouldNotifyPlayer;
public OptimizeByWorkstation() { public OptimizeByWorkstation() {
shouldEnable(); shouldEnable();
this.villagerCache = VillagerOptimizer.getCache(); this.villagerCache = VillagerOptimizer.getCache();
Config config = VillagerOptimizer.getConfiguration(); Config config = VillagerOptimizer.getConfiguration();
config.addComment("optimization-methods.workstation-optimization.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, the closest villager near a matching workstation being placed will be optimized.\s
will be optimized."""); If a nearby matching workstation is broken, the villager will become unoptimized again.""");
config.getList("optimization-methods.workstation-optimization.workstation-materials", List.of(
"COMPOSTER", "SMOKER", "BARREL", "LOOM", "BLAST_FURNACE", "BREWING_STAND", "CAULDRON",
"FLETCHING_TABLE", "CARTOGRAPHY_TABLE", "LECTERN", "SMITHING_TABLE", "STONECUTTER", "GRINDSTONE"
), "Values here need to be valid bukkit Material enums for your server version."
).forEach(configuredMaterial -> {
try {
Material disableBlock = Material.valueOf(configuredMaterial);
this.workstations_that_disable.add(disableBlock);
} catch (IllegalArgumentException e) {
LogUtil.materialNotRecognized("workstation-optimization", configuredMaterial);
}
});
this.search_radius = config.getDouble("optimization-methods.workstation-optimization.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;
@ -84,18 +67,15 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onBlockPlace(BlockPlaceEvent event) { private void onBlockPlace(BlockPlaceEvent event) {
Block placed = event.getBlock(); Block placed = event.getBlock();
final Material placedType = placed.getType(); Villager.Profession workstationProfession = getWorkstationProfession(placed.getType());
if (!workstations_that_disable.contains(placedType)) return; if (workstationProfession.equals(Villager.Profession.NONE)) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!player.hasPermission(Permissions.Optimize.WORKSTATION.get())) return; if (!player.hasPermission(Permissions.Optimize.WORKSTATION.get())) return;
Villager.Profession workstationProfession = getWorkstationProfession(placedType);
if (workstationProfession.equals(Villager.Profession.NONE)) return;
final Location workstationLoc = placed.getLocation(); final Location workstationLoc = placed.getLocation();
WrappedVillager closestOptimizableVillager = null; WrappedVillager closestOptimizableVillager = null;
double closestDistance = Double.MAX_VALUE; double closestDistance = Double.MAX_VALUE;
for (Entity entity : workstationLoc.getNearbyEntities(search_radius, search_radius, search_radius)) { for (Entity entity : workstationLoc.getNearbyEntities(search_radius, search_radius, search_radius)) {
if (!entity.getType().equals(EntityType.VILLAGER)) continue; if (!entity.getType().equals(EntityType.VILLAGER)) continue;
Villager villager = (Villager) entity; Villager villager = (Villager) entity;
@ -119,10 +99,10 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
closestOptimizableVillager.setOptimization(OptimizationType.WORKSTATION); closestOptimizableVillager.setOptimization(OptimizationType.WORKSTATION);
closestOptimizableVillager.saveOptimizeTime(); closestOptimizableVillager.saveOptimizeTime();
if (shouldNotifyPlayer) { if (shouldNotifyPlayer) {
final String villagerType = closestOptimizableVillager.villager().getProfession().toString().toLowerCase(); final String vilProfession = closestOptimizableVillager.villager().getProfession().toString().toLowerCase();
final String workstation = placed.getType().toString().toLowerCase(); final String workstation = placed.getType().toString().toLowerCase();
VillagerOptimizer.getLang(player.locale()).workstation_optimize_success.forEach(line -> player.sendMessage(line VillagerOptimizer.getLang(player.locale()).workstation_optimize_success.forEach(line -> player.sendMessage(line
.replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(villagerType).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(vilProfession).build())
.replaceText(TextReplacementConfig.builder().matchLiteral("%workstation%").replacement(workstation).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%workstation%").replacement(workstation).build())
)); ));
} }
@ -141,15 +121,13 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onBlockBreak(BlockBreakEvent event) { private void onBlockBreak(BlockBreakEvent event) {
Block placed = event.getBlock(); Block broken = event.getBlock();
final Material brokenType = placed.getType(); Villager.Profession workstationProfession = getWorkstationProfession(broken.getType());
if (!workstations_that_disable.contains(brokenType)) return; if (workstationProfession.equals(Villager.Profession.NONE)) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!player.hasPermission(Permissions.Optimize.WORKSTATION.get())) return; if (!player.hasPermission(Permissions.Optimize.WORKSTATION.get())) return;
Villager.Profession workstationProfession = getWorkstationProfession(brokenType);
if (workstationProfession.equals(Villager.Profession.NONE)) return;
final Location workstationLoc = placed.getLocation(); final Location workstationLoc = broken.getLocation();
WrappedVillager closestOptimizedVillager = null; WrappedVillager closestOptimizedVillager = null;
double closestDistance = Double.MAX_VALUE; double closestDistance = Double.MAX_VALUE;
@ -164,7 +142,6 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
if (distance < closestDistance) { if (distance < closestDistance) {
final OptimizationType type = wVillager.getOptimizationType(); final OptimizationType type = wVillager.getOptimizationType();
if (type.equals(OptimizationType.WORKSTATION) || type.equals(OptimizationType.COMMAND)) { if (type.equals(OptimizationType.WORKSTATION) || type.equals(OptimizationType.COMMAND)) {
closestOptimizedVillager = wVillager; closestOptimizedVillager = wVillager;
closestDistance = distance; closestDistance = distance;
} }
@ -175,18 +152,18 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
closestOptimizedVillager.setOptimization(OptimizationType.NONE); closestOptimizedVillager.setOptimization(OptimizationType.NONE);
if (shouldNotifyPlayer) { if (shouldNotifyPlayer) {
final String villagerType = closestOptimizedVillager.villager().getProfession().toString().toLowerCase(); final String vilProfession = closestOptimizedVillager.villager().getProfession().toString().toLowerCase();
final String workstation = placed.getType().toString().toLowerCase(); final String workstation = broken.getType().toString().toLowerCase();
VillagerOptimizer.getLang(player.locale()).workstation_unoptimize_success.forEach(line -> player.sendMessage(line VillagerOptimizer.getLang(player.locale()).workstation_unoptimize_success.forEach(line -> player.sendMessage(line
.replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(villagerType).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%vil_profession%").replacement(vilProfession).build())
.replaceText(TextReplacementConfig.builder().matchLiteral("%workstation%").replacement(workstation).build()) .replaceText(TextReplacementConfig.builder().matchLiteral("%workstation%").replacement(workstation).build())
)); ));
} }
if (shouldLog) if (shouldLog)
VillagerOptimizer.getLog().info(player.getName() + " unoptimized a villager by breaking workstation: '" + placed.getType().toString().toLowerCase() + "'"); VillagerOptimizer.getLog().info(player.getName() + " unoptimized a villager by breaking workstation: '" + broken.getType().toString().toLowerCase() + "'");
} }
private Villager.Profession getWorkstationProfession(Material workstation) { private Villager.Profession getWorkstationProfession(final Material workstation) {
return switch (workstation) { return switch (workstation) {
case BARREL -> Villager.Profession.FISHERMAN; case BARREL -> Villager.Profession.FISHERMAN;
case CARTOGRAPHY_TABLE -> Villager.Profession.CARTOGRAPHER; case CARTOGRAPHY_TABLE -> Villager.Profession.CARTOGRAPHER;