Add config option for those that insist on broken builds for #715

This commit is contained in:
libraryaddict 2023-06-09 19:03:57 +12:00
parent 10fcc8535d
commit ee48f783be
5 changed files with 32 additions and 19 deletions

View File

@ -283,6 +283,9 @@ public class DisguiseConfig {
@Getter
@Setter
private static List<String> disabledMethods = new ArrayList<>();
@Getter
@Setter
private static boolean neverUpdateProtocolLib;
public static boolean isArmorstandsName() {
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
@ -707,6 +710,8 @@ public class DisguiseConfig {
setDisabledMethods(config.getStringList("DisabledMethods"));
setNeverUpdateProtocolLib(config.getBoolean("NeverUpdateProtocolLib", false));
String seeCommands = config.getString("Permissions.SeeCommands");
PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands);

View File

@ -82,26 +82,30 @@ public class LibsDisguises extends JavaPlugin {
Plugin plugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
if (plugin == null || DisguiseUtilities.isProtocolLibOutdated()) {
getLogger().warning("Noticed you're using an older version of ProtocolLib (or not using it)! We're forcibly updating you!");
if (DisguiseConfig.isNeverUpdateProtocolLib()) {
getLogger().warning(
"Defined in plugins/LibsDisguises/configs/sanity.yml, you have requested that Lib's Disguises never updates or installs ProtocolLib. " +
"Please do not report any issues with this plugin.");
} else {
getLogger().warning("Noticed you're using an older version of ProtocolLib (or not using it)! We're forcibly updating you!");
try {
File dest = DisguiseUtilities.updateProtocolLib();
try {
File dest = DisguiseUtilities.updateProtocolLib();
if (plugin == null) {
getLogger().info("ProtocolLib downloaded and stuck in plugins folder! Now trying to load it!");
plugin = Bukkit.getPluginManager().loadPlugin(dest);
plugin.onLoad();
if (plugin == null) {
getLogger().info("ProtocolLib downloaded and stuck in plugins folder! Now trying to load it!");
plugin = Bukkit.getPluginManager().loadPlugin(dest);
plugin.onLoad();
Bukkit.getPluginManager().enablePlugin(plugin);
} else {
getLogger().severe("Please restart the server to complete the ProtocolLib update!");
Bukkit.getPluginManager().enablePlugin(plugin);
} else {
getLogger().severe("Please restart the server to complete the ProtocolLib update!");
}
} catch (Exception e) {
getLogger().severe("Looks like ProtocolLib's site may be down! Try download it manually from https://ci.dmulloy2.net/job/ProtocolLib/");
e.printStackTrace();
}
} catch (Exception e) {
getLogger().severe(
"Looks like ProtocolLib's site may be down! Try download it manually from https://ci.dmulloy2.net/job/ProtocolLib/");
e.printStackTrace();
}
}
try {
@ -198,7 +202,7 @@ public class LibsDisguises extends JavaPlugin {
return;
}
if (DisguiseUtilities.isProtocolLibOutdated()) {
if (DisguiseUtilities.isProtocolLibOutdated() && !DisguiseConfig.isNeverUpdateProtocolLib()) {
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
String version = Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();

View File

@ -83,7 +83,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
if (DisguiseUtilities.isProtocolLibOutdated() && sender.hasPermission("libsdisguises.update")) {
if (!DisguiseConfig.isNeverUpdateProtocolLib() && DisguiseUtilities.isProtocolLibOutdated() && sender.hasPermission("libsdisguises.update")) {
DisguiseUtilities.sendProtocolLibUpdateMessage(sender, version, requiredProtocolLib);
}

View File

@ -401,7 +401,7 @@ public class DisguiseListener implements Listener {
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
if (DisguiseUtilities.isProtocolLibOutdated() && p.hasPermission("libsdisguises.update")) {
if (!DisguiseConfig.isNeverUpdateProtocolLib() && DisguiseUtilities.isProtocolLibOutdated() && p.hasPermission("libsdisguises.update")) {
DisguiseUtilities.sendProtocolLibUpdateMessage(p, version, requiredProtocolLib);
new BukkitRunnable() {

View File

@ -43,4 +43,8 @@ SaddleableHorse: false
# You shouldn't need to touch this, but if you do; This was added so scoreboard stuff that affects a certain UUID, will still continue to affect that UUID
# This doesn't affect player disguises as those would be severely impacted
# If you are getting issues using this, please do not report them. You disable this at your own risk.
RandomUUIDs: true
RandomUUIDs: true
# When you for some strange reason don't want ProtocolLib to update, enable this!
# Disclaimer: If you enable this, you are responsible for ensuring ProtocolLib is up to date.
NeverUpdateProtocolLib: false