feat: add specific admin permissions for placing vehicles (#4258)

- fixes #3850
This commit is contained in:
Jordan 2024-01-07 15:57:36 +01:00 committed by GitHub
parent 449af2f3a4
commit 8c44b2d2d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 43 deletions

View File

@ -59,6 +59,9 @@ public enum Permission implements ComponentLike {
PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED("plots.admin.vehicle.break.unowned"), PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED("plots.admin.vehicle.break.unowned"),
PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER("plots.admin.vehicle.break.other"), PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER("plots.admin.vehicle.break.other"),
PERMISSION_ADMIN_PVE("plots.admin.pve"), PERMISSION_ADMIN_PVE("plots.admin.pve"),
PERMISSION_ADMIN_PLACE_VEHICLE_ROAD("plots.admin.vehicle.place.road"),
PERMISSION_ADMIN_PLACE_VEHICLE_UNOWNED("plots.admin.vehicle.place.unowned"),
PERMISSION_ADMIN_PLACE_VEHICLE_OTHER("plots.admin.vehicle.place.other"),
PERMISSION_ADMIN_PVP("plots.admin.pvp"), PERMISSION_ADMIN_PVP("plots.admin.pvp"),
PERMISSION_ADMIN_BUILD_ROAD("plots.admin.build.road"), PERMISSION_ADMIN_BUILD_ROAD("plots.admin.build.road"),
PERMISSION_ADMIN_PROJECTILE_ROAD("plots.admin.projectile.road"), PERMISSION_ADMIN_PROJECTILE_ROAD("plots.admin.projectile.road"),

View File

@ -382,14 +382,10 @@ public class EventDispatcher {
return true; return true;
} }
} }
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
);
} }
final List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class); final List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
for (final BlockTypeWrapper blockTypeWrapper : use) { for (final BlockTypeWrapper blockTypeWrapper : use) {
@ -398,7 +394,7 @@ public class EventDispatcher {
return true; return true;
} }
} }
if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), false)) { if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false)) {
return true; return true;
} }
// we check for the EditSignFlag in the PlayerSignOpenEvent again, but we must not cancel the interact event // we check for the EditSignFlag in the PlayerSignOpenEvent again, but we must not cancel the interact event
@ -423,14 +419,10 @@ public class EventDispatcher {
return true; return true;
} }
} }
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, false);
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), false
);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, false);
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), false
);
} }
if (plot.getFlag(DeviceInteractFlag.class)) { if (plot.getFlag(DeviceInteractFlag.class)) {
return true; return true;
@ -442,21 +434,14 @@ public class EventDispatcher {
return true; return true;
} }
} }
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false);
Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(),
false
);
} }
case SPAWN_MOB -> { case SPAWN_MOB -> {
if (plot == null) { if (plot == null) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
);
} }
if (plot.getFlag(MobPlaceFlag.class)) { if (plot.getFlag(MobPlaceFlag.class)) {
return true; return true;
@ -468,10 +453,7 @@ public class EventDispatcher {
return true; return true;
} }
} }
if (player.hasPermission( if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false)) {
Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(),
false
)) {
return true; return true;
} }
if (notifyPerms) { if (notifyPerms) {
@ -491,14 +473,10 @@ public class EventDispatcher {
} }
case PLACE_MISC -> { case PLACE_MISC -> {
if (plot == null) { if (plot == null) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
);
} }
if (plot.getFlag(MiscPlaceFlag.class)) { if (plot.getFlag(MiscPlaceFlag.class)) {
return true; return true;
@ -510,10 +488,7 @@ public class EventDispatcher {
return true; return true;
} }
} }
if (player.hasPermission( if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false)) {
Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(),
false
)) {
return true; return true;
} }
if (notifyPerms) { if (notifyPerms) {
@ -533,16 +508,28 @@ public class EventDispatcher {
} }
case PLACE_VEHICLE -> { case PLACE_VEHICLE -> {
if (plot == null) { if (plot == null) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_PLACE_VEHICLE_ROAD, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return player.hasPermission( return player.hasPermission(Permission.PERMISSION_ADMIN_PLACE_VEHICLE_UNOWNED, notifyPerms);
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms }
if (plot.getFlag(VehiclePlaceFlag.class)) {
return true;
}
if (player.hasPermission(Permission.PERMISSION_ADMIN_PLACE_VEHICLE_OTHER, false)) {
return true;
}
if (notifyPerms) {
player.sendMessage(
TranslatableCaption.of("commandconfig.flag_tutorial_usage"),
TagResolver.resolver(
"flag",
Tag.inserting(
PlotFlag.getFlagNameComponent(VehiclePlaceFlag.class)
)
)
); );
} }
return plot.getFlag(VehiclePlaceFlag.class);
} }
default -> { default -> {
} }