chore: remove uses of deprecated Permissions class and add javadoc notes (#3930)

- Closes #3907
This commit is contained in:
Jordan
2023-01-15 13:08:59 +00:00
committed by GitHub
parent 86919b8841
commit 39d2f1a72c
60 changed files with 428 additions and 484 deletions

View File

@ -55,7 +55,6 @@ import com.plotsquared.core.plot.flag.implementations.VineGrowFlag;
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
@ -278,7 +277,7 @@ public class BlockEventListener implements Listener {
return;
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
@ -295,7 +294,7 @@ public class BlockEventListener implements Listener {
return;
}
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
@ -306,7 +305,7 @@ public class BlockEventListener implements Listener {
return;
}
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("done.building_restricted")
);
@ -322,7 +321,7 @@ public class BlockEventListener implements Listener {
+ " did not fall because of disable-physics = true");
}
}
} else if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
} else if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
@ -344,8 +343,7 @@ public class BlockEventListener implements Listener {
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
// == rather than <= as we only care about the "ground level" not being destroyed
if (event.getBlock().getY() == area.getMinGenHeight()) {
if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL))
@ -358,8 +356,7 @@ public class BlockEventListener implements Listener {
return;
}
if (!plot.hasOwner()) {
if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) {
event.setCancelled(true);
}
return;
@ -373,8 +370,7 @@ public class BlockEventListener implements Listener {
return;
}
}
if (Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
plotPlayer.sendMessage(
@ -383,7 +379,7 @@ public class BlockEventListener implements Listener {
);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("done.building_restricted")
);
@ -394,7 +390,7 @@ public class BlockEventListener implements Listener {
return;
}
BukkitPlayer pp = BukkitUtil.adapt(player);
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
return;
}
if (this.worldEdit != null && pp.getAttribute("worldedit")) {
@ -479,18 +475,18 @@ public class BlockEventListener implements Listener {
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
if (plot != null) {
if (!plot.hasOwner()) {
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
return;
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
return;
}
} else {
return;
}
} else {
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
return;
}
if (this.worldEdit != null && plotPlayer.getAttribute("worldedit")) {
@ -635,8 +631,7 @@ public class BlockEventListener implements Listener {
}
if (!plot.hasOwner()) {
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
if (Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return;
}
event.setCancelled(true);
@ -648,8 +643,7 @@ public class BlockEventListener implements Listener {
Block block = event.getBlock();
if (destroy
.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))
|| Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
|| plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
plot.debug(player.getName() + " could not break " + block.getType()
@ -660,7 +654,7 @@ public class BlockEventListener implements Listener {
return;
}
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
return;
}
event.setCancelled(true);
@ -1088,8 +1082,7 @@ public class BlockEventListener implements Listener {
return;
}
if (plot == null) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_BUILD_ROAD
)) {
pp.sendMessage(
@ -1099,8 +1092,7 @@ public class BlockEventListener implements Listener {
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_BUILD_UNOWNED
)) {
pp.sendMessage(
@ -1110,7 +1102,7 @@ public class BlockEventListener implements Listener {
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
@ -1234,8 +1226,7 @@ public class BlockEventListener implements Listener {
for (final BlockState state : event.getReplacedBlockStates()) {
Location currentLocation = BukkitUtil.adapt(state.getLocation());
if (!Permissions.hasPermission(
pp,
if (!pp.hasPermission(
Permission.PERMISSION_ADMIN_BUILD_ROAD
) && !(Objects.equals(currentLocation.getPlot(), plot))) {
pp.sendMessage(

View File

@ -37,7 +37,6 @@ import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
@ -371,14 +370,13 @@ public class EntityEventListener implements Listener {
if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
entity.remove();
event.setCancelled(true);
}
return;
}
if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
return;
}
entity.remove();

View File

@ -25,7 +25,6 @@ import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.ForcefieldFlag;
import com.plotsquared.core.util.Permissions;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -109,8 +108,7 @@ public class ForceFieldListener {
if (plot.isAdded(uuid)) {
Set<PlotPlayer<?>> players = getNearbyPlayers(player, plot);
for (PlotPlayer<?> oPlayer : players) {
if (!Permissions
.hasPermission(oPlayer, Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
if (!oPlayer.hasPermission(Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
((BukkitPlayer) oPlayer).player
.setVelocity(calculateVelocity(plotPlayer, oPlayer));
}
@ -120,8 +118,7 @@ public class ForceFieldListener {
if (oPlayer == null) {
return;
}
if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
player.setVelocity(calculateVelocity(oPlayer, plotPlayer));
}
}

View File

@ -43,7 +43,6 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.Chunk;
@ -335,8 +334,7 @@ public class PaperListener implements Listener {
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_PROJECTILE_ROAD
)) {
pp.sendMessage(
@ -347,7 +345,7 @@ public class PaperListener implements Listener {
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
@ -357,7 +355,7 @@ public class PaperListener implements Listener {
}
} else if (!plot.isAdded(pp.getUUID())) {
if (!plot.getFlag(ProjectilesFlag.class)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))

View File

@ -67,7 +67,6 @@ import com.plotsquared.core.plot.flag.implementations.VillagerInteractFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.entity.EntityCategories;
@ -275,8 +274,10 @@ public class PlayerEventListener implements Listener {
switch (parts[0]) {
case "up":
case "worldedit:up":
if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER, true))) {
if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !plotPlayer.hasPermission(
Permission.PERMISSION_ADMIN_BUILD_OTHER,
true
))) {
event.setCancelled(true);
return;
}
@ -291,7 +292,7 @@ public class PlayerEventListener implements Listener {
if (blockedCommands.isEmpty()) {
return;
}
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
return;
}
// When using namespaced commands, we're not interested in the namespace
@ -310,7 +311,7 @@ public class PlayerEventListener implements Listener {
} else {
perm = "plots.admin.command.blocked-cmds.road";
}
if (!Permissions.hasPermission(plotPlayer, perm)) {
if (!plotPlayer.hasPermission(perm)) {
plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked"));
event.setCancelled(true);
}
@ -600,7 +601,7 @@ public class PlayerEventListener implements Listener {
int border = area.getBorder();
int x1;
if (x2 > border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setX(border - 1);
this.tmpTeleport = false;
player.teleport(event.getTo());
@ -610,7 +611,7 @@ public class PlayerEventListener implements Listener {
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
}
} else if (x2 < -border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setX(-border + 1);
this.tmpTeleport = false;
player.teleport(event.getTo());
@ -620,7 +621,7 @@ public class PlayerEventListener implements Listener {
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)) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
pp.sendMessage(TranslatableCaption.of("border.bypass.entered"));
}
}
@ -691,7 +692,7 @@ public class PlayerEventListener implements Listener {
int border = area.getBorder();
int z1;
if (z2 > border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setZ(border - 1);
this.tmpTeleport = false;
player.teleport(event.getTo());
@ -701,7 +702,7 @@ public class PlayerEventListener implements Listener {
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
}
} else if (z2 < -border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setZ(-border + 1);
this.tmpTeleport = false;
player.teleport(event.getTo());
@ -711,7 +712,7 @@ public class PlayerEventListener implements Listener {
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)) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
pp.sendMessage(TranslatableCaption.of("border.bypass.entered"));
}
}
@ -738,8 +739,7 @@ public class PlayerEventListener implements Listener {
|| area.isForcingPlotChat())) {
return;
}
if (plot.isDenied(plotPlayer.getUUID()) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_CHAT_BYPASS)) {
if (plot.isDenied(plotPlayer.getUUID()) && !plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_CHAT_BYPASS)) {
return;
}
event.setCancelled(true);
@ -824,7 +824,7 @@ public class PlayerEventListener implements Listener {
plotListener.plotExit(pp, plot);
}
if (this.worldEdit != null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_WORLDEDIT_BYPASS)) {
if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) {
if (pp.getAttribute("worldedit")) {
pp.removeAttribute("worldedit");
}
@ -880,8 +880,7 @@ public class PlayerEventListener implements Listener {
final Plot plot = pp.getCurrentPlot();
if (plot != null) {
if (plot.getFlag(PreventCreativeCopyFlag.class) && !plot
.isAdded(player.getUniqueId()) && !Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
.isAdded(player.getUniqueId()) && !pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
final ItemStack newStack =
new ItemStack(newItem.getType(), newItem.getAmount());
event.setCursor(newStack);
@ -943,7 +942,7 @@ public class PlayerEventListener implements Listener {
Plot plot = area.getPlotAbs(location);
boolean cancelled = false;
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
@ -951,7 +950,7 @@ public class PlayerEventListener implements Listener {
cancelled = true;
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
@ -961,7 +960,7 @@ public class PlayerEventListener implements Listener {
} else {
UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
@ -998,8 +997,7 @@ public class PlayerEventListener implements Listener {
Plot plot = location.getPlotAbs();
BukkitPlayer pp = BukkitUtil.adapt(e.getPlayer());
if (plot == null) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, MiscInteractFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, MiscInteractFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_ROAD
)) {
pp.sendMessage(
@ -1010,14 +1008,14 @@ public class PlayerEventListener implements Listener {
}
} else {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(TranslatableCaption.of("done.building_restricted"));
e.setCancelled(true);
return;
}
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
if (!pp.hasPermission("plots.admin.interact.unowned")) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
@ -1032,7 +1030,7 @@ public class PlayerEventListener implements Listener {
if (plot.getFlag(MiscInteractFlag.class)) {
return;
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
@ -1257,7 +1255,7 @@ public class PlayerEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(event.getPlayer());
Plot plot = area.getPlot(location);
if (plot == null) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
return;
}
pp.sendMessage(
@ -1266,7 +1264,7 @@ public class PlayerEventListener implements Listener {
);
event.setCancelled(true);
} else if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
}
pp.sendMessage(
@ -1275,7 +1273,7 @@ public class PlayerEventListener implements Listener {
);
event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
return;
}
pp.sendMessage(
@ -1284,7 +1282,7 @@ public class PlayerEventListener implements Listener {
);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("done.building_restricted")
);
@ -1322,7 +1320,7 @@ public class PlayerEventListener implements Listener {
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
Plot plot = area.getPlot(location);
if (plot == null) {
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
return;
}
plotPlayer.sendMessage(
@ -1331,7 +1329,7 @@ public class PlayerEventListener implements Listener {
);
event.setCancelled(true);
} else if (!plot.hasOwner()) {
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
}
plotPlayer.sendMessage(
@ -1340,7 +1338,7 @@ public class PlayerEventListener implements Listener {
);
event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
return;
}
plotPlayer.sendMessage(
@ -1349,7 +1347,7 @@ public class PlayerEventListener implements Listener {
);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("done.building_restricted")
);
@ -1374,7 +1372,7 @@ public class PlayerEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(p);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
@ -1383,7 +1381,7 @@ public class PlayerEventListener implements Listener {
}
} else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
@ -1394,7 +1392,7 @@ public class PlayerEventListener implements Listener {
}
if (!plot.isAdded(pp.getUUID())) {
if (!plot.getFlag(HangingPlaceFlag.class)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
@ -1423,7 +1421,7 @@ public class PlayerEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(p);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
@ -1431,7 +1429,7 @@ public class PlayerEventListener implements Listener {
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
@ -1442,7 +1440,7 @@ public class PlayerEventListener implements Listener {
if (plot.getFlag(HangingBreakFlag.class)) {
return;
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
@ -1463,8 +1461,7 @@ public class PlayerEventListener implements Listener {
Plot plot = area.getPlot(BukkitUtil.adapt(event.getEntity().getLocation()));
if (plot != null) {
if (!plot.hasOwner()) {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
if (!player.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
@ -1473,8 +1470,7 @@ public class PlayerEventListener implements Listener {
}
} else if (!plot.isAdded(player.getUUID())) {
if (!plot.getFlag(HangingBreakFlag.class)) {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
if (!player.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
@ -1506,7 +1502,7 @@ public class PlayerEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(p);
Plot plot = area.getPlot(location);
if (plot == null && !area.isRoadFlags()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
@ -1514,7 +1510,7 @@ public class PlayerEventListener implements Listener {
event.setCancelled(true);
}
} else if (plot != null && !plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
@ -1572,7 +1568,7 @@ public class PlayerEventListener implements Listener {
return;
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
@ -1594,8 +1590,7 @@ public class PlayerEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(p);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, VehicleBreakFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, VehicleBreakFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD
)) {
pp.sendMessage(
@ -1606,7 +1601,7 @@ public class PlayerEventListener implements Listener {
}
} else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED))
@ -1620,7 +1615,7 @@ public class PlayerEventListener implements Listener {
if (plot.getFlag(VehicleBreakFlag.class)) {
return;
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER))

View File

@ -30,7 +30,6 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotHandler;
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.entity.Entity;
@ -106,8 +105,7 @@ public class ProjectileEventListener implements Listener {
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_PROJECTILE_ROAD
)) {
pp.sendMessage(
@ -118,7 +116,7 @@ public class ProjectileEventListener implements Listener {
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
@ -128,7 +126,7 @@ public class ProjectileEventListener implements Listener {
}
} else if (!plot.isAdded(pp.getUUID())) {
if (!plot.getFlag(ProjectilesFlag.class)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
@ -170,8 +168,7 @@ public class ProjectileEventListener implements Listener {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission(
pp,
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !pp.hasPermission(
Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED
)) {
entity.remove();
@ -179,8 +176,8 @@ public class ProjectileEventListener implements Listener {
}
return;
}
if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(ProjectilesFlag.class)) {
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(
ProjectilesFlag.class)) {
return;
}
entity.remove();

View File

@ -87,4 +87,9 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
);
}
@Override
public boolean hasPermission(@NonNull final String permission, final boolean notify) {
return hasPermission(permission);
}
}

View File

@ -40,7 +40,6 @@ import com.plotsquared.core.plot.flag.implementations.PvpFlag;
import com.plotsquared.core.plot.flag.implementations.TamedAttackFlag;
import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag;
import com.plotsquared.core.util.EntityUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.entity.EntityCategories;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import net.kyori.adventure.text.minimessage.Template;
@ -168,8 +167,7 @@ public class BukkitEntityUtil {
if (plot != null && (plot.getFlag(HangingBreakFlag.class) || plot
.isAdded(plotPlayer.getUUID()))) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("done.building_restricted")
);
@ -178,7 +176,7 @@ public class BukkitEntityUtil {
}
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
@ -190,7 +188,7 @@ public class BukkitEntityUtil {
.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
@ -211,7 +209,7 @@ public class BukkitEntityUtil {
.getFlag(PveFlag.class))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
@ -232,7 +230,7 @@ public class BukkitEntityUtil {
.getFlag(PveFlag.class))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
@ -245,8 +243,7 @@ public class BukkitEntityUtil {
}
} else if (EntityCategories.PLAYER.contains(entityType)) {
if (isPlot) {
if (!plot.getFlag(PvpFlag.class) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
if (!plot.getFlag(PvpFlag.class) && !plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
@ -260,7 +257,7 @@ public class BukkitEntityUtil {
} else if (roadFlags && area.getRoadFlag(PvpFlag.class)) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
@ -277,7 +274,7 @@ public class BukkitEntityUtil {
.getFlag(PveFlag.class))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
@ -299,7 +296,7 @@ public class BukkitEntityUtil {
} else if (roadFlags && area.getRoadFlag(PveFlag.class)) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)