From b88e93a61c7672f007cfc37a8cebf08203e7ff4d Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Thu, 13 Dec 2018 09:58:35 +0100 Subject: [PATCH] Added IslandInfoCommand #361 * Added IslandInfoCommand : "/is info" or "/is who". This is basically a copy/paste from AdminInfoCommand, and it uses the same methods. * Updated en-US locale accordingly --- .../commands/island/IslandInfoCommand.java | 56 +++++++++++++++++++ src/main/resources/locales/en-US.yml | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java new file mode 100644 index 000000000..052eb39f4 --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandInfoCommand.java @@ -0,0 +1,56 @@ +package world.bentobox.bentobox.api.commands.island; + +import world.bentobox.bentobox.api.commands.CompositeCommand; +import world.bentobox.bentobox.api.localization.TextVariables; +import world.bentobox.bentobox.api.user.User; + +import java.util.List; +import java.util.UUID; + +/** + * @author Poslovitch + */ +public class IslandInfoCommand extends CompositeCommand { + + public IslandInfoCommand(CompositeCommand parent) { + super(parent, "info", "who"); + } + + @Override + public void setup() { + setPermission("island.info"); + setOnlyPlayer(false); + setParametersHelp("commands.island.info.parameters"); + setDescription("commands.island.info.description"); + } + + @Override + public boolean execute(User user, String label, List args) { + if (args.size() > 1 || (args.isEmpty() && !user.isPlayer())) { + // Show help + showHelp(this, user); + return false; + } + // If there are no args, then the player wants info on the island at this location + if (args.isEmpty()) { + if (!getIslands().getIslandAt(user.getLocation()).map(i -> i.showInfo(getPlugin(), user, getWorld())).orElse(false)) { + user.sendMessage("commands.admin.info.no-island"); + return false; + } + return true; + } + // Get target player + UUID targetUUID = getPlayers().getUUID(args.get(0)); + if (targetUUID == null) { + user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0)); + return false; + } + if (!getIslands().hasIsland(getWorld(), targetUUID)) { + user.sendMessage("general.errors.player-has-no-island"); + return false; + } + // Show info for this player + getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld()); + return true; + } +} diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 95ab19b3f..5ec09a0c5 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -245,7 +245,8 @@ commands: creating-island: "&aCreating your island..." pick-world: "&cPick a world from [worlds]." info: - description: "display info about your island" + description: "display info about your island or the player's island" + parameters: "" reset: description: "restart your island and remove the old one" must-remove-members: "&cYou must remove all members from your island before you can restart it (/island team kick )."