Skip to content

Commit

Permalink
VERSION 3.10 RELEASE CANDIDATE 2
Browse files Browse the repository at this point in the history
Closes #162
  • Loading branch information
JustBru00 committed Jun 29, 2021
1 parent e53a7a2 commit c5d8b4a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
48 changes: 45 additions & 3 deletions src/com/gmail/justbru00/epic/rename/main/v3/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ public class Main extends JavaPlugin {
public static MCVersion MC_VERSION;
public static Main plugin;
public static PluginFile messages = null;
public static PluginFile statsFile = null;

/**
* Vault economy.
*/
public static Economy econ = null;
public static boolean USE_ECO = false;
public static boolean USE_XP_COST = false;

public static boolean usesEpicRenameOnlineFeatures = false;

public static ConsoleCommandSender clogger = Bukkit.getServer().getConsoleSender();
public static Logger log = Bukkit.getLogger();
Expand All @@ -80,8 +79,11 @@ public void onDisable() {
public void onEnable() {
plugin = this;

// Save default yaml files.
this.saveDefaultConfig();
messages = new PluginFile(this, "messages.yml", "messages.yml");
statsFile = new PluginFile(this, "stats.yml"); // Issue #162

PLUGIN_VERISON = Main.getInstance().getDescription().getVersion();

checkServerVerison();
Expand Down Expand Up @@ -159,7 +161,7 @@ public String call() throws Exception {

@Override
public String call() throws Exception {
return Boolean.toString(Main.usesEpicRenameOnlineFeatures);
return Boolean.toString(Main.isEpicRenameOnlineFeaturesUsedBefore());
}

}));
Expand Down Expand Up @@ -290,4 +292,44 @@ public static String getStackTrace(Throwable aThrowable) {
public static PluginFile getMessagesYmlFile() {
return messages;
}

/**
* Issue #162
* Saves the given value to the stats.yml file.
* Will only actually save the value to the file if it is different than the value already set in the file.
* This is to prevent any extra IO calls.
* @param The boolean value of EpicRenameOnline feature use.
*/
public static void setEpicRenameOnlineFeaturesUsedBefore(boolean value) {
if (statsFile != null) {
if (statsFile.isBoolean("epicrenameonline_features_used_before")) {
if (statsFile.getBoolean("epicrenameonline_features_used_before") != value) {
statsFile.set("epicrenameonline_features_used_before", value);
statsFile.save();
}
}
} else {
Debug.send("[Main#setEpicRenameOnlineFeaturesUsedBefore] stats.yml file is null. Are you sure it was able to be saved during onEnable?");
}
}

/**
* Issue #162
* Reads the current boolean value of the key epicrenameonline_features_used_before from stats.yml
* @return The boolean value.
*/
public static boolean isEpicRenameOnlineFeaturesUsedBefore() {
if (statsFile == null) {
Debug.send("[Main#isEpicRenameOnlineFeaturesUsedBefore] stats.yml file is null. Are you sure it was able to be saved duriong onEnable?");
return false;
}

if (statsFile.isBoolean("epicrenameonline_features_used_before")) {
return statsFile.getBoolean("epicrenameonline_features_used_before");
} else {
statsFile.set("epicrenameonline_features_used_before", false);
statsFile.save();
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class EpicRenameOnlineAPI {
* @throws IOException
*/
public static Optional<String> getTextFromURL(String url) throws IOException, EpicRenameOnlineExpiredException, EpicRenameOnlineNotFoundException {
Main.usesEpicRenameOnlineFeatures = true;
Main.setEpicRenameOnlineFeaturesUsedBefore(true);
if (url.contains("https://pastebin.com/") && !url.contains("raw/")) {
String newUrl = "";

Expand Down Expand Up @@ -115,7 +115,7 @@ public static Optional<String> getTextFromURL(String url) throws IOException, Ep
*/
public static String paste(String data) throws MalformedURLException, IOException {
String response = post(data);
Main.usesEpicRenameOnlineFeatures = true;
Main.setEpicRenameOnlineFeaturesUsedBefore(true);

return response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: EpicRename
main: com.gmail.justbru00.epic.rename.main.v3.Main
version: 3.10-RC1
version: 3.10-RC2
description: Performs different item modifications with easy to use commands.
authors: [Justin Brubaker,JustBru00,jayoevans]
softdepend: [Vault]
Expand Down

0 comments on commit c5d8b4a

Please sign in to comment.