From 1fe43f87e2ba7dfe588d428c7ade64dd78f0f308 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 7 Mar 2018 14:20:18 -0500 Subject: [PATCH] Add help to /tp --- .../command/teleport/TeleportCommand.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/teleport/TeleportCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/teleport/TeleportCommand.java index 21c26eb72..23f613d1a 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/teleport/TeleportCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/teleport/TeleportCommand.java @@ -1,7 +1,9 @@ package mineplex.mapparser.command.teleport; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -15,6 +17,11 @@ import mineplex.mapparser.command.BaseCommand; public class TeleportCommand extends BaseCommand { + private final static List COMMANDS = Arrays.asList( + "/tp - Teleport to another player", + "/tp - Teleport the from player to the destination player", + "/tp - Teleport to coordinates" + ); private final static String COORDINATE_FORMAT = "%.2f"; private TeleportManager _teleportManager; @@ -56,6 +63,22 @@ public class TeleportCommand extends BaseCommand } } + private void help(Player player) + { + player.sendMessage(F.main(getPlugin().getName(), "Teleport command usage:")); + COMMANDS.stream().map(c -> { + List parts = Arrays.stream(c.split("\\s*-\\s*")).collect(Collectors.toList()); + + String commandMessage = " "; + + commandMessage += C.cYellow + parts.get(0); + commandMessage += C.cGray + " - "; + commandMessage += C.cGold + parts.get(1); + + return commandMessage; + }).forEach(player::sendMessage); + } + @Override public boolean execute(Player player, String alias, String[] args) { @@ -119,6 +142,7 @@ public class TeleportCommand extends BaseCommand if (coordinate == null) { message(player, "Hmm, those coordinates don't look quite right."); + help(player); return true; } } @@ -140,6 +164,7 @@ public class TeleportCommand extends BaseCommand else { message(player, "Hmm, your command doesn't look quite right."); + help(player); } return true;