From b81f99aa0fc98d02aee51b7cbb9927ba8492ea7f Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 16 Dec 2018 17:19:59 +1300 Subject: [PATCH] Fix typo for numbered/custom build numbers display --- .../libraryaddict/disguise/DisguiseListener.java | 2 +- .../me/libraryaddict/disguise/LibsDisguises.java | 16 +++++++++++++--- .../disguise/commands/LibsDisguisesCommand.java | 8 +++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java index e93090fd..a4f035f3 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java @@ -96,7 +96,7 @@ public class DisguiseListener implements Listener { } // If build number is null, or not a number. Then we can't check snapshots regardless - if (plugin.getBuildNo() == null || !plugin.getBuildNo().matches("[0-9]+")) { + if (!plugin.isNumberedBuild()) { return true; } diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 88a12945..dfd7e13d 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -43,8 +43,7 @@ public class LibsDisguises extends JavaPlugin { getLogger().info("Discovered nms version: " + ReflectionManager.getBukkitVersion()); - boolean hashBuild = getBuildNo() != null && getBuildNo().matches("[0-9]+"); - getLogger().info("Jenkins Build: " + (hashBuild ? "#" : "") + getBuildNo()); + getLogger().info("Jenkins Build: " + (isNumberedBuild() ? "#" : "") + getBuildNo()); LibsPremium.check(getDescription().getVersion()); @@ -116,8 +115,15 @@ public class LibsDisguises extends JavaPlugin { // If a release build, attach build number if (!isReleaseBuild()) { + version += "-"; + // 9.7.0-SNAPSHOT-b30 - version += "-b" + getBuildNo(); + if (isNumberedBuild()) { + version += "b"; + } + // else 9.7.0-SNAPSHOT-unknown + + version += getBuildNo(); } Metrics metrics = new Metrics(this, version); @@ -314,6 +320,10 @@ public class LibsDisguises extends JavaPlugin { return buildNumber; } + public boolean isNumberedBuild() { + return getBuildNo() != null && getBuildNo().matches("[0-9]+"); + } + private void registerCommand(String commandName, CommandExecutor executioner) { PluginCommand command = getCommand(commandName); diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java index b551e5a5..f3090a06 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java @@ -57,7 +57,13 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { String version = disguises.getDescription().getVersion(); if (!disguises.isReleaseBuild()) { - version += "-b" + disguises.getBuildNo(); + version += "-"; + + if (disguises.isNumberedBuild()) { + version += "b"; + } + + version += disguises.getBuildNo(); } sender.sendMessage(ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + version +