Minor cleanup and untested disguise modify commands

This commit is contained in:
libraryaddict
2017-02-20 03:53:03 +13:00
parent 7ab456c7e6
commit 77a7e91766
7 changed files with 284 additions and 170 deletions

View File

@@ -66,7 +66,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
return newArgs.toArray(new String[0]);
}
public String getPermNode() {
public final String getPermNode() {
if (this instanceof DisguiseCommand) {
return "disguise";
}
@@ -79,8 +79,21 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
else if (this instanceof DisguiseRadiusCommand) {
return "disguiseradius";
}
else
else if (this instanceof DisguiseModifyCommand) {
return "disguisemodify";
}
else if (this instanceof DisguiseModifyEntityCommand) {
return "disguisemodifyentity";
}
else if (this instanceof DisguiseModifyPlayerCommand) {
return "disguisemodifyplayer";
}
else if (this instanceof DisguiseModifyRadiusCommand) {
return "disguisemodifyradius";
}
else {
throw new UnsupportedOperationException("Unknown disguise command, perm node not found");
}
}
protected HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender) {

View File

@@ -11,6 +11,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import me.libraryaddict.disguise.DisguiseAPI;
@@ -27,7 +28,7 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {
if (!(sender instanceof Entity)) {
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
return true;
}

View File

@@ -27,11 +27,16 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
return true;
}
if (getPermissions(sender).isEmpty()) {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
return true;
}
if (args.length == 0) {
sendCommandUsage(sender, getPermissions(sender));
return true;
@@ -56,7 +61,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
sender.sendMessage(ChatColor.RED + "Right click an entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
return true;
}
@@ -64,6 +69,11 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
ArrayList<String> tabs = new ArrayList<String>();
if (!(sender instanceof Player)) {
return tabs;
}
String[] args = getArgs(origArgs);
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = getPermissions(sender);