Renaming commands, fixing evoker fangs

This commit is contained in:
libraryaddict
2016-11-29 10:47:48 +13:00
parent 1de16cb4d7
commit ce134af4fa
12 changed files with 277 additions and 467 deletions

View File

@@ -43,7 +43,7 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
/**
* @author libraryaddict
*/
public abstract class BaseDisguiseCommand implements CommandExecutor {
public abstract class DisguiseBaseCommand implements CommandExecutor {
public class DisguiseParseException extends Exception {
private static final long serialVersionUID = 1276971370793124510L;
@@ -123,6 +123,23 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
return newArgs.toArray(new String[0]);
}
public String getPermNode() {
if (this instanceof DisguiseCommand) {
return "disguise";
}
else if (this instanceof DisguiseEntityCommand) {
return "disguiseentity";
}
else if (this instanceof DisguisePlayerCommand) {
return "disguiseplayer";
}
else if (this instanceof DisguiseRadiusCommand) {
return "disguiseradius";
}
else
throw new UnsupportedOperationException("Unknown disguise command, perm node not found");
}
protected HashMap<String, Boolean> getDisguiseOptions(CommandSender sender, DisguiseType type) {
switch (type) {
case PLAYER:
@@ -133,7 +150,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
case DROPPED_ITEM:
HashMap<String, Boolean> returns = new HashMap<>();
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
String beginning = "libsdisguises.options." + getPermNode() + ".";
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
String lowerPerm = permission.getPermission().toLowerCase();
@@ -192,7 +209,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
}
protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender) {
return getPermissions(sender, "libsdisguises." + getClass().getSimpleName().replace("Command", "").toLowerCase() + ".");
return getPermissions(sender, "libsdisguises." + getPermNode() + ".");
}
/**
@@ -309,6 +326,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
for (String perm : perms.keySet()) {
if (!perms.get(perm)) {
perm = perm.substring(permissionNode.length());
String disguiseType = perm.split("\\.")[0];
DisguiseType dType = null;
@@ -424,7 +442,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
* @param args
* @param map
* @return
* @throws BaseDisguiseCommand.DisguiseParseException
* @throws DisguiseBaseCommand.DisguiseParseException
* @throws java.lang.IllegalAccessException
* @throws java.lang.reflect.InvocationTargetException
*/

View File

@@ -14,7 +14,7 @@ import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
public class CloneDisguiseCommand extends BaseDisguiseCommand implements TabCompleter {
public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {

View File

@@ -21,7 +21,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class DisguiseCommand extends BaseDisguiseCommand implements TabCompleter {
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {

View File

@@ -21,7 +21,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class EntityDisguiseCommand extends BaseDisguiseCommand implements TabCompleter {
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {

View File

@@ -18,7 +18,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class DisguiseHelpCommand extends BaseDisguiseCommand implements TabCompleter {
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
@@ -149,6 +149,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand implements TabCompl
}
}
}
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
return true;
}

View File

@@ -21,7 +21,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class PlayerDisguiseCommand extends BaseDisguiseCommand implements TabCompleter {
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

View File

@@ -26,11 +26,11 @@ import me.libraryaddict.disguise.utilities.ClassGetter;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
public class RadiusDisguiseCommand extends BaseDisguiseCommand implements TabCompleter {
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
private int maxRadius = 30;
private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>();
public RadiusDisguiseCommand(int maxRadius) {
public DisguiseRadiusCommand(int maxRadius) {
this.maxRadius = maxRadius;
for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) {
if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) {

View File

@@ -11,7 +11,7 @@ import me.libraryaddict.disguise.DisguiseAPI;
/**
* @author Navid
*/
public class DisguiseViewSelf implements CommandExecutor {
public class DisguiseViewSelfCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {