Add config option to OTT to limit to same world
This commit is contained in:
1 parent
332e701b89
commit
557b47e4ea
3 files changed
+20
No files matched your search
+7
@@ -20,6 +20,7 @@ public final class OneTimeTeleportConfig extends SimpleHackConfig {
|
||||
private List<Material> materialBlacklist;
|
||||
private List<Material> unsafeMaterials;
|
||||
private long timeLimitOnUsage;
|
||||
private boolean limitToSameWorld;
|
||||
|
||||
public OneTimeTeleportConfig(
|
||||
final @NotNull SimpleAdminHacks plugin,
|
||||
@@ -58,6 +59,8 @@ public final class OneTimeTeleportConfig extends SimpleHackConfig {
|
||||
.toList();
|
||||
// Parse maximum time limit to use OTT
|
||||
this.timeLimitOnUsage = ConfigHelper.parseTime(config.getString("ott_timeout", "2d"));
|
||||
// Parse same-world limit
|
||||
this.limitToSameWorld = config.getBoolean("limitToSameWorld", false);
|
||||
}
|
||||
|
||||
public @NotNull List<Material> getMaterialBlacklist() {
|
||||
@@ -71,4 +74,8 @@ public final class OneTimeTeleportConfig extends SimpleHackConfig {
|
||||
public long getTimeLimitOnUsageInMillis() {
|
||||
return this.timeLimitOnUsage;
|
||||
}
|
||||
|
||||
public boolean isLimitingToSameWorld() {
|
||||
return this.limitToSameWorld;
|
||||
}
|
||||
}
|
||||
+11
@@ -137,6 +137,11 @@ public final class OneTimeTeleport extends SimpleHack<OneTimeTeleportConfig> imp
|
||||
return;
|
||||
}
|
||||
|
||||
if (config().isLimitingToSameWorld() && !Objects.equals(sender.getWorld(), targetPlayer.getPlayer().getWorld())) {
|
||||
sender.sendMessage(Component.text("You cannot OTT to another world!", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID previousRequest = OneTimeTeleport.this.senderToReceiver.put(
|
||||
sender.getUniqueId(),
|
||||
targetPlayer.getPlayer().getUniqueId()
|
||||
@@ -226,6 +231,12 @@ public final class OneTimeTeleport extends SimpleHack<OneTimeTeleportConfig> imp
|
||||
return;
|
||||
}
|
||||
|
||||
if (config().isLimitingToSameWorld() && !Objects.equals(sender.getWorld(), requestingPlayer.getWorld())) {
|
||||
sender.sendMessage(Component.text(requestingPlayer.getName() + " could not one-time teleport as they're in a different world!", NamedTextColor.RED));
|
||||
requestingPlayer.sendMessage(Component.text(sender.getName() + " accepted your request, but you're in a different world!", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSafeLocation(sender, requestingPlayer)) {
|
||||
sender.sendMessage(Component.text("This isn't a safe location to accept a one-time teleport!", NamedTextColor.RED));
|
||||
requestingPlayer.sendMessage(Component.text(sender.getName() + " tried to accept your one-time teleport but is in an unsafe location!", NamedTextColor.RED));
|
||||
|
||||
@@ -475,6 +475,8 @@ hacks:
|
||||
unsafe_materials: [LAVA, WATER]
|
||||
# How long newfriends will have to use OTT before it expires
|
||||
ott_timeout: 2d
|
||||
# Whether or not to limit OTT to same-world teleports
|
||||
limitToSameWorld: false
|
||||
ReinforcedChestBreak:
|
||||
enabled: true
|
||||
# in seconds
|
||||
|
||||
Reference in new issue
Block a user