From 0a2b41d99d9d0ce454254101aed84f6cee17669a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 3 Feb 2019 14:02:59 +1300 Subject: [PATCH] Add config option to change player disguise tablist expiry time, fixes #326 --- .../libraryaddict/disguise/DisguiseConfig.java | 16 +++++++++++++--- .../packethandlers/PacketHandlerSpawn.java | 2 +- src/main/resources/config.yml | 7 +++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 07cab6b1..ba61a346 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -4,9 +4,9 @@ import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.packets.PacketsManager; -import me.libraryaddict.disguise.utilities.translations.TranslateType; import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; import me.libraryaddict.disguise.utilities.parser.DisguiseParser; +import me.libraryaddict.disguise.utilities.translations.TranslateType; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; @@ -76,6 +76,15 @@ public class DisguiseConfig { private static boolean disableCommands; private static int uuidGeneratedVersion; private static UpdatesBranch updatesBranch = UpdatesBranch.SAME_BUILDS; + private static int playerDisguisesTablistExpires; + + public static int getPlayerDisguisesTablistExpires() { + return playerDisguisesTablistExpires; + } + + public static void setPlayerDisguisesTablistExpires(int playerDisguisesTablistExpiresTicks) { + playerDisguisesTablistExpires = playerDisguisesTablistExpiresTicks; + } public static UpdatesBranch getUpdatesBranch() { return updatesBranch; @@ -270,6 +279,7 @@ public class DisguiseConfig { disableCommands = config.getBoolean("DisableCommands"); setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplicitDisguises")); setUUIDGeneratedVersion(config.getInt("UUIDVersion")); + setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpires")); if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!"); @@ -279,8 +289,8 @@ public class DisguiseConfig { setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase())); } catch (Exception ex) { - DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("UpdatesBranch") + - "' to a valid option for UpdatesBranch"); + DisguiseUtilities.getLogger().warning( + "Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch"); } try { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index 2474a3e3..bc41f93b 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -289,7 +289,7 @@ public class PacketHandlerSpawn implements IPacketHandler { deleteTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4)); if (!((PlayerDisguise) disguise).isDisplayedInTab()) { - packets.addDelayedPacket(deleteTab, 40); + packets.addDelayedPacket(deleteTab, DisguiseConfig.getPlayerDisguisesTablistExpires()); } } else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) { Vector vec = disguisedEntity.getVelocity(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bbafb99b..22b92028 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -186,6 +186,13 @@ HideDisguisedPlayersFromTab: false # Always show player disguises in tab? The names will continue to appear in tab until the disguise is removed. ShowPlayerDisguisesInTab: false +# On player disguise, a fake player is added to tablist so the skin can load properly. +# If the viewer sees the player disguise but there's no tablist name, they won't see a skin. +# 2 seconds is normally long enough to load the skin properly, but sometimes the server needs longer +# This is in ticks, there are 20 ticks in every second. 40 ticks = 2 seconds. 200 ticks = 10 seconds. +# This option is ignored if 'ShowPlayerDisguisesInTab' is enabled. +PlayerDisguisesTablistExpires: 40 + # Don't like players able to set themselves invisible when using the disguise commands? Toggle this to true and no one can use setInvisible! Plugins can still use this however. DisableInvisibility: false