From 68a97c577ae9be97003e27aeccebf65c13138b8a Mon Sep 17 00:00:00 2001 From: Brianna Date: Fri, 26 Apr 2019 03:38:16 -0400 Subject: [PATCH] Songoda Update --- .../UltimateModeration.java | 11 +++++-- .../command/commands/CommandSettings.java | 4 +-- .../utils/SettingsManager.java | 1 - .../utils/updateModules/LocaleModule.java | 32 +++++++++++++++++++ src/main/resources/plugin.yml | 2 +- 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/songoda/ultimatemoderation/utils/updateModules/LocaleModule.java diff --git a/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java b/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java index c9a4ff9..c08b92c 100644 --- a/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java +++ b/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java @@ -24,9 +24,11 @@ import com.songoda.ultimatemoderation.utils.Metrics; import com.songoda.ultimatemoderation.utils.ServerVersion; import com.songoda.ultimatemoderation.utils.SettingsManager; import com.songoda.ultimatemoderation.utils.gui.AbstractGUI; +import com.songoda.ultimatemoderation.utils.updateModules.LocaleModule; +import com.songoda.update.Plugin; +import com.songoda.update.SongodaUpdate; import org.apache.commons.lang.ArrayUtils; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; @@ -60,7 +62,6 @@ public class UltimateModeration extends JavaPlugin { console.sendMessage(Methods.formatText("&a=============================")); console.sendMessage(Methods.formatText("&7UltimateModeration " + this.getDescription().getVersion() + " by &5Songoda <3!")); console.sendMessage(Methods.formatText("&7Action: &aEnabling&7...")); - console.sendMessage(Methods.formatText("&a=============================")); this.settingsManager = new SettingsManager(this); this.setupConfig(); @@ -71,6 +72,11 @@ public class UltimateModeration extends JavaPlugin { Locale.saveDefaultLocale("en_US"); this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode)); + //Running Songoda Updater + Plugin plugin = new Plugin(this, 29); + plugin.addModule(new LocaleModule()); + SongodaUpdate.load(plugin); + this.references = new References(); // Setup Managers @@ -102,6 +108,7 @@ public class UltimateModeration extends JavaPlugin { int timeout = SettingsManager.Setting.AUTOSAVE.getInt() * 60 * 20; Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout); + console.sendMessage(Methods.formatText("&a=============================")); } @Override diff --git a/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSettings.java b/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSettings.java index 085b14e..d3f7a89 100644 --- a/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSettings.java +++ b/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSettings.java @@ -15,8 +15,8 @@ public class CommandSettings extends AbstractCommand { @Override protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) { - Player p = (Player) sender; - instance.getSettingsManager().openSettingsManager(p); + Player player = (Player) sender; + instance.getSettingsManager().openSettingsManager(player); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/utils/SettingsManager.java b/src/main/java/com/songoda/ultimatemoderation/utils/SettingsManager.java index 9481b4a..3eb10dd 100644 --- a/src/main/java/com/songoda/ultimatemoderation/utils/SettingsManager.java +++ b/src/main/java/com/songoda/ultimatemoderation/utils/SettingsManager.java @@ -197,7 +197,6 @@ public class SettingsManager implements Listener { DATABASE_USERNAME("Database.Username", "PUT_USERNAME_HERE"), DATABASE_PASSWORD("Database.Password", "PUT_PASSWORD_HERE"), - DOWNLOAD_FILES("System.Download Needed Data Files", true), LANGUGE_MODE("System.Language Mode", "en_US"); private String setting; diff --git a/src/main/java/com/songoda/ultimatemoderation/utils/updateModules/LocaleModule.java b/src/main/java/com/songoda/ultimatemoderation/utils/updateModules/LocaleModule.java new file mode 100644 index 0000000..b3d69f2 --- /dev/null +++ b/src/main/java/com/songoda/ultimatemoderation/utils/updateModules/LocaleModule.java @@ -0,0 +1,32 @@ +package com.songoda.ultimatemoderation.utils.updateModules; + +import com.songoda.ultimatemoderation.UltimateModeration; +import com.songoda.update.Module; +import com.songoda.update.Plugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +public class LocaleModule implements Module { + + @Override + public void run(Plugin plugin) { + JSONObject json = plugin.getJson(); + try { + JSONArray files = (JSONArray) json.get("neededFiles"); + for (Object o : files) { + JSONObject file = (JSONObject) o; + + if (file.get("type").equals("locale")) { + InputStream in = new URL((String) file.get("link")).openStream(); + UltimateModeration.getInstance().getLocale().saveDefaultLocale(in, (String) file.get("name")); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 378b243..7e989ad 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: UltimateModeration description: UltimateModeration main: com.songoda.ultimatemoderation.UltimateModeration -version: 1 +version: maven-version-number author: Songoda api-version: 1.13 commands: