mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 12:25:46 +01:00
feat: Add border bypass permission (#3302)
* Add border bypass permission - Fixes #3297 * Add permission to plots.admin permpack * Implement messages on leaving/entering border area * Rename to border.denied and make border msg red * change too le/ge as tthey are likely to be equal to border when hit. - Since we check for being across the border beforehand, it will hopefully not be spammed too much? - If it's spammed then either we use meta to set if a player's left the border, or we just remove the come-back-in altogether because it's a little looong
This commit is contained in:
parent
f2368f97df
commit
be85708e5a
@ -564,19 +564,31 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
int border = area.getBorder();
|
||||
int x1;
|
||||
if (x2 > border && this.tmpTeleport) {
|
||||
to.setX(border - 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.border"));
|
||||
}
|
||||
if (x2 < -border && this.tmpTeleport) {
|
||||
to.setX(-border + 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.border"));
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
to.setX(border - 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
} else {
|
||||
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
|
||||
}
|
||||
} else if (x2 < -border && this.tmpTeleport) {
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
to.setX(-border + 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
} else {
|
||||
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
|
||||
}
|
||||
} else if (((x1 = MathMan.roundInt(from.getX())) >= border && x2 <= border) || (x1 <= -border && x2 >= -border)) {
|
||||
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
pp.sendMessage(TranslatableCaption.of("border.bypass.entered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
int z2;
|
||||
@ -643,18 +655,31 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
int border = area.getBorder();
|
||||
int z1;
|
||||
if (z2 > border && this.tmpTeleport) {
|
||||
to.setZ(border - 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.border"));
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
to.setZ(border - 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
} else {
|
||||
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
|
||||
}
|
||||
} else if (z2 < -border && this.tmpTeleport) {
|
||||
to.setZ(-border + 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.border"));
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
to.setZ(-border + 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
pp.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
} else {
|
||||
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
|
||||
}
|
||||
} else if (((z1 = MathMan.roundInt(from.getZ())) >= border && z2 <= border) || (z1 <= -border && z2 >= -border)) {
|
||||
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
pp.sendMessage(TranslatableCaption.of("border.bypass.entered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -248,9 +248,12 @@ permissions:
|
||||
plots.admin.components.other: true
|
||||
plots.admin.vehicle.break.unowned: true
|
||||
plots.admin.pve.unowned: true
|
||||
plots.admin.border.bypass: true
|
||||
|
||||
plots.teleport.delay.bypass:
|
||||
default: op
|
||||
plots.admin.border.bypass:
|
||||
default: op
|
||||
plots.worldedit.bypass:
|
||||
default: op
|
||||
plots.gamemode.bypass:
|
||||
|
@ -183,10 +183,12 @@ public class Claim extends SubCommand {
|
||||
);
|
||||
}
|
||||
}
|
||||
int border = area.getBorder();
|
||||
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
|
||||
player.sendMessage(TranslatableCaption.of("border.border"));
|
||||
return false;
|
||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
|
||||
int border = area.getBorder();
|
||||
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
|
||||
player.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
plot.setOwnerAbs(player.getUUID());
|
||||
final String finalSchematic = schematic;
|
||||
|
@ -274,7 +274,7 @@ public class MainCommand extends Command {
|
||||
}
|
||||
tp = true;
|
||||
} else {
|
||||
player.sendMessage(TranslatableCaption.of("border.border"));
|
||||
player.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
}
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
@ -204,7 +204,8 @@ public enum Permission {
|
||||
PERMISSION_ADMIN_DEBUG_OTHER("plots.admin.debug.other"),
|
||||
PERMISSION_RATE("plots.rate"),
|
||||
PERMISSION_ADMIN_FLIGHT("plots.admin.flight"),
|
||||
PERMISSION_ADMIN_COMPONENTS_OTHER("plots.admin.component.other");
|
||||
PERMISSION_ADMIN_COMPONENTS_OTHER("plots.admin.component.other"),
|
||||
PERMISSION_ADMIN_BYPASS_BORDER("plots.admin.border.bypass");
|
||||
//</editor-fold>
|
||||
|
||||
private final String text;
|
||||
|
@ -53,7 +53,9 @@
|
||||
"cluster.cluster_regenerated": "<prefix><dark_aqua>Successfully started cluster regeneration.</dark_aqua>",
|
||||
"cluster.cluster_teleporting": "<prefix><dark_aqua>Teleporting...</dark_aqua>",
|
||||
"cluster.cluster_info": "<prefix><gold>Current cluster: </gold><gray><id></gray>\n<gold>Name: </gold><gray><name></gray>\n<gold>Owner: </gold><gray><owner></gray>\n<gold>Size: </gold><gray><size></gray>\n<gold>Rights: </gold><gray><rights></gray>",
|
||||
"border.border": "<prefix><gray>You are outside the current map border.</gray>",
|
||||
"border.denied": "<prefix><red>You are outside the current map border.</red>",
|
||||
"border.bypass.exited": "<prefix><red>You have bypassed the current map border area.</red>",
|
||||
"border.bypass.entered": "<prefix><gray>You have re-entered the current map border area.</gray>",
|
||||
"worldedit.worldedit_bypass": "<prefix><gray><italic>To bypass your restrictions use </gray><dark_aqua><command></dark_aqua></italic>",
|
||||
"worldedit.worldedit_bypassed": "<prefix><gray>Currently bypassing WorldEdit restriction.</gray>",
|
||||
"gamemode.gamemode_was_bypassed": "<prefix><gold>You bypassed the gamemode (</gold><gray><gamemode></gray><gold>) <gold>set for </gold><gray><plot>.</gray>",
|
||||
|
Loading…
Reference in New Issue
Block a user