Fixed custom name still being set despite being overridden
This commit is contained in:
		| @@ -129,7 +129,6 @@ public class LibsDisguises extends JavaPlugin { | ||||
|         registerCommand("libsdisguises", new LibsDisguisesCommand()); | ||||
|  | ||||
|         if (!DisguiseConfig.isDisableCommands()) { | ||||
|             if (!LibsPremium.isAPIPlugin()) { | ||||
|             registerCommand("disguise", new DisguiseCommand()); | ||||
|             registerCommand("undisguise", new UndisguiseCommand()); | ||||
|             registerCommand("disguiseplayer", new DisguisePlayerCommand()); | ||||
| @@ -137,8 +136,7 @@ public class LibsDisguises extends JavaPlugin { | ||||
|             registerCommand("undisguiseentity", new UndisguiseEntityCommand()); | ||||
|             registerCommand("disguiseentity", new DisguiseEntityCommand()); | ||||
|             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("disguiseclone", new DisguiseCloneCommand()); | ||||
|             registerCommand("disguiseviewself", new DisguiseViewSelfCommand()); | ||||
| @@ -148,10 +146,6 @@ public class LibsDisguises extends JavaPlugin { | ||||
|             registerCommand("disguisemodifyradius", | ||||
|                     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("savedisguise", new SaveDisguiseCommand()); | ||||
|         } else { | ||||
|   | ||||
| @@ -85,8 +85,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | ||||
|                 version += disguises.getBuildNo(); | ||||
|             } | ||||
|  | ||||
|             sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + | ||||
|                     (LibsPremium.isAPIPlugin() ? "API " : "") + "v" + version + | ||||
|             sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + "v" + version + | ||||
|                     " by libraryaddict, formerly maintained by Byteflux and NavidK0."); | ||||
|  | ||||
|             if (sender.hasPermission("libsdisguises.reload")) { | ||||
|   | ||||
| @@ -28,7 +28,6 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import net.md_5.bungee.api.ChatMessageType; | ||||
| import net.md_5.bungee.api.chat.ComponentBuilder; | ||||
| import org.apache.commons.lang.ArrayUtils; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.Location; | ||||
| import org.bukkit.NamespacedKey; | ||||
|   | ||||
| @@ -295,6 +295,8 @@ public class FlagWatcher { | ||||
|             } else { | ||||
|                 getDisguise().setMultiName(DisguiseUtilities.splitNewLine(name)); | ||||
|             } | ||||
|  | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         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.ReflectionManager; | ||||
| 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.math.RandomUtils; | ||||
| 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) { | ||||
|   | ||||
| @@ -68,10 +68,6 @@ public class LibsPremium { | ||||
|         return !userID.contains("__USER__") && resourceID.equals("32453"); | ||||
|     } | ||||
|  | ||||
|     public static Boolean isAPIPlugin() { | ||||
|         return !isPremium() && getResourceID().equals("81"); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns true if this plugin is premium | ||||
|      */ | ||||
|   | ||||
| @@ -63,8 +63,6 @@ public class MetricsInitalizer { | ||||
|             } else { | ||||
|                 premiumType = "Paid Builds"; | ||||
|             } | ||||
|         } else if (LibsPremium.isAPIPlugin()) { | ||||
|             premiumType = "Free Plugin"; | ||||
|         } else { | ||||
|             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); | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -25,7 +25,7 @@ public class PluginInformation { | ||||
|         this.userID = userID; | ||||
|         this.resourceID = resourceID; | ||||
|         this.downloadID = downloadID; | ||||
|         this.premium = premium && !"81".equals(resourceID); | ||||
|         this.premium = premium; | ||||
|         this.version = version; | ||||
|         this.buildNumber = buildNumber; | ||||
|         this.buildDate = buildDate; | ||||
|   | ||||
| @@ -12,6 +12,8 @@ import org.bukkit.Sound; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.PrintWriter; | ||||
| import java.lang.annotation.Retention; | ||||
| import java.lang.annotation.RetentionPolicy; | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| @@ -22,6 +24,12 @@ import java.util.Random; | ||||
|  * Created by libraryaddict on 13/02/2020. | ||||
|  */ | ||||
| public class CompileMethods { | ||||
|     @Retention(RetentionPolicy.RUNTIME) | ||||
|     public @interface CompileMethodsIntfer { | ||||
|         String user() default "%%__USER__%%"; | ||||
|     } | ||||
|  | ||||
|     @CompileMethodsIntfer(user = "%%__USER__%%") | ||||
|     public static void main(String[] args) { | ||||
|         doMethods(); | ||||
|         doSounds(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user