Skip to content

Commit

Permalink
Fixed and optimised update checker for client-sided Debug Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
toydotgame committed Feb 12, 2021
1 parent 5d53a2e commit 1d6d2b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/io/github/Toydotgame/DataStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
// Ah, so simple, yet so helpful.

public class DataStorage {
public static String version;
public static String localVersion;
public static String serverVersion;
public static boolean isUpToDate;


public static boolean debug;
public static String facing;

Expand Down
6 changes: 2 additions & 4 deletions src/io/github/Toydotgame/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public void onEnable() {

CompletableFuture<Resource> future = api.getResource(87115);
future.thenAccept(resource -> {
DataStorage.localVersion = this.getDescription().getVersion();
DataStorage.serverVersion = resource.getVersion();
DataStorage.version = this.getDescription().getVersion();

if(DataStorage.serverVersion.equals(DataStorage.version)) {
DataStorage.isUpToDate = true;
if(this.getDescription().getVersion().equals(resource.getVersion())) { // if(localVersion == serverVersion) {}
System.out.print("[Thisway] Plugin loaded successfully!");
} else {
DataStorage.isUpToDate = false;
System.out.print("[Thisway] Thisway is out-of-date or you are using a beta version of the plugin. If it's the former; I strongly suggest that you update in case of any potential bugs in your copy of the plugin.");
System.out.print("[Thisway] The plugin was loaded anyway.");
}
Expand Down
9 changes: 5 additions & 4 deletions src/io/github/Toydotgame/Thisway.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if(args[0].matches("^[0-9]*$") && args[0] != "0") { // If the first argument is an accepted number.
DataStorage.debug = true;
sender.sendMessage(ChatColor.YELLOW + "=== THISWAY DEBUG START ==="); // Debug header in player chat.
sender.sendMessage("Plugin version: " + DataStorage.version);
sender.sendMessage("Server's Latest Version: " + DataStorage.serverVersion);
if(DataStorage.isUpToDate == true) {

sender.sendMessage("Plugin version: " + DataStorage.localVersion);
sender.sendMessage("Latest Version: " + DataStorage.serverVersion);
if(DataStorage.localVersion.equals(DataStorage.serverVersion)) {
sender.sendMessage(ChatColor.GREEN + "Thisway is up-to-date.");
} else {
sender.sendMessage(ChatColor.RED + "Thisway is not up-to-date with the latest stable version!");
}

thisway(sender, args);
sender.sendMessage(ChatColor.YELLOW + "=== THISWAY DEBUG END ==="); // Debug footer.
return true;
Expand Down

0 comments on commit 1d6d2b1

Please sign in to comment.