add config toggle for sneaking
This commit is contained in:
parent
d0dc4a3346
commit
a1eacfad56
@ -31,9 +31,9 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
|
|||||||
|
|
||||||
private final VillagerCache villagerCache;
|
private final VillagerCache villagerCache;
|
||||||
private final HashSet<Material> blocks_that_disable = new HashSet<>(4);
|
private final HashSet<Material> blocks_that_disable = new HashSet<>(4);
|
||||||
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 onlyWhileSneaking, shouldLog, shouldNotifyPlayer;
|
||||||
|
|
||||||
public OptimizeByBlock() {
|
public OptimizeByBlock() {
|
||||||
shouldEnable();
|
shouldEnable();
|
||||||
@ -59,6 +59,8 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
|
|||||||
this.search_radius = config.getDouble("optimization-methods.block-optimization.search-radius-in-blocks", 2.0, """
|
this.search_radius = config.getDouble("optimization-methods.block-optimization.search-radius-in-blocks", 2.0, """
|
||||||
The radius in blocks a villager can be away from the player when he places an optimize block.\s
|
The radius in blocks a villager can be away from the player when he places an optimize block.\s
|
||||||
The closest unoptimized villager to the player will be optimized.""") / 2;
|
The closest unoptimized villager to the player will be optimized.""") / 2;
|
||||||
|
this.onlyWhileSneaking = config.getBoolean("optimization-methods.block-optimization.only-when-sneaking", true,
|
||||||
|
"Only optimize/unoptimize by workstation when player is sneaking during place or break.");
|
||||||
this.shouldNotifyPlayer = config.getBoolean("optimization-methods.block-optimization.notify-player", true,
|
this.shouldNotifyPlayer = config.getBoolean("optimization-methods.block-optimization.notify-player", true,
|
||||||
"Sends players a message when they successfully optimized or unoptimized a villager.");
|
"Sends players a message when they successfully optimized or unoptimized a villager.");
|
||||||
this.shouldLog = config.getBoolean("optimization-methods.block-optimization.log", false);
|
this.shouldLog = config.getBoolean("optimization-methods.block-optimization.log", false);
|
||||||
@ -86,6 +88,7 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
|
|||||||
if (!blocks_that_disable.contains(placed.getType())) return;
|
if (!blocks_that_disable.contains(placed.getType())) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.hasPermission(Permissions.Optimize.BLOCK.get())) return;
|
if (!player.hasPermission(Permissions.Optimize.BLOCK.get())) return;
|
||||||
|
if (onlyWhileSneaking && !player.isSneaking()) return;
|
||||||
|
|
||||||
final Location blockLoc = placed.getLocation();
|
final Location blockLoc = placed.getLocation();
|
||||||
WrappedVillager closestOptimizableVillager = null;
|
WrappedVillager closestOptimizableVillager = null;
|
||||||
@ -140,6 +143,7 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
|
|||||||
if (!blocks_that_disable.contains(broken.getType())) return;
|
if (!blocks_that_disable.contains(broken.getType())) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.hasPermission(Permissions.Optimize.BLOCK.get())) return;
|
if (!player.hasPermission(Permissions.Optimize.BLOCK.get())) return;
|
||||||
|
if (onlyWhileSneaking && !player.isSneaking()) return;
|
||||||
|
|
||||||
final Location blockLoc = broken.getLocation();
|
final Location blockLoc = broken.getLocation();
|
||||||
WrappedVillager closestOptimizedVillager = null;
|
WrappedVillager closestOptimizedVillager = null;
|
||||||
|
@ -28,7 +28,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
|
|||||||
private final VillagerCache villagerCache;
|
private final VillagerCache villagerCache;
|
||||||
private final long cooldown;
|
private final long cooldown;
|
||||||
private final double search_radius;
|
private final double search_radius;
|
||||||
private final boolean shouldLog, shouldNotifyPlayer;
|
private final boolean onlyWhileSneaking, shouldLog, shouldNotifyPlayer;
|
||||||
|
|
||||||
public OptimizeByWorkstation() {
|
public OptimizeByWorkstation() {
|
||||||
shouldEnable();
|
shouldEnable();
|
||||||
@ -43,6 +43,8 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
|
|||||||
this.cooldown = config.getInt("optimization-methods.workstation-optimization.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 a workstation.\s
|
Cooldown in seconds until a villager can be optimized again using a workstation.\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.onlyWhileSneaking = config.getBoolean("optimization-methods.workstation-optimization.only-when-sneaking", true,
|
||||||
|
"Only optimize/unoptimize by workstation when player is sneaking during place or break");
|
||||||
this.shouldNotifyPlayer = config.getBoolean("optimization-methods.workstation-optimization.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.workstation-optimization.log", false);
|
this.shouldLog = config.getBoolean("optimization-methods.workstation-optimization.log", false);
|
||||||
@ -71,6 +73,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
|
|||||||
if (workstationProfession.equals(Villager.Profession.NONE)) 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;
|
||||||
|
if (onlyWhileSneaking && !player.isSneaking()) return;
|
||||||
|
|
||||||
final Location workstationLoc = placed.getLocation();
|
final Location workstationLoc = placed.getLocation();
|
||||||
WrappedVillager closestOptimizableVillager = null;
|
WrappedVillager closestOptimizableVillager = null;
|
||||||
@ -126,6 +129,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
|
|||||||
if (workstationProfession.equals(Villager.Profession.NONE)) 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;
|
||||||
|
if (onlyWhileSneaking && !player.isSneaking()) return;
|
||||||
|
|
||||||
final Location workstationLoc = broken.getLocation();
|
final Location workstationLoc = broken.getLocation();
|
||||||
WrappedVillager closestOptimizedVillager = null;
|
WrappedVillager closestOptimizedVillager = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user