Add build number

This commit is contained in:
Telesphoreo 2022-03-26 16:36:29 -05:00
parent 0d662c18ea
commit 4646b87893
4 changed files with 40 additions and 6 deletions

View file

@ -45,12 +45,6 @@ ext {
buildNumber = System.getenv("BUILD_NUMBER") ?: "unknown"
}
tasks.register('printProperties') {
doLast {
println buildNumber
}
}
shadowJar {
archiveClassifier.set("")
relocate "org.bstats", "dev.plex"
@ -66,6 +60,12 @@ bukkit {
apiVersion = "1.18"
}
task buildProperties {
ant.propertyfile(file: "$project.rootDir/src/main/resources/build.properties") {
entry(key: "buildNumber", value: buildNumber)
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

View file

@ -24,6 +24,8 @@ import dev.plex.util.PlexUtils;
import dev.plex.util.UpdateChecker;
import dev.plex.world.CustomWorld;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
@ -219,4 +221,29 @@ public class Plex extends JavaPlugin
}
});
}
public static class BuildProperties
{
public String number;
public void load(Plex plugin)
{
try
{
final Properties props;
try (InputStream in = plugin.getResource("build.properties"))
{
props = new Properties();
props.load(in);
}
number = props.getProperty("buildNumber", "unknown");
}
catch (Exception ex)
{
PlexLog.error("Could not load build properties! Did you compile with NetBeans/Maven?");
}
}
}
}

View file

@ -1,5 +1,6 @@
package dev.plex.command.impl;
import dev.plex.Plex;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
@ -24,6 +25,8 @@ import org.jetbrains.annotations.Nullable;
public class PlexCMD extends PlexCommand
{
// Don't modify this command
Plex.BuildProperties build = new Plex.BuildProperties();
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
@ -32,6 +35,7 @@ public class PlexCMD extends PlexCommand
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion()));
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
send(sender, mmString("<light_purple>Build: <gold>" + build.number));
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
return null;
}

View file

@ -0,0 +1,3 @@
#Sat, 26 Mar 2022 16:36:02 -0500
buildNumber=unknown