mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-06-30 11:01:40 +00:00
Implement tab completion for all commands. (#1282)
List of supported commands: ``` /afk /balance /balancetop /ban /banip /bigtree /book /broadcastworld /burn /clearinventory /condense /delhome /deljail /delwarp /eco /enchant /enderchest /essentials /exp /ext /feed /fireball /firework /gamemode /getpos /give /hat /heal /help /helpop /home /ignore /invsee /item /itemdb /jump /kick /kill /kit /lightning /list /mail /me /msg /mute /near /nick /nuke /pay /potion /powertool /ptime /pweather /recipe /remove /repair /sell /showkit /skull /speed /tempban /thunder /time /togglejail /tp /tpa /tpaall /tpahere /tpall /tphere /tpo /tpohere /tppos /tree /warp /weather /world /worth```
This commit is contained in:
parent
e572788a8c
commit
bbe0ca9302
82 changed files with 1783 additions and 118 deletions
|
@ -1,5 +1,8 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.Potions;
|
||||
import com.earth2me.essentials.User;
|
||||
|
@ -11,6 +14,8 @@ import org.bukkit.inventory.meta.PotionMeta;
|
|||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -70,4 +75,35 @@ public class Commandpotion extends EssentialsCommand {
|
|||
throw new Exception(tl("holdPotion"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
||||
// Note: this enforces an order of effect power duration splash, which the actual command doesn't have. But that's fine.
|
||||
if (args.length == 1) {
|
||||
List<String> options = Lists.newArrayList();
|
||||
options.add("clear");
|
||||
if (user.isAuthorized("essentials.potion.apply")) {
|
||||
options.add("apply");
|
||||
}
|
||||
for (Map.Entry<String, PotionEffectType> entry : Potions.entrySet()) {
|
||||
final String potionName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user.isAuthorized("essentials.potion." + potionName)) {
|
||||
options.add("effect:" + entry.getKey());
|
||||
}
|
||||
}
|
||||
return options;
|
||||
} else if (args.length == 2 && args[0].startsWith("effect:")) {
|
||||
return Lists.newArrayList("power:1", "power:2", "power:3", "power:4");
|
||||
} else if (args.length == 3 && args[0].startsWith("effect:")) {
|
||||
List<String> options = Lists.newArrayList();
|
||||
for (String duration : COMMON_DURATIONS) {
|
||||
options.add("duration:" + duration);
|
||||
}
|
||||
return options;
|
||||
} else if (args.length == 4 && args[0].startsWith("effect:")) {
|
||||
return Lists.newArrayList("splash:true", "splash:false");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue