Skip to content

Commit

Permalink
chore(HomeCommand): remove unnecessary parameters and provide status-…
Browse files Browse the repository at this point in the history
…code handling for teleporting operation
  • Loading branch information
aivruu committed Dec 28, 2024
1 parent b30a224 commit 64807ce
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ public HomeCommand(
.executes(ctx -> {
final Player player = (Player) ctx.getSource().getSender();
final MessagesConfigurationModel messages = super.messages.model();
final boolean wasTeleported = this.playerHomeController.teleportToHome(player, ctx.getArgument("id", String.class));
if (!wasTeleported) {
player.sendMessage(MiniMessageHelper.parse(messages.unknownHome));
} else {
player.sendMessage(MiniMessageHelper.parse(messages.teleported));
final byte teleportStatusCode = this.playerHomeController.teleportToHome(player, ctx.getArgument("id", String.class));
switch (teleportStatusCode) {
case PlayerHomeController.PLAYER_HOME_DOES_NOT_EXIST ->
player.sendMessage(MiniMessageHelper.parse(messages.unknownHome));
case PlayerHomeController.PLAYER_HOME_WORLD_IS_NOT_AVAILABLE ->
player.sendMessage(MiniMessageHelper.parse(messages.homeWorldUnavailable));
case PlayerHomeController.PLAYER_HOME_TELEPORT_VALID ->
player.sendMessage(MiniMessageHelper.parse(messages.teleported));
default -> player.sendMessage(MiniMessageHelper.parse(messages.playerUnknownInfo));
}
return Command.SINGLE_SUCCESS;
})
Expand All @@ -150,7 +154,7 @@ public HomeCommand(
final MessagesConfigurationModel messages = super.messages.model();
final Player player = (Player) ctx.getSource().getSender();
final ValueObjectMutationResult<HomePositionValueObject> result = this.homePositionUpdater.updatePosition(
player, ctx.getArgument("id", String.class), player.getLocation());
player, ctx.getArgument("id", String.class));
switch (result.status()) {
case ValueObjectMutationResult.MUTATED_STATUS ->
player.sendMessage(MiniMessageHelper.parse(messages.locationModified));
Expand Down

0 comments on commit 64807ce

Please sign in to comment.