Auto build number + helpHeader config

This commit is contained in:
Gabriele C 2015-11-29 14:27:44 +01:00
parent d6df921841
commit 109c85f4dd
8 changed files with 99 additions and 19 deletions

65
pom.xml
View File

@ -53,6 +53,7 @@
<pluginName>AuthMe</pluginName> <pluginName>AuthMe</pluginName>
<mainClass>fr.xephi.authme.AuthMe</mainClass> <mainClass>fr.xephi.authme.AuthMe</mainClass>
<pluginAuthors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu</pluginAuthors> <pluginAuthors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu</pluginAuthors>
<buildNumber>Unknown</buildNumber>
<!-- Change Compiler Version (JDK) HERE! --> <!-- Change Compiler Version (JDK) HERE! -->
<javaVersion>1.7</javaVersion> <javaVersion>1.7</javaVersion>
@ -61,6 +62,20 @@
<bukkitVersion>1.8.8-R0.1-SNAPSHOT</bukkitVersion> <bukkitVersion>1.8.8-R0.1-SNAPSHOT</bukkitVersion>
</properties> </properties>
<profiles>
<profile>
<id>jenkins</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<buildNumber>${env.BUILD_NUMBER}</buildNumber>
</properties>
</profile>
</profiles>
<build> <build>
<finalName>AuthMe-${project.version}</finalName> <finalName>AuthMe-${project.version}</finalName>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
@ -101,6 +116,39 @@
</testResource> </testResource>
</testResources> </testResources>
<!-- Just to keep Eclipse compatibility... -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>create-timestamp</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnConfiguration>true</runOnConfiguration>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -111,6 +159,23 @@
<target>${javaVersion}</target> <target>${javaVersion}</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<timestampFormat>dd-MM-yy_HH:mm</timestampFormat>
<timestampPropertyName>build.time</timestampPropertyName>
</configuration>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- TODO: we need also to relocate the other libs --> <!-- TODO: we need also to relocate the other libs -->
<plugin> <plugin>

View File

@ -60,15 +60,9 @@ public class AuthMe extends JavaPlugin {
* Defines the name of the plugin. * Defines the name of the plugin.
*/ */
private static final String PLUGIN_NAME = "AuthMeReloaded"; private static final String PLUGIN_NAME = "AuthMeReloaded";
/**
* Defines the current AuthMeReloaded version name. private static String pluginVersion = "N/D";
*/ private static String pluginBuildNumber = "Unknown";
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 AuthMe plugin; private static AuthMe plugin;
private static Server server; private static Server server;
@ -128,8 +122,8 @@ public class AuthMe extends JavaPlugin {
* *
* @return The version name of the currently installed AuthMeReloaded instance. * @return The version name of the currently installed AuthMeReloaded instance.
*/ */
public static String getVersionName() { public static String getPluginVersion() {
return PLUGIN_VERSION_NAME; return pluginVersion;
} }
/** /**
@ -137,8 +131,8 @@ public class AuthMe extends JavaPlugin {
* *
* @return The version code of the currently installed AuthMeReloaded instance. * @return The version code of the currently installed AuthMeReloaded instance.
*/ */
public static int getVersionCode() { public static String getPluginBuildNumber() {
return PLUGIN_VERSION_CODE; return pluginBuildNumber;
} }
/** /**
@ -187,6 +181,15 @@ public class AuthMe extends JavaPlugin {
this.canConnect = canConnect; 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. * Method called when the server enables the plugin.
* *
@ -197,6 +200,7 @@ public class AuthMe extends JavaPlugin {
// Set various instances // Set various instances
server = getServer(); server = getServer();
plugin = this; plugin = this;
setupConstants();
// Set up the permissions manager // Set up the permissions manager
setupPermissionsManager(); setupPermissionsManager();

View File

@ -13,7 +13,7 @@ public class AuthMeCommand extends ExecutableCommand {
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info // 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) + " help" + ChatColor.YELLOW + " to view help.");
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about."); sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about.");
return true; return true;

View File

@ -3,6 +3,8 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Settings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -24,8 +26,8 @@ public class VersionCommand extends ExecutableCommand {
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info // Show some version info
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName().toUpperCase() + " ABOUT ]=========="); sender.sendMessage(ChatColor.GOLD + "==========[ " + Settings.helpHeader.toUpperCase() + " ABOUT ]==========");
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getVersionName() + ChatColor.GRAY + " (code: " + AuthMe.getVersionCode() + ")"); sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")");
sender.sendMessage(ChatColor.GOLD + "Developers:"); sender.sendMessage(ChatColor.GOLD + "Developers:");
printDeveloper(sender, "Xephi", "xephi59", "Lead Developer"); printDeveloper(sender, "Xephi", "xephi59", "Lead Developer");
printDeveloper(sender, "DNx5", "DNx5", "Developer"); printDeveloper(sender, "DNx5", "DNx5", "Developer");

View File

@ -4,6 +4,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandDescription; import fr.xephi.authme.command.CommandDescription;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.FoundCommandResult; import fr.xephi.authme.command.FoundCommandResult;
import fr.xephi.authme.settings.Settings;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -99,7 +101,7 @@ public class HelpProvider {
} }
// Print the help header // 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 // Print the command help information
if (showCommand) if (showCommand)

View File

@ -69,7 +69,7 @@ public final class Settings extends YamlConfiguration {
broadcastWelcomeMessage, forceRegKick, forceRegLogin, broadcastWelcomeMessage, forceRegKick, forceRegLogin,
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect, checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite; customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost,
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
getMySQLTablename, getMySQLColumnName, getMySQLColumnPassword, getMySQLTablename, getMySQLColumnName, getMySQLColumnPassword,
getMySQLColumnIp, getMySQLColumnLastLogin, getMySQLColumnSalt, getMySQLColumnIp, getMySQLColumnLastLogin, getMySQLColumnSalt,
@ -129,6 +129,7 @@ public final class Settings extends YamlConfiguration {
public static void loadVariables() { public static void loadVariables() {
helpHeader = configFile.getString("settings.helpHeader", "AuthMeReloaded");
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en").toLowerCase()); messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en").toLowerCase());
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false); isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true); isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
@ -551,6 +552,10 @@ public final class Settings extends YamlConfiguration {
set("Protection.countriesBlacklist", countriesBlacklist); set("Protection.countriesBlacklist", countriesBlacklist);
changes = true; changes = true;
} }
if (!contains("settings.helpHeader")) {
set("settings.helpHeader", "AuthMeReloaded");
changes = true;
}
if (!contains("settings.broadcastWelcomeMessage")) { if (!contains("settings.broadcastWelcomeMessage")) {
set("settings.broadcastWelcomeMessage", false); set("settings.broadcastWelcomeMessage", false);
changes = true; changes = true;

View File

@ -45,6 +45,8 @@ DataSource:
# Enable this when you allow registration through a website # Enable this when you allow registration through a website
mySQLWebsite: false mySQLWebsite: false
settings: settings:
# The name shown in the help messages.
helpHeader: AuthMeReloaded
sessions: sessions:
# Do you want to enable the session feature? # Do you want to enable the session feature?
# If enabled, when a player authenticates successfully, # If enabled, when a player authenticates successfully,

View File

@ -3,7 +3,7 @@ authors: [${pluginAuthors}]
website: ${project.url} website: ${project.url}
description: ${project.description} description: ${project.description}
main: ${mainClass} main: ${mainClass}
version: ${project.version}-b${env.BUILD_NUMBER} version: ${project.version}-b${buildNumber}-t${build.time}
softdepend: softdepend:
- Vault - Vault
- PermissionsBukkit - PermissionsBukkit