Created
April 25, 2024 12:24
-
-
Save mworzala/229b4cd6dc84f1de90542fc50c584e34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapAlterCommand { | |
private final Argument<MapData> mapArg; | |
private final Argument<String> nameArg = Argument.GreedyString("name") | |
.description("The new name for the map"); | |
private final Argument<Material> displayItemArg = Argument.Material("item") | |
.description("The new display item for the map"); | |
private final Argument<String> subvariantArg; | |
private final Argument<MapSize> sizeArg = Argument.Enum("size", MapSize.class) | |
.description("The new world border size for the map"); | |
private final Argument<MapTags.Tag> tagArg = Argument.Enum("tag", MapTags.Tag.class) | |
.description("The tag to modify"); | |
private final Argument<MapQuality> qualityArg = Argument.Enum("quality", MapQuality.class) | |
.description("The new quality rating for the map"); | |
private final MapService mapService; | |
private final PermManager permManager; | |
public MapAlterCommand(@NotNull MapService mapService, PermManager permManager) { | |
this.mapService = mapService; | |
this.permManager = permManager; | |
mapArg = CoreArgument.PlayableMap("map", mapService) //todo should be any map dependent on context. | |
.description("The ID of the map to edit"); | |
var subvariantTypes = new ArrayList<String>(); | |
for (var bsv : BuildingSubVariant.values()) | |
subvariantTypes.add(bsv.name().toLowerCase()); | |
for (var psv : ParkourSubVariant.values()) | |
subvariantTypes.add(psv.name().toLowerCase()); | |
subvariantArg = Argument.Word("variant").with(subvariantTypes) | |
.description("The new variant for the map"); | |
} | |
public void build(@NotNull CommandBuilder builder) { | |
builder.child("alter", root -> root | |
.condition(permManager.createPlatformCondition2(PlatformPerm.MAP_ADMIN)) | |
.description("Edit information related to a map") | |
.child(mapArg, alter -> alter | |
.child("name", name -> name | |
.executes(playerOnly(this::handleSetName), nameArg) | |
.description("Change the name of a map") | |
.examples("/map alter 123-456-789 name Floating Parkour")) | |
.child("displayItem", di -> di | |
.executes(playerOnly(this::handleSetDisplayItem), displayItemArg) | |
.description("Change the display item of a map") | |
.examples("/map alter 123-456-789 displayItem book")) | |
.child("variant", sv -> sv | |
.executes(playerOnly(this::handleSetSubVariant), subvariantArg) | |
.description("Change the variant of a map") | |
.examples("/map alter 123-456-789 variant speedrun")) | |
.child("size", size -> size | |
.executes(playerOnly(this::handleSetSize), sizeArg) | |
.description("Change the world size of a map") | |
.examples("/map alter 123-456-789 size large")) | |
.child("tag", tag -> tag | |
.description("Add or remove a tag from a map") | |
.examples("/map alter 123-456-789 tag add puzzle", "/map alter 123-456-789 tag remove story") | |
.child("add", add -> add | |
.executes(playerOnly(this::handleAddTag), tagArg) | |
.description("Add a tag to a map")) | |
.child("remove", rem -> rem | |
.executes(playerOnly(this::handleRemoveTag), tagArg) | |
.description("Remove a tag from a map"))) | |
.child("quality", quality -> quality | |
.executes(playerOnly(this::handleSetQuality), qualityArg) | |
.description("Change the rating of a map") | |
.examples("/map alter 123-456-789 quality unrated")) | |
// todo toggle settings? | |
)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapEditCommand extends CommandDsl { | |
private final Argument<@NotNull MapData> mapArg; | |
private final MapService mapService; | |
private final ServerBridge bridge; | |
public MapEditCommand(@NotNull MapService mapService, @NotNull PermManager permManager, @NotNull ServerBridge bridge) { | |
super("edit"); | |
this.mapService = mapService; | |
this.bridge = bridge; | |
description = "Edit a map world (forced)"; | |
examples = List.of("/map edit 123-456-789", "/map edit a12345bc-67de-8f91-ghij-2345k6l78912"); | |
mapArg = CoreArgument.PlayableMap("map", mapService) | |
.description("The ID of the map to edit"); | |
setCondition(permManager.createPlatformCondition2(PlatformPerm.MAP_ADMIN)); | |
addSyntax(playerOnly(this::handleForceEditMap), mapArg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment