diff options
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java | 39 | ||||
-rw-r--r-- | src/main/resources/assets/skyblocker/lang/en_us.json | 4 |
2 files changed, 35 insertions, 8 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java index 0a3d6641..dd50e71e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -80,7 +80,7 @@ public class CrystalsLocationsManager { try { //make sure that it is only reading user messages and not from skyblocker if (text.contains(":") && !text.startsWith(Constants.PREFIX.get().getString())) { - String userMessage = text.split(":",2)[1]; + String userMessage = text.split(":", 2)[1]; //get the message text Matcher matcher = TEXT_CWORDS_PATTERN.matcher(userMessage); @@ -136,16 +136,23 @@ public class CrystalsLocationsManager { private static void registerWaypointLocationCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) { dispatcher.register(literal(SkyblockerMod.NAMESPACE) .then(literal("crystalWaypoints") - .then(argument("pos", ClientBlockPosArgumentType.blockPos()) + .then(literal("add") + .then(argument("pos", BlockPosArgumentType.blockPos()) + .then(argument("place", StringArgumentType.greedyString()) + .suggests((context, builder) -> suggestMatching(WAYPOINT_LOCATIONS.keySet(), builder)) + .executes(context -> addWaypointFromCommand(context.getSource(), getString(context, "place"), context.getArgument("pos", ClientPosArgument.class))) + ) + )) + .then(literal("share") .then(argument("place", StringArgumentType.greedyString()) .suggests((context, builder) -> suggestMatching(WAYPOINT_LOCATIONS.keySet(), builder)) - .executes(context -> addWaypointFromCommand(context.getSource(), getString(context, "place"), context.getArgument("pos", ClientPosArgument.class))) + .executes(context -> shareWaypoint(getString(context, "place"))) ) ) - .then(literal("share") + .then(literal("remove") .then(argument("place", StringArgumentType.greedyString()) .suggests((context, builder) -> suggestMatching(WAYPOINT_LOCATIONS.keySet(), builder)) - .executes(context -> shareWaypoint(getString(context, "place"))) + .executes(context -> removeWaypoint(getString(context, "place"))) ) ) ) @@ -154,10 +161,11 @@ public class CrystalsLocationsManager { protected static Text getSetLocationMessage(String location, BlockPos blockPos) { MutableText text = Constants.PREFIX.get(); - text.append(Text.literal("Added waypoint for ")); + text.append(Text.translatable("skyblocker.config.mining.crystalsWaypoints.addedWaypoint")); int locationColor = WAYPOINT_LOCATIONS.get(location).getColor(); text.append(Text.literal(location).withColor(locationColor)); - text.append(Text.literal(" at : " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ() + ".")); + text.append(Text.literal(" ").append(Text.translatable("skyblocker.config.mining.crystalsWaypoints.addedWaypoint.at"))); + text.append(Text.literal(" : " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ() + ".")); return text; } @@ -167,7 +175,7 @@ public class CrystalsLocationsManager { for (String waypointLocation : WAYPOINT_LOCATIONS.keySet()) { int locationColor = WAYPOINT_LOCATIONS.get(waypointLocation).getColor(); - text.append(Text.literal("[" + waypointLocation + "]").withColor(locationColor).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/skyblocker crystalWaypoints " + location + " " + waypointLocation)))); + text.append(Text.literal("[" + waypointLocation + "]").withColor(locationColor).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/skyblocker crystalWaypoints add" + waypointLocation + " " + location)))); } return text; @@ -205,6 +213,21 @@ public class CrystalsLocationsManager { return Command.SINGLE_SUCCESS; } + public static int removeWaypoint(String place) { + if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { + return 0; + } + if (activeWaypoints.containsKey(place)) { + CLIENT.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.mining.crystalsWaypoints.removeSuccess").formatted(Formatting.GREEN)).append(Text.literal(place).withColor(WAYPOINT_LOCATIONS.get(place).getColor())), false); + activeWaypoints.remove(place); + } else { + //send fail message + CLIENT.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.mining.crystalsWaypoints.removeFail").formatted(Formatting.RED)), false); + } + + return Command.SINGLE_SUCCESS; + } + protected static void addCustomWaypoint(String waypointName, BlockPos pos) { MiningLocationLabel.CrystalHollowsLocationsCategory category = WAYPOINT_LOCATIONS.get(waypointName); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index b7096424..8bdc5965 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -473,7 +473,11 @@ "skyblocker.config.mining.crystalsWaypoints.enabled.@Tooltip": "Show a waypoint (waypoint selected in general/waypoints) at important areas in the crystal hollows, e.g., Jungle Temple and Fairy Grotto. ", "skyblocker.config.mining.crystalsWaypoints.findInChat": "Find Waypoints In Chat", "skyblocker.config.mining.crystalsWaypoints.findInChat.@Tooltip": "When in crystal hollows read the chat to see if coordinates are sent and extract these to show as waypoint or on the map", + "skyblocker.config.mining.crystalsWaypoints.addedWaypoint": "Added waypoint for ", + "skyblocker.config.mining.crystalsWaypoints.addedWaypoint.at": "at", "skyblocker.config.mining.crystalsWaypoints.shareFail": "Can only share waypoints you have found.", + "skyblocker.config.mining.crystalsWaypoints.removeSuccess": "Removed waypoint for ", + "skyblocker.config.mining.crystalsWaypoints.removeFail": "Can only remove waypoints you have found.", "skyblocker.config.mining.dwarvenHud": "Dwarven HUD", "skyblocker.config.mining.dwarvenHud.enabledCommissions": "Enable Commissions", |