diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandwarpinfo.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandwarpinfo.java new file mode 100644 index 000000000..f46f9a929 --- /dev/null +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandwarpinfo.java @@ -0,0 +1,47 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.CommandSource; +import org.bukkit.Location; +import org.bukkit.Server; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static com.earth2me.essentials.I18n.tl; + +public class Commandwarpinfo extends EssentialsCommand { + + public Commandwarpinfo() { + super("warpinfo"); + } + + @Override + public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { + if (args.length == 0) { + throw new NotEnoughArgumentsException(); + } + final String name = args[0]; + final Location loc = ess.getWarps().getWarp(name); + sender.sendMessage(tl("warpInfo", name)); + sender.sendMessage(tl("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + } + + @Override + protected List getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) { + if (args.length == 1) { + if (ess.getSettings().getPerWarpPermission() && sender.isPlayer()) { + final List list = new ArrayList<>(); + for (String curWarp : ess.getWarps().getList()) { + if (sender.isAuthorized("essentials.warps." + curWarp, ess)) { + list.add(curWarp); + } + } + return list; + } + return new ArrayList<>(ess.getWarps().getList()); + } else { + return Collections.emptyList(); + } + } +} diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 09405461a..6c9a9b190 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -933,6 +933,9 @@ walking=walking warpCommandDescription=List all warps or warp to the specified location. warpCommandUsage=/ [player] warpDeleteError=\u00a74Problem deleting the warp file. +warpInfo=\u00a76Information for warp\u00a7c {0}\u00a76: +warpinfoCommandDescription=Finds location information for a specified warp. +warpinfoCommandUsage=/ warpingTo=\u00a76Warping to\u00a7c {0}\u00a76. warpList={0} warpListPermission=\u00a74You do not have permission to list warps. diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 0608bd842..0152779d8 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -568,6 +568,10 @@ commands: description: List all warps or warp to the specified location. usage: / [player] aliases: [ewarp,warps,ewarps] + warpinfo: + description: Finds location information for a specified warp. + usage: / + aliases: [ewarpinfo] weather: description: Sets the weather. usage: / [duration]