Add config option to change player disguise tablist expiry time, fixes #326

This commit is contained in:
libraryaddict 2019-02-03 14:02:59 +13:00
parent f4eed5481d
commit 0a2b41d99d
3 changed files with 21 additions and 4 deletions

View File

@ -4,9 +4,9 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.packets.PacketsManager; 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.DisguiseParseException;
import me.libraryaddict.disguise.utilities.parser.DisguiseParser; import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -76,6 +76,15 @@ public class DisguiseConfig {
private static boolean disableCommands; private static boolean disableCommands;
private static int uuidGeneratedVersion; private static int uuidGeneratedVersion;
private static UpdatesBranch updatesBranch = UpdatesBranch.SAME_BUILDS; 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() { public static UpdatesBranch getUpdatesBranch() {
return updatesBranch; return updatesBranch;
@ -270,6 +279,7 @@ public class DisguiseConfig {
disableCommands = config.getBoolean("DisableCommands"); disableCommands = config.getBoolean("DisableCommands");
setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplicitDisguises")); setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplicitDisguises"));
setUUIDGeneratedVersion(config.getInt("UUIDVersion")); setUUIDGeneratedVersion(config.getInt("UUIDVersion"));
setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpires"));
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!"); 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())); setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase()));
} }
catch (Exception ex) { catch (Exception ex) {
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("UpdatesBranch") + DisguiseUtilities.getLogger().warning(
"' to a valid option for UpdatesBranch"); "Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch");
} }
try { try {

View File

@ -289,7 +289,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
deleteTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4)); deleteTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4));
if (!((PlayerDisguise) disguise).isDisplayedInTab()) { if (!((PlayerDisguise) disguise).isDisplayedInTab()) {
packets.addDelayedPacket(deleteTab, 40); packets.addDelayedPacket(deleteTab, DisguiseConfig.getPlayerDisguisesTablistExpires());
} }
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) { } else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
Vector vec = disguisedEntity.getVelocity(); Vector vec = disguisedEntity.getVelocity();

View File

@ -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. # Always show player disguises in tab? The names will continue to appear in tab until the disguise is removed.
ShowPlayerDisguisesInTab: false 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. # 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 DisableInvisibility: false