use of com.loohp.interactivechat.updater.Version in project InteractiveChat-DiscordSRV-Addon by LOOHP.
the class CMLMain method downloadAssets.
protected static void downloadAssets() throws IOException {
File defaultAssetsFolder = new File("InteractiveChatDiscordSrvAddon/built-in", "Default");
defaultAssetsFolder.mkdirs();
System.out.println("Available Minecraft Versions:");
for (String version : ResourceDownloadManager.getMinecraftVersions()) {
System.out.println(version);
}
System.out.println();
System.out.println("Select Minecraft Version: (Type the version string)");
String input;
while (true) {
input = IN.readLine();
if (ResourceDownloadManager.getMinecraftVersions().contains(input)) {
break;
}
System.out.println("That is not a valid Minecraft version!");
System.out.println();
}
ResourceDownloadManager downloadManager = new ResourceDownloadManager(input, defaultAssetsFolder);
CompletableFuture<Void> future = new CompletableFuture<>();
new Thread(() -> {
downloadManager.downloadResources((type, fileName, percentage) -> {
switch(type) {
case CLIENT_DOWNLOAD:
System.out.println("Downloading client jar");
break;
case EXTRACT:
System.out.println("Extracting " + fileName);
break;
case DOWNLOAD:
System.out.println("Downloading " + fileName);
break;
case DONE:
System.out.println("Done!");
break;
}
});
future.complete(null);
}).start();
future.join();
System.out.println("Assets saved at: " + defaultAssetsFolder.getAbsolutePath());
}
use of com.loohp.interactivechat.updater.Version in project InteractiveChat by LOOHP.
the class ConfigDataFixer method update.
public static void update(Config config) {
String versionString = config.getConfiguration().getString("ConfigVersion");
if (versionString == null) {
versionString = BASE_PLUGIN_VERSION;
config.getConfiguration().set("ConfigVersion", versionString);
}
Version configVersion = new Version(versionString);
boolean backup = false;
if (configVersion.compareTo(new Version("4.1.1.9")) < 0) {
if (!backup) {
config.save(new File(config.getFile().getParent(), config.getFile().getName() + "." + versionString + ".bak"));
}
backup = true;
// Regex placeholder
boolean itemCase = config.getConfiguration().getBoolean("ItemDisplay.Item.CaseSensitive", false);
config.getConfiguration().set("ItemDisplay.Item.CaseSensitive", null);
config.getConfiguration().set("ItemDisplay.Item.Aliases", null);
config.getConfiguration().set("ItemDisplay.Item.Name", config.getConfiguration().getString("ItemDisplay.Item.Keyword"));
config.getConfiguration().set("ItemDisplay.Item.Keyword", (itemCase ? "" : "(?i)") + CustomStringUtils.escapeMetaCharacters(config.getConfiguration().getString("ItemDisplay.Item.Keyword")));
boolean invCase = config.getConfiguration().getBoolean("ItemDisplay.Inventory.CaseSensitive", false);
config.getConfiguration().set("ItemDisplay.Inventory.CaseSensitive", null);
config.getConfiguration().set("ItemDisplay.Inventory.Aliases", null);
config.getConfiguration().set("ItemDisplay.Inventory.Name", config.getConfiguration().getString("ItemDisplay.Inventory.Keyword"));
config.getConfiguration().set("ItemDisplay.Inventory.Keyword", (invCase ? "" : "(?i)") + CustomStringUtils.escapeMetaCharacters(config.getConfiguration().getString("ItemDisplay.Inventory.Keyword")));
boolean enderCase = config.getConfiguration().getBoolean("ItemDisplay.EnderChest.CaseSensitive", false);
config.getConfiguration().set("ItemDisplay.EnderChest.CaseSensitive", null);
config.getConfiguration().set("ItemDisplay.EnderChest.Aliases", null);
config.getConfiguration().set("ItemDisplay.EnderChest.Name", config.getConfiguration().getString("ItemDisplay.EnderChest.Keyword"));
config.getConfiguration().set("ItemDisplay.EnderChest.Keyword", (enderCase ? "" : "(?i)") + CustomStringUtils.escapeMetaCharacters(config.getConfiguration().getString("ItemDisplay.EnderChest.Keyword")));
for (int customNo = 1; config.getConfiguration().contains("CustomPlaceholders." + customNo); customNo++) {
ConfigurationSection s = config.getConfiguration().getConfigurationSection("CustomPlaceholders." + customNo);
String text = s.getString("Text");
s.set("Text", null);
boolean caseSensitive = s.getBoolean("CaseSensitive", false);
s.set("CaseSensitive", null);
s.set("Keyword", (caseSensitive ? "" : "(?i)") + CustomStringUtils.escapeMetaCharacters(text));
s.set("Name", text);
s.set("Aliases", null);
}
}
if (configVersion.compareTo(new Version("4.1.1.13")) < 0) {
if (!backup) {
config.save(new File(config.getFile().getParent(), config.getFile().getName() + "." + versionString + ".bak"));
}
backup = true;
config.getConfiguration().set("Settings.FormattingTags.AdditionalRGBFormats", Collections.singletonList("#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])"));
}
if (configVersion.compareTo(new Version("4.1.2.14")) < 0) {
if (!backup) {
config.save(new File(config.getFile().getParent(), config.getFile().getName() + "." + versionString + ".bak"));
}
backup = true;
config.getConfiguration().set("Settings.ChatListeningPlugins", null);
}
config.getConfiguration().set("ConfigVersion", InteractiveChat.plugin.getDescription().getVersion());
config.save();
}
use of com.loohp.interactivechat.updater.Version in project InteractiveChat by LOOHP.
the class CMLMain method checkForUpdates.
protected static void checkForUpdates(String localPluginVersion) throws URISyntaxException, IOException {
JSONObject response = (JSONObject) HTTPRequestUtils.getJSONResponse("https://api.loohpjames.com/spigot/data").get("InteractiveChat");
String spigotPluginVersion = (String) ((JSONObject) response.get("latestversion")).get("release");
String devBuildVersion = (String) ((JSONObject) response.get("latestversion")).get("devbuild");
int spigotPluginId = (int) (long) ((JSONObject) response.get("spigotmc")).get("pluginid");
int posOfThirdDot = localPluginVersion.indexOf(".", localPluginVersion.indexOf(".", localPluginVersion.indexOf(".") + 1) + 1);
Version currentDevBuild = new Version(localPluginVersion);
Version currentRelease = new Version(localPluginVersion.substring(0, posOfThirdDot >= 0 ? posOfThirdDot : localPluginVersion.length()));
Version spigotmc = new Version(spigotPluginVersion);
Version devBuild = new Version(devBuildVersion);
int input;
if (currentRelease.compareTo(spigotmc) < 0) {
// update
System.out.println("There is a new version available! (" + currentDevBuild + ")\nLocal version: " + localPluginVersion + "");
System.out.println("You can download a new build at: https://ci.loohpjames.com/job/InteractiveChat/");
} else if (currentDevBuild.compareTo(devBuild) < 0) {
// dev build update
System.out.println("There is a new DEV build available! (" + currentDevBuild + ")\nLocal version: " + localPluginVersion);
System.out.println("You can download a new build at: https://ci.loohpjames.com/job/InteractiveChat/");
} else {
// latest
System.out.println("You are already running the latest version! (" + localPluginVersion + ")");
}
}
use of com.loohp.interactivechat.updater.Version in project InteractiveChat by LOOHP.
the class GUIMain method checkForUpdates.
protected static void checkForUpdates(String title, Icon icon, String localPluginVersion) throws URISyntaxException, IOException {
JSONObject response = (JSONObject) HTTPRequestUtils.getJSONResponse("https://api.loohpjames.com/spigot/data").get("InteractiveChat");
String spigotPluginVersion = (String) ((JSONObject) response.get("latestversion")).get("release");
String devBuildVersion = (String) ((JSONObject) response.get("latestversion")).get("devbuild");
int spigotPluginId = (int) (long) ((JSONObject) response.get("spigotmc")).get("pluginid");
int posOfThirdDot = localPluginVersion.indexOf(".", localPluginVersion.indexOf(".", localPluginVersion.indexOf(".") + 1) + 1);
Version currentDevBuild = new Version(localPluginVersion);
Version currentRelease = new Version(localPluginVersion.substring(0, posOfThirdDot >= 0 ? posOfThirdDot : localPluginVersion.length()));
Version spigotmc = new Version(spigotPluginVersion);
Version devBuild = new Version(devBuildVersion);
int input;
if (currentRelease.compareTo(spigotmc) < 0) {
// update
input = JOptionPane.showOptionDialog(null, createLabel("There is a new version available! (" + currentDevBuild + ")\nLocal version: " + localPluginVersion, 15), title, JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, icon, new Object[] { "OK", "Download Link" }, null);
} else if (currentDevBuild.compareTo(devBuild) < 0) {
// dev build update
input = JOptionPane.showOptionDialog(null, createLabel("There is a new DEV build available! (" + currentDevBuild + ")\nLocal version: " + localPluginVersion, 15), title, JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, icon, new Object[] { "OK", "Download Link" }, null);
} else {
// latest
JOptionPane.showMessageDialog(null, createLabel("You are already running the latest version! (" + localPluginVersion + ")", 15), title, JOptionPane.INFORMATION_MESSAGE, icon);
input = 0;
}
if (input == 1) {
if (Desktop.isDesktopSupported()) {
Desktop dt = Desktop.getDesktop();
dt.browse(new URI("https://ci.loohpjames.com/job/InteractiveChat/"));
}
}
}
use of com.loohp.interactivechat.updater.Version in project InteractiveChat-DiscordSRV-Addon by LOOHP.
the class CMLMain method checkForUpdates.
protected static void checkForUpdates(String localPluginVersion) throws URISyntaxException, IOException {
JSONObject response = (JSONObject) HTTPRequestUtils.getJSONResponse("https://api.loohpjames.com/spigot/data").get("InteractiveChat-DiscordSRV-Addon");
String spigotPluginVersion = (String) ((JSONObject) response.get("latestversion")).get("release");
String devBuildVersion = (String) ((JSONObject) response.get("latestversion")).get("devbuild");
int spigotPluginId = (int) (long) ((JSONObject) response.get("spigotmc")).get("pluginid");
int posOfThirdDot = localPluginVersion.indexOf(".", localPluginVersion.indexOf(".", localPluginVersion.indexOf(".") + 1) + 1);
Version currentDevBuild = new Version(localPluginVersion);
Version currentRelease = new Version(localPluginVersion.substring(0, posOfThirdDot >= 0 ? posOfThirdDot : localPluginVersion.length()));
Version spigotmc = new Version(spigotPluginVersion);
Version devBuild = new Version(devBuildVersion);
int input;
if (currentRelease.compareTo(spigotmc) < 0) {
// update
System.out.println("There is a new version available! (" + currentDevBuild + ")\nLocal version: " + localPluginVersion + "");
System.out.println("You can download a new build at: https://ci.loohpjames.com/job/InteractiveChat-DiscordSRV-Addon/");
} else if (currentDevBuild.compareTo(devBuild) < 0) {
// dev build update
System.out.println("There is a new DEV build available! (" + currentDevBuild + ")\nLocal version: " + localPluginVersion);
System.out.println("You can download a new build at: https://ci.loohpjames.com/job/InteractiveChat-DiscordSRV-Addon/");
} else {
// latest
System.out.println("You are already running the latest version! (" + localPluginVersion + ")");
}
}
Aggregations