diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 1ab4f6d3..63631629 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -264,6 +264,9 @@ public class DisguiseConfig { @Getter @Setter private static String nameAboveDisguise; + @Getter + @Setter + private static int playerDisguisesSkinExpiresMove; public static boolean isArmorstandsName() { return getPlayerNameType() == PlayerNameType.ARMORSTANDS; @@ -694,6 +697,7 @@ public class DisguiseConfig { setOverrideCustomNames(config.getBoolean("OverrideCustomNames")); setRandomDisguises(config.getBoolean("RandomDisguiseOptions")); setSaveUserPreferences(config.getBoolean("SaveUserPreferences")); + setPlayerDisguisesSkinExpiresMove(config.getInt("PlayerDisguisesTablistExpiresMove")); if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!"); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java index b6f188bb..be30a093 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java @@ -58,7 +58,7 @@ public class PlayerSkinHandler implements Listener { public boolean canRemove(boolean onMoved) { return firstPacketSent + (DisguiseConfig.getTablistRemoveDelay() * 50) + - (onMoved ? 0 : TimeUnit.SECONDS.toMillis(5)) < System.currentTimeMillis(); + (onMoved ? 0 : DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50) < System.currentTimeMillis(); } @Override @@ -75,8 +75,9 @@ public class PlayerSkinHandler implements Listener { } @Getter - private final Cache> cache = - CacheBuilder.newBuilder().weakKeys().expireAfterWrite(30, TimeUnit.SECONDS).removalListener((event) -> { + private final Cache> cache = CacheBuilder.newBuilder().weakKeys() + .expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS) + .removalListener((event) -> { if (event.getCause() != RemovalCause.EXPIRED) { return; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5c8f9413..22e443cf 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -291,6 +291,11 @@ ShowPlayerDisguisesInTab: false # 3 ticks should easily be enough. PlayerDisguisesTablistExpires: 3 +# To prevent skins from defaulting to alex/steve, there is a timer that only expires after X ticks or when the player moves +# You shouldn't actually touch this, but eh. Your server. +# Default is 5 seconds +PlayerDisguisesTablistExpiresMove: 100 + # 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