aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky
diff options
context:
space:
mode:
authorolim <bobq4582@gmail.com>2024-06-19 20:47:38 +0100
committerolim <bobq4582@gmail.com>2024-07-15 12:37:17 +0100
commite30367c9b7b2370850e839e994d3c0bf95b3b9ad (patch)
tree4de410bb399e599a17f6039e998d51c1fff4795e /src/main/java/de/hysky
parentb3aa88019789eeec86627afd7e25e2edcd1dd675 (diff)
downloadSkyblocker-e30367c9b7b2370850e839e994d3c0bf95b3b9ad.tar.gz
Skyblocker-e30367c9b7b2370850e839e994d3c0bf95b3b9ad.tar.bz2
Skyblocker-e30367c9b7b2370850e839e994d3c0bf95b3b9ad.zip
add remove command and consistence
add command to remove way-point and consistence for the add and share
Diffstat (limited to 'src/main/java/de/hysky')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java39
1 files changed, 31 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);