Renaming commands, fixing evoker fangs
This commit is contained in:
		| @@ -21,14 +21,14 @@ import com.comphenix.protocol.reflect.FieldAccessException; | |||||||
| import com.comphenix.protocol.wrappers.WrappedDataWatcher; | import com.comphenix.protocol.wrappers.WrappedDataWatcher; | ||||||
| import com.comphenix.protocol.wrappers.WrappedWatchableObject; | import com.comphenix.protocol.wrappers.WrappedWatchableObject; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.commands.CloneDisguiseCommand; | import me.libraryaddict.disguise.commands.DisguiseCloneCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseCommand; | import me.libraryaddict.disguise.commands.DisguiseCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseHelpCommand; | import me.libraryaddict.disguise.commands.DisguiseHelpCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseViewSelf; | import me.libraryaddict.disguise.commands.DisguiseViewSelfCommand; | ||||||
| import me.libraryaddict.disguise.commands.EntityDisguiseCommand; | import me.libraryaddict.disguise.commands.DisguiseEntityCommand; | ||||||
| import me.libraryaddict.disguise.commands.LibsDisguisesCommand; | import me.libraryaddict.disguise.commands.LibsDisguisesCommand; | ||||||
| import me.libraryaddict.disguise.commands.PlayerDisguiseCommand; | import me.libraryaddict.disguise.commands.DisguisePlayerCommand; | ||||||
| import me.libraryaddict.disguise.commands.RadiusDisguiseCommand; | import me.libraryaddict.disguise.commands.DisguiseRadiusCommand; | ||||||
| import me.libraryaddict.disguise.commands.UndisguiseCommand; | import me.libraryaddict.disguise.commands.UndisguiseCommand; | ||||||
| import me.libraryaddict.disguise.commands.UndisguiseEntityCommand; | import me.libraryaddict.disguise.commands.UndisguiseEntityCommand; | ||||||
| import me.libraryaddict.disguise.commands.UndisguisePlayerCommand; | import me.libraryaddict.disguise.commands.UndisguisePlayerCommand; | ||||||
| @@ -98,16 +98,16 @@ public class LibsDisguises extends JavaPlugin { | |||||||
|  |  | ||||||
|         registerCommand("disguise", new DisguiseCommand()); |         registerCommand("disguise", new DisguiseCommand()); | ||||||
|         registerCommand("undisguise", new UndisguiseCommand()); |         registerCommand("undisguise", new UndisguiseCommand()); | ||||||
|         registerCommand("disguiseplayer", new PlayerDisguiseCommand()); |         registerCommand("disguiseplayer", new DisguisePlayerCommand()); | ||||||
|         registerCommand("undisguiseplayer", new UndisguisePlayerCommand()); |         registerCommand("undisguiseplayer", new UndisguisePlayerCommand()); | ||||||
|         registerCommand("undisguiseentity", new UndisguiseEntityCommand()); |         registerCommand("undisguiseentity", new UndisguiseEntityCommand()); | ||||||
|         registerCommand("disguiseentity", new EntityDisguiseCommand()); |         registerCommand("disguiseentity", new DisguiseEntityCommand()); | ||||||
|         registerCommand("disguiseradius", new RadiusDisguiseCommand(getConfig().getInt("DisguiseRadiusMax"))); |         registerCommand("disguiseradius", new DisguiseRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); | ||||||
|         registerCommand("undisguiseradius", new UndisguiseRadiusCommand(getConfig().getInt("UndisguiseRadiusMax"))); |         registerCommand("undisguiseradius", new UndisguiseRadiusCommand(getConfig().getInt("UndisguiseRadiusMax"))); | ||||||
|         registerCommand("disguisehelp", new DisguiseHelpCommand()); |         registerCommand("disguisehelp", new DisguiseHelpCommand()); | ||||||
|         registerCommand("disguiseclone", new CloneDisguiseCommand()); |         registerCommand("disguiseclone", new DisguiseCloneCommand()); | ||||||
|         registerCommand("libsdisguises", new LibsDisguisesCommand()); |         registerCommand("libsdisguises", new LibsDisguisesCommand()); | ||||||
|         registerCommand("disguiseviewself", new DisguiseViewSelf()); |         registerCommand("disguiseviewself", new DisguiseViewSelfCommand()); | ||||||
|  |  | ||||||
|         registerValues(); |         registerValues(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,7 +43,7 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | |||||||
| /** | /** | ||||||
|  * @author libraryaddict |  * @author libraryaddict | ||||||
|  */ |  */ | ||||||
| public abstract class BaseDisguiseCommand implements CommandExecutor { | public abstract class DisguiseBaseCommand implements CommandExecutor { | ||||||
|     public class DisguiseParseException extends Exception { |     public class DisguiseParseException extends Exception { | ||||||
|         private static final long serialVersionUID = 1276971370793124510L; |         private static final long serialVersionUID = 1276971370793124510L; | ||||||
| 
 | 
 | ||||||
| @@ -123,6 +123,23 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|         return newArgs.toArray(new String[0]); |         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) { |     protected HashMap<String, Boolean> getDisguiseOptions(CommandSender sender, DisguiseType type) { | ||||||
|         switch (type) { |         switch (type) { | ||||||
|         case PLAYER: |         case PLAYER: | ||||||
| @@ -133,7 +150,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|         case DROPPED_ITEM: |         case DROPPED_ITEM: | ||||||
|             HashMap<String, Boolean> returns = new HashMap<>(); |             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()) { |             for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { | ||||||
|                 String lowerPerm = permission.getPermission().toLowerCase(); |                 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) { |     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()) { |         for (String perm : perms.keySet()) { | ||||||
|             if (!perms.get(perm)) { |             if (!perms.get(perm)) { | ||||||
|                 perm = perm.substring(permissionNode.length()); |                 perm = perm.substring(permissionNode.length()); | ||||||
|  | 
 | ||||||
|                 String disguiseType = perm.split("\\.")[0]; |                 String disguiseType = perm.split("\\.")[0]; | ||||||
|                 DisguiseType dType = null; |                 DisguiseType dType = null; | ||||||
| 
 | 
 | ||||||
| @@ -424,7 +442,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|      * @param args |      * @param args | ||||||
|      * @param map |      * @param map | ||||||
|      * @return |      * @return | ||||||
|      * @throws BaseDisguiseCommand.DisguiseParseException |      * @throws DisguiseBaseCommand.DisguiseParseException | ||||||
|      * @throws java.lang.IllegalAccessException |      * @throws java.lang.IllegalAccessException | ||||||
|      * @throws java.lang.reflect.InvocationTargetException |      * @throws java.lang.reflect.InvocationTargetException | ||||||
|      */ |      */ | ||||||
| @@ -14,7 +14,7 @@ import me.libraryaddict.disguise.DisguiseConfig; | |||||||
| import me.libraryaddict.disguise.LibsDisguises; | import me.libraryaddict.disguise.LibsDisguises; | ||||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||||
| 
 | 
 | ||||||
| public class CloneDisguiseCommand extends BaseDisguiseCommand implements TabCompleter { | public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
| @@ -21,7 +21,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | |||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
|  |  | ||||||
| public class DisguiseCommand extends BaseDisguiseCommand implements TabCompleter { | public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; | |||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| 
 | 
 | ||||||
| public class EntityDisguiseCommand extends BaseDisguiseCommand implements TabCompleter { | public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
| @@ -18,7 +18,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | |||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
|  |  | ||||||
| public class DisguiseHelpCommand extends BaseDisguiseCommand implements TabCompleter { | public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     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."); |         sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | |||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| 
 | 
 | ||||||
| public class PlayerDisguiseCommand extends BaseDisguiseCommand implements TabCompleter { | public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
| @@ -26,11 +26,11 @@ import me.libraryaddict.disguise.utilities.ClassGetter; | |||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | 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 int maxRadius = 30; | ||||||
|     private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>(); |     private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>(); | ||||||
| 
 | 
 | ||||||
|     public RadiusDisguiseCommand(int maxRadius) { |     public DisguiseRadiusCommand(int maxRadius) { | ||||||
|         this.maxRadius = maxRadius; |         this.maxRadius = maxRadius; | ||||||
|         for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) { |         for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) { | ||||||
|             if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) { |             if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) { | ||||||
| @@ -11,7 +11,7 @@ import me.libraryaddict.disguise.DisguiseAPI; | |||||||
| /** | /** | ||||||
|  * @author Navid |  * @author Navid | ||||||
|  */ |  */ | ||||||
| public class DisguiseViewSelf implements CommandExecutor { | public class DisguiseViewSelfCommand implements CommandExecutor { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||||||
| @@ -215,8 +215,16 @@ public abstract class Disguise { | |||||||
|                             DisguiseUtilities.refreshTrackers(disguise); |                             DisguiseUtilities.refreshTrackers(disguise); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |                     else if (getType() == DisguiseType.EVOKER_FANGS) { | ||||||
|  |                         refreshDisguise++; | ||||||
|  |  | ||||||
|                     if (getType() == DisguiseType.ITEM_FRAME) { |                         if (refreshDisguise % 20 == 0) { | ||||||
|  |                             refreshDisguise = 0; | ||||||
|  |  | ||||||
|  |                             DisguiseUtilities.refreshTrackers(disguise); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     else if (getType() == DisguiseType.ITEM_FRAME) { | ||||||
|                         Location loc = getEntity().getLocation(); |                         Location loc = getEntity().getLocation(); | ||||||
|  |  | ||||||
|                         int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4; |                         int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4; | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -186,7 +186,6 @@ public class PacketsManager { | |||||||
|                 ItemStack itemstack = disguise.getWatcher().getItemStack(slot); |                 ItemStack itemstack = disguise.getWatcher().getItemStack(slot); | ||||||
|  |  | ||||||
|                 if (itemstack == null || itemstack.getType() == Material.AIR) { |                 if (itemstack == null || itemstack.getType() == Material.AIR) { | ||||||
|                     System.out.println("Not wearing anything for " + slot.name()); |  | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user