Skip to content

Commit

Permalink
Add build number from Jenkins to startup splash message
Browse files Browse the repository at this point in the history
  • Loading branch information
SparklingComet committed Oct 14, 2023
1 parent e2d0a16 commit 9898123
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/shanerx/tradeshop/TradeShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ public void onEnable() {

registration();

getSettingManager().updateSkipHoppers();
getVarManager().getSettingManager().updateSkipHoppers();

getSigns();
getStorages();
getListManager();
getVarManager().getSigns();
getVarManager().getStorages();
getVarManager().getListManager();

if (Setting.CHECK_UPDATES.getBoolean()) {
new Thread(() -> getUpdater().checkCurrentVersion()).start();
}

if (Setting.ALLOW_METRICS.getBoolean()) {
getMetricsManager();
getVarManager().getMetricsManager();
getLogger().info("Metrics successfully initialized!");
} else {
getLogger().warning("Metrics are disabled! Please consider enabling them to support the authors!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package org.shanerx.tradeshop.commands.commandrunners;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.commands.SubCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package org.shanerx.tradeshop.commands.commandrunners;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.commands.CommandType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.shanerx.tradeshop.TradeShop;

public class Updater {

Expand Down Expand Up @@ -85,6 +89,19 @@ public String getVersionComponent(SemVer semver) {
public BuildType getBuildType() {
return build;
}

public String buildNumberSuffix() {
try {
Path path = Paths.get(TradeShop.class.getProtectionDomain().getCodeSource().getLocation().toURI());
String name = path.getFileName().toString();
if (!name.matches(".+\\d+.jar$")) return "";
String buildNum = name.substring(name.length() - 7, name.length() - 4);
return " build " + buildNum;
} catch (URISyntaxException e) {
e.printStackTrace();
}
return "";
}

public RelationalStatus checkCurrentVersion() {
try {
Expand All @@ -106,11 +123,11 @@ public RelationalStatus checkCurrentVersion() {
log.log(Level.WARNING, "[Updater] +------------------------------------------------+");
in.close();
return RelationalStatus.BEHIND;
} else if (rs == RelationalStatus.AHEAD) {
} else if (rs == RelationalStatus.AHEAD || getVersion().endsWith("DEV")) {
log.log(Level.WARNING, "[Updater] +-----------------------------------------------------+");
log.log(Level.WARNING, "[Updater] You are running a developmental version of " + pdf.getName() + "!");
log.log(Level.WARNING, "[Updater] Most recent stable version: " + inputLine);
log.log(Level.WARNING, "[Updater] Current version: " + getVersion());
log.log(Level.WARNING, "[Updater] Current version: " + getVersion() + buildNumberSuffix());
log.log(Level.WARNING, "[Updater] Please notice that the build may contain critical bugs!");
log.log(Level.WARNING, "[Updater] +-----------------------------------------------------+");
in.close();
Expand Down

0 comments on commit 9898123

Please sign in to comment.