From e0bbcbd43ef5eff47415f217d95592c8331e7d24 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 2 Feb 2022 20:16:24 +1300 Subject: [PATCH] Fix imports, run code formatter --- .../libraryaddict/disguise/DisguiseAPI.java | 15 +- .../disguise/DisguiseConfig.java | 48 ++-- .../libraryaddict/disguise/LibsDisguises.java | 27 +-- .../commands/DisguiseBaseCommand.java | 25 +- .../commands/LibsDisguisesCommand.java | 25 +- .../commands/disguise/DisguiseCommand.java | 12 +- .../disguise/DisguiseEntityCommand.java | 7 +- .../disguise/DisguisePlayerCommand.java | 17 +- .../disguise/DisguiseRadiusCommand.java | 12 +- .../interactions/CopyDisguiseInteraction.java | 8 +- .../DisguiseModifyInteraction.java | 5 +- .../UndisguiseEntityInteraction.java | 10 +- .../commands/libsdisguises/LDChangelog.java | 8 +- .../commands/libsdisguises/LDCommand.java | 3 +- .../commands/libsdisguises/LDConfig.java | 7 +- .../commands/libsdisguises/LDCount.java | 21 +- .../libsdisguises/LDDebugMineSkin.java | 5 +- .../commands/libsdisguises/LDDebugPlayer.java | 26 +-- .../commands/libsdisguises/LDHelp.java | 5 +- .../commands/libsdisguises/LDJson.java | 10 +- .../commands/libsdisguises/LDMetaInfo.java | 33 +-- .../commands/libsdisguises/LDMods.java | 8 +- .../commands/libsdisguises/LDPermTest.java | 8 +- .../commands/libsdisguises/LDReload.java | 5 +- .../commands/libsdisguises/LDScoreboard.java | 52 ++--- .../commands/libsdisguises/LDUpdate.java | 5 +- .../libsdisguises/LDUpdateProtocolLib.java | 13 +- .../commands/libsdisguises/LDUploadLogs.java | 35 +-- .../modify/DisguiseModifyCommand.java | 23 +- .../modify/DisguiseModifyEntityCommand.java | 12 +- .../modify/DisguiseModifyPlayerCommand.java | 35 ++- .../modify/DisguiseModifyRadiusCommand.java | 13 +- .../undisguise/UndisguiseCommand.java | 6 +- .../undisguise/UndisguiseEntityCommand.java | 9 +- .../undisguise/UndisguisePlayerCommand.java | 40 ++-- .../undisguise/UndisguiseRadiusCommand.java | 9 +- .../commands/utils/CopyDisguiseCommand.java | 15 +- .../commands/utils/DisguiseCloneCommand.java | 10 +- .../commands/utils/DisguiseHelpCommand.java | 36 ++- .../commands/utils/GrabHeadCommand.java | 12 +- .../commands/utils/GrabSkinCommand.java | 8 +- .../commands/utils/SaveDisguiseCommand.java | 9 +- .../disguise/disguisetypes/AnimalColor.java | 14 +- .../disguise/disguisetypes/Disguise.java | 46 ++-- .../disguisetypes/DisguiseRunnable.java | 11 +- .../disguise/disguisetypes/DisguiseType.java | 3 +- .../disguise/disguisetypes/FlagWatcher.java | 17 +- .../disguise/disguisetypes/LibsEquipment.java | 4 +- .../disguise/disguisetypes/MetaIndex.java | 42 ++-- .../disguise/disguisetypes/MiscDisguise.java | 14 +- .../disguise/disguisetypes/MobDisguise.java | 14 +- .../disguisetypes/ModdedDisguise.java | 6 +- .../disguisetypes/PlayerDisguise.java | 3 +- .../disguisetypes/TargetedDisguise.java | 33 ++- .../watchers/AbstractHorseWatcher.java | 5 +- .../watchers/ArmorStandWatcher.java | 3 +- .../disguisetypes/watchers/CatWatcher.java | 3 +- .../watchers/CreeperWatcher.java | 6 +- .../watchers/DroppedItemWatcher.java | 3 +- .../watchers/EnderCrystalWatcher.java | 3 +- .../watchers/EndermanWatcher.java | 3 +- .../watchers/FallingBlockWatcher.java | 7 +- .../watchers/FireworkWatcher.java | 3 +- .../watchers/FishingHookWatcher.java | 3 +- .../disguisetypes/watchers/FoxWatcher.java | 3 +- .../watchers/GuardianWatcher.java | 3 +- .../disguisetypes/watchers/LivingWatcher.java | 15 +- .../watchers/MushroomCowWatcher.java | 3 +- .../disguisetypes/watchers/OcelotWatcher.java | 5 +- .../disguisetypes/watchers/PandaWatcher.java | 3 +- .../disguisetypes/watchers/PlayerWatcher.java | 3 +- .../watchers/ShulkerWatcher.java | 9 +- .../watchers/TameableWatcher.java | 5 +- .../watchers/TropicalFishWatcher.java | 8 +- .../disguisetypes/watchers/WitherWatcher.java | 9 +- .../watchers/ZombieVillagerWatcher.java | 3 +- .../disguise/utilities/DisguiseUtilities.java | 83 +++---- .../disguise/utilities/DisguiseValues.java | 3 +- .../disguise/utilities/LibsPremium.java | 37 +-- .../disguise/utilities/SkinUtils.java | 28 +-- .../utilities/config/ConfigLoader.java | 11 +- .../config/DisguiseCommandConfig.java | 19 +- .../utilities/json/SerializerBlockData.java | 9 +- .../json/SerializerChatComponent.java | 7 +- .../utilities/json/SerializerDisguise.java | 3 +- .../utilities/json/SerializerFlagWatcher.java | 15 +- .../utilities/json/SerializerGameProfile.java | 8 +- .../utilities/json/SerializerItemStack.java | 10 +- .../utilities/json/SerializerMetaIndex.java | 12 +- .../utilities/json/SerializerParticle.java | 3 +- .../json/SerializerWrappedBlockData.java | 9 +- .../utilities/listeners/DisguiseListener.java | 19 +- .../listeners/PaperDisguiseListener.java | 6 +- .../listeners/PlayerSkinHandler.java | 43 ++-- .../disguise/utilities/metrics/Metrics.java | 48 ++-- .../utilities/metrics/MetricsInitalizer.java | 42 ++-- .../utilities/mineskin/MineSkinAPI.java | 19 +- .../utilities/mineskin/MineSkinResponse.java | 3 +- .../utilities/modded/ModdedManager.java | 30 ++- .../utilities/packets/LibsPackets.java | 11 +- .../utilities/packets/PacketsHandler.java | 8 +- .../utilities/packets/PacketsManager.java | 11 +- .../PacketHandlerAnimation.java | 3 +- .../PacketHandlerAttachEntity.java | 6 +- .../PacketHandlerAttributes.java | 8 +- .../packethandlers/PacketHandlerCollect.java | 3 +- .../PacketHandlerEntityStatus.java | 3 +- .../PacketHandlerEquipment.java | 16 +- .../PacketHandlerHeadRotation.java | 24 +- .../packethandlers/PacketHandlerMetadata.java | 3 +- .../packethandlers/PacketHandlerMovement.java | 7 +- .../packethandlers/PacketHandlerSpawn.java | 33 +-- .../packethandlers/PacketHandlerVelocity.java | 6 +- .../PacketListenerClientCustomPayload.java | 11 +- .../PacketListenerClientInteract.java | 2 +- .../PacketListenerEntityDestroy.java | 5 +- .../PacketListenerInventory.java | 13 +- .../packetlisteners/PacketListenerMain.java | 22 +- .../PacketListenerModdedClient.java | 34 ++- .../packetlisteners/PacketListenerSounds.java | 7 +- .../PacketListenerTabList.java | 20 +- .../PacketListenerViewSelfDisguise.java | 42 ++-- .../disguise/utilities/params/ParamInfo.java | 8 +- .../utilities/params/ParamInfoManager.java | 7 +- .../utilities/params/ParamInfoTypes.java | 87 +++---- .../utilities/params/types/ParamInfoEnum.java | 3 +- .../params/types/base/ParamInfoBoolean.java | 5 +- .../types/custom/ParamInfoBlockData.java | 9 +- .../params/types/custom/ParamInfoColor.java | 3 +- .../types/custom/ParamInfoItemBlock.java | 8 +- .../types/custom/ParamInfoItemStack.java | 19 +- .../types/custom/ParamInfoItemStackArray.java | 16 +- .../types/custom/ParamInfoParticle.java | 17 +- .../types/custom/ParamInfoPotionEffect.java | 6 +- .../types/custom/ParamInfoSoundGroup.java | 5 +- .../utilities/parser/DisguiseParser.java | 35 +-- .../utilities/parser/DisguisePerm.java | 15 +- .../utilities/parser/DisguisePermissions.java | 34 ++- .../utilities/parser/WatcherMethod.java | 5 +- .../utilities/plugin/BisectHosting.java | 13 +- .../utilities/plugin/PluginInformation.java | 13 +- .../utilities/reflection/ClassGetter.java | 5 +- .../utilities/reflection/ClassMappings.java | 22 +- .../reflection/ReflectionManager.java | 115 +++++----- .../utilities/sounds/DisguiseSoundEnums.java | 129 +++++------ .../disguise/utilities/sounds/SoundGroup.java | 5 +- .../utilities/sounds/SoundManager.java | 15 +- .../utilities/translations/LibsMsg.java | 43 ++-- .../translations/TranslateFiller.java | 38 ++- .../utilities/translations/TranslateType.java | 25 +- .../disguise/utilities/updates/LDGithub.java | 11 +- .../disguise/utilities/updates/LDJenkins.java | 28 +-- .../utilities/updates/UpdateChecker.java | 25 +- .../utilities/watchers/CompileMethods.java | 21 +- .../utilities/watchers/DisguiseMethods.java | 38 +-- plugin/src/main/resources/plugin.yml | 56 ++--- .../disguisetypes/DisguiseCloneTest.java | 5 +- .../disguise/utilities/DisguiseTypesTest.java | 3 +- .../utilities/DisguiseUtilitiesTest.java | 67 ++---- .../parser/DisguisePermissionsTest.java | 217 ++++++++---------- pom.xml | 8 +- .../reflection/ReflectionManagerAbstract.java | 7 +- .../reflection/v1_17/ReflectionManager.java | 29 +-- .../reflection/v1_18/ReflectionManager.java | 29 +-- 164 files changed, 1494 insertions(+), 1527 deletions(-) diff --git a/plugin/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java b/plugin/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java index 47f73bb1..7683b7de 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index a562ddd2..d764daf9 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -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 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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 873cec6f..64760a7d 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -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"); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/DisguiseBaseCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/DisguiseBaseCommand.java index baa690ad..8840e77d 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/DisguiseBaseCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/DisguiseBaseCommand.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java index 44baa187..30484da8 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java @@ -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 commands = new ArrayList<>(); @@ -53,8 +54,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { } protected ArrayList filterTabs(ArrayList list, String[] origArgs) { - if (origArgs.length == 0) + if (origArgs.length == 0) { return list; + } Iterator 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"); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java index 58755593..2e9c452e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java @@ -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()); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseEntityCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseEntityCommand.java index e3d8112d..b8abc2dd 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseEntityCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseEntityCommand.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguisePlayerCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguisePlayerCommand.java index 737a0b5c..1dc0dccf 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguisePlayerCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguisePlayerCommand.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java index b4ec2600..df288d65 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java @@ -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> 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()); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/CopyDisguiseInteraction.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/CopyDisguiseInteraction.java index a41d1fc0..4efa51d7 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/CopyDisguiseInteraction.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/CopyDisguiseInteraction.java @@ -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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/DisguiseModifyInteraction.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/DisguiseModifyInteraction.java index 1da16045..e1d64ed7 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/DisguiseModifyInteraction.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/DisguiseModifyInteraction.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/UndisguiseEntityInteraction.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/UndisguiseEntityInteraction.java index cc4fc154..bbd58a7e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/UndisguiseEntityInteraction.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/interactions/UndisguiseEntityInteraction.java @@ -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); + } } } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDChangelog.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDChangelog.java index 7fc7433b..4756e329 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDChangelog.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDChangelog.java @@ -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()) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java index 2c99dc55..6fbf4bae 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java index f87bfdf0..bdd34adc 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java index 7b8d065c..65bf1cc5 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java @@ -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 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()); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugMineSkin.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugMineSkin.java index 1e15872c..3c82f187 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugMineSkin.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugMineSkin.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugPlayer.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugPlayer.java index 1b174079..86aff536 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugPlayer.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDDebugPlayer.java @@ -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))); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDHelp.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDHelp.java index 25287f95..717886e3 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDHelp.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDHelp.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java index 14fedf17..a5b47500 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java index 318e0e29..9c40a285 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java @@ -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 itel = names.iterator(); + Iterator 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())); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java index fa7852bd..0699de81 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java @@ -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) player.getMetadata("forge_mods").get(0).value(), ", ")); + LibsMsg.MODS_LIST.send(sender, player.getName(), StringUtils.join((List) player.getMetadata("forge_mods").get(0).value(), ", ")); } @Override diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java index dc154e30..863073af 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java @@ -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); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java index 84cfd39f..e70ceb3e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java index cd06b5df..f3257971 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java @@ -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 listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream() - .filter(listener -> listener.getPlugin() != LibsDisguises.getInstance() && - listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList()); + List 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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java index 85a3d187..fde853be 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdateProtocolLib.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdateProtocolLib.java index a8b78b3a..ec9b6576 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdateProtocolLib.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdateProtocolLib.java @@ -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()); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java index 0d1b7909..f8020a9f 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java @@ -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 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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyCommand.java index 95768915..a4ae67a3 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyCommand.java @@ -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 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())); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyEntityCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyEntityCommand.java index c4d9ef67..6b4f9b05 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyEntityCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyEntityCommand.java @@ -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 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())); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyPlayerCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyPlayerCommand.java index b11ed4a1..fa06ef1f 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyPlayerCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyPlayerCommand.java @@ -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 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())); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java index 19c2a1e2..c475b189 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java @@ -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 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 classes = new ArrayList<>(); for (DisguiseType type : DisguiseType.values()) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseCommand.java index edf7385b..3d762c62 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseCommand.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseEntityCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseEntityCommand.java index 79917cb3..09d84565 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseEntityCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseEntityCommand.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguisePlayerCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguisePlayerCommand.java index 906cd09f..7ad7d70a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguisePlayerCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguisePlayerCommand.java @@ -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 filterTabs(ArrayList list, String[] origArgs) { - if (origArgs.length == 0) + if (origArgs.length == 0) { return list; + } Iterator 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 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 diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java index 58989b27..2a2e6228 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java index 5131eee5..587810c8 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java @@ -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(); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseCloneCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseCloneCommand.java index 0bb1b5c0..936a6df5 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseCloneCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseCloneCommand.java @@ -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()); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseHelpCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseHelpCommand.java index 5dccac52..efd29e2e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseHelpCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/DisguiseHelpCommand.java @@ -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()); } } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java index df53806a..b43fee79 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java @@ -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(); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java index b00772bc..99797be4 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java index 9451f6c6..c36e9176 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java index 85e35af9..b6f72e1b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java @@ -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()) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index 0b635d0f..02d7f3cd 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -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()) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseRunnable.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseRunnable.java index 989232a7..ce0d4338 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseRunnable.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseRunnable.java @@ -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(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java index a18af919..f0a88cdc 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java @@ -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), diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index d32fcaa2..942539cb 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -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(); /** diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/LibsEquipment.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/LibsEquipment.java index a338b8b6..25930184 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/LibsEquipment.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/LibsEquipment.java @@ -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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java index 20fc16db..82115444 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java @@ -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 { private static MetaIndex[] _values = new MetaIndex[0]; @@ -136,7 +137,7 @@ public class MetaIndex { */ @NmsAddedIn(NmsVersion.v1_13) public static MetaIndex 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 AREA_EFFECT_PARTICLE_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0); @@ -368,7 +369,7 @@ public class MetaIndex { public static MetaIndex FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR)); public static MetaIndex 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 FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false); @@ -543,7 +544,7 @@ public class MetaIndex { public static MetaIndex MINECART_COMMAND_STRING = new MetaIndex<>(MinecartCommandWatcher.class, 0, ""); public static MetaIndex 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 { public static MetaIndex ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0); @NmsAddedIn(NmsVersion.v1_14) - public static MetaIndex VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0, - NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); + public static MetaIndex VILLAGER_DATA = + new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); public static MetaIndex WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false); @@ -740,7 +741,7 @@ public class MetaIndex { @NmsAddedIn(NmsVersion.v1_14) public static MetaIndex 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 { 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 { 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 { 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]; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java index ef952e7f..4dfe7e1a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java @@ -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)); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java index f53e8a2c..7292408a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java @@ -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 diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/ModdedDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/ModdedDisguise.java index 64266ce8..80203227 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/ModdedDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/ModdedDisguise.java @@ -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(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index 9864c6fb..712d6c35 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java index bd2d7a0b..2a062bbe 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java @@ -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(); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java index f611b26e..cd54663d 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java index a052dbef..18881b27 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java @@ -31,8 +31,9 @@ public class ArmorStandWatcher extends LivingWatcher { } private EulerAngle getPose(MetaIndex type) { - if (!hasValue(type)) + if (!hasValue(type)) { return new EulerAngle(0, 0, 0); + } Vector3F vec = getData(type); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java index e9a03349..f51dc305 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java index a6d177fd..58338ced 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java @@ -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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java index 33ff7d98..d4c78142 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java @@ -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(), " "))); } } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java index 6f9d2521..f6eada77 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java @@ -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 */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java index 9a0785fd..75311ce7 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java @@ -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) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java index ee18e3eb..e581df62 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java @@ -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) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java index d257dbbb..b63ecfae 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java @@ -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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java index f679e05f..0ccd5534 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java index 06cce594..cf876b8c 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java index a1ba6e49..0da6d457 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java @@ -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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index 25517872..6f0c083b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java index 93d286e3..df1382b9 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java index d7126eab..ed044554 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java @@ -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) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java index 07868cc6..f7a6285b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 07190c53..14b12f9a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java index 7c7336c7..16558acb 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java @@ -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); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java index f86856a9..91f01539 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java @@ -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) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java index b5659955..4e94a534 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java @@ -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() { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java index 739e5c8a..305733d9 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java @@ -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]); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java index ee053091..dbc2c622 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java @@ -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) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 8d79aaaf..632cbc27 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -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 { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java index fa50eeb9..03cd11eb 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java index ba9a1b48..8d23d774 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java @@ -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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/SkinUtils.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/SkinUtils.java index cf56a1cd..f6a84240 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/SkinUtils.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/SkinUtils.java @@ -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) { } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/ConfigLoader.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/ConfigLoader.java index 5da875d8..9bac4d04 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/ConfigLoader.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/ConfigLoader.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/DisguiseCommandConfig.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/DisguiseCommandConfig.java index 47b3c207..ea965f6b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/DisguiseCommandConfig.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/config/DisguiseCommandConfig.java @@ -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(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java index f1284006..5f2ec5ed 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java @@ -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, - JsonSerializer { +public class SerializerBlockData implements JsonDeserializer, JsonSerializer { @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()); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerChatComponent.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerChatComponent.java index 0ad2c571..768a13e5 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerChatComponent.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerChatComponent.java @@ -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, - JsonSerializer { +public class SerializerChatComponent implements JsonDeserializer, JsonSerializer { @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()); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerDisguise.java index f35bcbbc..bf17141f 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerDisguise.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerFlagWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerFlagWatcher.java index aa8ca28d..32e1dd42 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerFlagWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerFlagWatcher.java @@ -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, Ins } private void correct(FlagWatcher watcher, Class flagWatcher, String name) - throws NoSuchFieldException, IllegalAccessException, DisguiseParseException { + throws NoSuchFieldException, IllegalAccessException, DisguiseParseException { Field field = FlagWatcher.class.getDeclaredField(name); field.setAccessible(true); HashMap map = (HashMap) field.get(watcher); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerGameProfile.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerGameProfile.java index ba7697c6..303b78a2 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerGameProfile.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerGameProfile.java @@ -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 } @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)); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerItemStack.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerItemStack.java index 4c95ab20..d0b50236 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerItemStack.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerItemStack.java @@ -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, 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")) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerMetaIndex.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerMetaIndex.java index e4518831..a767d2ca 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerMetaIndex.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerMetaIndex.java @@ -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, 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; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerParticle.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerParticle.java index 37edd898..be8d55f3 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerParticle.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerParticle.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerWrappedBlockData.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerWrappedBlockData.java index 2c8522c4..f899fbe2 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerWrappedBlockData.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerWrappedBlockData.java @@ -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, - JsonDeserializer { +public class SerializerWrappedBlockData implements JsonSerializer, JsonDeserializer { @Override public JsonElement serialize(WrappedBlockData src, Type typeOfSrc, JsonSerializationContext context) { @@ -26,8 +26,7 @@ public class SerializerWrappedBlockData implements JsonSerializer interactions = new HashMap<>(); private HashMap 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 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 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!"); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java index 40b899f3..67087536 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java @@ -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(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java index a3e50798..76704d5b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java @@ -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> 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 skins = (List) event.getValue(); + List skins = (List) 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); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/Metrics.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/Metrics.java index e71fbb2e..74c0696c 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/Metrics.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/Metrics.java @@ -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); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/MetricsInitalizer.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/MetricsInitalizer.java index c770c6d9..79416713 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/MetricsInitalizer.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/metrics/MetricsInitalizer.java @@ -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 getValues(HashMap hashMap) { for (Set 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 getValues(HashMap hashMap) { for (Set 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> list = DisguiseUtilities.getDisguises().values(); - if (list.isEmpty()) + if (list.isEmpty()) { return "Unknown"; + } for (Set dList : list) { for (TargetedDisguise disg : dList) { - if (disg.getObservers().isEmpty()) + if (disg.getObservers().isEmpty()) { continue; + } targetedDisguises = true; return "Yes"; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinAPI.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinAPI.java index 68bf394f..9b5b3c99 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinAPI.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinAPI.java @@ -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 { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinResponse.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinResponse.java index df2d9e3c..2d87c10a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinResponse.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/mineskin/MineSkinResponse.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java index cadf65ec..612ebc47 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java @@ -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> forgeMods = CacheBuilder.newBuilder() - .expireAfterWrite(1, TimeUnit.MINUTES).build(); + private static final Cache> forgeMods = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(); public ModdedManager(ArrayList 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 perms = new ArrayList<>(); for (Map.Entry 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; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java index 23dad12c..2d0e5123 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java @@ -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. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java index d7e339b9..7768716a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java @@ -2,8 +2,6 @@ package me.libraryaddict.disguise.utilities.packets; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; -import java.util.ArrayList; -import java.util.Collection; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -22,6 +20,9 @@ import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerV import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collection; + /** * Created by libraryaddict on 3/01/2019. */ @@ -45,8 +46,7 @@ public class PacketsHandler { packetHandlers.add(new PacketHandlerHeadRotation()); // If not prem, if build is from jenkins, else its a custom and needs paid info - if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || - LibsPremium.getPaidInformation() != null) { + if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || LibsPremium.getPaidInformation() != null) { packetHandlers.add(new PacketHandlerMetadata(this)); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java index 42d444d4..29d8021e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java @@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType.Play.Server; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketListener; -import java.util.ArrayList; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; @@ -23,6 +22,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.ArrayList; + public class PacketsManager { private static PacketListener clientInteractEntityListener; private static PacketListener inventoryListener; @@ -92,7 +93,7 @@ public class PacketsManager { if (disguise != null) { if (viewDisguisesListenerEnabled && disguise.isSelfDisguiseVisible() && - (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { + (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { player.updateInventory(); } } @@ -177,8 +178,7 @@ public class PacketsManager { ProtocolLibrary.getProtocolManager().addPacketListener(mainListener); ProtocolLibrary.getProtocolManager().addPacketListener(destroyListener); - if (NmsVersion.v1_13.isSupported() && - DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) { + if (NmsVersion.v1_13.isSupported() && DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) { scoreboardTeamListener = new PacketListenerScoreboardTeam(); ProtocolLibrary.getProtocolManager().addPacketListener(scoreboardTeamListener); @@ -207,8 +207,7 @@ public class PacketsManager { DisguiseUtilities.removeSelfDisguise(disguise); } - if (inventoryModifierEnabled && - (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { + if (inventoryModifierEnabled && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { player.updateInventory(); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimation.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimation.java index 3ad5bb18..15913a29 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimation.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimation.java @@ -18,8 +18,7 @@ public class PacketHandlerAnimation implements IPacketHandler { } @Override - public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, - Entity entity) { + public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { // Else if the disguise is attempting to send players a forbidden packet if (disguise.getType().isMisc()) { packets.clear(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttachEntity.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttachEntity.java index 48215fa4..4c142352 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttachEntity.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttachEntity.java @@ -20,15 +20,13 @@ public class PacketHandlerAttachEntity implements IPacketHandler { } @Override - public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, - Entity entity) { + public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { if (observer.getVehicle() == null) { DisguiseUtilities.removeInvisibleSlime(observer); return; } - if (observer.getVehicle() != entity || - !AbstractHorse.class.isAssignableFrom(disguise.getType().getEntityClass())) { + if (observer.getVehicle() != entity || !AbstractHorse.class.isAssignableFrom(disguise.getType().getEntityClass())) { return; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java index ba3d8691..2a61bc7c 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java @@ -4,8 +4,6 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.WrappedAttribute; -import java.util.ArrayList; -import java.util.List; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher; @@ -18,6 +16,9 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.List; + /** * Created by libraryaddict on 3/01/2019. */ @@ -72,7 +73,8 @@ public class PacketHandlerAttributes implements IPacketHandler { builder.packet(updateAttributes); attributes.add(builder.build()); - } else if (attribute.getAttributeKey().equals(NmsVersion.v1_16.isSupported() ? "generic.movement_speed" : "generic.movementSpeed") && disguise.getWatcher() instanceof AbstractHorseWatcher) { + } else if (attribute.getAttributeKey().equals(NmsVersion.v1_16.isSupported() ? "generic.movement_speed" : "generic.movementSpeed") && + disguise.getWatcher() instanceof AbstractHorseWatcher) { WrappedAttribute.Builder builder = WrappedAttribute.newBuilder(attribute); builder.packet(updateAttributes); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollect.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollect.java index c93425f9..b744bfed 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollect.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollect.java @@ -18,8 +18,7 @@ public class PacketHandlerCollect implements IPacketHandler { } @Override - public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, - Entity entity) { + public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { if (disguise.getType().isMisc()) { packets.clear(); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityStatus.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityStatus.java index a0fcad34..96560bf0 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityStatus.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityStatus.java @@ -18,8 +18,7 @@ public class PacketHandlerEntityStatus implements IPacketHandler { } @Override - public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, - Entity entity) { + public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { // If the entity is updating their status, stop them from showing death if (packets.getPackets().get(0).getBytes().read(0) == (byte) 3) { packets.clear(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java index d6764302..3dd4b160 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java @@ -5,8 +5,6 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedWatchableObject; import com.mojang.datafixers.util.Pair; -import java.util.ArrayList; -import java.util.List; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; @@ -21,6 +19,9 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.EquipmentSlot; +import java.util.ArrayList; +import java.util.List; + /** * Created by libraryaddict on 3/01/2019. */ @@ -81,15 +82,15 @@ public class PacketHandlerEquipment implements IPacketHandler { } if ((disguise.getWatcher().isMainHandRaised() && slot == EquipmentSlot.HAND) || - (disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() && - slot == EquipmentSlot.OFF_HAND)) { + (disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() && + slot == EquipmentSlot.OFF_HAND)) { if (itemStack != null && itemStack.getType() != Material.AIR) { // Convert the datawatcher List list = new ArrayList<>(); if (DisguiseConfig.isMetaPacketsEnabled()) { WrappedWatchableObject watch = ReflectionManager.createWatchable(MetaIndex.LIVING_META, - WrappedDataWatcher.getEntityWatcher(entity).getByte(MetaIndex.LIVING_META.getIndex())); + WrappedDataWatcher.getEntityWatcher(entity).getByte(MetaIndex.LIVING_META.getIndex())); if (watch != null) { list.add(watch); @@ -154,8 +155,7 @@ public class PacketHandlerEquipment implements IPacketHandler { } if ((disguise.getWatcher().isMainHandRaised() && slot == EquipmentSlot.HAND) || - (disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() && - slot == EquipmentSlot.OFF_HAND)) { + (disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() && slot == EquipmentSlot.OFF_HAND)) { if (itemStack == null) { itemStack = packets.getPackets().get(0).getItemModifier().read(0); } @@ -167,7 +167,7 @@ public class PacketHandlerEquipment implements IPacketHandler { if (DisguiseConfig.isMetaPacketsEnabled()) { WrappedWatchableObject watch = - ReflectionManager.createWatchable(toUse, WrappedDataWatcher.getEntityWatcher(entity).getByte(toUse.getIndex())); + ReflectionManager.createWatchable(toUse, WrappedDataWatcher.getEntityWatcher(entity).getByte(toUse.getIndex())); if (watch != null) { list.add(watch); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerHeadRotation.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerHeadRotation.java index e2b55db5..16140564 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerHeadRotation.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerHeadRotation.java @@ -3,7 +3,6 @@ package me.libraryaddict.disguise.utilities.packets.packethandlers; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; -import java.util.ArrayList; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -15,6 +14,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.ArrayList; + /** * Created by libraryaddict on 3/01/2019. */ @@ -25,8 +26,7 @@ public class PacketHandlerHeadRotation implements IPacketHandler { } @Override - public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, - Entity entity) { + public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { if (disguise.getType() == DisguiseType.FALLING_BLOCK) { packets.clear(); return; @@ -36,8 +36,7 @@ public class PacketHandlerHeadRotation implements IPacketHandler { Float yawLock = disguise.getWatcher().getYawLock(); boolean riding = observer.getVehicle() == entity; - if (pitchLock == null && yawLock == null && - (!disguise.getType().isPlayer() || entity.getType() == EntityType.PLAYER)) { + if (pitchLock == null && yawLock == null && (!disguise.getType().isPlayer() || entity.getType() == EntityType.PLAYER)) { if (riding) { sentPacket = sentPacket.shallowClone(); sentPacket.getModifier().write(0, DisguiseAPI.getEntityAttachmentId()); @@ -86,31 +85,26 @@ public class PacketHandlerHeadRotation implements IPacketHandler { case SNOWBALL: case PAINTING: case PRIMED_TNT: - if ((pitchLock == null || yawLock == null) && sentPacket.getBytes().read(0) == 0 && - entity.getVelocity().lengthSquared() > 0) { + if ((pitchLock == null || yawLock == null) && sentPacket.getBytes().read(0) == 0 && entity.getVelocity().lengthSquared() > 0) { loc.setDirection(entity.getVelocity()); if (pitchLock == null) { - pitch = DisguiseUtilities - .getPitch(DisguiseType.PLAYER, (byte) (int) (loc.getPitch() * 256.0F / 360.0F)); + pitch = DisguiseUtilities.getPitch(DisguiseType.PLAYER, (byte) (int) (loc.getPitch() * 256.0F / 360.0F)); } if (yawLock == null) { - yaw = DisguiseUtilities - .getYaw(DisguiseType.PLAYER, (byte) (int) (loc.getYaw() * 256.0F / 360.0F)); + yaw = DisguiseUtilities.getYaw(DisguiseType.PLAYER, (byte) (int) (loc.getYaw() * 256.0F / 360.0F)); } break; } default: if (pitchLock == null) { - pitch = DisguiseUtilities.getPitch(DisguiseType.getType(entity.getType()), - (byte) (int) (loc.getPitch() * 256.0F / 360.0F)); + pitch = DisguiseUtilities.getPitch(DisguiseType.getType(entity.getType()), (byte) (int) (loc.getPitch() * 256.0F / 360.0F)); } if (yawLock == null) { - yaw = DisguiseUtilities.getYaw(DisguiseType.getType(entity.getType()), - (byte) (int) (loc.getYaw() * 256.0F / 360.0F)); + yaw = DisguiseUtilities.getYaw(DisguiseType.getType(entity.getType()), (byte) (int) (loc.getYaw() * 256.0F / 360.0F)); } break; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java index 7a897e7e..c9972a23 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java @@ -4,7 +4,6 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.WrappedWatchableObject; -import java.util.List; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.packets.IPacketHandler; @@ -13,6 +12,8 @@ import me.libraryaddict.disguise.utilities.packets.PacketsHandler; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.util.List; + /** * Created by libraryaddict on 3/01/2019. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMovement.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMovement.java index 07d20352..303facb3 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMovement.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMovement.java @@ -3,7 +3,6 @@ package me.libraryaddict.disguise.utilities.packets.packethandlers; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; -import java.util.ArrayList; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; @@ -22,6 +21,8 @@ import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; +import java.util.ArrayList; + /** * Created by libraryaddict on 3/01/2019. */ @@ -31,7 +32,7 @@ public class PacketHandlerMovement implements IPacketHandler { @Override public PacketType[] getHandledPackets() { return new PacketType[]{PacketType.Play.Server.REL_ENTITY_MOVE_LOOK, PacketType.Play.Server.ENTITY_LOOK, PacketType.Play.Server.ENTITY_TELEPORT, - PacketType.Play.Server.REL_ENTITY_MOVE}; + PacketType.Play.Server.REL_ENTITY_MOVE}; } private short conRel(double oldCord, double newCord) { @@ -157,7 +158,7 @@ public class PacketHandlerMovement implements IPacketHandler { packets.addPacket(movePacket); return; } else if (disguise.getType() == DisguiseType.RABBIT && - (sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE || sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE_LOOK)) { + (sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE || sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE_LOOK)) { // When did the rabbit disguise last hop long lastHop = 999999; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index 0bef0e59..4b428c49 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -7,9 +7,6 @@ import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.WrappedAttribute; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.mojang.datafixers.util.Pair; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; @@ -40,6 +37,10 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * Created by libraryaddict on 3/01/2019. */ @@ -53,7 +54,7 @@ public class PacketHandlerSpawn implements IPacketHandler { @Override public PacketType[] getHandledPackets() { return new PacketType[]{PacketType.Play.Server.NAMED_ENTITY_SPAWN, PacketType.Play.Server.SPAWN_ENTITY_LIVING, - PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.SPAWN_ENTITY_PAINTING}; + PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.SPAWN_ENTITY_PAINTING}; } @Override @@ -149,8 +150,8 @@ public class PacketHandlerSpawn implements IPacketHandler { // Add player to the list, necessary to spawn them sendTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0)); - List playerList = Collections.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(), ReflectionManager - .getGameProfileWithThisSkin(playerDisguise.getUUID(), playerDisguise.getProfileName(), playerDisguise.getGameProfile()))); + List playerList = Collections.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(), + ReflectionManager.getGameProfileWithThisSkin(playerDisguise.getUUID(), playerDisguise.getProfileName(), playerDisguise.getGameProfile()))); sendTab.getModifier().write(1, playerList); packets.addPacket(sendTab); @@ -179,8 +180,8 @@ public class PacketHandlerSpawn implements IPacketHandler { // If self disguise, or further than 50 blocks, or not in front of entity normalPlayerDisguise = observer == disguisedEntity || disguisedEntity.getPassengers().contains(observer) || dist > (50 * 50) || - (observer.getLocation().add(observer.getLocation().getDirection().normalize()).toVector() - .distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3; + (observer.getLocation().add(observer.getLocation().getDirection().normalize()).toVector() + .distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3; sendArmor = normalPlayerDisguise; skin.setSleepPackets(!normalPlayerDisguise); @@ -213,8 +214,8 @@ public class PacketHandlerSpawn implements IPacketHandler { if (NmsVersion.v1_15.isSupported()) { PacketContainer metaPacket = - ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entityId, toSend, true) - .createPacket(entityId, toSend, true); + ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entityId, toSend, true) + .createPacket(entityId, toSend, true); packets.addPacket(metaPacket); } else { @@ -277,12 +278,12 @@ public class PacketHandlerSpawn implements IPacketHandler { mods.write(11, yaw); WrappedDataWatcher newWatcher = - DisguiseUtilities.createSanitizedDataWatcher(observer, WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher()); + DisguiseUtilities.createSanitizedDataWatcher(observer, WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher()); if (NmsVersion.v1_15.isSupported()) { PacketContainer metaPacket = ProtocolLibrary.getProtocolManager() - .createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, disguisedEntity.getEntityId(), newWatcher, true) - .createPacket(disguisedEntity.getEntityId(), newWatcher, true); + .createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, disguisedEntity.getEntityId(), newWatcher, true) + .createPacket(disguisedEntity.getEntityId(), newWatcher, true); packets.addPacket(metaPacket); } else { @@ -326,7 +327,7 @@ public class PacketHandlerSpawn implements IPacketHandler { } Object[] params = new Object[]{disguisedEntity.getEntityId(), disguise.getUUID(), x, y, z, loc.getPitch(), loc.getYaw(), entityType, data, - ReflectionManager.getVec3D(disguisedEntity.getVelocity())}; + ReflectionManager.getVec3D(disguisedEntity.getVelocity())}; spawnEntity = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, params).createPacket(params); } else { @@ -339,7 +340,7 @@ public class PacketHandlerSpawn implements IPacketHandler { Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity); spawnEntity = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data) - .createPacket(nmsEntity, objectId, data); + .createPacket(nmsEntity, objectId, data); StructureModifier doubles = spawnEntity.getDoubles(); @@ -409,7 +410,7 @@ public class PacketHandlerSpawn implements IPacketHandler { ArrayList attributes = new ArrayList<>(); WrappedAttribute.Builder builder = - WrappedAttribute.newBuilder().attributeKey(NmsVersion.v1_16.isSupported() ? "generic.max_health" : "generic.maxHealth"); + WrappedAttribute.newBuilder().attributeKey(NmsVersion.v1_16.isSupported() ? "generic.max_health" : "generic.maxHealth"); if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth()); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java index e786cc52..81be46b8 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java @@ -19,11 +19,9 @@ public class PacketHandlerVelocity implements IPacketHandler { } @Override - public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, - Entity entity) { + public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { // If the disguise isnt a misc or the disguised is the same type - if ((!disguise.getType().isMisc() && disguise.getType() != DisguiseType.SQUID) || - DisguiseType.getType(entity) == disguise.getType()) { + if ((!disguise.getType().isMisc() && disguise.getType() != DisguiseType.SQUID) || DisguiseType.getType(entity) == disguise.getType()) { return; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientCustomPayload.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientCustomPayload.java index 961f15a6..3b3409ac 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientCustomPayload.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientCustomPayload.java @@ -5,14 +5,15 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + /** * Created by libraryaddict on 21/05/2020. */ @@ -51,8 +52,7 @@ public class PacketListenerClientCustomPayload extends PacketAdapter { } if (player.hasMetadata("ld_tabsend") && !player.getMetadata("ld_tabsend").isEmpty()) { - ArrayList packets = (ArrayList) player.getMetadata("ld_tabsend") - .get(0).value(); + ArrayList packets = (ArrayList) player.getMetadata("ld_tabsend").get(0).value(); player.removeMetadata("ld_tabsend", LibsDisguises.getInstance()); @@ -60,8 +60,7 @@ public class PacketListenerClientCustomPayload extends PacketAdapter { for (PacketContainer packet : packets) { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); } - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { e.printStackTrace(); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java index 9d97f765..8aa2db4d 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java @@ -130,7 +130,7 @@ public class PacketListenerClientInteract extends PacketAdapter { public void run() { // Fire self interact event DisguiseInteractEvent selfEvent = - new DisguiseInteractEvent((TargetedDisguise) disguise, handUsed, interactType == EnumWrappers.EntityUseAction.ATTACK); + new DisguiseInteractEvent((TargetedDisguise) disguise, handUsed, interactType == EnumWrappers.EntityUseAction.ATTACK); Bukkit.getPluginManager().callEvent(selfEvent); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java index 60a3b23a..ff03b360 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java @@ -4,8 +4,6 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; -import java.lang.reflect.InvocationTargetException; -import java.util.List; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -13,6 +11,9 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + /** * Created by libraryaddict on 3/05/2020. */ diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java index 1ee1d3e1..7ac47f1c 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java @@ -8,9 +8,6 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; @@ -25,12 +22,16 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + public class PacketListenerInventory extends PacketAdapter { private LibsDisguises libsDisguises; public PacketListenerInventory(LibsDisguises plugin) { super(plugin, ListenerPriority.HIGH, Server.SET_SLOT, Server.WINDOW_ITEMS, PacketType.Play.Client.SET_CREATIVE_SLOT, - PacketType.Play.Client.WINDOW_CLICK); + PacketType.Play.Client.WINDOW_CLICK); libsDisguises = plugin; } @@ -66,7 +67,7 @@ public class PacketListenerInventory extends PacketAdapter { // If player isn't disguise, isn't self disguised, or isn't hiding items from themselves // If player is disguised, views self disguises and has a inventory modifier if (disguise == null || !DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()) || - (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) { + (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) { return; } @@ -236,7 +237,7 @@ public class PacketListenerInventory extends PacketAdapter { Disguise disguise = DisguiseAPI.getDisguise(player, player); if (disguise == null || !DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()) || - (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) { + (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) { return; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java index f17da7d0..5848efd6 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java @@ -7,8 +7,6 @@ import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; @@ -17,6 +15,9 @@ import me.libraryaddict.disguise.utilities.packets.LibsPackets; import me.libraryaddict.disguise.utilities.packets.PacketsManager; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + public class PacketListenerMain extends PacketAdapter { public PacketListenerMain(LibsDisguises plugin, ArrayList packetsToListen) { super(plugin, ListenerPriority.HIGH, packetsToListen); @@ -24,13 +25,16 @@ public class PacketListenerMain extends PacketAdapter { @Override public void onPacketSending(final PacketEvent event) { - if (event.isCancelled()) + if (event.isCancelled()) { return; + } final Player observer = event.getPlayer(); if (observer.getName().contains("UNKNOWN[")) // If the player is temporary + { return; + } // First get the entity, the one sending this packet @@ -48,15 +52,12 @@ public class PacketListenerMain extends PacketAdapter { LibsPackets packets; try { - packets = PacketsManager.getPacketsHandler() - .transformPacket(event.getPacket(), disguise, observer, disguise.getEntity()); + packets = PacketsManager.getPacketsHandler().transformPacket(event.getPacket(), disguise, observer, disguise.getEntity()); if (disguise.isPlayerDisguise()) { - LibsDisguises.getInstance().getSkinHandler() - .handlePackets(observer, (PlayerDisguise) disguise, packets); + LibsDisguises.getInstance().getSkinHandler().handlePackets(observer, (PlayerDisguise) disguise, packets); } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); event.setCancelled(true); return; @@ -74,8 +75,7 @@ public class PacketListenerMain extends PacketAdapter { } packets.sendDelayed(observer); - } - catch (InvocationTargetException ex) { + } catch (InvocationTargetException ex) { ex.printStackTrace(); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerModdedClient.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerModdedClient.java index e2f78171..f665d3e3 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerModdedClient.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerModdedClient.java @@ -12,21 +12,21 @@ import com.mojang.authlib.GameProfile; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.handler.codec.DecoderException; -import java.lang.reflect.InvocationTargetException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.concurrent.TimeUnit; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.utilities.modded.ModdedManager; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; + /** * Created by libraryaddict on 11/06/2020. */ public class PacketListenerModdedClient extends PacketAdapter { - private final Cache loginAttempts = CacheBuilder.newBuilder().expireAfterWrite(15, TimeUnit.SECONDS) - .build(); + private final Cache loginAttempts = CacheBuilder.newBuilder().expireAfterWrite(15, TimeUnit.SECONDS).build(); private final int packetId1 = 5555554, packetId2 = 5555555; public PacketListenerModdedClient() { @@ -73,17 +73,14 @@ public class PacketListenerModdedClient extends PacketAdapter { int size = 256; if (j > size * 4) { - throw new DecoderException( - "The received encoded string buffer length is longer than maximum allowed (" + j + " > " + - size * 4 + ")"); + throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + j + " > " + size * 4 + ")"); } else if (j < 0) { throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); } else { String s = buf.toString(buf.readerIndex(), j, StandardCharsets.UTF_8); buf.readerIndex(buf.readerIndex() + j); if (s.length() > size) { - throw new DecoderException( - "The received string length is longer than maximum allowed (" + j + " > " + size + ")"); + throw new DecoderException("The received string length is longer than maximum allowed (" + j + " > " + size + ")"); } else { return s; } @@ -97,8 +94,7 @@ public class PacketListenerModdedClient extends PacketAdapter { try { ProtocolLibrary.getProtocolManager().recieveClientPacket(player, packet, false); - } - catch (IllegalAccessException | InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } } @@ -134,16 +130,15 @@ public class PacketListenerModdedClient extends PacketAdapter { return; } - loginAttempts - .put(event.getPlayer().getAddress().toString(), event.getPacket().getGameProfiles().read(0).getName()); + loginAttempts.put(event.getPlayer().getAddress().toString(), event.getPacket().getGameProfiles().read(0).getName()); PacketContainer packet1 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD); packet1.getIntegers().write(0, packetId1); packet1.getMinecraftKeys().write(0, new com.comphenix.protocol.wrappers.MinecraftKey("fml", "handshake")); try { - Object obj1 = ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class) - .newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake())); + Object obj1 = + ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class).newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake())); packet1.getModifier().write(2, obj1); @@ -151,14 +146,13 @@ public class PacketListenerModdedClient extends PacketAdapter { packet2.getIntegers().write(0, packetId2); packet2.getMinecraftKeys().write(0, new MinecraftKey("fml", "handshake")); Object obj2 = ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class) - .newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries())); + .newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries())); packet2.getModifier().write(2, obj2); ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet1); ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet2); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerSounds.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerSounds.java index f2c5f73b..bf8c0134 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerSounds.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerSounds.java @@ -7,8 +7,6 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; -import java.lang.reflect.InvocationTargetException; -import java.util.Set; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -23,6 +21,9 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; +import java.util.Set; + public class PacketListenerSounds extends PacketAdapter { /** @@ -238,7 +239,7 @@ public class PacketListenerSounds extends PacketAdapter { Location loc = entity.getLocation(); PacketContainer packet = - new PacketContainer(sound.getClass().getSimpleName().equals("MinecraftKey") ? Server.CUSTOM_SOUND_EFFECT : Server.NAMED_SOUND_EFFECT); + new PacketContainer(sound.getClass().getSimpleName().equals("MinecraftKey") ? Server.CUSTOM_SOUND_EFFECT : Server.NAMED_SOUND_EFFECT); mods = packet.getModifier(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerTabList.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerTabList.java index 39fd05c2..6240a4aa 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerTabList.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerTabList.java @@ -6,14 +6,15 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; import com.comphenix.protocol.wrappers.PlayerInfoData; -import java.util.Iterator; -import java.util.List; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.Iterator; +import java.util.List; + public class PacketListenerTabList extends PacketAdapter { public PacketListenerTabList(LibsDisguises plugin) { super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO); @@ -21,13 +22,15 @@ public class PacketListenerTabList extends PacketAdapter { @Override public void onPacketSending(final PacketEvent event) { - if (event.isCancelled()) + if (event.isCancelled()) { return; + } Player observer = event.getPlayer(); - if (event.getPacket().getPlayerInfoAction().read(0) != PlayerInfoAction.ADD_PLAYER) + if (event.getPacket().getPlayerInfoAction().read(0) != PlayerInfoAction.ADD_PLAYER) { return; + } List list = event.getPacket().getPlayerInfoDataLists().read(0); Iterator itel = list.iterator(); @@ -37,16 +40,19 @@ public class PacketListenerTabList extends PacketAdapter { Player player = Bukkit.getPlayer(data.getProfile().getUUID()); - if (player == null) + if (player == null) { continue; + } Disguise disguise = DisguiseAPI.getDisguise(observer, player); - if (disguise == null) + if (disguise == null) { continue; + } - if (!disguise.isHidePlayer()) + if (!disguise.isHidePlayer()) { continue; + } itel.remove(); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java index b0d78719..7d958987 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java @@ -8,10 +8,6 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.WrappedWatchableObject; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; @@ -24,12 +20,16 @@ import me.libraryaddict.disguise.utilities.packets.PacketsManager; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public class PacketListenerViewSelfDisguise extends PacketAdapter { public PacketListenerViewSelfDisguise(LibsDisguises plugin) { - super(plugin, ListenerPriority.HIGH, Server.NAMED_ENTITY_SPAWN, Server.ATTACH_ENTITY, Server.REL_ENTITY_MOVE, - Server.REL_ENTITY_MOVE_LOOK, Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, Server.ENTITY_HEAD_ROTATION, - Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION, Server.ENTITY_EFFECT, - Server.ENTITY_VELOCITY, Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS); + super(plugin, ListenerPriority.HIGH, Server.NAMED_ENTITY_SPAWN, Server.ATTACH_ENTITY, Server.REL_ENTITY_MOVE, Server.REL_ENTITY_MOVE_LOOK, + Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, Server.ENTITY_HEAD_ROTATION, Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION, + Server.ENTITY_EFFECT, Server.ENTITY_VELOCITY, Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS); } @Override @@ -63,8 +63,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { } // Here I grab the packets to convert them to, So I can display them as if the disguise sent them. - LibsPackets transformed = - PacketsManager.getPacketsHandler().transformPacket(packet, disguise, observer, observer); + LibsPackets transformed = PacketsManager.getPacketsHandler().transformPacket(packet, disguise, observer, observer); if (transformed.isUnhandled()) { transformed.addPacket(packet); @@ -74,7 +73,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { for (PacketContainer newPacket : transformed.getPackets()) { if (newPacket.getType() != Server.PLAYER_INFO && newPacket.getType() != Server.ENTITY_DESTROY && - newPacket.getIntegers().read(0) == observer.getEntityId()) { + newPacket.getIntegers().read(0) == observer.getEntityId()) { if (newPacket == packet) { newPacket = newPacket.shallowClone(); } @@ -100,8 +99,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { } if (disguise.isPlayerDisguise()) { - LibsDisguises.getInstance().getSkinHandler() - .handlePackets(observer, (PlayerDisguise) disguise, selfTransformed); + LibsDisguises.getInstance().getSkinHandler().handlePackets(observer, (PlayerDisguise) disguise, selfTransformed); } try { @@ -116,7 +114,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { if (event.getPacketType() == Server.ENTITY_METADATA) { if (!LibsPremium.getPluginInformation().isPremium() || LibsPremium.getPaidInformation() != null || - LibsPremium.getPluginInformation().getBuildNumber().matches("#[0-9]+")) { + LibsPremium.getPluginInformation().getBuildNumber().matches("#[0-9]+")) { event.setPacket(packet = packet.deepClone()); } @@ -165,20 +163,16 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { if (packet.getIntegers().read(1) != 2) { event.setCancelled(true); } - } else if (event.getPacketType() == Server.ATTACH_ENTITY || - event.getPacketType() == Server.REL_ENTITY_MOVE || - event.getPacketType() == Server.REL_ENTITY_MOVE_LOOK || - event.getPacketType() == Server.ENTITY_LOOK || event.getPacketType() == Server.ENTITY_TELEPORT || - event.getPacketType() == Server.ENTITY_HEAD_ROTATION || - event.getPacketType() == Server.ENTITY_EQUIPMENT) { + } else if (event.getPacketType() == Server.ATTACH_ENTITY || event.getPacketType() == Server.REL_ENTITY_MOVE || + event.getPacketType() == Server.REL_ENTITY_MOVE_LOOK || event.getPacketType() == Server.ENTITY_LOOK || + event.getPacketType() == Server.ENTITY_TELEPORT || event.getPacketType() == Server.ENTITY_HEAD_ROTATION || + event.getPacketType() == Server.ENTITY_EQUIPMENT) { event.setCancelled(true); } else if (event.getPacketType() == Server.ENTITY_STATUS) { - if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() && - packet.getBytes().read(0) == 2) { + if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() && packet.getBytes().read(0) == 2) { event.setCancelled(true); } - } else if (event.getPacketType() == Server.ENTITY_VELOCITY && - !DisguiseUtilities.isPlayerVelocity(observer)) { + } else if (event.getPacketType() == Server.ENTITY_VELOCITY && !DisguiseUtilities.isPlayerVelocity(observer)) { // The player only sees velocity changes when there is a velocity event. As the method claims there // was no velocity event... event.setCancelled(true); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java index 15edbbb7..63d94d95 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java @@ -1,13 +1,14 @@ package me.libraryaddict.disguise.utilities.params; +import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; +import me.libraryaddict.disguise.utilities.translations.TranslateType; + import java.util.Arrays; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; -import me.libraryaddict.disguise.utilities.translations.TranslateType; /** * Created by libraryaddict on 7/09/2018. @@ -52,8 +53,7 @@ public abstract class ParamInfo { this(paramClass, name, name, description, possibleValues); } - public ParamInfo(Class paramClass, String name, String descriptiveName, String description, - Map possibleValues) { + public ParamInfo(Class paramClass, String name, String descriptiveName, String description, Map possibleValues) { this(paramClass, name, descriptiveName, description); this.possibleValues = new LinkedHashMap<>(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java index 7ffa620c..11957033 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java @@ -1,8 +1,5 @@ package me.libraryaddict.disguise.utilities.params; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; import javax.annotation.Nullable; import lombok.Getter; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -18,6 +15,10 @@ import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + public class ParamInfoManager { private static List paramList; @Getter diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java index 64f25fff..03e4b85f 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java @@ -3,13 +3,6 @@ package me.libraryaddict.disguise.utilities.params; import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedParticle; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.EntityPose; import me.libraryaddict.disguise.disguisetypes.GolemCrack; @@ -63,6 +56,14 @@ import org.bukkit.inventory.MainHand; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.EulerAngle; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + /** * Created by libraryaddict on 7/09/2018. */ @@ -84,54 +85,43 @@ public class ParamInfoTypes { // Register enum types //paramInfos.add(new ParamInfoEnum(AnimalColor.class, "Animal Color", // "View all the colors you can use for an animal color")); - paramInfos - .add(new ParamInfoEnum(Art.class, "Art", "View all the paintings you can use for a painting disguise")); - paramInfos.add(new ParamInfoEnum(Horse.Color.class, "Horse Color", - "View all the colors you can use for a horses color")); + paramInfos.add(new ParamInfoEnum(Art.class, "Art", "View all the paintings you can use for a painting disguise")); + paramInfos.add(new ParamInfoEnum(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color")); - paramInfos.add(new ParamInfoEnum(Villager.Profession.class, "Villager Profession", - "View all the professions you can set on a Villager and Zombie Villager")); + paramInfos.add( + new ParamInfoEnum(Villager.Profession.class, "Villager Profession", "View all the professions you can set on a Villager and Zombie Villager")); if (NmsVersion.v1_14.isSupported()) { - paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome", - "View all the biomes you can set on a Villager and Zombie Villager")); + paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome", "View all the biomes you can set on a Villager and Zombie Villager")); } paramInfos.add(new ParamInfoEnum(BlockFace.class, "Direction", "Direction (North, East, South, West, Up, Down)", - "View the directions usable on player setSleeping and shulker direction", - Arrays.copyOf(BlockFace.values(), 6))); - paramInfos - .add(new ParamInfoEnum(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into")); - paramInfos - .add(new ParamInfoEnum(TreeSpecies.class, "Tree Species", "View the different types of tree species")); + "View the directions usable on player setSleeping and shulker direction", Arrays.copyOf(BlockFace.values(), 6))); + paramInfos.add(new ParamInfoEnum(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into")); + paramInfos.add(new ParamInfoEnum(TreeSpecies.class, "Tree Species", "View the different types of tree species")); paramInfos.add(new ParamInfoEnum(MainHand.class, "Main Hand", "Set the main hand for an entity")); - paramInfos.add(new ParamInfoEnum(Llama.Color.class, "Llama Color", - "View all the colors you can use for a llama color")); - paramInfos.add(new ParamInfoEnum(Parrot.Variant.class, "Parrot Variant", - "View the different colors a parrot can be")); + paramInfos.add(new ParamInfoEnum(Llama.Color.class, "Llama Color", "View all the colors you can use for a llama color")); + paramInfos.add(new ParamInfoEnum(Parrot.Variant.class, "Parrot Variant", "View the different colors a parrot can be")); if (NmsVersion.v1_13.isSupported()) { - paramInfos.add(new ParamInfoParticle(WrappedParticle.class, "Particle", - "The different particles of Minecraft", Particle.values(), getMaterials())); + paramInfos.add(new ParamInfoParticle(WrappedParticle.class, "Particle", "The different particles of Minecraft", Particle.values(), getMaterials())); paramInfos.add(new ParamInfoEnum(TropicalFish.Pattern.class, "Pattern", "Patterns of a tropical fish")); - paramInfos.add(new ParamInfoBlockData(BlockData.class, "BlockData", - "The block data states, barrel[facing=north,open=false] as example", getMaterials())); + paramInfos.add( + new ParamInfoBlockData(BlockData.class, "BlockData", "The block data states, barrel[facing=north,open=false] as example", getMaterials())); } else { paramInfos.add(new ParamInfoEnum(Particle.class, "Particle", "The different particles of Minecraft")); } paramInfos.add(new ParamInfoEnum(DyeColor.class, "DyeColor", "Dye colors of many different colors")); - paramInfos.add(new ParamInfoEnum(Horse.Style.class, "Horse Style", - "Horse style which is the patterns on the horse")); + paramInfos.add(new ParamInfoEnum(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse")); if (NmsVersion.v1_14.isSupported()) { paramInfos.add(new ParamInfoEnum(EntityPose.class, "EntityPose", "The pose the entity should strike")); paramInfos.add(new ParamInfoEnum(Cat.Type.class, "Cat Type", "The type of cat")); paramInfos.add(new ParamInfoEnum(Fox.Type.class, "Fox Type", "The type of fox")); paramInfos.add(new ParamInfoEnum(Panda.Gene.class, "Panda Gene", "The panda gene type")); - paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant", - "The different variants for mushroom cows")); + paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant", "The different variants for mushroom cows")); if (NmsVersion.v1_17.isSupported()) { paramInfos.add(new ParamInfoEnum(Axolotl.Variant.class, "Axolotl Variant", "The variant of Axolotl")); @@ -140,34 +130,25 @@ public class ParamInfoTypes { paramInfos.add(new ParamInfoEnum(Ocelot.Type.class, "Ocelot Type", "The type of ocelot")); } - paramInfos.add(new ParamInfoEnum(DisguiseConfig.NotifyBar.class, "NotifyBar", - "Where the disguised indicator should appear")); + paramInfos.add(new ParamInfoEnum(DisguiseConfig.NotifyBar.class, "NotifyBar", "Where the disguised indicator should appear")); paramInfos.add(new ParamInfoEnum(BarColor.class, "BarColor", "The color of the boss bar")); paramInfos.add(new ParamInfoEnum(BarStyle.class, "BarStyle", "The style of the boss bar")); // Register custom types - paramInfos.add(new ParamInfoEulerAngle(EulerAngle.class, "Euler Angle", "Euler Angle (X,Y,Z)", - "Set the X,Y,Z directions on an armorstand")); - paramInfos.add(new ParamInfoColor(Color.class, "Color", "Colors that can also be defined through RGB", - getColors())); - paramInfos.add(new ParamInfoEnum(Material.class, "Material", "A material used for blocks and items", - getMaterials())); + paramInfos.add(new ParamInfoEulerAngle(EulerAngle.class, "Euler Angle", "Euler Angle (X,Y,Z)", "Set the X,Y,Z directions on an armorstand")); + paramInfos.add(new ParamInfoColor(Color.class, "Color", "Colors that can also be defined through RGB", getColors())); + paramInfos.add(new ParamInfoEnum(Material.class, "Material", "A material used for blocks and items", getMaterials())); paramInfos.add(new ParamInfoItemStack(ItemStack.class, "ItemStack", "ItemStack (Material,Amount?,Glow?)", - "An ItemStack compromised of Material,Amount,Glow. Only requires Material", getMaterials())); - paramInfos.add(new ParamInfoItemStackArray(ItemStack[].class, "ItemStack[]", - "Four ItemStacks (Material:Amount?:Glow?,Material:Amount?:Glow?..)", - "Four ItemStacks separated by a comma", getMaterials())); - paramInfos.add(new ParamInfoPotionEffect(PotionEffectType.class, "Potion Effect", - "View all the potion effects you can add", getPotions())); + "An ItemStack compromised of Material,Amount,Glow. Only requires Material", getMaterials())); + paramInfos.add(new ParamInfoItemStackArray(ItemStack[].class, "ItemStack[]", "Four ItemStacks (Material:Amount?:Glow?,Material:Amount?:Glow?..)", + "Four ItemStacks separated by a comma", getMaterials())); + paramInfos.add(new ParamInfoPotionEffect(PotionEffectType.class, "Potion Effect", "View all the potion effects you can add", getPotions())); - paramInfos.add(new ParamInfoBlockPosition(BlockPosition.class, "Block Position", "Block Position (num,num,num)", - "Three numbers separated by a ,")); + paramInfos.add(new ParamInfoBlockPosition(BlockPosition.class, "Block Position", "Block Position (num,num,num)", "Three numbers separated by a ,")); paramInfos.add(new ParamInfoGameProfile(WrappedGameProfile.class, "GameProfile", - "Get the gameprofile here https://sessionserver.mojang" + - ".com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false")); + "Get the gameprofile here https://sessionserver.mojang" + ".com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false")); paramInfos.add(new ParamInfoTime(long.class, "Expiry Time", - "Set how long the disguise lasts,