mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Add config for max /tree and /bigtree range (#4728)
Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>
This commit is contained in:
parent
debf09437e
commit
d5822e9a41
6 changed files with 17 additions and 3 deletions
|
@ -228,6 +228,8 @@ public interface ISettings extends IConf {
|
||||||
|
|
||||||
boolean isWorldHomePermissions();
|
boolean isWorldHomePermissions();
|
||||||
|
|
||||||
|
int getMaxTreeCommandRange();
|
||||||
|
|
||||||
boolean registerBackInListener();
|
boolean registerBackInListener();
|
||||||
|
|
||||||
boolean getDisableItemPickupWhileAfk();
|
boolean getDisableItemPickupWhileAfk();
|
||||||
|
|
|
@ -1212,6 +1212,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return registerBackInListener;
|
return registerBackInListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxTreeCommandRange() {
|
||||||
|
return config.getInt("tree-command-range-limit", 300);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean _registerBackInListener() {
|
private boolean _registerBackInListener() {
|
||||||
return config.getBoolean("register-back-in-listener", false);
|
return config.getBoolean("register-back-in-listener", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class Commandbigtree extends EssentialsCommand {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
|
final Location loc = LocationUtil.getTarget(user.getBase(), ess.getSettings().getMaxTreeCommandRange()).add(0, 1, 0);
|
||||||
if (loc.getBlock().getType().isSolid()) {
|
if (loc.getBlock().getType().isSolid()) {
|
||||||
throw new Exception(tl("bigTreeFailure"));
|
throw new Exception(tl("bigTreeFailure"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Commandtree extends EssentialsCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
|
final Location loc = LocationUtil.getTarget(user.getBase(), ess.getSettings().getMaxTreeCommandRange()).add(0, 1, 0);
|
||||||
if (loc.getBlock().getType().isSolid()) {
|
if (loc.getBlock().getType().isSolid()) {
|
||||||
throw new Exception(tl("treeFailure"));
|
throw new Exception(tl("treeFailure"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,9 +84,13 @@ public final class LocationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getTarget(final LivingEntity entity) throws Exception {
|
public static Location getTarget(final LivingEntity entity) throws Exception {
|
||||||
|
return getTarget(entity, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Location getTarget(final LivingEntity entity, final int maxDistance) throws Exception {
|
||||||
Block block = null;
|
Block block = null;
|
||||||
try {
|
try {
|
||||||
block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
|
block = entity.getTargetBlock(TRANSPARENT_MATERIALS, maxDistance);
|
||||||
} catch (final NoSuchMethodError ignored) {
|
} catch (final NoSuchMethodError ignored) {
|
||||||
} // failing now :(
|
} // failing now :(
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
|
|
|
@ -593,6 +593,9 @@ repair-enchanted: true
|
||||||
# Warning: Mixing and overleveling some enchantments can cause issues with clients, servers and plugins.
|
# Warning: Mixing and overleveling some enchantments can cause issues with clients, servers and plugins.
|
||||||
unsafe-enchantments: false
|
unsafe-enchantments: false
|
||||||
|
|
||||||
|
# The maximum range from the player that the /tree and /bigtree commands can spawn trees.
|
||||||
|
tree-command-range-limit: 300
|
||||||
|
|
||||||
#Do you want Essentials to keep track of previous location for /back in the teleport listener?
|
#Do you want Essentials to keep track of previous location for /back in the teleport listener?
|
||||||
#If you set this to true any plugin that uses teleport will have the previous location registered.
|
#If you set this to true any plugin that uses teleport will have the previous location registered.
|
||||||
register-back-in-listener: false
|
register-back-in-listener: false
|
||||||
|
|
Loading…
Reference in a new issue