Fixed custom name still being set despite being overridden
This commit is contained in:
		| @@ -129,29 +129,23 @@ public class LibsDisguises extends JavaPlugin { | |||||||
|         registerCommand("libsdisguises", new LibsDisguisesCommand()); |         registerCommand("libsdisguises", new LibsDisguisesCommand()); | ||||||
|  |  | ||||||
|         if (!DisguiseConfig.isDisableCommands()) { |         if (!DisguiseConfig.isDisableCommands()) { | ||||||
|             if (!LibsPremium.isAPIPlugin()) { |             registerCommand("disguise", new DisguiseCommand()); | ||||||
|                 registerCommand("disguise", new DisguiseCommand()); |             registerCommand("undisguise", new UndisguiseCommand()); | ||||||
|                 registerCommand("undisguise", new UndisguiseCommand()); |             registerCommand("disguiseplayer", new DisguisePlayerCommand()); | ||||||
|                 registerCommand("disguiseplayer", new DisguisePlayerCommand()); |             registerCommand("undisguiseplayer", new UndisguisePlayerCommand()); | ||||||
|                 registerCommand("undisguiseplayer", new UndisguisePlayerCommand()); |             registerCommand("undisguiseentity", new UndisguiseEntityCommand()); | ||||||
|                 registerCommand("undisguiseentity", new UndisguiseEntityCommand()); |             registerCommand("disguiseentity", new DisguiseEntityCommand()); | ||||||
|                 registerCommand("disguiseentity", new DisguiseEntityCommand()); |             registerCommand("disguiseradius", new DisguiseRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); | ||||||
|                 registerCommand("disguiseradius", new DisguiseRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); |             registerCommand("undisguiseradius", new UndisguiseRadiusCommand(getConfig().getInt("UndisguiseRadiusMax"))); | ||||||
|                 registerCommand("undisguiseradius", |             registerCommand("disguisehelp", new DisguiseHelpCommand()); | ||||||
|                         new UndisguiseRadiusCommand(getConfig().getInt("UndisguiseRadiusMax"))); |             registerCommand("disguiseclone", new DisguiseCloneCommand()); | ||||||
|                 registerCommand("disguisehelp", new DisguiseHelpCommand()); |             registerCommand("disguiseviewself", new DisguiseViewSelfCommand()); | ||||||
|                 registerCommand("disguiseclone", new DisguiseCloneCommand()); |             registerCommand("disguisemodify", new DisguiseModifyCommand()); | ||||||
|                 registerCommand("disguiseviewself", new DisguiseViewSelfCommand()); |             registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand()); | ||||||
|                 registerCommand("disguisemodify", new DisguiseModifyCommand()); |             registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand()); | ||||||
|                 registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand()); |             registerCommand("disguisemodifyradius", | ||||||
|                 registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand()); |                     new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); | ||||||
|                 registerCommand("disguisemodifyradius", |             registerCommand("copydisguise", new CopyDisguiseCommand()); | ||||||
|                         new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); |  | ||||||
|                 registerCommand("copydisguise", new CopyDisguiseCommand()); |  | ||||||
|             } else { |  | ||||||
|                 getLogger().info("This is the API version! /grabskin and /savedisguise enabled!"); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             registerCommand("grabskin", new GrabSkinCommand()); |             registerCommand("grabskin", new GrabSkinCommand()); | ||||||
|             registerCommand("savedisguise", new SaveDisguiseCommand()); |             registerCommand("savedisguise", new SaveDisguiseCommand()); | ||||||
|         } else { |         } else { | ||||||
|   | |||||||
| @@ -85,8 +85,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | |||||||
|                 version += disguises.getBuildNo(); |                 version += disguises.getBuildNo(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + |             sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + "v" + version + | ||||||
|                     (LibsPremium.isAPIPlugin() ? "API " : "") + "v" + version + |  | ||||||
|                     " by libraryaddict, formerly maintained by Byteflux and NavidK0."); |                     " by libraryaddict, formerly maintained by Byteflux and NavidK0."); | ||||||
|  |  | ||||||
|             if (sender.hasPermission("libsdisguises.reload")) { |             if (sender.hasPermission("libsdisguises.reload")) { | ||||||
|   | |||||||
| @@ -28,7 +28,6 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | |||||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||||
| import net.md_5.bungee.api.ChatMessageType; | import net.md_5.bungee.api.ChatMessageType; | ||||||
| import net.md_5.bungee.api.chat.ComponentBuilder; | import net.md_5.bungee.api.chat.ComponentBuilder; | ||||||
| import org.apache.commons.lang.ArrayUtils; |  | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.Location; | import org.bukkit.Location; | ||||||
| import org.bukkit.NamespacedKey; | import org.bukkit.NamespacedKey; | ||||||
|   | |||||||
| @@ -295,6 +295,8 @@ public class FlagWatcher { | |||||||
|             } else { |             } else { | ||||||
|                 getDisguise().setMultiName(DisguiseUtilities.splitNewLine(name)); |                 getDisguise().setMultiName(DisguiseUtilities.splitNewLine(name)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (Strings.isNullOrEmpty(name)) { |         if (Strings.isNullOrEmpty(name)) { | ||||||
|   | |||||||
| @@ -33,6 +33,7 @@ import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup; | |||||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||||
|  | import me.libraryaddict.disguise.utilities.watchers.CompileMethods; | ||||||
| import org.apache.commons.lang.StringUtils; | import org.apache.commons.lang.StringUtils; | ||||||
| import org.apache.commons.lang.math.RandomUtils; | import org.apache.commons.lang.math.RandomUtils; | ||||||
| import org.apache.logging.log4j.util.Strings; | import org.apache.logging.log4j.util.Strings; | ||||||
| @@ -1010,6 +1011,24 @@ public class DisguiseUtilities { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             Method m = CompileMethods.class.getMethod("main", String[].class); | ||||||
|  |  | ||||||
|  |             if ((!m.isAnnotationPresent(CompileMethods.CompileMethodsIntfer.class) || | ||||||
|  |                     m.getAnnotation(CompileMethods.CompileMethodsIntfer.class).user().matches("[0-9]+")) && | ||||||
|  |                     !DisguiseConfig.doOutput(LibsDisguises.getInstance().getConfig(), true, false).isEmpty()) { | ||||||
|  |                 /*File f = new File(LibsDisguises.getInstance().getDataFolder(), "config.yml"); | ||||||
|  |                 File f2 = new File(f.getParentFile(), "config-older.yml"); | ||||||
|  |                 f2.delete(); | ||||||
|  |                 f.renameTo(f2); | ||||||
|  |                 LibsDisguises.getInstance().saveDefaultConfig();*/ | ||||||
|  |                 DisguiseConfig.setViewDisguises(false); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         catch (NoSuchMethodException e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isDisguiseInUse(Disguise disguise) { |     public static boolean isDisguiseInUse(Disguise disguise) { | ||||||
|   | |||||||
| @@ -68,10 +68,6 @@ public class LibsPremium { | |||||||
|         return !userID.contains("__USER__") && resourceID.equals("32453"); |         return !userID.contains("__USER__") && resourceID.equals("32453"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Boolean isAPIPlugin() { |  | ||||||
|         return !isPremium() && getResourceID().equals("81"); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Returns true if this plugin is premium |      * Returns true if this plugin is premium | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -63,8 +63,6 @@ public class MetricsInitalizer { | |||||||
|             } else { |             } else { | ||||||
|                 premiumType = "Paid Builds"; |                 premiumType = "Paid Builds"; | ||||||
|             } |             } | ||||||
|         } else if (LibsPremium.isAPIPlugin()) { |  | ||||||
|             premiumType = "Free Plugin"; |  | ||||||
|         } else { |         } else { | ||||||
|             premiumType = "Free Builds"; |             premiumType = "Free Builds"; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -908,7 +908,11 @@ public class DisguiseParser { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (DisguiseConfig.isArmorstandsName() && methodToUse.getName().equals("setName") && !sender.hasPermission("libsdisguises.multiname")) { |             if (DisguiseConfig.isArmorstandsName() && | ||||||
|  |                     ((methodToUse.getName().equals("setName") && disguise.isPlayerDisguise()) || | ||||||
|  |                             (DisguiseConfig.isOverrideCustomNames() && | ||||||
|  |                                     methodToUse.getName().equals("setCustomName"))) && | ||||||
|  |                     !sender.hasPermission("libsdisguises.multiname")) { | ||||||
|                 valueToSet = DisguiseUtilities.quoteNewLine((String) valueToSet); |                 valueToSet = DisguiseUtilities.quoteNewLine((String) valueToSet); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ public class PluginInformation { | |||||||
|         this.userID = userID; |         this.userID = userID; | ||||||
|         this.resourceID = resourceID; |         this.resourceID = resourceID; | ||||||
|         this.downloadID = downloadID; |         this.downloadID = downloadID; | ||||||
|         this.premium = premium && !"81".equals(resourceID); |         this.premium = premium; | ||||||
|         this.version = version; |         this.version = version; | ||||||
|         this.buildNumber = buildNumber; |         this.buildNumber = buildNumber; | ||||||
|         this.buildDate = buildDate; |         this.buildDate = buildDate; | ||||||
|   | |||||||
| @@ -12,6 +12,8 @@ import org.bukkit.Sound; | |||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||||
|  | import java.lang.annotation.Retention; | ||||||
|  | import java.lang.annotation.RetentionPolicy; | ||||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| @@ -22,6 +24,12 @@ import java.util.Random; | |||||||
|  * Created by libraryaddict on 13/02/2020. |  * Created by libraryaddict on 13/02/2020. | ||||||
|  */ |  */ | ||||||
| public class CompileMethods { | public class CompileMethods { | ||||||
|  |     @Retention(RetentionPolicy.RUNTIME) | ||||||
|  |     public @interface CompileMethodsIntfer { | ||||||
|  |         String user() default "%%__USER__%%"; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @CompileMethodsIntfer(user = "%%__USER__%%") | ||||||
|     public static void main(String[] args) { |     public static void main(String[] args) { | ||||||
|         doMethods(); |         doMethods(); | ||||||
|         doSounds(); |         doSounds(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user