Fix imports, run code formatter
This commit is contained in:
		| @@ -3,13 +3,6 @@ package me.libraryaddict.disguise; | ||||
| import com.comphenix.protocol.wrappers.WrappedDataWatcher; | ||||
| import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||||
| import com.comphenix.protocol.wrappers.WrappedWatchableObject; | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||
| @@ -36,6 +29,14 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.inventory.EntityEquipment; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| public class DisguiseAPI { | ||||
|     private static int selfDisguiseId; | ||||
|     private static int entityAttachmentId; | ||||
|   | ||||
| @@ -1,17 +1,5 @@ | ||||
| package me.libraryaddict.disguise; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | ||||
| import java.io.PrintWriter; | ||||
| import java.io.UnsupportedEncodingException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Locale; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.Random; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import lombok.AccessLevel; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| @@ -41,6 +29,19 @@ import org.bukkit.permissions.Permission; | ||||
| import org.bukkit.permissions.PermissionDefault; | ||||
| import org.bukkit.scheduler.BukkitTask; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | ||||
| import java.io.PrintWriter; | ||||
| import java.io.UnsupportedEncodingException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Locale; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.Random; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| public class DisguiseConfig { | ||||
|     @Getter | ||||
|     @Setter | ||||
| @@ -323,7 +324,7 @@ public class DisguiseConfig { | ||||
|  | ||||
|     private static void doUpdaterTask() { | ||||
|         boolean startTask = isAutoUpdate() || isNotifyUpdate() || | ||||
|                 "1592".equals((LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() : LibsPremium.getPaidInformation()).getUserID()); | ||||
|             "1592".equals((LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() : LibsPremium.getPaidInformation()).getUserID()); | ||||
|  | ||||
|         // Don't ever run the auto updater on a custom build.. | ||||
|         if (!LibsDisguises.getInstance().isNumberedBuild()) { | ||||
| @@ -415,7 +416,7 @@ public class DisguiseConfig { | ||||
|  | ||||
|         // Bisect hosted, server ip, release builds | ||||
|         for (Object s : new Object[]{isBisectHosted(), getSavedServerIp(), isUsingReleaseBuild(), getLastUpdateRequest(), isHittingRateLimit(), | ||||
|                 getLastGithubUpdateETag(), getLastPluginUpdateVersion(), getData()}) { | ||||
|             getLastGithubUpdateETag(), getLastPluginUpdateVersion(), getData()}) { | ||||
|             internalConfig = internalConfig.replaceFirst("%data%", "" + s); | ||||
|         } | ||||
|  | ||||
| @@ -668,7 +669,7 @@ public class DisguiseConfig { | ||||
|  | ||||
|             if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) { | ||||
|                 DisguiseUtilities.getLogger() | ||||
|                         .warning("BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + "ACTION_BAR"); | ||||
|                     .warning("BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + "ACTION_BAR"); | ||||
|  | ||||
|                 setNotifyBar(NotifyBar.ACTION_BAR); | ||||
|             } | ||||
| @@ -695,11 +696,11 @@ public class DisguiseConfig { | ||||
|         } | ||||
|  | ||||
|         String seeCommands = config.getString("Permissions.SeeCommands"); | ||||
|         PermissionDefault commandVisibility =  seeCommands == null ? null : PermissionDefault.getByName(seeCommands); | ||||
|         PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands); | ||||
|  | ||||
|         if (commandVisibility == null) { | ||||
|             DisguiseUtilities.getLogger() | ||||
|                     .warning("Invalid option '" + config.getString("Permissions.SeeCommands") + "' for Permissions.SeeCommands when loading config!"); | ||||
|                 .warning("Invalid option '" + config.getString("Permissions.SeeCommands") + "' for Permissions.SeeCommands when loading config!"); | ||||
|         } else { | ||||
|             setCommandVisibility(commandVisibility); | ||||
|         } | ||||
| @@ -738,8 +739,9 @@ public class DisguiseConfig { | ||||
|             ArrayList<String> returns = doOutput(config, changed, verbose); | ||||
|  | ||||
|             if (!returns.isEmpty()) { | ||||
|                 DisguiseUtilities.getLogger().info("This is not an error! Now outputting " + (verbose ? "missing " : "") + | ||||
|                         (changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values"); | ||||
|                 DisguiseUtilities.getLogger().info( | ||||
|                     "This is not an error! Now outputting " + (verbose ? "missing " : "") + (changed ? (verbose ? "and " : "") + "changed/invalid " : "") + | ||||
|                         "config values"); | ||||
|  | ||||
|                 for (String v : returns) { | ||||
|                     DisguiseUtilities.getLogger().info(v); | ||||
| @@ -829,8 +831,8 @@ public class DisguiseConfig { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 ModdedManager | ||||
|                         .registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity, register); | ||||
|                 ModdedManager.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity, | ||||
|                     register); | ||||
|  | ||||
|                 DisguiseUtilities.getLogger().info("Modded entity " + name + " has been " + (register ? "registered" : "added")); | ||||
|             } catch (Exception ex) { | ||||
| @@ -918,7 +920,7 @@ public class DisguiseConfig { | ||||
|  | ||||
|             if (!NmsVersion.v1_13.isSupported() && key.equals("libraryaddict")) { | ||||
|                 toParse = | ||||
|                         toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET", "GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET"); | ||||
|                     toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET", "GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET"); | ||||
|             } | ||||
|  | ||||
|             try { | ||||
| @@ -960,7 +962,7 @@ public class DisguiseConfig { | ||||
|             String[] disguiseArgs = DisguiseUtilities.split(toParse); | ||||
|  | ||||
|             Disguise disguise = DisguiseParser.parseTestDisguise(Bukkit.getConsoleSender(), "disguise", disguiseArgs, | ||||
|                     DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise")); | ||||
|                 DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise")); | ||||
|  | ||||
|             DisguisePerm perm = new DisguisePerm(disguise.getType(), disguiseName); | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,5 @@ | ||||
| package me.libraryaddict.disguise; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.util.Arrays; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.commands.LibsDisguisesCommand; | ||||
| import me.libraryaddict.disguise.commands.disguise.DisguiseCommand; | ||||
| @@ -53,6 +48,12 @@ import org.bukkit.plugin.Plugin; | ||||
| import org.bukkit.plugin.java.JavaPlugin; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.util.Arrays; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| public class LibsDisguises extends JavaPlugin { | ||||
|     private static LibsDisguises instance; | ||||
|     private DisguiseListener listener; | ||||
| @@ -94,8 +95,8 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                     } | ||||
|                 } catch (Exception e) { | ||||
|                     getLogger().severe( | ||||
|                             "Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + | ||||
|                                     " can " + "join. Check the pins in #libs-support for a ProtocolLib.jar you can download!"); | ||||
|                         "Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + " can " + | ||||
|                             "join. Check the pins in #libs-support for a ProtocolLib.jar you can download!"); | ||||
|                     e.printStackTrace(); | ||||
|                 } | ||||
|  | ||||
| @@ -105,7 +106,7 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                 Class cl = Class.forName("org.bukkit.Server$Spigot"); | ||||
|             } catch (ClassNotFoundException e) { | ||||
|                 getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " + | ||||
|                         "plugin will continue to load, but it will look like a mugging victim"); | ||||
|                     "plugin will continue to load, but it will look like a mugging victim"); | ||||
|             } | ||||
|  | ||||
|             commandConfig = new DisguiseCommandConfig(); | ||||
| @@ -141,7 +142,7 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                 Class cl = Class.forName("org.bukkit.Server$Spigot"); | ||||
|             } catch (ClassNotFoundException e) { | ||||
|                 getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " + | ||||
|                         "plugin will continue to load, but it will look like a mugging victim"); | ||||
|                     "plugin will continue to load, but it will look like a mugging victim"); | ||||
|             } | ||||
|  | ||||
|             File disguiseFile = new File(getDataFolder(), "configs/disguises.yml"); | ||||
| @@ -175,12 +176,12 @@ public class LibsDisguises extends JavaPlugin { | ||||
|  | ||||
|             if (!LibsPremium.isPremium()) { | ||||
|                 getLogger().info( | ||||
|                         "You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)"); | ||||
|                     "You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)"); | ||||
|             } | ||||
|  | ||||
|             if (ReflectionManager.getVersion() == null) { | ||||
|                 getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " + "intended for " + | ||||
|                         StringUtils.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", ".")).collect(Collectors.toList()), " & ") + "!"); | ||||
|                     StringUtils.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", ".")).collect(Collectors.toList()), " & ") + "!"); | ||||
|                 getPluginLoader().disablePlugin(this); | ||||
|                 return; | ||||
|             } | ||||
| @@ -196,8 +197,8 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                     public void run() { | ||||
|                         getLogger().severe("!! May I have your attention please !!"); | ||||
|                         getLogger().severe( | ||||
|                                 "Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib + | ||||
|                                         "!"); | ||||
|                             "Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib + | ||||
|                                 "!"); | ||||
|                         getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar"); | ||||
|                         getLogger().severe("Or! Use /ld protocollib - To update to the latest development build"); | ||||
|  | ||||
|   | ||||
| @@ -3,16 +3,6 @@ package me.libraryaddict.disguise.commands; | ||||
| import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.google.common.cache.Cache; | ||||
| import com.google.common.cache.CacheBuilder; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.commands.disguise.DisguiseCommand; | ||||
| import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand; | ||||
| @@ -40,6 +30,17 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| /** | ||||
|  * @author libraryaddict | ||||
|  */ | ||||
| @@ -85,9 +86,9 @@ public abstract class DisguiseBaseCommand implements CommandExecutor { | ||||
|         } | ||||
|  | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and " + | ||||
|                     "Operators only! Purchase the plugin for non-admin usage!"); | ||||
|                 "Operators only! Purchase the plugin for non-admin usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.commands.libsdisguises.LDChangelog; | ||||
| @@ -30,6 +26,11 @@ import org.bukkit.command.CommandExecutor; | ||||
| import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.command.TabCompleter; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
|  | ||||
| public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | ||||
|     @Getter | ||||
|     private final ArrayList<LDCommand> commands = new ArrayList<>(); | ||||
| @@ -53,8 +54,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | ||||
|     } | ||||
|  | ||||
|     protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) { | ||||
|         if (origArgs.length == 0) | ||||
|         if (origArgs.length == 0) { | ||||
|             return list; | ||||
|         } | ||||
|  | ||||
|         Iterator<String> itel = list.iterator(); | ||||
|         String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH); | ||||
| @@ -62,8 +64,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | ||||
|         while (itel.hasNext()) { | ||||
|             String name = itel.next(); | ||||
|  | ||||
|             if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) | ||||
|             if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             itel.remove(); | ||||
|         } | ||||
| @@ -77,8 +80,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | ||||
|         for (int i = 0; i < args.length - 1; i++) { | ||||
|             String s = args[i]; | ||||
|  | ||||
|             if (s.trim().isEmpty()) | ||||
|             if (s.trim().isEmpty()) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             newArgs.add(s); | ||||
|         } | ||||
| @@ -104,12 +108,11 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | ||||
|             } | ||||
|  | ||||
|             sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + "v" + version + | ||||
|                     " by libraryaddict, formerly maintained by Byteflux and NavidK0."); | ||||
|                 " by libraryaddict, formerly maintained by Byteflux and NavidK0."); | ||||
|  | ||||
|             if (sender.hasPermission("libsdisguises.reload")) { | ||||
|                 sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + | ||||
|                         ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" + | ||||
|                         "."); | ||||
|                 sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN + | ||||
|                     " to reload the config. All disguises will be blown by doing this" + "."); | ||||
|                 sender.sendMessage(ChatColor.DARK_GREEN + "Use /libsdisguises help to see more help"); | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.disguise; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -19,6 +17,9 @@ import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
| @@ -43,8 +44,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter | ||||
|         Disguise disguise; | ||||
|  | ||||
|         try { | ||||
|             disguise = DisguiseParser | ||||
|                     .parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender)); | ||||
|             disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")), | ||||
|                 getPermissions(sender)); | ||||
|         } catch (DisguiseParseException ex) { | ||||
|             ex.send(sender); | ||||
|  | ||||
| @@ -68,7 +69,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter | ||||
|  | ||||
|         if (!setViewDisguise(args)) { | ||||
|             // They prefer to have the opposite of whatever the view disguises option is | ||||
|             if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) { | ||||
|             if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && | ||||
|                 disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) { | ||||
|                 disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible()); | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.disguise; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -18,6 +16,9 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
| @@ -59,7 +60,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | ||||
|         } | ||||
|  | ||||
|         LibsDisguises.getInstance().getListener() | ||||
|                 .addInteraction(sender.getName(), new DisguiseEntityInteraction(disguiseArgs), DisguiseConfig.getDisguiseEntityExpire()); | ||||
|             .addInteraction(sender.getName(), new DisguiseEntityInteraction(disguiseArgs), DisguiseConfig.getDisguiseEntityExpire()); | ||||
|  | ||||
|         LibsMsg.DISG_ENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getDisguiseName()); | ||||
|         return true; | ||||
|   | ||||
| @@ -1,8 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.disguise; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -22,6 +19,10 @@ import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|  | ||||
|     @Override | ||||
| @@ -106,7 +107,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | ||||
|  | ||||
|         if (!setViewDisguise(args)) { | ||||
|             // They prefer to have the opposite of whatever the view disguises option is | ||||
|             if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) { | ||||
|             if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && | ||||
|                 disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) { | ||||
|                 disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible()); | ||||
|             } | ||||
|         } | ||||
| @@ -119,11 +121,10 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | ||||
|  | ||||
|         if (disguise.isDisguiseInUse()) { | ||||
|             LibsMsg.DISG_PLAYER_AS_DISG.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(), | ||||
|                     disguise.getDisguiseName()); | ||||
|                 disguise.getDisguiseName()); | ||||
|         } else { | ||||
|             LibsMsg.DISG_PLAYER_AS_DISG_FAIL | ||||
|                     .send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(), | ||||
|                             disguise.getDisguiseName()); | ||||
|             LibsMsg.DISG_PLAYER_AS_DISG_FAIL.send(sender, | ||||
|                 entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName()); | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|   | ||||
| @@ -1,9 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.disguise; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -27,6 +23,11 @@ import org.bukkit.entity.EntityType; | ||||
| import org.bukkit.entity.LivingEntity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
|  | ||||
| public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|     private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>(); | ||||
|  | ||||
| @@ -188,7 +189,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | ||||
|  | ||||
|                 if (!setViewDisguise(args)) { | ||||
|                     // They prefer to have the opposite of whatever the view disguises option is | ||||
|                     if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) { | ||||
|                     if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && | ||||
|                         disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) { | ||||
|                         disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible()); | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -26,13 +26,11 @@ public class CopyDisguiseInteraction implements LibsEntityInteract { | ||||
|             Disguise disguise = DisguiseAPI.getDisguise(player, entity); | ||||
|             String disguiseString = DisguiseParser.parseToString(disguise, false); | ||||
|  | ||||
|             getCopyDisguiseCommand() | ||||
|                     .sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false); | ||||
|             getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false); | ||||
|  | ||||
|             if (disguise instanceof PlayerDisguise) { | ||||
|                 getCopyDisguiseCommand() | ||||
|                         .sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY, | ||||
|                                 DisguiseParser.parseToString(disguise), true); | ||||
|                 getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY, | ||||
|                     DisguiseParser.parseToString(disguise), true); | ||||
|             } | ||||
|         } else { | ||||
|             LibsMsg.TARGET_NOT_DISGUISED.send(player); | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.interactions; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import lombok.AllArgsConstructor; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| @@ -15,6 +13,9 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 4/04/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -24,15 +24,17 @@ public class UndisguiseEntityInteraction implements LibsEntityInteract { | ||||
|         if (DisguiseAPI.isDisguised(entity)) { | ||||
|             DisguiseAPI.undisguiseToAll(p, entity); | ||||
|  | ||||
|             if (entity instanceof Player) | ||||
|             if (entity instanceof Player) { | ||||
|                 LibsMsg.LISTEN_UNDISG_PLAYER.send(p, entityName); | ||||
|             else | ||||
|             } else { | ||||
|                 LibsMsg.LISTEN_UNDISG_ENT.send(p, entityName); | ||||
|             } | ||||
|         } else { | ||||
|             if (entity instanceof Player) | ||||
|             if (entity instanceof Player) { | ||||
|                 LibsMsg.LISTEN_UNDISG_PLAYER_FAIL.send(p, entityName); | ||||
|             else | ||||
|             } else { | ||||
|                 LibsMsg.LISTEN_UNDISG_ENT_FAIL.send(p, entityName); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,13 +1,14 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import me.libraryaddict.disguise.utilities.updates.UpdateChecker; | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 27/04/2020. | ||||
|  */ | ||||
| @@ -43,8 +44,7 @@ public class LDChangelog implements LDCommand { | ||||
|  | ||||
|         if (!checker.getUpdate().isReleaseBuild()) { | ||||
|             sender.sendMessage( | ||||
|                     ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + | ||||
|                             LibsDisguises.getInstance().getBuildNo()); | ||||
|                 ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + LibsDisguises.getInstance().getBuildNo()); | ||||
|         } | ||||
|  | ||||
|         for (String msg : checker.getUpdate().getChangelog()) { | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -1,13 +1,14 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -1,10 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; | ||||
| @@ -13,6 +8,12 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import me.libraryaddict.disguise.utilities.translations.TranslateType; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
| @@ -40,18 +41,16 @@ public class LDCount implements LDCommand { | ||||
|         if (counts.isEmpty()) { | ||||
|             LibsMsg.NO_DISGUISES_IN_USE.send(sender); | ||||
|         } else { | ||||
|             LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender, | ||||
|                     counts.values().stream().reduce(Integer::sum).get()); | ||||
|             LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender, counts.values().stream().reduce(Integer::sum).get()); | ||||
|  | ||||
|             ArrayList<DisguiseType> types = new ArrayList<>(counts.keySet()); | ||||
|             types.sort((d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()), | ||||
|                     TranslateType.DISGUISES.get(d2.toReadable()))); | ||||
|             types.sort( | ||||
|                 (d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()), TranslateType.DISGUISES.get(d2.toReadable()))); | ||||
|  | ||||
|             StringBuilder builder = new StringBuilder(); | ||||
|  | ||||
|             for (int i = 0; i < types.size(); i++) { | ||||
|                 builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE | ||||
|                         .get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i)))); | ||||
|                 builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i)))); | ||||
|  | ||||
|                 if (i + 1 < types.size()) { | ||||
|                     builder.append(LibsMsg.ACTIVE_DISGUISES_SEPERATOR.get()); | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.mineskin.MineSkinAPI; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 22/05/2021. | ||||
|  */ | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import com.google.gson.Gson; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| @@ -18,6 +16,9 @@ import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.scoreboard.Team; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 24/04/2020. | ||||
|  */ | ||||
| @@ -49,18 +50,14 @@ public class LDDebugPlayer implements LDCommand { | ||||
|             DisguiseUtilities.DScoreTeam name = disg.getScoreboardName(); | ||||
|  | ||||
|             player.sendMessage(ChatColor.RED + | ||||
|                     String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'", | ||||
|                             name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'), | ||||
|                             name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'), | ||||
|                             name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName())); | ||||
|                 String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'", name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'), | ||||
|                     name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'), name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName())); | ||||
|  | ||||
|             if (DisguiseConfig.isArmorstandsName()) { | ||||
|                 player.sendMessage( | ||||
|                         ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too.."); | ||||
|                 player.sendMessage(ChatColor.RED + String.format("Names: %s, Length: %s, Custom Name: '%s'", | ||||
|                         new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'), | ||||
|                         disg.getMultiNameLength(), | ||||
|                         disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&'))); | ||||
|                 player.sendMessage(ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too.."); | ||||
|                 player.sendMessage(ChatColor.RED + | ||||
|                     String.format("Names: %s, Length: %s, Custom Name: '%s'", new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'), | ||||
|                         disg.getMultiNameLength(), disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&'))); | ||||
|             } | ||||
|  | ||||
|             Team team = player.getScoreboard().getTeam(name.getTeamName()); | ||||
| @@ -75,9 +72,8 @@ public class LDDebugPlayer implements LDCommand { | ||||
|             } | ||||
|  | ||||
|             player.sendMessage(ChatColor.RED + | ||||
|                     String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s", | ||||
|                             team.getPrefix().equals(name.getPrefix()), team.getSuffix().equals(name.getSuffix()), | ||||
|                             team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY))); | ||||
|                 String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s", team.getPrefix().equals(name.getPrefix()), | ||||
|                     team.getSuffix().equals(name.getSuffix()), team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY))); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,13 +1,14 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.commands.LibsDisguisesCommand; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 22/04/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -1,9 +1,6 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.nbt.NbtFactory; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.params.ParamInfoManager; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| @@ -17,6 +14,10 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
| @@ -114,8 +115,7 @@ public class LDJson implements LDCommand { | ||||
|  | ||||
|             builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub)); | ||||
|             builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, | ||||
|                     new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg)) | ||||
|                             .create())); | ||||
|                 new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg)).create())); | ||||
|             msg += 1; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import net.md_5.bungee.api.chat.ClickEvent; | ||||
| @@ -12,6 +8,11 @@ import net.md_5.bungee.api.chat.HoverEvent; | ||||
| import net.md_5.bungee.api.chat.TextComponent; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
| @@ -46,24 +47,24 @@ public class LDMetaInfo implements LDCommand { | ||||
|  | ||||
|             names.sort(String::compareToIgnoreCase); | ||||
|  | ||||
|            // if (NmsVersion.v1_13.isSupported()) { | ||||
|                 ComponentBuilder builder = new ComponentBuilder("").append(LibsMsg.META_VALUES.getBase()); | ||||
|             // if (NmsVersion.v1_13.isSupported()) { | ||||
|             ComponentBuilder builder = new ComponentBuilder("").append(LibsMsg.META_VALUES.getBase()); | ||||
|  | ||||
|                 Iterator<String> itel = names.iterator(); | ||||
|             Iterator<String> itel = names.iterator(); | ||||
|  | ||||
|                 while (itel.hasNext()) { | ||||
|                     String name = itel.next(); | ||||
|             while (itel.hasNext()) { | ||||
|                 String name = itel.next(); | ||||
|  | ||||
|                     builder.append(TextComponent.fromLegacyText(name)); | ||||
|                     builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name)); | ||||
|                     builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.META_CLICK_SHOW.getBase(name))); | ||||
|                 builder.append(TextComponent.fromLegacyText(name)); | ||||
|                 builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name)); | ||||
|                 builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.META_CLICK_SHOW.getBase(name))); | ||||
|  | ||||
|                     if (itel.hasNext()) { | ||||
|                         builder.append(LibsMsg.META_VALUE_SEPERATOR.getBase()); | ||||
|                     } | ||||
|                 if (itel.hasNext()) { | ||||
|                     builder.append(LibsMsg.META_VALUE_SEPERATOR.getBase()); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|                 sender.spigot().sendMessage(builder.create()); | ||||
|             sender.spigot().sendMessage(builder.create()); | ||||
|             /*} else { | ||||
|                 LibsMsg.META_VALUES_NO_CLICK.send(sender, | ||||
|                         StringUtils.join(names, LibsMsg.META_VALUE_SEPERATOR.get())); | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.utilities.modded.ModdedManager; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| @@ -9,6 +7,9 @@ import org.bukkit.Bukkit; | ||||
| import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
| @@ -51,8 +52,7 @@ public class LDMods implements LDCommand { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         LibsMsg.MODS_LIST.send(sender, player.getName(), | ||||
|                 StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", ")); | ||||
|         LibsMsg.MODS_LIST.send(sender, player.getName(), StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", ")); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | ||||
| @@ -13,6 +11,9 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.command.PluginCommand; | ||||
| import org.bukkit.permissions.Permissible; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
| @@ -65,8 +66,7 @@ public class LDPermTest implements LDCommand { | ||||
|             LibsMsg.NORMAL_PERM_CHECK_FAIL.send(sender); | ||||
|         } | ||||
|  | ||||
|         if (player.hasPermission("libsdisguises.disguise.zombie") || | ||||
|                 permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) { | ||||
|         if (player.hasPermission("libsdisguises.disguise.zombie") || permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) { | ||||
|             LibsMsg.LIBS_PERM_CHECK_ZOMBIE_PERMISSIONS.send(sender); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.utilities.sounds.SoundManager; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.command.CommandSender; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -3,11 +3,6 @@ package me.libraryaddict.disguise.commands.libsdisguises; | ||||
| import com.comphenix.protocol.PacketType; | ||||
| import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.comphenix.protocol.events.PacketListener; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
| import java.util.stream.Collectors; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| @@ -27,6 +22,12 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.scoreboard.Scoreboard; | ||||
| import org.bukkit.scoreboard.Team; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
| @@ -56,7 +57,7 @@ public class LDScoreboard implements LDCommand { | ||||
|                     if (!((PlayerDisguise) disguise).hasScoreboardName()) { | ||||
|                         if (unexpected++ < 3) { | ||||
|                             sender.sendMessage( | ||||
|                                     "The player disguise " + ((PlayerDisguise) disguise).getName() + " isn't using a scoreboard name? This is unexpected"); | ||||
|                                 "The player disguise " + ((PlayerDisguise) disguise).getName() + " isn't using a scoreboard name? This is unexpected"); | ||||
|                         } | ||||
|                         continue; | ||||
|                     } | ||||
| @@ -78,28 +79,27 @@ public class LDScoreboard implements LDCommand { | ||||
|  | ||||
|                         checked.add(board); | ||||
|  | ||||
|  | ||||
|                         Team team = board.getTeam(scoreboardName.getTeamName()); | ||||
|  | ||||
|                         if (team == null) { | ||||
|                             if (issuesFound++ < 5) { | ||||
|                                 sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') + | ||||
|                                         " is missing a scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() + | ||||
|                                         " and possibly more players!"); | ||||
|                                     " is missing a scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() + | ||||
|                                     " and possibly more players!"); | ||||
|                             } | ||||
|  | ||||
|                             continue; | ||||
|                         } | ||||
|  | ||||
|                         if (!team.getPrefix().equals("Colorize") && | ||||
|                                 (!team.getPrefix().equals(scoreboardName.getPrefix()) || !team.getSuffix().equals(scoreboardName.getSuffix()))) { | ||||
|                             (!team.getPrefix().equals(scoreboardName.getPrefix()) || !team.getSuffix().equals(scoreboardName.getSuffix()))) { | ||||
|                             if (issuesFound++ < 5) { | ||||
|                                 sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') + | ||||
|                                         " on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() + | ||||
|                                         " has an unexpected prefix/suffix of '" + team.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" + | ||||
|                                         team.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'! Expected '" + | ||||
|                                         scoreboardName.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" + | ||||
|                                         scoreboardName.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'"); | ||||
|                                     " on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() + | ||||
|                                     " has an unexpected prefix/suffix of '" + team.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" + | ||||
|                                     team.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'! Expected '" + | ||||
|                                     scoreboardName.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" + | ||||
|                                     scoreboardName.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'"); | ||||
|                             } | ||||
|                             continue; | ||||
|                         } | ||||
| @@ -107,9 +107,9 @@ public class LDScoreboard implements LDCommand { | ||||
|                         if (!team.hasEntry(scoreboardName.getPlayer())) { | ||||
|                             if (issuesFound++ < 5) { | ||||
|                                 sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') + | ||||
|                                         " on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() + | ||||
|                                         " does not have the player entry expected! Instead has '" + | ||||
|                                         StringUtils.join(team.getEntries(), ", ").replace(ChatColor.COLOR_CHAR, '&') + "'"); | ||||
|                                     " on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() + | ||||
|                                     " does not have the player entry expected! Instead has '" + | ||||
|                                     StringUtils.join(team.getEntries(), ", ").replace(ChatColor.COLOR_CHAR, '&') + "'"); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
| @@ -125,9 +125,9 @@ public class LDScoreboard implements LDCommand { | ||||
|             LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.send(sender); | ||||
|         } | ||||
|  | ||||
|         List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream() | ||||
|                 .filter(listener -> listener.getPlugin() != LibsDisguises.getInstance() && | ||||
|                         listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList()); | ||||
|         List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream().filter( | ||||
|             listener -> listener.getPlugin() != LibsDisguises.getInstance() && | ||||
|                 listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList()); | ||||
|  | ||||
|         if (!listeners.isEmpty()) { | ||||
|             ComponentBuilder builder = new ComponentBuilder(""); | ||||
| @@ -149,15 +149,15 @@ public class LDScoreboard implements LDCommand { | ||||
|                 builder.append(listener.getPlugin().getName()); | ||||
|                 builder.color(net.md_5.bungee.api.ChatColor.AQUA); | ||||
|  | ||||
|                 String plugin = ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" + | ||||
|                         listener.getPlugin().getDescription().getVersion(); | ||||
|                 String plugin = | ||||
|                     ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" + listener.getPlugin().getDescription().getVersion(); | ||||
|                 String listenerClass = ChatColor.GOLD + "Listener: " + ChatColor.YELLOW + listener.getClass().toString(); | ||||
|                 String packets = ChatColor.GOLD + "Packets: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getTypes(), ", "); | ||||
|                 String priority = ChatColor.GOLD + "Priority: " + ChatColor.YELLOW + listener.getSendingWhitelist().getPriority(); | ||||
|                 String options = ChatColor.GOLD + "Options: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getOptions(), ", "); | ||||
|  | ||||
|                 builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, | ||||
|                         TextComponent.fromLegacyText(plugin + "\n" + listenerClass + "\n" + packets + "\n" + priority + "\n" + options))); | ||||
|                     TextComponent.fromLegacyText(plugin + "\n" + listenerClass + "\n" + packets + "\n" + priority + "\n" + options))); | ||||
|             } | ||||
|  | ||||
|             sender.spigot().sendMessage(builder.create()); | ||||
| @@ -165,8 +165,8 @@ public class LDScoreboard implements LDCommand { | ||||
|  | ||||
|         LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.send(sender); | ||||
|  | ||||
|         sender.sendMessage(ChatColor.RED + | ||||
|                 "This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players"); | ||||
|         sender.sendMessage( | ||||
|             ChatColor.RED + "This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players"); | ||||
|  | ||||
|         Player player; | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| @@ -12,6 +10,9 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/04/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -1,9 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.atomic.AtomicBoolean; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| @@ -11,6 +7,11 @@ import org.bukkit.ChatColor; | ||||
| import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.atomic.AtomicBoolean; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 30/06/2020. | ||||
|  */ | ||||
| @@ -62,8 +63,8 @@ public class LDUpdateProtocolLib implements LDCommand { | ||||
|                         @Override | ||||
|                         public void run() { | ||||
|                             sender.sendMessage(ChatColor.RED + | ||||
|                                     "Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + | ||||
|                                     " can join. Check the pins in #libs-support for a ProtocolLib.jar you can download!"); | ||||
|                                 "Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + | ||||
|                                 " can join. Check the pins in #libs-support for a ProtocolLib.jar you can download!"); | ||||
|                             sender.sendMessage(ChatColor.RED + "Update failed, " + ex.getMessage()); | ||||
|                         } | ||||
|                     }.runTask(LibsDisguises.getInstance()); | ||||
|   | ||||
| @@ -1,5 +1,18 @@ | ||||
| package me.libraryaddict.disguise.commands.libsdisguises; | ||||
|  | ||||
| import javax.net.ssl.HttpsURLConnection; | ||||
| import lombok.Data; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.config.ConfigLoader; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import net.md_5.bungee.api.chat.ClickEvent; | ||||
| import net.md_5.bungee.api.chat.ComponentBuilder; | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.io.BufferedReader; | ||||
| import java.io.DataOutputStream; | ||||
| import java.io.File; | ||||
| @@ -15,18 +28,6 @@ import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.stream.Collectors; | ||||
| import javax.net.ssl.HttpsURLConnection; | ||||
| import lombok.Data; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.config.ConfigLoader; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import net.md_5.bungee.api.chat.ClickEvent; | ||||
| import net.md_5.bungee.api.chat.ComponentBuilder; | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 18/06/2020. | ||||
| @@ -133,7 +134,7 @@ public class LDUploadLogs implements LDCommand { | ||||
|         File disguises = new File(LibsDisguises.getInstance().getDataFolder(), "configs/disguises.yml"); | ||||
|  | ||||
|         List<File> configs = | ||||
|                 new ConfigLoader().getConfigs().stream().map(f -> new File(LibsDisguises.getInstance().getDataFolder(), f)).collect(Collectors.toList()); | ||||
|             new ConfigLoader().getConfigs().stream().map(f -> new File(LibsDisguises.getInstance().getDataFolder(), f)).collect(Collectors.toList()); | ||||
|  | ||||
|         StringBuilder configText = new StringBuilder(); | ||||
|  | ||||
| @@ -154,13 +155,13 @@ public class LDUploadLogs implements LDCommand { | ||||
|  | ||||
|         if (isTooBig(latest)) { | ||||
|             sender.sendMessage( | ||||
|                     ChatColor.RED + "Your latest.log file is too big! It should be less than 512kb! Please restart and run this " + "command again!"); | ||||
|                 ChatColor.RED + "Your latest.log file is too big! It should be less than 512kb! Please restart and run this " + "command again!"); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         if (isTooBig(disguises)) { | ||||
|             sender.sendMessage(ChatColor.RED + "Your disguises.yml is too big! You'll need to trim that file down before using this command! It " + | ||||
|                     "should be less than 512kb!"); | ||||
|                 "should be less than 512kb!"); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| @@ -230,8 +231,8 @@ public class LDUploadLogs implements LDCommand { | ||||
|                                     sender.sendMessage(ChatColor.GOLD + "Click on the below message to have it appear in your chat input"); | ||||
|                                 } | ||||
|  | ||||
|                                 String text = "My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " + | ||||
|                                         disguisesPaste; | ||||
|                                 String text = | ||||
|                                     "My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " + disguisesPaste; | ||||
|  | ||||
|                                 ComponentBuilder builder = new ComponentBuilder(""); | ||||
|                                 builder.append(text); | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.modify; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| @@ -18,6 +16,9 @@ import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
| @@ -57,15 +58,12 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | ||||
|         options = DisguiseParser.parsePlaceholders(options, sender, sender); | ||||
|  | ||||
|         try { | ||||
|             DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, | ||||
|                     "DisguiseModify"); | ||||
|         } | ||||
|         catch (DisguiseParseException ex) { | ||||
|             DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModify"); | ||||
|         } catch (DisguiseParseException ex) { | ||||
|             ex.send(sender); | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|         catch (Throwable ex) { | ||||
|         } catch (Throwable ex) { | ||||
|             ex.printStackTrace(); | ||||
|             return true; | ||||
|         } | ||||
| @@ -77,13 +75,15 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | ||||
|  | ||||
|     @Override | ||||
|     public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) { | ||||
|         if (!(sender instanceof Player)) | ||||
|         if (!(sender instanceof Player)) { | ||||
|             return new ArrayList<>(); | ||||
|         } | ||||
|  | ||||
|         Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender); | ||||
|  | ||||
|         if (disguise == null) | ||||
|         if (disguise == null) { | ||||
|             return new ArrayList<>(); | ||||
|         } | ||||
|  | ||||
|         String[] args = getPreviousArgs(origArgs); | ||||
|  | ||||
| @@ -105,7 +105,6 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | ||||
|  | ||||
|         LibsMsg.DMODIFY_HELP1.send(sender); | ||||
|         LibsMsg.DMODIFY_HELP2.send(sender); | ||||
|         LibsMsg.DMODIFY_HELP3.send(sender, | ||||
|                 StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())); | ||||
|         LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.modify; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -16,6 +14,9 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|  | ||||
|     @Override | ||||
| @@ -39,8 +40,8 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements | ||||
|  | ||||
|         // TODO Validate if any disguises have this arg | ||||
|  | ||||
|         LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), | ||||
|                 new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))), | ||||
|         LibsDisguises.getInstance().getListener() | ||||
|             .addInteraction(sender.getName(), new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))), | ||||
|                 DisguiseConfig.getDisguiseEntityExpire()); | ||||
|  | ||||
|         LibsMsg.DMODIFYENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire()); | ||||
| @@ -78,7 +79,6 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements | ||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(permissions); | ||||
|  | ||||
|         LibsMsg.DMODENT_HELP1.send(sender); | ||||
|         LibsMsg.DMODIFY_HELP3.send(sender, | ||||
|                 StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())); | ||||
|         LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.modify; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| @@ -20,6 +17,10 @@ import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|  | ||||
|     @Override | ||||
| @@ -42,8 +43,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | ||||
|             if (args[0].contains("-")) { | ||||
|                 try { | ||||
|                     entityTarget = Bukkit.getEntity(UUID.fromString(args[0])); | ||||
|                 } | ||||
|                 catch (Exception ignored) { | ||||
|                 } catch (Exception ignored) { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @@ -63,11 +63,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | ||||
|  | ||||
|         Disguise disguise = null; | ||||
|  | ||||
|         if (sender instanceof Player) | ||||
|         if (sender instanceof Player) { | ||||
|             disguise = DisguiseAPI.getDisguise((Player) sender, entityTarget); | ||||
|         } | ||||
|  | ||||
|         if (disguise == null) | ||||
|         if (disguise == null) { | ||||
|             disguise = DisguiseAPI.getDisguise(entityTarget); | ||||
|         } | ||||
|  | ||||
|         if (disguise == null) { | ||||
|             LibsMsg.DMODPLAYER_NODISGUISE.send(sender, entityTarget.getName()); | ||||
| @@ -86,15 +88,11 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | ||||
|         options = DisguiseParser.parsePlaceholders(options, sender, entityTarget); | ||||
|  | ||||
|         try { | ||||
|             DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, | ||||
|                     "DisguiseModifyPlayer"); | ||||
|         } | ||||
|         catch (DisguiseParseException ex) { | ||||
|             DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModifyPlayer"); | ||||
|         } catch (DisguiseParseException ex) { | ||||
|             ex.send(sender); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         catch (Throwable ex) { | ||||
|         } catch (Throwable ex) { | ||||
|             ex.printStackTrace(); | ||||
|             return true; | ||||
|         } | ||||
| @@ -133,11 +131,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | ||||
|  | ||||
|             Disguise disguise = null; | ||||
|  | ||||
|             if (sender instanceof Player) | ||||
|             if (sender instanceof Player) { | ||||
|                 disguise = DisguiseAPI.getDisguise((Player) sender, player); | ||||
|             } | ||||
|  | ||||
|             if (disguise == null) | ||||
|             if (disguise == null) { | ||||
|                 disguise = DisguiseAPI.getDisguise(player); | ||||
|             } | ||||
|  | ||||
|             if (disguise == null) { | ||||
|                 return tabs; | ||||
| @@ -159,7 +159,6 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | ||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(permissions); | ||||
|  | ||||
|         LibsMsg.DMODPLAYER_HELP1.send(sender); | ||||
|         LibsMsg.DMODIFY_HELP3.send(sender, | ||||
|                 StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())); | ||||
|         LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.modify; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -29,6 +24,12 @@ import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|     private Collection<Entity> getNearbyEntities(CommandSender sender, int radius) { | ||||
|         Location center; | ||||
| @@ -62,7 +63,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | ||||
|         } | ||||
|  | ||||
|         if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType")) || | ||||
|                 args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) { | ||||
|             args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) { | ||||
|             ArrayList<String> classes = new ArrayList<>(); | ||||
|  | ||||
|             for (DisguiseType type : DisguiseType.values()) { | ||||
|   | ||||
| @@ -15,8 +15,10 @@ public class UndisguiseCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " + | ||||
|                 "usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -15,8 +15,10 @@ public class UndisguiseEntityCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " + | ||||
|                 "usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
| @@ -30,8 +32,7 @@ public class UndisguiseEntityCommand implements CommandExecutor { | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(), | ||||
|                 DisguiseConfig.getDisguiseEntityExpire()); | ||||
|         LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(), DisguiseConfig.getDisguiseEntityExpire()); | ||||
|         LibsMsg.UND_ENTITY.send(sender); | ||||
|  | ||||
|         return true; | ||||
|   | ||||
| @@ -1,10 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.undisguise; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | ||||
| @@ -18,10 +13,17 @@ import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|     protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) { | ||||
|         if (origArgs.length == 0) | ||||
|         if (origArgs.length == 0) { | ||||
|             return list; | ||||
|         } | ||||
|  | ||||
|         Iterator<String> itel = list.iterator(); | ||||
|         String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH); | ||||
| @@ -29,8 +31,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|         while (itel.hasNext()) { | ||||
|             String name = itel.next(); | ||||
|  | ||||
|             if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) | ||||
|             if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             itel.remove(); | ||||
|         } | ||||
| @@ -44,8 +47,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|         for (int i = 0; i < args.length - 1; i++) { | ||||
|             String s = args[i]; | ||||
|  | ||||
|             if (s.trim().isEmpty()) | ||||
|             if (s.trim().isEmpty()) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             newArgs.add(s); | ||||
|         } | ||||
| @@ -56,8 +60,10 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " + | ||||
|                 "usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
| @@ -77,8 +83,7 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|             if (args[0].contains("-")) { | ||||
|                 try { | ||||
|                     entityTarget = Bukkit.getEntity(UUID.fromString(args[0])); | ||||
|                 } | ||||
|                 catch (Exception ignored) { | ||||
|                 } catch (Exception ignored) { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @@ -90,13 +95,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|  | ||||
|         if (DisguiseAPI.isDisguised(entityTarget)) { | ||||
|             DisguiseAPI.undisguiseToAll(sender, entityTarget); | ||||
|             LibsMsg.UNDISG_PLAYER.send(sender, | ||||
|                     entityTarget instanceof Player ? entityTarget.getName() : | ||||
|                             DisguiseType.getType(entityTarget).toReadable()); | ||||
|             LibsMsg.UNDISG_PLAYER.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable()); | ||||
|         } else { | ||||
|             LibsMsg.UNDISG_PLAYER_FAIL.send(sender, | ||||
|                     entityTarget instanceof Player ? entityTarget.getName() : | ||||
|                             DisguiseType.getType(entityTarget).toReadable()); | ||||
|             LibsMsg.UNDISG_PLAYER_FAIL.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable()); | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
| @@ -107,8 +108,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | ||||
|         ArrayList<String> tabs = new ArrayList<>(); | ||||
|         String[] args = getArgs(origArgs); | ||||
|  | ||||
|         if (args.length != 0) | ||||
|         if (args.length != 0) { | ||||
|             return filterTabs(tabs, origArgs); | ||||
|         } | ||||
|  | ||||
|         for (Player player : Bukkit.getOnlinePlayers()) { | ||||
|             // If command user cannot see player online, don't tab-complete name | ||||
|   | ||||
| @@ -18,8 +18,7 @@ public class UndisguiseRadiusCommand implements CommandExecutor { | ||||
|         try { | ||||
|             Integer.parseInt(string); | ||||
|             return true; | ||||
|         } | ||||
|         catch (Exception ex) { | ||||
|         } catch (Exception ex) { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
| @@ -27,8 +26,10 @@ public class UndisguiseRadiusCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " + | ||||
|                 "usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.utils; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| @@ -23,6 +21,9 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.UUID; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/01/2020. | ||||
|  */ | ||||
| @@ -30,10 +31,10 @@ public class CopyDisguiseCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                     "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + | ||||
|                     "non-admin usage!"); | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + | ||||
|                 "non-admin usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
| @@ -66,7 +67,7 @@ public class CopyDisguiseCommand implements CommandExecutor { | ||||
|  | ||||
|         if (disguise == null) { | ||||
|             LibsDisguises.getInstance().getListener() | ||||
|                     .addInteraction(sender.getName(), new CopyDisguiseInteraction(this), DisguiseConfig.getDisguiseEntityExpire()); | ||||
|                 .addInteraction(sender.getName(), new CopyDisguiseInteraction(this), DisguiseConfig.getDisguiseEntityExpire()); | ||||
|  | ||||
|             LibsMsg.DISGUISECOPY_INTERACT.send(sender, DisguiseConfig.getDisguiseEntityExpire()); | ||||
|             return true; | ||||
| @@ -136,7 +137,7 @@ public class CopyDisguiseCommand implements CommandExecutor { | ||||
|                 builder.append(LibsMsg.CLICK_COPY.getBase(sections)); | ||||
|                 builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, current.toString())); | ||||
|                 builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, | ||||
|                         new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + sections).create())); | ||||
|                     new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + sections).create())); | ||||
|  | ||||
|                 current = new StringBuilder(); | ||||
|             } | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.utils; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| @@ -16,6 +14,9 @@ import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.command.TabCompleter; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|  | ||||
|     @Override | ||||
| @@ -45,7 +46,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | ||||
|                 doEquipment = false; | ||||
|             } else if (option.equalsIgnoreCase(LibsMsg.DCLONE_ADDEDANIMATIONS.get())) { | ||||
|                 doAdded = true; | ||||
|             }  else { | ||||
|             } else { | ||||
|                 LibsMsg.INVALID_CLONE.send(sender, option); | ||||
|                 return true; | ||||
|             } | ||||
| @@ -57,8 +58,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | ||||
|             DisguiseUtilities.createClonedDisguise((Player) sender, player, options); | ||||
|         } else { | ||||
|             LibsDisguises.getInstance().getListener() | ||||
|                     .addInteraction(sender.getName(), new DisguiseCloneInteraction(options), | ||||
|                             DisguiseConfig.getDisguiseCloneExpire()); | ||||
|                 .addInteraction(sender.getName(), new DisguiseCloneInteraction(options), DisguiseConfig.getDisguiseCloneExpire()); | ||||
|  | ||||
|             LibsMsg.CLICK_TIMER.send(sender, DisguiseConfig.getDisguiseCloneExpire()); | ||||
|         } | ||||
|   | ||||
| @@ -1,9 +1,5 @@ | ||||
| package me.libraryaddict.disguise.commands.utils; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import me.libraryaddict.disguise.commands.DisguiseBaseCommand; | ||||
| import me.libraryaddict.disguise.utilities.params.ParamInfo; | ||||
| import me.libraryaddict.disguise.utilities.params.ParamInfoManager; | ||||
| @@ -19,6 +15,11 @@ import org.bukkit.command.Command; | ||||
| import org.bukkit.command.CommandSender; | ||||
| import org.bukkit.command.TabCompleter; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
|  | ||||
| public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter { | ||||
|  | ||||
|     @Override | ||||
| @@ -47,12 +48,10 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | ||||
|  | ||||
|                 if (help != null) { | ||||
|                     if (help.hasValues() && help.canTranslateValues()) { | ||||
|                         LibsMsg.DHELP_HELP4.send(sender, help.getName(), | ||||
|                                 StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get())); | ||||
|                         LibsMsg.DHELP_HELP4.send(sender, help.getName(), StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get())); | ||||
|                     } else { | ||||
|                         if (!help.getName().equals(help.getDescriptiveName())) { | ||||
|                             LibsMsg.DHELP_HELP6 | ||||
|                                     .send(sender, help.getName(), help.getDescriptiveName(), help.getDescription()); | ||||
|                             LibsMsg.DHELP_HELP6.send(sender, help.getName(), help.getDescriptiveName(), help.getDescription()); | ||||
|                         } else { | ||||
|                             LibsMsg.DHELP_HELP5.send(sender, help.getName(), help.getDescription()); | ||||
|                         } | ||||
| @@ -80,8 +79,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | ||||
|                 try { | ||||
|                     for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) { | ||||
|                         if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) { | ||||
|                             if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase( | ||||
|                                     Locale.ENGLISH)))) { | ||||
|                             if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(Locale.ENGLISH)))) { | ||||
|                                 ignored++; | ||||
|                                 continue; | ||||
|                             } | ||||
| @@ -98,13 +96,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | ||||
|                             methodColor = ChatColor.GRAY; | ||||
|                         } | ||||
|  | ||||
|                         String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" + | ||||
|                                 ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")"; | ||||
|                         String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName() + | ||||
|                             ChatColor.DARK_RED + ")"; | ||||
|  | ||||
|                         methods.add(methodColor + str); | ||||
|                     } | ||||
|                 } | ||||
|                 catch (Exception ex) { | ||||
|                 } catch (Exception ex) { | ||||
|                     ex.printStackTrace(); | ||||
|                 } | ||||
|  | ||||
| @@ -112,8 +109,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | ||||
|                     methods.add(LibsMsg.DHELP_NO_OPTIONS.get()); | ||||
|                 } | ||||
|  | ||||
|                 LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(), | ||||
|                         StringUtils.join(methods, ChatColor.DARK_RED + ", ")); | ||||
|                 LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(), StringUtils.join(methods, ChatColor.DARK_RED + ", ")); | ||||
|  | ||||
|                 if (ignored > 0) { | ||||
|                     LibsMsg.NO_PERMS_USE_OPTIONS.send(sender, ignored); | ||||
| @@ -137,8 +133,9 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | ||||
|  | ||||
|             if (args.length == 0) { | ||||
|                 for (DisguisePerm type : perms.getAllowed()) { | ||||
|                     if (type.isUnknown()) | ||||
|                     if (type.isUnknown()) { | ||||
|                         continue; | ||||
|                     } | ||||
|  | ||||
|                     tabs.add(type.toReadable().replaceAll(" ", "_")); | ||||
|                 } | ||||
| @@ -163,9 +160,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | ||||
|         LibsMsg.DHELP_HELP2.send(sender); | ||||
|  | ||||
|         for (ParamInfo s : ParamInfoManager.getParamInfos()) { | ||||
|             LibsMsg.DHELP_HELP3.send(sender, s.getName().replaceAll(" ", "") + | ||||
|                             (!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""), | ||||
|                     s.getDescription()); | ||||
|             LibsMsg.DHELP_HELP3.send(sender, | ||||
|                 s.getName().replaceAll(" ", "") + (!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""), s.getDescription()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package me.libraryaddict.disguise.commands.utils; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||||
| import java.lang.reflect.Field; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | ||||
| @@ -19,6 +18,8 @@ import org.bukkit.inventory.meta.SkullMeta; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
| import org.bukkit.scheduler.BukkitTask; | ||||
|  | ||||
| import java.lang.reflect.Field; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/06/2020. | ||||
|  */ | ||||
| @@ -26,8 +27,10 @@ public class GrabHeadCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " + | ||||
|                 "usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
| @@ -93,8 +96,7 @@ public class GrabHeadCommand implements CommandExecutor { | ||||
|                             Field field = meta.getClass().getDeclaredField("profile"); | ||||
|                             field.setAccessible(true); | ||||
|                             field.set(meta, profile.getHandle()); | ||||
|                         } | ||||
|                         catch (NoSuchFieldException | IllegalAccessException e) { | ||||
|                         } catch (NoSuchFieldException | IllegalAccessException e) { | ||||
|                             e.printStackTrace(); | ||||
|                         } | ||||
|  | ||||
|   | ||||
| @@ -28,10 +28,10 @@ public class GrabSkinCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                     "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + | ||||
|                     "non-admin usage!"); | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + | ||||
|                 "non-admin usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
| @@ -142,7 +142,7 @@ public class GrabSkinCommand implements CommandExecutor { | ||||
|  | ||||
|                     builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub)); | ||||
|                     builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, | ||||
|                             new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + msg).create())); | ||||
|                         new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + msg).create())); | ||||
|                     msg += 1; | ||||
|                 } | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package me.libraryaddict.disguise.commands.utils; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||||
| import java.util.Arrays; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| @@ -20,6 +19,8 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
| import org.bukkit.scheduler.BukkitTask; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 28/12/2019. | ||||
|  */ | ||||
| @@ -28,10 +29,10 @@ public class SaveDisguiseCommand implements CommandExecutor { | ||||
|     @Override | ||||
|     public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) { | ||||
|         if (sender instanceof Player && !sender.isOp() && | ||||
|                 (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { | ||||
|             sender.sendMessage(ChatColor.RED + | ||||
|                     "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + | ||||
|                     "non-admin usage!"); | ||||
|                 "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + | ||||
|                 "non-admin usage!"); | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -6,27 +6,23 @@ import org.bukkit.Material; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| public enum AnimalColor { | ||||
|     BLACK(DyeColor.BLACK, | ||||
|             NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")), | ||||
|     BLACK(DyeColor.BLACK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")), | ||||
|     BLUE(DyeColor.BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LAPIS_LAZULI") : null), | ||||
|     BROWN(DyeColor.BROWN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("COCOA_BEANS") : null), | ||||
|     CYAN(DyeColor.CYAN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("CYAN_DYE") : null), | ||||
|     GRAY(DyeColor.GRAY, NmsVersion.v1_13.isSupported() ? Material.getMaterial("GRAY_DYE") : null), | ||||
|     GREEN(DyeColor.GREEN, | ||||
|             NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")), | ||||
|     GREEN(DyeColor.GREEN, NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")), | ||||
|     LIGHT_BLUE(DyeColor.LIGHT_BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_BLUE_DYE") : null), | ||||
|     LIME(DyeColor.LIME, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIME_DYE") : null), | ||||
|     MAGENTA(DyeColor.MAGENTA, NmsVersion.v1_13.isSupported() ? Material.getMaterial("MAGENTA_DYE") : null), | ||||
|     ORANGE(DyeColor.ORANGE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("ORANGE_DYE") : null), | ||||
|     PINK(DyeColor.PINK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PINK_DYE") : null), | ||||
|     PURPLE(DyeColor.PURPLE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PURPLE_DYE") : null), | ||||
|     RED(DyeColor.RED, | ||||
|             NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")), | ||||
|     RED(DyeColor.RED, NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")), | ||||
|     LIGHT_GRAY(DyeColor.valueOf(NmsVersion.v1_13.isSupported() ? "LIGHT_GRAY" : "SILVER"), | ||||
|             NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null), | ||||
|         NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null), | ||||
|     WHITE(DyeColor.WHITE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("BONE_MEAL") : null), | ||||
|     YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") : | ||||
|             Material.getMaterial("DANDELION_YELLOW")); | ||||
|     YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") : Material.getMaterial("DANDELION_YELLOW")); | ||||
|  | ||||
|     public static AnimalColor getColorByWool(int woolId) { | ||||
|         for (AnimalColor color : values()) { | ||||
|   | ||||
| @@ -7,16 +7,6 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; | ||||
| import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; | ||||
| import com.comphenix.protocol.wrappers.PlayerInfoData; | ||||
| import com.comphenix.protocol.wrappers.WrappedChatComponent; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.LinkedHashMap; | ||||
| import java.util.Random; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import lombok.AccessLevel; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| @@ -54,6 +44,17 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.metadata.FixedMetadataValue; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.LinkedHashMap; | ||||
| import java.util.Random; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| public abstract class Disguise { | ||||
|     private transient boolean disguiseInUse; | ||||
|     private DisguiseType disguiseType; | ||||
| @@ -260,8 +261,8 @@ public abstract class Disguise { | ||||
|     protected void createDisguise() { | ||||
|         if (getType().getEntityType() == null) { | ||||
|             throw new RuntimeException( | ||||
|                     "DisguiseType " + getType() + " was used in a futile attempt to construct a disguise, but this Minecraft version does not have " + | ||||
|                             "that entity"); | ||||
|                 "DisguiseType " + getType() + " was used in a futile attempt to construct a disguise, but this Minecraft version does not have " + | ||||
|                     "that entity"); | ||||
|         } | ||||
|  | ||||
|         // Get if they are a adult now.. | ||||
| @@ -373,7 +374,7 @@ public abstract class Disguise { | ||||
|         removeBossBar(); | ||||
|  | ||||
|         BossBar bar = Bukkit.createBossBar(getBossBar(), BaseComponent.toLegacyText(LibsMsg.ACTION_BAR_MESSAGE.getBase(getDisguiseName())), getBossBarColor(), | ||||
|                 getBossBarStyle()); | ||||
|             getBossBarStyle()); | ||||
|         bar.setProgress(1); | ||||
|         bar.addPlayer((Player) getEntity()); | ||||
|     } | ||||
| @@ -390,7 +391,7 @@ public abstract class Disguise { | ||||
|  | ||||
|     protected void doActionBar() { | ||||
|         if (getNotifyBar() == DisguiseConfig.NotifyBar.ACTION_BAR && getEntity() instanceof Player && !getEntity().hasPermission("libsdisguises.noactionbar") && | ||||
|                 DisguiseAPI.getDisguise(getEntity()) == Disguise.this) { | ||||
|             DisguiseAPI.getDisguise(getEntity()) == Disguise.this) { | ||||
|             ((Player) getEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, LibsMsg.ACTION_BAR_MESSAGE.getBase(getDisguiseName())); | ||||
|         } | ||||
|  | ||||
| @@ -511,8 +512,9 @@ public abstract class Disguise { | ||||
|     @Deprecated | ||||
|     public Disguise setWatcher(FlagWatcher newWatcher) { | ||||
|         if (!getType().getWatcherClass().isInstance(newWatcher)) { | ||||
|             throw new IllegalArgumentException((newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " + | ||||
|                     getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); | ||||
|             throw new IllegalArgumentException( | ||||
|                 (newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " + getType().getWatcherClass().getSimpleName() + | ||||
|                     " for DisguiseType " + getType().name()); | ||||
|         } | ||||
|  | ||||
|         watcher = newWatcher; | ||||
| @@ -708,7 +710,7 @@ public abstract class Disguise { | ||||
|  | ||||
|         // Can only continue a disguise that's valid | ||||
|         if (event.isCancelled() && getEntity() != null && Bukkit.getWorlds().contains(getEntity().getWorld()) && | ||||
|                 (!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) { | ||||
|             (!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) { | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
| @@ -736,7 +738,7 @@ public abstract class Disguise { | ||||
|                 PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); | ||||
|                 deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); | ||||
|                 deleteTab.getPlayerInfoDataLists().write(0, Collections.singletonList( | ||||
|                         new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getProfileName())))); | ||||
|                     new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getProfileName())))); | ||||
|  | ||||
|                 try { | ||||
|                     for (Player player : Bukkit.getOnlinePlayers()) { | ||||
| @@ -784,8 +786,8 @@ public abstract class Disguise { | ||||
|         } | ||||
|  | ||||
|         if (isHidePlayer() && getEntity() instanceof Player && ((Player) getEntity()).isOnline()) { | ||||
|             PlayerInfoData playerInfo = new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, | ||||
|                     NativeGameMode.fromBukkit(((Player) getEntity()).getGameMode()), | ||||
|             PlayerInfoData playerInfo = | ||||
|                 new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.fromBukkit(((Player) getEntity()).getGameMode()), | ||||
|                     WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity()))); | ||||
|  | ||||
|             PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); | ||||
| @@ -873,7 +875,7 @@ public abstract class Disguise { | ||||
|  | ||||
|         // If a horse is disguised as a horse, it should obey parent no gravity rule | ||||
|         if ((getEntity() instanceof Boat || getEntity() instanceof AbstractHorse) && | ||||
|                 (getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) { | ||||
|             (getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) { | ||||
|             getWatcher().setNoGravity(!getEntity().hasGravity()); | ||||
|         } else { | ||||
|             getWatcher().setNoGravity(true); | ||||
| @@ -1017,7 +1019,7 @@ public abstract class Disguise { | ||||
|             PacketContainer removeTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); | ||||
|             removeTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); | ||||
|             removeTab.getPlayerInfoDataLists().write(0, Collections.singletonList( | ||||
|                     new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("")))); | ||||
|                 new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("")))); | ||||
|  | ||||
|             try { | ||||
|                 for (Player player : Bukkit.getOnlinePlayers()) { | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType; | ||||
| import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.comphenix.protocol.events.PacketContainer; | ||||
| import com.comphenix.protocol.reflect.StructureModifier; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher; | ||||
| @@ -17,6 +16,8 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
| import org.bukkit.util.Vector; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 20/05/2021. | ||||
|  */ | ||||
| @@ -84,7 +85,7 @@ class DisguiseRunnable extends BukkitRunnable { | ||||
|         if (disguise.getEntity() instanceof Player && !((Player) disguise.getEntity()).isOnline()) { | ||||
|             disguise.removeDisguise(); | ||||
|         } else if (disguise.disguiseExpires > 0 && (DisguiseConfig.isDynamicExpiry() ? disguise.disguiseExpires-- == 1 : | ||||
|                 disguise.disguiseExpires < System.currentTimeMillis())) { // If disguise expired | ||||
|             disguise.disguiseExpires < System.currentTimeMillis())) { // If disguise expired | ||||
|             disguise.removeDisguise(); | ||||
|  | ||||
|             if (disguise.getEntity() instanceof Player) { | ||||
| @@ -182,9 +183,9 @@ class DisguiseRunnable extends BukkitRunnable { | ||||
|                     Location loc = disguise.getEntity().getLocation(); | ||||
|  | ||||
|                     mods.write(4, | ||||
|                             DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); | ||||
|                     mods.write(5, DisguiseUtilities | ||||
|                             .getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); | ||||
|                         DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); | ||||
|                     mods.write(5, | ||||
|                         DisguiseUtilities.getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); | ||||
|  | ||||
|                     if (disguise.isSelfDisguiseVisible() && disguise.getEntity() instanceof Player) { | ||||
|                         PacketContainer selfLookPacket = lookPacket.shallowClone(); | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes; | ||||
|  | ||||
| import java.util.Locale; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| @@ -9,6 +8,8 @@ import org.apache.commons.lang.StringUtils; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.EntityType; | ||||
|  | ||||
| import java.util.Locale; | ||||
|  | ||||
| public enum DisguiseType { | ||||
|     AREA_EFFECT_CLOUD(3, 0), | ||||
|  | ||||
|   | ||||
| @@ -10,14 +10,6 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher; | ||||
| import com.comphenix.protocol.wrappers.WrappedWatchableObject; | ||||
| import com.google.common.base.Strings; | ||||
| import com.mojang.datafixers.util.Pair; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
| import lombok.AccessLevel; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| @@ -41,6 +33,15 @@ import org.bukkit.inventory.EntityEquipment; | ||||
| import org.bukkit.inventory.EquipmentSlot; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
|  | ||||
| public class FlagWatcher { | ||||
|     private boolean addEntityAnimations = DisguiseConfig.isAddEntityAnimations(); | ||||
|     /** | ||||
|   | ||||
| @@ -243,13 +243,13 @@ public class LibsEquipment implements EntityEquipment { | ||||
|         setHelmet(helmet); | ||||
|     } | ||||
|  | ||||
|   // @Override | ||||
|     // @Override | ||||
|     @Deprecated | ||||
|     public void setItem(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) { | ||||
|         setItem(equipmentSlot, itemStack); | ||||
|     } | ||||
|  | ||||
|    // @Override | ||||
|     // @Override | ||||
|     @Deprecated | ||||
|     public void setItemInMainHand(ItemStack itemStack, boolean silent) { | ||||
|         setItemInMainHand(itemStack); | ||||
|   | ||||
| @@ -10,16 +10,6 @@ import com.comphenix.protocol.wrappers.WrappedParticle; | ||||
| import com.comphenix.protocol.wrappers.nbt.NbtBase; | ||||
| import com.comphenix.protocol.wrappers.nbt.NbtFactory; | ||||
| import com.comphenix.protocol.wrappers.nbt.NbtType; | ||||
| import java.lang.reflect.Field; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Comparator; | ||||
| import java.util.HashMap; | ||||
| import java.util.Locale; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.Optional; | ||||
| import java.util.OptionalInt; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.AbstractSkeletonWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.AbstractVillagerWatcher; | ||||
| @@ -113,6 +103,17 @@ import org.bukkit.Particle; | ||||
| import org.bukkit.entity.Villager; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.lang.reflect.Field; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Comparator; | ||||
| import java.util.HashMap; | ||||
| import java.util.Locale; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.Optional; | ||||
| import java.util.OptionalInt; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class MetaIndex<Y> { | ||||
|     private static MetaIndex[] _values = new MetaIndex[0]; | ||||
|  | ||||
| @@ -136,7 +137,7 @@ public class MetaIndex<Y> { | ||||
|      */ | ||||
|     @NmsAddedIn(NmsVersion.v1_13) | ||||
|     public static MetaIndex<WrappedParticle> AREA_EFFECT_PARTICLE = | ||||
|             new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null); | ||||
|         new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null); | ||||
|  | ||||
|     @NmsRemovedIn(NmsVersion.v1_13) | ||||
|     public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0); | ||||
| @@ -368,7 +369,7 @@ public class MetaIndex<Y> { | ||||
|     public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR)); | ||||
|  | ||||
|     public static MetaIndex<ItemStack> FIREWORK_ITEM = | ||||
|             new MetaIndex<>(FireworkWatcher.class, 0, new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR)); | ||||
|         new MetaIndex<>(FireworkWatcher.class, 0, new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR)); | ||||
|  | ||||
|     public static MetaIndex<Boolean> FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false); | ||||
|  | ||||
| @@ -543,7 +544,7 @@ public class MetaIndex<Y> { | ||||
|     public static MetaIndex<String> MINECART_COMMAND_STRING = new MetaIndex<>(MinecartCommandWatcher.class, 0, ""); | ||||
|  | ||||
|     public static MetaIndex<WrappedChatComponent> MINECART_COMMAND_LAST_OUTPUT = | ||||
|             new MetaIndex<>(MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText("")); | ||||
|         new MetaIndex<>(MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText("")); | ||||
|  | ||||
|     /** | ||||
|      * If the minecart furnace is fueled and burning | ||||
| @@ -697,8 +698,8 @@ public class MetaIndex<Y> { | ||||
|     public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0); | ||||
|  | ||||
|     @NmsAddedIn(NmsVersion.v1_14) | ||||
|     public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0, | ||||
|             NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); | ||||
|     public static MetaIndex<VillagerData> VILLAGER_DATA = | ||||
|         new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); | ||||
|  | ||||
|     public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false); | ||||
|  | ||||
| @@ -740,7 +741,7 @@ public class MetaIndex<Y> { | ||||
|  | ||||
|     @NmsAddedIn(NmsVersion.v1_14) | ||||
|     public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1, | ||||
|             NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); | ||||
|         NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); | ||||
|  | ||||
|     /** | ||||
|      * Shown for villager conversion | ||||
| @@ -814,7 +815,7 @@ public class MetaIndex<Y> { | ||||
|  | ||||
|                     if (found != null) { | ||||
|                         DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" + | ||||
|                                 type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")"); | ||||
|                             type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")"); | ||||
|                         continue loop; | ||||
|                     } | ||||
|  | ||||
| @@ -832,7 +833,7 @@ public class MetaIndex<Y> { | ||||
|  | ||||
|     public String toString() { | ||||
|         return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(), getDefault().getClass().getSimpleName(), | ||||
|                 DisguiseUtilities.getGson().toJson(getDefault())); | ||||
|             DisguiseUtilities.getGson().toJson(getDefault())); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -1002,8 +1003,9 @@ public class MetaIndex<Y> { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 DisguiseUtilities.getLogger().severe("MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() + | ||||
|                         " has already registered this! (" + metaIndex.getDefault() + "," + index.getDefault() + ")"); | ||||
|                 DisguiseUtilities.getLogger().severe( | ||||
|                     "MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() + " has already registered this! (" + | ||||
|                         metaIndex.getDefault() + "," + index.getDefault() + ")"); | ||||
|             } | ||||
|  | ||||
|             values()[i] = metaIndexes[a]; | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher; | ||||
| @@ -12,6 +11,8 @@ import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
|  | ||||
| public class MiscDisguise extends TargetedDisguise { | ||||
|     private int id = -1, data = 0; | ||||
|  | ||||
| @@ -27,8 +28,7 @@ public class MiscDisguise extends TargetedDisguise { | ||||
|         super(disguiseType); | ||||
|  | ||||
|         if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) { | ||||
|             throw new IllegalArgumentException( | ||||
|                     "This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!"); | ||||
|             throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!"); | ||||
|         } | ||||
|  | ||||
|         apply(0, itemStack); | ||||
| @@ -38,8 +38,7 @@ public class MiscDisguise extends TargetedDisguise { | ||||
|         super(disguiseType); | ||||
|  | ||||
|         if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) { | ||||
|             throw new IllegalArgumentException( | ||||
|                     "This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!"); | ||||
|             throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!"); | ||||
|         } | ||||
|  | ||||
|         apply(0, new ItemStack(material)); | ||||
| @@ -55,9 +54,8 @@ public class MiscDisguise extends TargetedDisguise { | ||||
|  | ||||
|         if (!disguiseType.isMisc()) { | ||||
|             throw new InvalidParameterException( | ||||
|                     "Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType + | ||||
|                             " instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + | ||||
|                             " instead"); | ||||
|                 "Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType + " instead. Please use " + | ||||
|                     (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + " instead"); | ||||
|         } | ||||
|  | ||||
|         apply(id, new ItemStack(Material.STONE)); | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | ||||
| @@ -10,6 +9,8 @@ import me.libraryaddict.disguise.utilities.DisguiseValues; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
|  | ||||
| public class MobDisguise extends TargetedDisguise { | ||||
|     private boolean isAdult; | ||||
|  | ||||
| @@ -22,9 +23,8 @@ public class MobDisguise extends TargetedDisguise { | ||||
|  | ||||
|         if (!disguiseType.isMob()) { | ||||
|             throw new InvalidParameterException( | ||||
|                     "Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType + | ||||
|                             " instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") + | ||||
|                             " instead"); | ||||
|                 "Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType + " instead. Please use " + | ||||
|                     (disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") + " instead"); | ||||
|         } | ||||
|  | ||||
|         this.isAdult = isAdult; | ||||
| @@ -46,8 +46,7 @@ public class MobDisguise extends TargetedDisguise { | ||||
|  | ||||
|         if (getWatcher() != null) { | ||||
|             if (getType() == DisguiseType.ARMOR_STAND) { | ||||
|                 return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox()) | ||||
|                         .getY(); | ||||
|                 return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox()).getY(); | ||||
|             } else if (getType() == DisguiseType.SLIME || getType() == DisguiseType.MAGMA_CUBE) { | ||||
|                 return 0.51 * (0.255 * ((SlimeWatcher) getWatcher()).getSize()); | ||||
|             } | ||||
| @@ -76,8 +75,7 @@ public class MobDisguise extends TargetedDisguise { | ||||
|     } | ||||
|  | ||||
|     public boolean doesDisguiseAge() { | ||||
|         return getWatcher() != null && | ||||
|                 (getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher); | ||||
|         return getWatcher() != null && (getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.ModdedWatcher; | ||||
| import me.libraryaddict.disguise.utilities.modded.ModdedEntity; | ||||
| @@ -8,6 +7,8 @@ import me.libraryaddict.disguise.utilities.modded.ModdedManager; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 15/04/2020. | ||||
|  */ | ||||
| @@ -30,8 +31,7 @@ public class ModdedDisguise extends TargetedDisguise { | ||||
|         super(disguiseType); | ||||
|  | ||||
|         if (disguiseType != DisguiseType.UNKNOWN) { | ||||
|             throw new InvalidParameterException( | ||||
|                     "CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN"); | ||||
|             throw new InvalidParameterException("CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN"); | ||||
|         } | ||||
|  | ||||
|         createDisguise(); | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.comphenix.protocol.events.PacketContainer; | ||||
| import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; | ||||
| import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| @@ -19,6 +18,8 @@ import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
|  | ||||
| public class PlayerDisguise extends TargetedDisguise { | ||||
|     private transient LibsProfileLookup currentLookup; | ||||
|     private WrappedGameProfile gameProfile; | ||||
|   | ||||
| @@ -7,17 +7,18 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; | ||||
| import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; | ||||
| import com.comphenix.protocol.wrappers.PlayerInfoData; | ||||
| import com.comphenix.protocol.wrappers.WrappedChatComponent; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.entity.Player; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| public abstract class TargetedDisguise extends Disguise { | ||||
|  | ||||
|     public TargetedDisguise(DisguiseType disguiseType) { | ||||
| @@ -61,17 +62,14 @@ public abstract class TargetedDisguise extends Disguise { | ||||
|                         if (player != null) { | ||||
|                             PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); | ||||
|  | ||||
|                             deleteTab.getPlayerInfoAction().write(0, | ||||
|                                     canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER); | ||||
|                             deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER); | ||||
|                             deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList( | ||||
|                                     new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, | ||||
|                                             NativeGameMode.SURVIVAL, WrappedChatComponent | ||||
|                                             .fromText(DisguiseUtilities.getPlayerListName((Player) getEntity()))))); | ||||
|                                 new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, | ||||
|                                     WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity()))))); | ||||
|  | ||||
|                             ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); | ||||
|                         } | ||||
|                     } | ||||
|                     catch (InvocationTargetException e) { | ||||
|                     } catch (InvocationTargetException e) { | ||||
|                         e.printStackTrace(); | ||||
|                     } | ||||
|                 } | ||||
| @@ -134,17 +132,14 @@ public abstract class TargetedDisguise extends Disguise { | ||||
|                         if (player != null) { | ||||
|                             PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); | ||||
|  | ||||
|                             deleteTab.getPlayerInfoAction().write(0, | ||||
|                                     canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER); | ||||
|                             deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER); | ||||
|                             deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList( | ||||
|                                     new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, | ||||
|                                             NativeGameMode.SURVIVAL, WrappedChatComponent | ||||
|                                             .fromText(DisguiseUtilities.getPlayerListName((Player) getEntity()))))); | ||||
|                                 new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, | ||||
|                                     WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity()))))); | ||||
|  | ||||
|                             ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); | ||||
|                         } | ||||
|                     } | ||||
|                     catch (InvocationTargetException e) { | ||||
|                     } catch (InvocationTargetException e) { | ||||
|                         e.printStackTrace(); | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
|  | ||||
| import java.util.Optional; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
|  | ||||
| public abstract class AbstractHorseWatcher extends AgeableWatcher { | ||||
|     private static final int TAMED = 2, SADDLED = 4, REPRODUCED = 8, GRAZING = 16, REARING = 32, EATING = 64; | ||||
|   | ||||
| @@ -31,8 +31,9 @@ public class ArmorStandWatcher extends LivingWatcher { | ||||
|     } | ||||
|  | ||||
|     private EulerAngle getPose(MetaIndex<Vector3F> type) { | ||||
|         if (!hasValue(type)) | ||||
|         if (!hasValue(type)) { | ||||
|             return new EulerAngle(0, 0, 0); | ||||
|         } | ||||
|  | ||||
|         Vector3F vec = getData(type); | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.Random; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.disguisetypes.AnimalColor; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| @@ -11,6 +10,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.DyeColor; | ||||
| import org.bukkit.entity.Cat; | ||||
|  | ||||
| import java.util.Random; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 6/05/2019. | ||||
|  */ | ||||
|   | ||||
| @@ -17,10 +17,8 @@ public class CreeperWatcher extends InsentientWatcher { | ||||
|  | ||||
|     public void setIgnited(boolean ignited) { | ||||
|         // If creeper is already ignited and they want to set it to unignited, then resend disguise | ||||
|         boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() && | ||||
|                 ((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) || | ||||
|                         (getDisguise().getEntity() instanceof Creeper && | ||||
|                                 ((Creeper) getDisguise().getEntity()).isPowered())); | ||||
|         boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() && ((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) || | ||||
|             (getDisguise().getEntity() instanceof Creeper && ((Creeper) getDisguise().getEntity()).isPowered())); | ||||
|  | ||||
|         setData(MetaIndex.CREEPER_IGNITED, ignited); | ||||
|         sendData(MetaIndex.CREEPER_IGNITED); | ||||
|   | ||||
| @@ -24,8 +24,7 @@ public class DroppedItemWatcher extends FlagWatcher { | ||||
|  | ||||
|         if (!getDisguise().isCustomDisguiseName()) { | ||||
|             getDisguise().setDisguiseName(TranslateType.DISGUISES.get(DisguiseType.DROPPED_ITEM.toReadable()) + " " + | ||||
|                     TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager | ||||
|                             .toReadable((item == null ? Material.AIR : item.getType()).name(), " "))); | ||||
|                 TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name(), " "))); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,11 +1,12 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.BlockPosition; | ||||
| import java.util.Optional; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
|  | ||||
| import java.util.Optional; | ||||
|  | ||||
| /** | ||||
|  * @author Navid | ||||
|  */ | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.WrappedBlockData; | ||||
| import java.util.Optional; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.util.Optional; | ||||
|  | ||||
| public class EndermanWatcher extends InsentientWatcher { | ||||
|  | ||||
|     public EndermanWatcher(Disguise disguise) { | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType; | ||||
| import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.comphenix.protocol.events.PacketContainer; | ||||
| import com.comphenix.protocol.reflect.StructureModifier; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||
| @@ -19,6 +18,8 @@ import org.bukkit.block.data.BlockData; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
|  | ||||
| public class FallingBlockWatcher extends FlagWatcher { | ||||
|     private int blockCombinedId = 1; | ||||
|     private boolean gridLocked; | ||||
| @@ -105,7 +106,7 @@ public class FallingBlockWatcher extends FlagWatcher { | ||||
|  | ||||
|         if (!getDisguise().isCustomDisguiseName()) { | ||||
|             getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " + | ||||
|                     TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(block.getType().name(), " "))); | ||||
|                 TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(block.getType().name(), " "))); | ||||
|         } | ||||
|  | ||||
|         if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { | ||||
| @@ -129,7 +130,7 @@ public class FallingBlockWatcher extends FlagWatcher { | ||||
|  | ||||
|         if (!getDisguise().isCustomDisguiseName()) { | ||||
|             getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " + | ||||
|                     TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(data.getMaterial().name(), " "))); | ||||
|                 TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(data.getMaterial().name(), " "))); | ||||
|         } | ||||
|  | ||||
|         if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.OptionalInt; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| @@ -9,6 +8,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.util.OptionalInt; | ||||
|  | ||||
| public class FireworkWatcher extends FlagWatcher { | ||||
|     public FireworkWatcher(Disguise disguise) { | ||||
|         super(disguise); | ||||
|   | ||||
| @@ -12,8 +12,9 @@ public class FishingHookWatcher extends FlagWatcher { | ||||
|     public int getHookedId() { | ||||
|         int hooked = getData(MetaIndex.FISHING_HOOK_HOOKED_ID); | ||||
|  | ||||
|         if (hooked > 0) | ||||
|         if (hooked > 0) { | ||||
|             hooked--; | ||||
|         } | ||||
|  | ||||
|         return hooked; | ||||
|     } | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.Random; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| @@ -9,6 +8,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.entity.Fox; | ||||
|  | ||||
| import java.util.Random; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 6/05/2019. | ||||
|  */ | ||||
|   | ||||
| @@ -49,8 +49,9 @@ public class GuardianWatcher extends InsentientWatcher { | ||||
|     public void setTarget(String playername) { | ||||
|         Player player = Bukkit.getPlayer(playername); | ||||
|  | ||||
|         if (player == null) | ||||
|         if (player == null) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         setData(MetaIndex.GUARDIAN_TARGET, player.getEntityId()); | ||||
|         sendData(MetaIndex.GUARDIAN_TARGET); | ||||
|   | ||||
| @@ -6,13 +6,6 @@ import com.comphenix.protocol.events.PacketContainer; | ||||
| import com.comphenix.protocol.wrappers.BlockPosition; | ||||
| import com.comphenix.protocol.wrappers.WrappedAttribute; | ||||
| import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| @@ -26,6 +19,14 @@ import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.potion.PotionEffectType; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| public class LivingWatcher extends FlagWatcher { | ||||
|     private double maxHealth; | ||||
|     private boolean maxHealthSet; | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.Locale; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.entity.MushroomCow; | ||||
|  | ||||
| import java.util.Locale; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 6/05/2019. | ||||
|  */ | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.Optional; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn; | ||||
| @@ -9,6 +7,9 @@ import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.entity.Ocelot; | ||||
|  | ||||
| import java.util.Optional; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class OcelotWatcher extends AgeableWatcher { | ||||
|  | ||||
|     public OcelotWatcher(Disguise disguise) { | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.Random; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| @@ -9,6 +8,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.entity.Panda; | ||||
|  | ||||
| import java.util.Random; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 6/05/2019. | ||||
|  */ | ||||
|   | ||||
| @@ -26,8 +26,9 @@ public class PlayerWatcher extends LivingWatcher { | ||||
|     } | ||||
|  | ||||
|     public void setDisplayedInTab(boolean showPlayerInTab) { | ||||
|         if (getDisguise().isDisguiseInUse()) | ||||
|         if (getDisguise().isDisguiseInUse()) { | ||||
|             throw new IllegalStateException("Cannot set this while disguise is in use!"); | ||||
|         } | ||||
|  | ||||
|         alwaysShowInTab = showPlayerInTab; | ||||
|     } | ||||
|   | ||||
| @@ -2,13 +2,14 @@ package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.BlockPosition; | ||||
| import com.comphenix.protocol.wrappers.EnumWrappers.Direction; | ||||
| import java.util.Optional; | ||||
| import me.libraryaddict.disguise.disguisetypes.AnimalColor; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| import org.bukkit.DyeColor; | ||||
| import org.bukkit.block.BlockFace; | ||||
|  | ||||
| import java.util.Optional; | ||||
|  | ||||
| /** | ||||
|  * @author Navid | ||||
|  */ | ||||
| @@ -41,11 +42,13 @@ public class ShulkerWatcher extends InsentientWatcher { | ||||
|     } | ||||
|  | ||||
|     public void setShieldHeight(int newHeight) { | ||||
|         if (newHeight < 0) | ||||
|         if (newHeight < 0) { | ||||
|             newHeight = 0; | ||||
|         } | ||||
|  | ||||
|         if (newHeight > 127) | ||||
|         if (newHeight > 127) { | ||||
|             newHeight = 127; | ||||
|         } | ||||
|  | ||||
|         setData(MetaIndex.SHULKER_PEEKING, (byte) newHeight); | ||||
|         sendData(MetaIndex.SHULKER_PEEKING); | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
|  | ||||
| import java.util.Optional; | ||||
| import java.util.UUID; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
|  | ||||
| public class TameableWatcher extends AgeableWatcher { | ||||
|     public TameableWatcher(Disguise disguise) { | ||||
|   | ||||
| @@ -1,7 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| @@ -10,6 +8,9 @@ import org.apache.commons.lang.math.RandomUtils; | ||||
| import org.bukkit.DyeColor; | ||||
| import org.bukkit.entity.TropicalFish; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 6/08/2018. | ||||
|  */ | ||||
| @@ -75,8 +76,7 @@ public class TropicalFishWatcher extends FishWatcher { | ||||
|     } | ||||
|  | ||||
|     private int getData(final DyeColor patternColor, final DyeColor bodyColor, final TropicalFish.Pattern type) { | ||||
|         return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | | ||||
|                 CraftPattern.values()[type.ordinal()].getDataValue(); | ||||
|         return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | CraftPattern.values()[type.ordinal()].getDataValue(); | ||||
|     } | ||||
|  | ||||
|     public DyeColor getBodyColor() { | ||||
|   | ||||
| @@ -1,10 +1,11 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| import org.bukkit.ChatColor; | ||||
|  | ||||
| import java.security.InvalidParameterException; | ||||
|  | ||||
| public class WitherWatcher extends InsentientWatcher { | ||||
|  | ||||
|     public WitherWatcher(Disguise disguise) { | ||||
| @@ -21,8 +22,7 @@ public class WitherWatcher extends InsentientWatcher { | ||||
|     } | ||||
|  | ||||
|     public int[] getTargets() { | ||||
|         return new int[]{getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2), | ||||
|                 getData(MetaIndex.WITHER_TARGET_3)}; | ||||
|         return new int[]{getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2), getData(MetaIndex.WITHER_TARGET_3)}; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -35,8 +35,7 @@ public class WitherWatcher extends InsentientWatcher { | ||||
|  | ||||
|     public void setTargets(int... targets) { | ||||
|         if (targets.length != 3) { | ||||
|             throw new InvalidParameterException( | ||||
|                     ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length); | ||||
|             throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length); | ||||
|         } | ||||
|         setData(MetaIndex.WITHER_TARGET_1, targets[0]); | ||||
|         setData(MetaIndex.WITHER_TARGET_2, targets[1]); | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package me.libraryaddict.disguise.disguisetypes.watchers; | ||||
|  | ||||
| import java.util.Random; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
| @@ -11,6 +10,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import org.bukkit.entity.Villager; | ||||
| import org.bukkit.entity.Villager.Profession; | ||||
|  | ||||
| import java.util.Random; | ||||
|  | ||||
| public class ZombieVillagerWatcher extends ZombieWatcher { | ||||
|  | ||||
|     public ZombieVillagerWatcher(Disguise disguise) { | ||||
|   | ||||
| @@ -22,47 +22,6 @@ import com.google.gson.JsonSerializer; | ||||
| import com.google.gson.JsonSyntaxException; | ||||
| import com.mojang.authlib.properties.PropertyMap; | ||||
| import com.mojang.datafixers.util.Pair; | ||||
| import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.FileReader; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | ||||
| import java.io.PrintWriter; | ||||
| import java.lang.reflect.Array; | ||||
| import java.lang.reflect.Field; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.lang.reflect.Method; | ||||
| import java.lang.reflect.ParameterizedType; | ||||
| import java.lang.reflect.Type; | ||||
| import java.net.HttpURLConnection; | ||||
| import java.net.URL; | ||||
| import java.nio.charset.StandardCharsets; | ||||
| import java.nio.file.Files; | ||||
| import java.nio.file.StandardCopyOption; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Base64; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.LinkedHashMap; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.Optional; | ||||
| import java.util.Random; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
| import java.util.stream.Collectors; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| @@ -135,6 +94,48 @@ import org.bukkit.scoreboard.Team.Option; | ||||
| import org.bukkit.scoreboard.Team.OptionStatus; | ||||
| import org.bukkit.util.Vector; | ||||
|  | ||||
| import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.FileReader; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | ||||
| import java.io.PrintWriter; | ||||
| import java.lang.reflect.Array; | ||||
| import java.lang.reflect.Field; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.lang.reflect.Method; | ||||
| import java.lang.reflect.ParameterizedType; | ||||
| import java.lang.reflect.Type; | ||||
| import java.net.HttpURLConnection; | ||||
| import java.net.URL; | ||||
| import java.nio.charset.StandardCharsets; | ||||
| import java.nio.file.Files; | ||||
| import java.nio.file.StandardCopyOption; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Base64; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.LinkedHashMap; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.Optional; | ||||
| import java.util.Random; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| public class DisguiseUtilities { | ||||
|     @Setter | ||||
|     public static class DScoreTeam { | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| package me.libraryaddict.disguise.utilities; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox; | ||||
|  | ||||
| import java.util.HashMap; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 19/02/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -1,5 +1,13 @@ | ||||
| package me.libraryaddict.disguise.utilities; | ||||
|  | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.plugin.BisectHosting; | ||||
| import me.libraryaddict.disguise.utilities.plugin.PluginInformation; | ||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
| import org.bukkit.util.FileUtil; | ||||
|  | ||||
| import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.InputStream; | ||||
| @@ -8,13 +16,6 @@ import java.net.URL; | ||||
| import java.net.URLClassLoader; | ||||
| import java.nio.charset.StandardCharsets; | ||||
| import java.util.stream.Collectors; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.plugin.BisectHosting; | ||||
| import me.libraryaddict.disguise.utilities.plugin.PluginInformation; | ||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
| import org.bukkit.util.FileUtil; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 2/06/2017. | ||||
| @@ -171,8 +172,8 @@ public class LibsPremium { | ||||
|             try { | ||||
|                 plugin = getInformation(file); | ||||
|             } catch (ClassNotFoundException | NoClassDefFoundError ex) { | ||||
|                 DisguiseUtilities.getLogger().warning("Found an unrecognized jar in the LibsDisguises folder (" + file.getName() + | ||||
|                         ") - It may need replacing with a newer jar from SpigotMC"); | ||||
|                 DisguiseUtilities.getLogger().warning( | ||||
|                     "Found an unrecognized jar in the LibsDisguises folder (" + file.getName() + ") - It may need replacing with a newer jar from SpigotMC"); | ||||
|                 continue; | ||||
|             } catch (Exception ex) { | ||||
|                 DisguiseUtilities.getLogger().warning("Error while trying to handle the file " + file.getName()); | ||||
| @@ -186,10 +187,10 @@ public class LibsPremium { | ||||
|  | ||||
|             if (plugin.isPremium()) { | ||||
|                 if (!isValidVersion(version, plugin.getVersion()) || plugin.getUserID() == null || plugin.getDownloadID() == null || | ||||
|                         plugin.getUserID().equals("666666")) { | ||||
|                     plugin.getUserID().equals("666666")) { | ||||
|                     DisguiseUtilities.getLogger().warning("You have an old Lib's Disguises jar (" + file.getName() + " " + fileInfo + | ||||
|                             ") in the LibsDisguises folder! For security purposes, please replace this with a" + " new " + | ||||
|                             "version from SpigotMC - https://www.spigotmc.org/resources/libs-disguises.32453/"); | ||||
|                         ") in the LibsDisguises folder! For security purposes, please replace this with a" + " new " + | ||||
|                         "version from SpigotMC - https://www.spigotmc.org/resources/libs-disguises.32453/"); | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
| @@ -202,7 +203,7 @@ public class LibsPremium { | ||||
|  | ||||
|                 // >.> | ||||
|                 if (plugin.getBuildNumber() == null || !plugin.getBuildNumber().matches("#[0-9]+") || | ||||
|                         Integer.parseInt(plugin.getBuildNumber().substring(1)) < 300) { | ||||
|                     Integer.parseInt(plugin.getBuildNumber().substring(1)) < 300) { | ||||
|                     file.delete(); | ||||
|                     continue; | ||||
|                 } | ||||
| @@ -211,9 +212,9 @@ public class LibsPremium { | ||||
|                 // You have a non-premium Lib's Disguises jar (LibsDisguises.jar v5.2.6, build #40, created | ||||
|                 // 16/02/2019) in the LibsDisguises folder! | ||||
|                 DisguiseUtilities.getLogger() | ||||
|                         .warning("You have a non-premium Lib's Disguises jar (" + file.getName() + " " + fileInfo + ") in the LibsDisguises folder!"); | ||||
|                     .warning("You have a non-premium Lib's Disguises jar (" + file.getName() + " " + fileInfo + ") in the LibsDisguises folder!"); | ||||
|                 DisguiseUtilities.getLogger() | ||||
|                         .warning("Please place the premium jar downloaded from https://www.spigotmc" + ".org/resources/libs-disguises.32453/ " + "in here!"); | ||||
|                     .warning("Please place the premium jar downloaded from https://www.spigotmc" + ".org/resources/libs-disguises.32453/ " + "in here!"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -226,7 +227,7 @@ public class LibsPremium { | ||||
|                 thisPluginIsPaidFor = true; | ||||
|             } else { | ||||
|                 DisguiseUtilities.getLogger().warning("If you own the plugin, place the premium jar downloaded from https://www.spigotmc" + | ||||
|                         ".org/resources/libs-disguises.32453/ in plugins/LibsDisguises/"); | ||||
|                     ".org/resources/libs-disguises.32453/ in plugins/LibsDisguises/"); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @@ -279,7 +280,7 @@ public class LibsPremium { | ||||
|             } | ||||
|  | ||||
|             pluginInformation = new PluginInformation(LibsDisguises.getInstance().getFile().length(), getUserID(), getResourceID(), getDownloadID(), | ||||
|                     isPremium(getResourceID(), getUserID()), version, buildNo, pluginBuildDate); | ||||
|                 isPremium(getResourceID(), getUserID()), version, buildNo, pluginBuildDate); | ||||
|         } | ||||
|  | ||||
|         if (!isPremium() || !LibsDisguises.getInstance().isReleaseBuild()) { | ||||
| @@ -303,7 +304,7 @@ public class LibsPremium { | ||||
|                         DisguiseUtilities.getLogger().info("Ew, I don't recognize " + f.getName()); | ||||
|                         continue; | ||||
|                     } else if (Integer.parseInt(info.getBuildNumber().replace("#", "")) < | ||||
|                             Integer.parseInt(LibsDisguises.getInstance().getBuildNo().replace("#", ""))) { | ||||
|                         Integer.parseInt(LibsDisguises.getInstance().getBuildNo().replace("#", ""))) { | ||||
|                         f.delete(); | ||||
|                         DisguiseUtilities.getLogger().info("Ew, " + f.getName() + " is so old"); | ||||
|                         continue; | ||||
|   | ||||
| @@ -2,10 +2,6 @@ package me.libraryaddict.disguise.utilities; | ||||
|  | ||||
| import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||||
| import com.mojang.authlib.GameProfile; | ||||
| import java.io.File; | ||||
| import java.util.Locale; | ||||
| import java.util.UUID; | ||||
| import java.util.regex.Pattern; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.mineskin.MineSkinResponse; | ||||
| import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup; | ||||
| @@ -13,6 +9,11 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.util.Locale; | ||||
| import java.util.UUID; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/01/2020. | ||||
|  */ | ||||
| @@ -35,8 +36,7 @@ public class SkinUtils { | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 try { | ||||
|                     MineSkinResponse response = DisguiseUtilities.getMineSkinAPI() | ||||
|                             .generateFromFile(callback, file, modelType); | ||||
|                     MineSkinResponse response = DisguiseUtilities.getMineSkinAPI().generateFromFile(callback, file, modelType); | ||||
|  | ||||
|                     new BukkitRunnable() { | ||||
|                         @Override | ||||
| @@ -51,8 +51,7 @@ public class SkinUtils { | ||||
|                             handleProfile(response.getGameProfile(), modelType, callback); | ||||
|                         } | ||||
|                     }.runTask(LibsDisguises.getInstance()); | ||||
|                 } | ||||
|                 catch (IllegalArgumentException e) { | ||||
|                 } catch (IllegalArgumentException e) { | ||||
|                     new BukkitRunnable() { | ||||
|                         @Override | ||||
|                         public void run() { | ||||
| @@ -68,8 +67,7 @@ public class SkinUtils { | ||||
|         new BukkitRunnable() { | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 MineSkinResponse response = DisguiseUtilities.getMineSkinAPI() | ||||
|                         .generateFromUrl(callback, url, modelType); | ||||
|                 MineSkinResponse response = DisguiseUtilities.getMineSkinAPI().generateFromUrl(callback, url, modelType); | ||||
|  | ||||
|                 new BukkitRunnable() { | ||||
|                     @Override | ||||
| @@ -130,8 +128,7 @@ public class SkinUtils { | ||||
|         new BukkitRunnable() { | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 WrappedGameProfile profile = ReflectionManager | ||||
|                         .getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated")); | ||||
|                 WrappedGameProfile profile = ReflectionManager.getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated")); | ||||
|  | ||||
|                 new BukkitRunnable() { | ||||
|                     @Override | ||||
| @@ -183,8 +180,8 @@ public class SkinUtils { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             File file = new File(LibsDisguises.getInstance().getDataFolder(), | ||||
|                     "/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png")); | ||||
|             File file = | ||||
|                 new File(LibsDisguises.getInstance().getDataFolder(), "/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png")); | ||||
|  | ||||
|             if (!file.exists()) { | ||||
|                 file = null; | ||||
| @@ -208,8 +205,7 @@ public class SkinUtils { | ||||
|                         callback.onInfo(LibsMsg.SKIN_API_USING_UUID); | ||||
|                         handleUUID(uuid, modelType, callback); | ||||
|                         return; | ||||
|                     } | ||||
|                     catch (Exception ignored) { | ||||
|                     } catch (Exception ignored) { | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,5 @@ | ||||
| package me.libraryaddict.disguise.utilities.config; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.io.PrintWriter; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| @@ -15,6 +10,12 @@ import org.apache.commons.lang.StringUtils; | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.io.PrintWriter; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 31/01/2021. | ||||
|  */ | ||||
|   | ||||
| @@ -1,6 +1,14 @@ | ||||
| package me.libraryaddict.disguise.utilities.config; | ||||
|  | ||||
| import com.google.common.base.Strings; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import org.bukkit.configuration.ConfigurationSection; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
| import org.bukkit.plugin.PluginDescriptionFile; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | ||||
| @@ -12,13 +20,6 @@ import java.util.Collection; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import org.bukkit.configuration.ConfigurationSection; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
| import org.bukkit.plugin.PluginDescriptionFile; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 28/01/2021. | ||||
| @@ -103,8 +104,8 @@ public class DisguiseCommandConfig { | ||||
|         configString = configString.replaceAll("\n([a-zA-Z])", "\n\n$1"); | ||||
|  | ||||
|         String s = | ||||
|                 "# The following can be changed to modify how the disguise commands are registered\n# This will only work on server startup\nModifyCommands: " + | ||||
|                         modifyCommands + "\n\n" + configString; | ||||
|             "# The following can be changed to modify how the disguise commands are registered\n# This will only work on server startup\nModifyCommands: " + | ||||
|                 modifyCommands + "\n\n" + configString; | ||||
|  | ||||
|         commandConfig.delete(); | ||||
|  | ||||
|   | ||||
| @@ -6,18 +6,17 @@ import com.google.gson.JsonElement; | ||||
| import com.google.gson.JsonParseException; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
| import java.lang.reflect.Type; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.block.data.BlockData; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 27/11/2018. | ||||
|  */ | ||||
| public class SerializerBlockData implements JsonDeserializer<BlockData>, | ||||
|         JsonSerializer<BlockData> { | ||||
| public class SerializerBlockData implements JsonDeserializer<BlockData>, JsonSerializer<BlockData> { | ||||
|     @Override | ||||
|     public BlockData deserialize(JsonElement json, Type typeOfT, | ||||
|             JsonDeserializationContext context) throws JsonParseException { | ||||
|     public BlockData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||||
|         return Bukkit.createBlockData(json.getAsString()); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -7,17 +7,16 @@ import com.google.gson.JsonElement; | ||||
| import com.google.gson.JsonParseException; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 27/11/2018. | ||||
|  */ | ||||
| public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>, | ||||
|         JsonSerializer<WrappedChatComponent> { | ||||
| public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>, JsonSerializer<WrappedChatComponent> { | ||||
|  | ||||
|     @Override | ||||
|     public WrappedChatComponent deserialize(JsonElement json, Type typeOfT, | ||||
|             JsonDeserializationContext context) throws JsonParseException { | ||||
|     public WrappedChatComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||||
|         if (json.isJsonPrimitive()) { | ||||
|             return WrappedChatComponent.fromJson(json.getAsString()); | ||||
|         } | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import com.google.gson.JsonDeserializer; | ||||
| import com.google.gson.JsonElement; | ||||
| import com.google.gson.JsonObject; | ||||
| import com.google.gson.JsonParseException; | ||||
| import java.lang.reflect.Type; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.disguisetypes.MiscDisguise; | ||||
| @@ -14,6 +13,8 @@ import me.libraryaddict.disguise.disguisetypes.MobDisguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/06/2017. | ||||
|  */ | ||||
|   | ||||
| @@ -9,12 +9,6 @@ import com.google.gson.JsonElement; | ||||
| import com.google.gson.JsonObject; | ||||
| import com.google.gson.JsonParseException; | ||||
| import com.google.gson.internal.LinkedTreeMap; | ||||
| import java.lang.reflect.Field; | ||||
| import java.lang.reflect.ParameterizedType; | ||||
| import java.lang.reflect.Type; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import java.util.Optional; | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.disguisetypes.EntityPose; | ||||
| @@ -28,6 +22,13 @@ import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoParticle | ||||
| import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.lang.reflect.Field; | ||||
| import java.lang.reflect.ParameterizedType; | ||||
| import java.lang.reflect.Type; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import java.util.Optional; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/06/2017. | ||||
|  */ | ||||
| @@ -57,7 +58,7 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Ins | ||||
|     } | ||||
|  | ||||
|     private void correct(FlagWatcher watcher, Class<? extends FlagWatcher> flagWatcher, String name) | ||||
|             throws NoSuchFieldException, IllegalAccessException, DisguiseParseException { | ||||
|         throws NoSuchFieldException, IllegalAccessException, DisguiseParseException { | ||||
|         Field field = FlagWatcher.class.getDeclaredField(name); | ||||
|         field.setAccessible(true); | ||||
|         HashMap<Integer, Object> map = (HashMap<Integer, Object>) field.get(watcher); | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import com.google.gson.JsonParseException; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
| import com.mojang.authlib.GameProfile; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| @@ -23,14 +24,13 @@ public class SerializerGameProfile implements JsonSerializer<WrappedGameProfile> | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public WrappedGameProfile deserialize(JsonElement json, Type typeOfT, | ||||
|             JsonDeserializationContext context) throws JsonParseException { | ||||
|     public WrappedGameProfile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||||
|         JsonObject obj = json.getAsJsonObject(); | ||||
|  | ||||
|         if (obj.has("id") && !obj.get("id").getAsString().contains("-")) { | ||||
|             obj.addProperty("id", | ||||
|                     Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)") | ||||
|                             .matcher(obj.get("id").getAsString()).replaceFirst("$1-$2-$3-$4-$5")); | ||||
|                 Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)").matcher(obj.get("id").getAsString()) | ||||
|                     .replaceFirst("$1-$2-$3-$4-$5")); | ||||
|         } | ||||
|  | ||||
|         return WrappedGameProfile.fromHandle(context.deserialize(json, GameProfile.class)); | ||||
|   | ||||
| @@ -6,13 +6,14 @@ import com.google.gson.JsonElement; | ||||
| import com.google.gson.JsonParseException; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
| import java.lang.reflect.Type; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
| import org.bukkit.inventory.meta.ItemMeta; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/06/2017. | ||||
|  */ | ||||
| @@ -30,8 +31,7 @@ public class SerializerItemStack implements JsonSerializer<ItemStack>, JsonDeser | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ItemStack deserialize(JsonElement json, Type typeOfT, | ||||
|             JsonDeserializationContext context) throws JsonParseException { | ||||
|     public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||||
|         HashMap map = context.deserialize(json, HashMap.class); | ||||
|  | ||||
|         if (map.containsKey("meta")) { | ||||
|   | ||||
| @@ -7,9 +7,10 @@ import com.google.gson.JsonObject; | ||||
| import com.google.gson.JsonParseException; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
| import java.lang.reflect.Type; | ||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/06/2017. | ||||
|  */ | ||||
| @@ -24,18 +25,19 @@ public class SerializerMetaIndex implements JsonSerializer<MetaIndex>, JsonDeser | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public MetaIndex deserialize(JsonElement json, Type typeOfT, | ||||
|             JsonDeserializationContext context) throws JsonParseException { | ||||
|     public MetaIndex deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||||
|         JsonObject obj = json.getAsJsonObject(); | ||||
|         String name = obj.get("flagwatcher").getAsString(); | ||||
|         int index = obj.get("index").getAsInt(); | ||||
|  | ||||
|         for (MetaIndex i : MetaIndex.values()) { | ||||
|             if (i.getIndex() != index) | ||||
|             if (i.getIndex() != index) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             if (!i.getFlagWatcher().getSimpleName().equals(name)) | ||||
|             if (!i.getFlagWatcher().getSimpleName().equals(name)) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             return i; | ||||
|         } | ||||
|   | ||||
| @@ -4,9 +4,10 @@ import com.comphenix.protocol.wrappers.WrappedParticle; | ||||
| import com.google.gson.JsonElement; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
| import java.lang.reflect.Type; | ||||
| import me.libraryaddict.disguise.utilities.params.ParamInfoManager; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 5/12/2020. | ||||
|  */ | ||||
|   | ||||
| @@ -8,14 +8,14 @@ import com.google.gson.JsonObject; | ||||
| import com.google.gson.JsonParseException; | ||||
| import com.google.gson.JsonSerializationContext; | ||||
| import com.google.gson.JsonSerializer; | ||||
| import java.lang.reflect.Type; | ||||
| import org.bukkit.Material; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 1/06/2017. | ||||
|  */ | ||||
| public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockData>, | ||||
|         JsonDeserializer<WrappedBlockData> { | ||||
| public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockData>, JsonDeserializer<WrappedBlockData> { | ||||
|  | ||||
|     @Override | ||||
|     public JsonElement serialize(WrappedBlockData src, Type typeOfSrc, JsonSerializationContext context) { | ||||
| @@ -26,8 +26,7 @@ public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockDa | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public WrappedBlockData deserialize(JsonElement json, Type typeOfT, | ||||
|             JsonDeserializationContext context) throws JsonParseException { | ||||
|     public WrappedBlockData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||||
|         JsonObject obj = json.getAsJsonObject(); | ||||
|  | ||||
|         return WrappedBlockData.createData(Material.valueOf(obj.get("type").getAsString()), obj.get("data").getAsInt()); | ||||
|   | ||||
| @@ -6,11 +6,6 @@ import com.comphenix.protocol.events.PacketContainer; | ||||
| import com.comphenix.protocol.reflect.StructureModifier; | ||||
| import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; | ||||
| import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.HashMap; | ||||
| import java.util.Optional; | ||||
| import java.util.Random; | ||||
| import java.util.Set; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| @@ -64,6 +59,12 @@ import org.bukkit.inventory.ItemStack; | ||||
| import org.bukkit.metadata.FixedMetadataValue; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.HashMap; | ||||
| import java.util.Optional; | ||||
| import java.util.Random; | ||||
| import java.util.Set; | ||||
|  | ||||
| public class DisguiseListener implements Listener { | ||||
|     private HashMap<String, LibsEntityInteract> interactions = new HashMap<>(); | ||||
|     private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<>(); | ||||
| @@ -187,7 +188,7 @@ public class DisguiseListener implements Listener { | ||||
|  | ||||
|     private boolean canRetaliate(Entity entity) { | ||||
|         return entity.hasMetadata("LD-LastAttacked") && | ||||
|                 entity.getMetadata("LD-LastAttacked").get(0).asLong() + (DisguiseConfig.getPvPTimer() * 1000) > System.currentTimeMillis(); | ||||
|             entity.getMetadata("LD-LastAttacked").get(0).asLong() + (DisguiseConfig.getPvPTimer() * 1000) > System.currentTimeMillis(); | ||||
|     } | ||||
|  | ||||
|     private void setRetaliation(Entity entity) { | ||||
| @@ -484,7 +485,7 @@ public class DisguiseListener implements Listener { | ||||
|  | ||||
|                 if (!p.hasMetadata("forge_mods")) { | ||||
|                     Optional<ModdedEntity> required = | ||||
|                             ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny(); | ||||
|                         ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny(); | ||||
|  | ||||
|                     required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired())); | ||||
|                 } | ||||
| @@ -508,7 +509,7 @@ public class DisguiseListener implements Listener { | ||||
|  | ||||
|                 if (!p.hasMetadata("forge_mods")) { | ||||
|                     Optional<ModdedEntity> required = | ||||
|                             ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny(); | ||||
|                         ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny(); | ||||
|  | ||||
|                     required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired())); | ||||
|                 } | ||||
| @@ -661,7 +662,7 @@ public class DisguiseListener implements Listener { | ||||
|         Location from = event.getFrom(); | ||||
|  | ||||
|         if (!player.isOp() && !player.hasPermission("minecraft.command.teleport") && LibsPremium.getPaidInformation() != null && | ||||
|                 LibsPremium.getPaidInformation().getUserID().equals("1592")) { | ||||
|             LibsPremium.getPaidInformation().getUserID().equals("1592")) { | ||||
|             player.sendMessage(ChatColor.GOLD + "Your teleport was a success!"); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -14,15 +14,17 @@ import org.bukkit.event.Listener; | ||||
| public class PaperDisguiseListener implements Listener { | ||||
|     @EventHandler | ||||
|     public void onEntityLoad(EntityAddToWorldEvent event) { | ||||
|         if (!DisguiseConfig.isSaveEntityDisguises()) | ||||
|         if (!DisguiseConfig.isSaveEntityDisguises()) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         Entity entity = event.getEntity(); | ||||
|  | ||||
|         Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity.getUniqueId(), true); | ||||
|  | ||||
|         if (disguises.length <= 0) | ||||
|         if (disguises.length <= 0) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         DisguiseUtilities.resetPluginTimer(); | ||||
|  | ||||
|   | ||||
| @@ -10,13 +10,6 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher; | ||||
| import com.google.common.cache.Cache; | ||||
| import com.google.common.cache.CacheBuilder; | ||||
| import com.google.common.cache.RemovalCause; | ||||
| import java.lang.ref.WeakReference; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import lombok.Getter; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.Setter; | ||||
| @@ -37,6 +30,14 @@ import org.bukkit.event.Listener; | ||||
| import org.bukkit.event.player.PlayerMoveEvent; | ||||
| import org.bukkit.scheduler.BukkitRunnable; | ||||
|  | ||||
| import java.lang.ref.WeakReference; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 15/09/2020. | ||||
|  */ | ||||
| @@ -57,7 +58,7 @@ public class PlayerSkinHandler implements Listener { | ||||
|  | ||||
|         public boolean canRemove(boolean onMoved) { | ||||
|             return firstPacketSent + (DisguiseConfig.getTablistRemoveDelay() * 50) + (onMoved ? 0 : DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50) < | ||||
|                     System.currentTimeMillis(); | ||||
|                 System.currentTimeMillis(); | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
| @@ -75,20 +76,20 @@ public class PlayerSkinHandler implements Listener { | ||||
|  | ||||
|     @Getter | ||||
|     private final Cache<Player, List<PlayerSkin>> cache = | ||||
|             CacheBuilder.newBuilder().weakKeys().expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS) | ||||
|                     .removalListener((event) -> { | ||||
|                         if (event.getCause() != RemovalCause.EXPIRED) { | ||||
|                             return; | ||||
|                         } | ||||
|         CacheBuilder.newBuilder().weakKeys().expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS) | ||||
|             .removalListener((event) -> { | ||||
|                 if (event.getCause() != RemovalCause.EXPIRED) { | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                         List<PlayerSkin> skins = (List<PlayerSkin>) event.getValue(); | ||||
|                 List<PlayerSkin> skins = (List<PlayerSkin>) event.getValue(); | ||||
|  | ||||
|                         for (PlayerSkin skin : skins) { | ||||
|                             doPacketRemoval((Player) event.getKey(), skin); | ||||
|                         } | ||||
|                 for (PlayerSkin skin : skins) { | ||||
|                     doPacketRemoval((Player) event.getKey(), skin); | ||||
|                 } | ||||
|  | ||||
|                         skins.clear(); | ||||
|                     }).build(); | ||||
|                 skins.clear(); | ||||
|             }).build(); | ||||
|  | ||||
|     public PlayerSkinHandler() { | ||||
|         new BukkitRunnable() { | ||||
| @@ -261,8 +262,8 @@ public class PlayerSkinHandler implements Listener { | ||||
|         WrappedDataWatcher watcher = DisguiseUtilities.createSanitizedDataWatcher(player, WrappedDataWatcher.getEntityWatcher(entity), disguise.getWatcher()); | ||||
|  | ||||
|         PacketContainer metaPacket = | ||||
|                 ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true) | ||||
|                         .createPacket(entity.getEntityId(), watcher, true); | ||||
|             ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true) | ||||
|                 .createPacket(entity.getEntityId(), watcher, true); | ||||
|  | ||||
|         ProtocolLibrary.getProtocolManager().sendServerPacket(player, metaPacket, false); | ||||
|     } | ||||
|   | ||||
| @@ -3,6 +3,13 @@ package me.libraryaddict.disguise.utilities.metrics; | ||||
| import com.google.gson.Gson; | ||||
| import com.google.gson.JsonArray; | ||||
| import com.google.gson.JsonObject; | ||||
| import javax.net.ssl.HttpsURLConnection; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
| import org.bukkit.plugin.ServicePriority; | ||||
| import org.bukkit.plugin.java.JavaPlugin; | ||||
|  | ||||
| import java.io.ByteArrayOutputStream; | ||||
| import java.io.DataOutputStream; | ||||
| import java.io.File; | ||||
| @@ -20,12 +27,6 @@ import java.util.TimerTask; | ||||
| import java.util.UUID; | ||||
| import java.util.logging.Level; | ||||
| import java.util.zip.GZIPOutputStream; | ||||
| import javax.net.ssl.HttpsURLConnection; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.configuration.file.YamlConfiguration; | ||||
| import org.bukkit.plugin.ServicePriority; | ||||
| import org.bukkit.plugin.java.JavaPlugin; | ||||
|  | ||||
| /** | ||||
|  * bStats collects some data for plugin authors. | ||||
| @@ -37,11 +38,9 @@ public class Metrics { | ||||
|     static { | ||||
|         // Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D | ||||
|         final String defaultPackage = new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'}); | ||||
|         final String examplePackage = new String( | ||||
|                 new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); | ||||
|         final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); | ||||
|         // We want to make sure nobody just copy & pastes the example and use the wrong package names | ||||
|         if (Metrics.class.getPackage().getName().equals(defaultPackage) || | ||||
|                 Metrics.class.getPackage().getName().equals(examplePackage)) { | ||||
|         if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { | ||||
|             throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); | ||||
|         } | ||||
|     } | ||||
| @@ -95,16 +94,13 @@ public class Metrics { | ||||
|             config.addDefault("logFailedRequests", false); | ||||
|  | ||||
|             // Inform the server owners about bStats | ||||
|             config.options() | ||||
|                     .header("bStats collects some data for plugin authors like how many servers are using their " + | ||||
|                             "plugins.\n" + "To honor their work, you should not disable it.\n" + | ||||
|                             "This has nearly no effect on the server performance!\n" + | ||||
|                             "Check out https://bStats.org/ to learn more :)").copyDefaults(true); | ||||
|             config.options().header("bStats collects some data for plugin authors like how many servers are using their " + "plugins.\n" + | ||||
|                 "To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" + | ||||
|                 "Check out https://bStats.org/ to learn more :)").copyDefaults(true); | ||||
|             try { | ||||
|                 config.save(configFile); | ||||
|                 DisguiseUtilities.getLogger().info("Saved bStats config"); | ||||
|             } | ||||
|             catch (IOException ignored) { | ||||
|             } catch (IOException ignored) { | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -119,8 +115,7 @@ public class Metrics { | ||||
|                     service.getField("B_STATS_VERSION"); // Our identifier :) | ||||
|                     found = true; // We aren't the first | ||||
|                     break; | ||||
|                 } | ||||
|                 catch (NoSuchFieldException ignored) { | ||||
|                 } catch (NoSuchFieldException ignored) { | ||||
|                 } | ||||
|             } | ||||
|             // Register our service | ||||
| @@ -249,15 +244,13 @@ public class Metrics { | ||||
|         for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) { | ||||
|             try { | ||||
|                 service.getField("B_STATS_VERSION"); // Our identifier :) | ||||
|             } | ||||
|             catch (NoSuchFieldException ignored) { | ||||
|             } catch (NoSuchFieldException ignored) { | ||||
|                 continue; // Continue "searching" | ||||
|             } | ||||
|             // Found one! | ||||
|             try { | ||||
|                 pluginData.add(new Gson().toJson(service.getMethod("getPluginData").invoke(Bukkit.getServicesManager().load(service)))); | ||||
|             } | ||||
|             catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { | ||||
|             } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -270,12 +263,10 @@ public class Metrics { | ||||
|                 try { | ||||
|                     // Send the data | ||||
|                     sendData(data); | ||||
|                 } | ||||
|                 catch (Exception e) { | ||||
|                 } catch (Exception e) { | ||||
|                     // Something went wrong! :( | ||||
|                     if (logFailedRequests) { | ||||
|                         plugin.getLogger() | ||||
|                                 .log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); | ||||
|                         plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| @@ -367,8 +358,7 @@ public class Metrics { | ||||
|                     return null; | ||||
|                 } | ||||
|                 chart.add("data", data); | ||||
|             } | ||||
|             catch (Throwable t) { | ||||
|             } catch (Throwable t) { | ||||
|                 if (logFailedRequests) { | ||||
|                     Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t); | ||||
|                 } | ||||
|   | ||||
| @@ -1,8 +1,5 @@ | ||||
| package me.libraryaddict.disguise.utilities.metrics; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.HashMap; | ||||
| import java.util.Set; | ||||
| import me.libraryaddict.disguise.DisguiseAPI; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| @@ -12,6 +9,10 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | ||||
| import me.libraryaddict.disguise.utilities.plugin.PluginInformation; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.HashMap; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 3/01/2019. | ||||
|  */ | ||||
| @@ -49,8 +50,8 @@ public class MetricsInitalizer { | ||||
|                 info = LibsPremium.getPluginInformation(); | ||||
|             } | ||||
|  | ||||
|             boolean customPremium = !info.getUserID().matches("[0-9]+") || info.getUserID().equals("1") || | ||||
|                     !info.getResourceID().equals("32453") || !info.getDownloadID().matches("-?[0-9]+"); | ||||
|             boolean customPremium = !info.getUserID().matches("[0-9]+") || info.getUserID().equals("1") || !info.getResourceID().equals("32453") || | ||||
|                 !info.getDownloadID().matches("-?[0-9]+"); | ||||
|  | ||||
|             if (customPremium) { | ||||
|                 if (plugin.isReleaseBuild() && LibsPremium.getPaidInformation() == null) { | ||||
| @@ -137,8 +138,9 @@ public class MetricsInitalizer { | ||||
|             public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) { | ||||
|                 for (Set<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) { | ||||
|                     for (Disguise disg : list) { | ||||
|                         if (disg.getEntity() == null || !disg.isDisguiseInUse()) | ||||
|                         if (disg.getEntity() == null || !disg.isDisguiseInUse()) { | ||||
|                             continue; | ||||
|                         } | ||||
|  | ||||
|                         String name = disg.getEntity().getType().name(); | ||||
|  | ||||
| @@ -155,8 +157,9 @@ public class MetricsInitalizer { | ||||
|             public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) { | ||||
|                 for (Set<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) { | ||||
|                     for (Disguise disg : list) { | ||||
|                         if (disg.getEntity() == null || !disg.isDisguiseInUse()) | ||||
|                         if (disg.getEntity() == null || !disg.isDisguiseInUse()) { | ||||
|                             continue; | ||||
|                         } | ||||
|  | ||||
|                         String name = disg.getType().name(); | ||||
|  | ||||
| @@ -194,20 +197,22 @@ public class MetricsInitalizer { | ||||
|                     disgs += set.size(); | ||||
|                 } | ||||
|  | ||||
|                 if (disgs == 0) | ||||
|                 if (disgs == 0) { | ||||
|                     return "0"; | ||||
|                 if (disgs <= 5) | ||||
|                 } | ||||
|                 if (disgs <= 5) { | ||||
|                     return "1 to 5"; | ||||
|                 else if (disgs <= 15) | ||||
|                 } else if (disgs <= 15) { | ||||
|                     return "6 to 15"; | ||||
|                 else if (disgs <= 30) | ||||
|                 } else if (disgs <= 30) { | ||||
|                     return "16 to 30"; | ||||
|                 else if (disgs <= 60) | ||||
|                 } else if (disgs <= 60) { | ||||
|                     return "30 to 60"; | ||||
|                 else if (disgs <= 100) | ||||
|                 } else if (disgs <= 100) { | ||||
|                     return "60 to 100"; | ||||
|                 else if (disgs <= 200) | ||||
|                 } else if (disgs <= 200) { | ||||
|                     return "100 to 200"; | ||||
|                 } | ||||
|  | ||||
|                 return "More than 200"; | ||||
|             } | ||||
| @@ -233,8 +238,7 @@ public class MetricsInitalizer { | ||||
|                 try { | ||||
|                     Class.forName("org.spigotmc.SpigotConfig"); | ||||
|                     return "Yes"; | ||||
|                 } | ||||
|                 catch (Exception ex) { | ||||
|                 } catch (Exception ex) { | ||||
|                     return "No"; | ||||
|                 } | ||||
|             } | ||||
| @@ -275,13 +279,15 @@ public class MetricsInitalizer { | ||||
|  | ||||
|                 Collection<Set<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values(); | ||||
|  | ||||
|                 if (list.isEmpty()) | ||||
|                 if (list.isEmpty()) { | ||||
|                     return "Unknown"; | ||||
|                 } | ||||
|  | ||||
|                 for (Set<TargetedDisguise> dList : list) { | ||||
|                     for (TargetedDisguise disg : dList) { | ||||
|                         if (disg.getObservers().isEmpty()) | ||||
|                         if (disg.getObservers().isEmpty()) { | ||||
|                             continue; | ||||
|                         } | ||||
|  | ||||
|                         targetedDisguises = true; | ||||
|                         return "Yes"; | ||||
|   | ||||
| @@ -1,6 +1,13 @@ | ||||
| package me.libraryaddict.disguise.utilities.mineskin; | ||||
|  | ||||
| import com.google.gson.Gson; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.SkinUtils; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
|  | ||||
| import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| @@ -18,12 +25,6 @@ import java.util.UUID; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.concurrent.locks.ReentrantLock; | ||||
| import java.util.stream.Collectors; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.SkinUtils; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 28/12/2019. | ||||
| @@ -164,8 +165,8 @@ public class MineSkinAPI { | ||||
|             printDebug("Received status code: " + connection.getResponseCode()); | ||||
|  | ||||
|             if (connection.getResponseCode() == 500) { | ||||
|                 String errorMessage = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8)).lines() | ||||
|                         .collect(Collectors.joining("\n")); | ||||
|                 String errorMessage = | ||||
|                     new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n")); | ||||
|  | ||||
|                 APIError error = new Gson().fromJson(errorMessage, APIError.class); | ||||
|  | ||||
| @@ -220,7 +221,7 @@ public class MineSkinAPI { | ||||
|         } catch (Exception ex) { | ||||
|             try { | ||||
|                 if (connection != null && (connection.getResponseCode() == 524 || connection.getResponseCode() == 408 || connection.getResponseCode() == 504 || | ||||
|                         connection.getResponseCode() == 599)) { | ||||
|                     connection.getResponseCode() == 599)) { | ||||
|                     if (getApiKey() != null && connection.getResponseCode() == 504) { | ||||
|                         callback.onError(LibsMsg.SKIN_API_TIMEOUT_API_KEY_ERROR); | ||||
|                     } else { | ||||
|   | ||||
| @@ -3,10 +3,11 @@ package me.libraryaddict.disguise.utilities.mineskin; | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import com.mojang.authlib.GameProfile; | ||||
| import com.mojang.authlib.properties.Property; | ||||
| import java.util.UUID; | ||||
| import lombok.Getter; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
|  | ||||
| import java.util.UUID; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 29/12/2019. | ||||
|  */ | ||||
|   | ||||
| @@ -4,14 +4,6 @@ import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.comphenix.protocol.utility.StreamSerializer; | ||||
| import com.google.common.cache.Cache; | ||||
| import com.google.common.cache.CacheBuilder; | ||||
| import java.io.ByteArrayOutputStream; | ||||
| import java.io.DataOutputStream; | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import lombok.Getter; | ||||
| import me.libraryaddict.disguise.DisguiseConfig; | ||||
| import me.libraryaddict.disguise.LibsDisguises; | ||||
| @@ -25,6 +17,15 @@ import org.bukkit.NamespacedKey; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.metadata.FixedMetadataValue; | ||||
|  | ||||
| import java.io.ByteArrayOutputStream; | ||||
| import java.io.DataOutputStream; | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 14/04/2020. | ||||
|  */ | ||||
| @@ -36,8 +37,7 @@ public class ModdedManager { | ||||
|     @Getter | ||||
|     private static byte[] fmlRegistries; | ||||
|     @Getter | ||||
|     private static final Cache<String, ArrayList<String>> forgeMods = CacheBuilder.newBuilder() | ||||
|             .expireAfterWrite(1, TimeUnit.MINUTES).build(); | ||||
|     private static final Cache<String, ArrayList<String>> forgeMods = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(); | ||||
|  | ||||
|     public ModdedManager(ArrayList<String> channels) { | ||||
|         if (getEntities().isEmpty()) { | ||||
| @@ -80,8 +80,7 @@ public class ModdedManager { | ||||
|  | ||||
|             // Only this one thx | ||||
|             // s.serializeString(output, "minecraft:entity_type"); | ||||
|         } | ||||
|         catch (IOException e) { | ||||
|         } catch (IOException e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|  | ||||
| @@ -123,8 +122,7 @@ public class ModdedManager { | ||||
|  | ||||
|             // Or dummied. What is dummied anyways. What are these others? | ||||
|             s.serializeVarInt(output, 0); | ||||
|         } | ||||
|         catch (IOException e) { | ||||
|         } catch (IOException e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|  | ||||
| @@ -202,9 +200,7 @@ public class ModdedManager { | ||||
|         ArrayList<DisguisePerm> perms = new ArrayList<>(); | ||||
|  | ||||
|         for (Map.Entry<NamespacedKey, ModdedEntity> entry : entities.entrySet()) { | ||||
|             perms.add(new DisguisePerm( | ||||
|                     entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC, | ||||
|                     entry.getValue().getName())); | ||||
|             perms.add(new DisguisePerm(entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC, entry.getValue().getName())); | ||||
|         } | ||||
|  | ||||
|         return perms; | ||||
|   | ||||
| @@ -5,11 +5,6 @@ import com.comphenix.protocol.ProtocolLibrary; | ||||
| import com.comphenix.protocol.events.PacketContainer; | ||||
| import com.comphenix.protocol.reflect.StructureModifier; | ||||
| import com.mojang.datafixers.util.Pair; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import lombok.Getter; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.Setter; | ||||
| @@ -23,6 +18,12 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.inventory.EquipmentSlot; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * Created by libraryaddict on 3/01/2019. | ||||
|  */ | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user