mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 03:34:42 +02:00
Migrate left-overs to enhanced switches
This commit is contained in:
@ -77,8 +77,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
String sub = args[0].toLowerCase();
|
||||
switch (sub) {
|
||||
case "l":
|
||||
case "list": {
|
||||
case "l", "list" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_LIST)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -133,8 +132,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "c":
|
||||
case "create": {
|
||||
case "c", "create" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_CREATE)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -269,9 +267,7 @@ public class Cluster extends SubCommand {
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case "disband":
|
||||
case "del":
|
||||
case "delete": {
|
||||
case "disband", "del", "delete" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_DELETE)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -330,8 +326,7 @@ public class Cluster extends SubCommand {
|
||||
));
|
||||
return true;
|
||||
}
|
||||
case "res":
|
||||
case "resize": {
|
||||
case "res", "resize" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_RESIZE)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -452,9 +447,7 @@ public class Cluster extends SubCommand {
|
||||
player.sendMessage(TranslatableCaption.of("cluster.cluster_resized"));
|
||||
return true;
|
||||
}
|
||||
case "add":
|
||||
case "inv":
|
||||
case "invite": {
|
||||
case "add", "inv", "invite" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_INVITE)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -523,9 +516,7 @@ public class Cluster extends SubCommand {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "k":
|
||||
case "remove":
|
||||
case "kick": {
|
||||
case "k", "remove", "kick" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_KICK)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -605,8 +596,7 @@ public class Cluster extends SubCommand {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "quit":
|
||||
case "leave": {
|
||||
case "quit", "leave" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_LEAVE)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -667,7 +657,7 @@ public class Cluster extends SubCommand {
|
||||
removePlayerPlots(cluster, uuid, player.getLocation().getWorldName());
|
||||
return true;
|
||||
}
|
||||
case "members": {
|
||||
case "members" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_HELPERS)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -728,9 +718,7 @@ public class Cluster extends SubCommand {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "spawn":
|
||||
case "home":
|
||||
case "tp": {
|
||||
case "spawn", "home", "tp" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_TP)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -778,10 +766,7 @@ public class Cluster extends SubCommand {
|
||||
player.sendMessage(TranslatableCaption.of("cluster.cluster_teleporting"));
|
||||
return true;
|
||||
}
|
||||
case "i":
|
||||
case "info":
|
||||
case "show":
|
||||
case "information": {
|
||||
case "i", "info", "show", "information" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_INFO)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
@ -850,9 +835,7 @@ public class Cluster extends SubCommand {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "sh":
|
||||
case "setspawn":
|
||||
case "sethome": {
|
||||
case "sh", "setspawn", "sethome" -> {
|
||||
if (!player.hasPermission(Permission.PERMISSION_CLUSTER_SETHOME)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
|
@ -559,9 +559,10 @@ public abstract class Command {
|
||||
|
||||
public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 0 -> {
|
||||
return this.allCommands;
|
||||
case 1:
|
||||
}
|
||||
case 1 -> {
|
||||
String arg = args[0].toLowerCase();
|
||||
if (space) {
|
||||
Command cmd = getCommand(arg);
|
||||
@ -580,13 +581,15 @@ public abstract class Command {
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
default:
|
||||
}
|
||||
default -> {
|
||||
Command cmd = getCommand(args[0]);
|
||||
if (cmd != null) {
|
||||
return cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,16 +75,19 @@ public class DebugRoadRegen extends SubCommand {
|
||||
}
|
||||
String kind = args[0].toLowerCase();
|
||||
switch (kind) {
|
||||
case "plot":
|
||||
case "plot" -> {
|
||||
return regenPlot(player);
|
||||
case "region":
|
||||
}
|
||||
case "region" -> {
|
||||
return regenRegion(player, Arrays.copyOfRange(args, 1, args.length));
|
||||
default:
|
||||
}
|
||||
default -> {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||
TagResolver.resolver("value", Tag.inserting(Component.text(DebugRoadRegen.USAGE)))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,10 @@ public class Help extends Command {
|
||||
RunnableVal2<Command, CommandResult> whenDone
|
||||
) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 0 -> {
|
||||
return displayHelp(player, null, 0);
|
||||
case 1:
|
||||
}
|
||||
case 1 -> {
|
||||
if (MathMan.isInteger(args[0])) {
|
||||
try {
|
||||
return displayHelp(player, null, Integer.parseInt(args[0]));
|
||||
@ -72,7 +73,8 @@ public class Help extends Command {
|
||||
} else {
|
||||
return displayHelp(player, args[0], 1);
|
||||
}
|
||||
case 2:
|
||||
}
|
||||
case 2 -> {
|
||||
if (MathMan.isInteger(args[1])) {
|
||||
try {
|
||||
return displayHelp(player, args[0], Integer.parseInt(args[1]));
|
||||
@ -81,8 +83,8 @@ public class Help extends Command {
|
||||
}
|
||||
}
|
||||
return CompletableFuture.completedFuture(false);
|
||||
default:
|
||||
sendUsage(player);
|
||||
}
|
||||
default -> sendUsage(player);
|
||||
}
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class Inbox extends SubCommand {
|
||||
final int page;
|
||||
if (args.length > 1) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "delete":
|
||||
case "delete" -> {
|
||||
if (!inbox.canModify(plot, player)) {
|
||||
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify"));
|
||||
return false;
|
||||
@ -225,7 +225,6 @@ public class Inbox extends SubCommand {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!inbox.getComments(plot, new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
@ -254,7 +253,8 @@ public class Inbox extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case "clear":
|
||||
}
|
||||
case "clear" -> {
|
||||
if (!inbox.canModify(plot, player)) {
|
||||
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify"));
|
||||
}
|
||||
@ -268,13 +268,15 @@ public class Inbox extends SubCommand {
|
||||
plot.getPlotCommentContainer().removeComments(comments);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
default -> {
|
||||
try {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
sendUsage(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
page = 1;
|
||||
|
@ -90,12 +90,8 @@ public class Purge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
switch (split[0].toLowerCase()) {
|
||||
case "world":
|
||||
case "w":
|
||||
world = split[1];
|
||||
break;
|
||||
case "area":
|
||||
case "a":
|
||||
case "world", "w" -> world = split[1];
|
||||
case "area", "a" -> {
|
||||
area = this.plotAreaManager.getPlotAreaByString(split[1]);
|
||||
if (area == null) {
|
||||
player.sendMessage(
|
||||
@ -104,9 +100,8 @@ public class Purge extends SubCommand {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "plotid":
|
||||
case "id":
|
||||
}
|
||||
case "plotid", "id" -> {
|
||||
try {
|
||||
id = PlotId.fromString(split[1]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
@ -116,9 +111,8 @@ public class Purge extends SubCommand {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "owner":
|
||||
case "o":
|
||||
}
|
||||
case "owner", "o" -> {
|
||||
UUIDMapping ownerMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]);
|
||||
if (ownerMapping == null) {
|
||||
player.sendMessage(
|
||||
@ -128,9 +122,8 @@ public class Purge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
owner = ownerMapping.uuid();
|
||||
break;
|
||||
case "shared":
|
||||
case "s":
|
||||
}
|
||||
case "shared", "s" -> {
|
||||
UUIDMapping addedMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]);
|
||||
if (addedMapping == null) {
|
||||
player.sendMessage(
|
||||
@ -140,22 +133,13 @@ public class Purge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
added = addedMapping.uuid();
|
||||
break;
|
||||
case "clear":
|
||||
case "c":
|
||||
case "delete":
|
||||
case "d":
|
||||
case "del":
|
||||
clear = Boolean.parseBoolean(split[1]);
|
||||
break;
|
||||
case "unknown":
|
||||
case "?":
|
||||
case "u":
|
||||
unknown = Boolean.parseBoolean(split[1]);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
case "clear", "c", "delete", "d", "del" -> clear = Boolean.parseBoolean(split[1]);
|
||||
case "unknown", "?", "u" -> unknown = Boolean.parseBoolean(split[1]);
|
||||
default -> {
|
||||
sendUsage(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashSet<Plot> toDelete = new HashSet<>();
|
||||
|
@ -185,30 +185,38 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
return null;
|
||||
}
|
||||
switch (hash) {
|
||||
case 8:
|
||||
case 8 -> {
|
||||
// north
|
||||
return plot.isMerged(Direction.NORTH) ? id : null;
|
||||
case 4:
|
||||
}
|
||||
case 4 -> {
|
||||
// east
|
||||
return plot.isMerged(Direction.EAST) ? id : null;
|
||||
case 2:
|
||||
}
|
||||
case 2 -> {
|
||||
// south
|
||||
return plot.isMerged(Direction.SOUTH) ? id : null;
|
||||
case 1:
|
||||
}
|
||||
case 1 -> {
|
||||
// west
|
||||
return plot.isMerged(Direction.WEST) ? id : null;
|
||||
case 12:
|
||||
}
|
||||
case 12 -> {
|
||||
// northeast
|
||||
return plot.isMerged(Direction.NORTHEAST) ? id : null;
|
||||
case 6:
|
||||
}
|
||||
case 6 -> {
|
||||
// southeast
|
||||
return plot.isMerged(Direction.SOUTHEAST) ? id : null;
|
||||
case 3:
|
||||
}
|
||||
case 3 -> {
|
||||
// southwest
|
||||
return plot.isMerged(Direction.SOUTHWEST) ? id : null;
|
||||
case 9:
|
||||
}
|
||||
case 9 -> {
|
||||
// northwest
|
||||
return plot.isMerged(Direction.NORTHWEST) ? id : null;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
LOGGER.error("Invalid plot / road width in settings.yml for world: {}", squarePlotWorld.getWorldName());
|
||||
|
@ -57,24 +57,15 @@ public class DenyTeleportFlag extends PlotFlag<DenyTeleportFlag.DeniedGroup, Den
|
||||
}
|
||||
final boolean result;
|
||||
switch (value) {
|
||||
case TRUSTED:
|
||||
result = !plot.getTrusted().contains(player.getUUID());
|
||||
break;
|
||||
case MEMBERS:
|
||||
result = !plot.getMembers().contains(player.getUUID());
|
||||
break;
|
||||
case NONMEMBERS:
|
||||
result = plot.isAdded(player.getUUID());
|
||||
break;
|
||||
case NONTRUSTED:
|
||||
result =
|
||||
plot.getTrusted().contains(player.getUUID()) || plot.isOwner(player.getUUID());
|
||||
break;
|
||||
case NONOWNERS:
|
||||
result = plot.isOwner(player.getUUID());
|
||||
break;
|
||||
default:
|
||||
case TRUSTED -> result = !plot.getTrusted().contains(player.getUUID());
|
||||
case MEMBERS -> result = !plot.getMembers().contains(player.getUUID());
|
||||
case NONMEMBERS -> result = plot.isAdded(player.getUUID());
|
||||
case NONTRUSTED -> result =
|
||||
plot.getTrusted().contains(player.getUUID()) || plot.isOwner(player.getUUID());
|
||||
case NONOWNERS -> result = plot.isOwner(player.getUUID());
|
||||
default -> {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return result || player.hasPermission("plots.admin.entry.denied");
|
||||
}
|
||||
|
@ -68,14 +68,11 @@ public class FlyFlag extends PlotFlag<FlyFlag.FlyStatus, FlyFlag> {
|
||||
|
||||
@Override
|
||||
protected FlyFlag flagOf(final @NonNull FlyStatus value) {
|
||||
switch (value) {
|
||||
case ENABLED:
|
||||
return FLIGHT_FLAG_ENABLED;
|
||||
case DISABLED:
|
||||
return FLIGHT_FLAG_DISABLED;
|
||||
default:
|
||||
return FLIGHT_FLAG_DEFAULT;
|
||||
}
|
||||
return switch (value) {
|
||||
case ENABLED -> FLIGHT_FLAG_ENABLED;
|
||||
case DISABLED -> FLIGHT_FLAG_DISABLED;
|
||||
default -> FLIGHT_FLAG_DEFAULT;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -359,11 +359,13 @@ public class EventDispatcher {
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case TELEPORT_OBJECT:
|
||||
case TELEPORT_OBJECT -> {
|
||||
return false;
|
||||
case READ:
|
||||
}
|
||||
case READ -> {
|
||||
return true;
|
||||
case INTERACT_BLOCK: {
|
||||
}
|
||||
case INTERACT_BLOCK -> {
|
||||
if (plot == null) {
|
||||
final List<BlockTypeWrapper> use = area.getRoadFlag(UseFlag.class);
|
||||
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
||||
@ -398,7 +400,7 @@ public class EventDispatcher {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case TRIGGER_PHYSICAL: {
|
||||
case TRIGGER_PHYSICAL -> {
|
||||
if (plot == null) {
|
||||
final List<BlockTypeWrapper> use = area.getRoadFlag(UseFlag.class);
|
||||
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
||||
@ -430,7 +432,7 @@ public class EventDispatcher {
|
||||
false
|
||||
);
|
||||
}
|
||||
case SPAWN_MOB: {
|
||||
case SPAWN_MOB -> {
|
||||
if (plot == null) {
|
||||
return player.hasPermission(
|
||||
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
|
||||
@ -472,7 +474,7 @@ public class EventDispatcher {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case PLACE_MISC: {
|
||||
case PLACE_MISC -> {
|
||||
if (plot == null) {
|
||||
return player.hasPermission(
|
||||
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
|
||||
@ -514,7 +516,7 @@ public class EventDispatcher {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case PLACE_VEHICLE:
|
||||
case PLACE_VEHICLE -> {
|
||||
if (plot == null) {
|
||||
return player.hasPermission(
|
||||
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
|
||||
@ -526,8 +528,9 @@ public class EventDispatcher {
|
||||
);
|
||||
}
|
||||
return plot.getFlag(VehiclePlaceFlag.class);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user