From 109c85f4dd1d7c4480bf7fcb571fb58a20acf323 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 29 Nov 2015 14:27:44 +0100 Subject: [PATCH] Auto build number + helpHeader config --- pom.xml | 65 +++++++++++++++++++ src/main/java/fr/xephi/authme/AuthMe.java | 30 +++++---- .../executable/authme/AuthMeCommand.java | 2 +- .../executable/authme/VersionCommand.java | 6 +- .../authme/command/help/HelpProvider.java | 4 +- .../fr/xephi/authme/settings/Settings.java | 7 +- src/main/resources/config.yml | 2 + src/main/resources/plugin.yml | 2 +- 8 files changed, 99 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index 42a9edc9c..2e8daf93e 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,7 @@ AuthMe fr.xephi.authme.AuthMe Xephi, sgdc3, DNx5, timvisee, games647, ljacqu + Unknown 1.7 @@ -61,6 +62,20 @@ 1.8.8-R0.1-SNAPSHOT + + + jenkins + + + env.BUILD_NUMBER + + + + ${env.BUILD_NUMBER} + + + + AuthMe-${project.version} src/main/java @@ -101,6 +116,39 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + [1.0,) + + create-timestamp + + + + + true + true + + + + + + + + + + org.apache.maven.plugins @@ -111,6 +159,23 @@ ${javaVersion} + + org.codehaus.mojo + buildnumber-maven-plugin + 1.4 + + dd-MM-yy_HH:mm + build.time + + + + generate-resources + + create-timestamp + + + + diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index ab54071a1..800cbc71c 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -60,15 +60,9 @@ public class AuthMe extends JavaPlugin { * Defines the name of the plugin. */ private static final String PLUGIN_NAME = "AuthMeReloaded"; - /** - * Defines the current AuthMeReloaded version name. - */ - private static final String PLUGIN_VERSION_NAME = "5.1-SNAPSHOT"; - /** - * Defines the current AuthMeReloaded version code. - */ - // TODO: increment this value manually - private static final int PLUGIN_VERSION_CODE = 120; + + private static String pluginVersion = "N/D"; + private static String pluginBuildNumber = "Unknown"; private static AuthMe plugin; private static Server server; @@ -128,8 +122,8 @@ public class AuthMe extends JavaPlugin { * * @return The version name of the currently installed AuthMeReloaded instance. */ - public static String getVersionName() { - return PLUGIN_VERSION_NAME; + public static String getPluginVersion() { + return pluginVersion; } /** @@ -137,8 +131,8 @@ public class AuthMe extends JavaPlugin { * * @return The version code of the currently installed AuthMeReloaded instance. */ - public static int getVersionCode() { - return PLUGIN_VERSION_CODE; + public static String getPluginBuildNumber() { + return pluginBuildNumber; } /** @@ -187,6 +181,15 @@ public class AuthMe extends JavaPlugin { this.canConnect = canConnect; } + // Get version and build number of the plugin + // TODO: enhance this + private void setupConstants() { + String versionRaw = this.getDescription().getVersion(); + pluginVersion = versionRaw.substring(0, versionRaw.indexOf("-b")); + String buildRaw = versionRaw.substring(1, versionRaw.indexOf("-b")); + pluginBuildNumber = buildRaw.substring(0, buildRaw.indexOf("-t")); + } + /** * Method called when the server enables the plugin. * @@ -197,6 +200,7 @@ public class AuthMe extends JavaPlugin { // Set various instances server = getServer(); plugin = this; + setupConstants(); // Set up the permissions manager setupPermissionsManager(); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java index 98ea2e9c8..f00ea9166 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java @@ -13,7 +13,7 @@ public class AuthMeCommand extends ExecutableCommand { @Override public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { // Show some version info - sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v" + AuthMe.getVersionName() + "! " + ChatColor.RED + "<3"); + sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + " b" + AuthMe.getPluginBuildNumber()+ "! " + ChatColor.RED + "<3"); sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " help" + ChatColor.YELLOW + " to view help."); sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about."); return true; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java index a07a0f88e..fc92ac8f5 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java @@ -3,6 +3,8 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.AuthMe; import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.ExecutableCommand; +import fr.xephi.authme.settings.Settings; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -24,8 +26,8 @@ public class VersionCommand extends ExecutableCommand { @Override public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { // Show some version info - sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName().toUpperCase() + " ABOUT ]=========="); - sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getVersionName() + ChatColor.GRAY + " (code: " + AuthMe.getVersionCode() + ")"); + sender.sendMessage(ChatColor.GOLD + "==========[ " + Settings.helpHeader.toUpperCase() + " ABOUT ]=========="); + sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")"); sender.sendMessage(ChatColor.GOLD + "Developers:"); printDeveloper(sender, "Xephi", "xephi59", "Lead Developer"); printDeveloper(sender, "DNx5", "DNx5", "Developer"); diff --git a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java index ce4e83173..45427c505 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java @@ -4,6 +4,8 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.command.CommandDescription; import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.FoundCommandResult; +import fr.xephi.authme.settings.Settings; + import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -99,7 +101,7 @@ public class HelpProvider { } // Print the help header - sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName().toUpperCase() + " HELP ]=========="); + sender.sendMessage(ChatColor.GOLD + "==========[ " + Settings.helpHeader.toUpperCase() + " HELP ]=========="); // Print the command help information if (showCommand) diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 55c24cf98..7a2096808 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -69,7 +69,7 @@ public final class Settings extends YamlConfiguration { broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect, customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite; - public static String getNickRegex, getUnloggedinGroup, getMySQLHost, + public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename, getMySQLColumnName, getMySQLColumnPassword, getMySQLColumnIp, getMySQLColumnLastLogin, getMySQLColumnSalt, @@ -129,6 +129,7 @@ public final class Settings extends YamlConfiguration { public static void loadVariables() { + helpHeader = configFile.getString("settings.helpHeader", "AuthMeReloaded"); messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en").toLowerCase()); isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false); isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true); @@ -551,6 +552,10 @@ public final class Settings extends YamlConfiguration { set("Protection.countriesBlacklist", countriesBlacklist); changes = true; } + if (!contains("settings.helpHeader")) { + set("settings.helpHeader", "AuthMeReloaded"); + changes = true; + } if (!contains("settings.broadcastWelcomeMessage")) { set("settings.broadcastWelcomeMessage", false); changes = true; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cbf62dcb2..5abd17eb8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -45,6 +45,8 @@ DataSource: # Enable this when you allow registration through a website mySQLWebsite: false settings: + # The name shown in the help messages. + helpHeader: AuthMeReloaded sessions: # Do you want to enable the session feature? # If enabled, when a player authenticates successfully, diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 50d9ff38c..3cb51c69e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ authors: [${pluginAuthors}] website: ${project.url} description: ${project.description} main: ${mainClass} -version: ${project.version}-b${env.BUILD_NUMBER} +version: ${project.version}-b${buildNumber}-t${build.time} softdepend: - Vault - PermissionsBukkit