Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirmation messages to home and warp commands #27

Open
wants to merge 3 commits into
base: 1.21.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Prometheus is a utility mod, granting users access to useful commands and quick utilities, and providing server owners with great control over player permissions, warps and even custom command scripts.
#### [Documentation](https://docs.terrarium.earth/docs/prometheus/intro)

### Download:
#### [Modrinth](https://modrinth.com/mod/prometheus)
#### [CurseForge](https://www.curseforge.com/minecraft/mc-mods/prometheus)

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ private static LiteralArgumentBuilder<CommandSourceStack> add() {
.requires(source -> source.hasPermission(2))
.then(Commands.argument("name", StringArgumentType.greedyString())
.executes(context -> {
WarpHandler.add(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "name"));
ServerPlayer player = context.getSource().getPlayerOrException();
String warpName = StringArgumentType.getString(context, "name");
WarpHandler.add(player, warpName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this need to return if add returns false

Suggested change
WarpHandler.add(player, warpName);
if (!WarpHandler.add(player, warpName)) return 0;

player.sendSystemMessage(CommonUtils.serverTranslatable("prometheus.locations.warp.created", warpName));
return 1;
})

Expand All @@ -68,7 +71,10 @@ private static LiteralArgumentBuilder<CommandSourceStack> remove() {
.then(Commands.argument("name", StringArgumentType.greedyString())
.suggests(SUGGESTION_PROVIDER)
.executes(context -> {
WarpHandler.remove(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "name"));
ServerPlayer player = context.getSource().getPlayerOrException();
String warpName = StringArgumentType.getString(context, "name");
WarpHandler.remove(player, warpName);
player.sendSystemMessage(CommonUtils.serverTranslatable("prometheus.locations.warp.removed", warpName));
return 1;
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ private static LiteralArgumentBuilder<CommandSourceStack> add() {
return Commands.literal("sethome")
.then(Commands.argument("name", StringArgumentType.greedyString())
.executes(context -> {
HomeHandler.add(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "name"));
ServerPlayer player = context.getSource().getPlayerOrException();
String homeName = StringArgumentType.getString(context, "name");
HomeHandler.add(player, homeName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this need to return if add returns false

Suggested change
HomeHandler.add(player, homeName);
if (!HomeHandler.add(player, homeName)) return 0;

player.sendSystemMessage(CommonUtils.serverTranslatable("prometheus.locations.home.created", homeName));
return 1;
})

Expand All @@ -72,7 +75,10 @@ private static LiteralArgumentBuilder<CommandSourceStack> remove() {
.then(Commands.argument("name", StringArgumentType.greedyString())
.suggests(SUGGEST_HOMES)
.executes(context -> {
HomeHandler.remove(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "name"));
ServerPlayer player = context.getSource().getPlayerOrException();
String homeName = StringArgumentType.getString(context, "name");
HomeHandler.remove(player, homeName);
player.sendSystemMessage(CommonUtils.serverTranslatable("prometheus.locations.home.removed", homeName));
return 1;
})

Expand Down
4 changes: 4 additions & 0 deletions common/src/main/resources/assets/prometheus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@
"prometheus.locations.home": "Homes",
"prometheus.locations.home.command": "Homes:",
"prometheus.locations.home.add": "Add a Home",
"prometheus.locations.home.created": "Home '%s' added.",
"prometheus.locations.home.removed": "Home '%s' removed.",
"prometheus.locations.home.to": "Click to teleport to %s",
"prometheus.locations.warp": "Warps",
"prometheus.locations.warp.command": "Warps:",
"prometheus.warps.error.warp_already_exists": "Warp already exists.",
"prometheus.warps.error.warp_does_not_exist": "Warp does not exist.",
"prometheus.warps.error.no_warps": "There are no warps.",
"prometheus.locations.warp.created": "Warp '%s' added.",
"prometheus.locations.warp.removed": "Warp '%s' removed.",
"prometheus.locations.warp.add": "Add a Warp",
"prometheus.locations.warp.to": "Click to warp to %s",
"prometheus.locations.add": "Add New Location:",
Expand Down