|
| 1 | +package com.earth2me.essentials.commands; |
| 2 | + |
| 3 | +import com.earth2me.essentials.CommandSource; |
| 4 | +import org.bukkit.Location; |
| 5 | +import org.bukkit.Server; |
| 6 | + |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.Collections; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +import static com.earth2me.essentials.I18n.tl; |
| 12 | + |
| 13 | +public class Commandwarpinfo extends EssentialsCommand { |
| 14 | + |
| 15 | + public Commandwarpinfo() { |
| 16 | + super("warpinfo"); |
| 17 | + } |
| 18 | + |
| 19 | + @Override |
| 20 | + public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { |
| 21 | + if (args.length == 0) { |
| 22 | + throw new NotEnoughArgumentsException(); |
| 23 | + } |
| 24 | + final String name = args[0]; |
| 25 | + final Location loc = ess.getWarps().getWarp(name); |
| 26 | + sender.sendMessage(tl("warpInfo", name)); |
| 27 | + sender.sendMessage(tl("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); |
| 28 | + } |
| 29 | + |
| 30 | + @Override |
| 31 | + protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) { |
| 32 | + if (args.length == 1) { |
| 33 | + if (ess.getSettings().getPerWarpPermission() && sender.isPlayer()) { |
| 34 | + final List<String> list = new ArrayList<>(); |
| 35 | + for (String curWarp : ess.getWarps().getList()) { |
| 36 | + if (sender.isAuthorized("essentials.warps." + curWarp, ess)) { |
| 37 | + list.add(curWarp); |
| 38 | + } |
| 39 | + } |
| 40 | + return list; |
| 41 | + } |
| 42 | + return new ArrayList<>(ess.getWarps().getList()); |
| 43 | + } else { |
| 44 | + return Collections.emptyList(); |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments