diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index e9bdc8a..3220ab9 100755
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -7,10 +7,12 @@
+
+
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml
new file mode 100644
index 0000000..6e5d5b7
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_guava_guava_21_0.xml b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml
new file mode 100644
index 0000000..a923456
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__commons_io_commons_io_2_6.xml b/.idea/libraries/Maven__commons_io_commons_io_2_6.xml
new file mode 100644
index 0000000..d722698
--- /dev/null
+++ b/.idea/libraries/Maven__commons_io_commons_io_2_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
new file mode 100644
index 0000000..befe1ab
--- /dev/null
+++ b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
new file mode 100644
index 0000000..ed73ade
--- /dev/null
+++ b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml b/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
new file mode 100644
index 0000000..33ccf19
--- /dev/null
+++ b/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index b7b1c7d..3dc26c2 100755
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,6 +2,7 @@
+
diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml
new file mode 100644
index 0000000..4902d56
--- /dev/null
+++ b/BuildConfigUpdater/BuildConfigUpdater.iml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BuildConfigUpdater/pom.xml b/BuildConfigUpdater/pom.xml
new file mode 100644
index 0000000..01781fb
--- /dev/null
+++ b/BuildConfigUpdater/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+ ButtonCore
+ com.github.TBMCPlugins
+ master-SNAPSHOT
+
+ 4.0.0
+
+ BuildConfigUpdater
+
+
+
+ Jitpack
+ https://jitpack.io/
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+
+
+
+ com.github.TBMCPlugins.ButtonCore
+ ButtonCore
+ master-SNAPSHOT
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2-R0.1-SNAPSHOT
+
+
+ commons-io
+ commons-io
+ 2.6
+
+
+
+
\ No newline at end of file
diff --git a/BuildConfigUpdater/src/main/java/BCUMain.java b/BuildConfigUpdater/src/main/java/BCUMain.java
new file mode 100644
index 0000000..5780afa
--- /dev/null
+++ b/BuildConfigUpdater/src/main/java/BCUMain.java
@@ -0,0 +1,16 @@
+import buttondevteam.lib.PluginUpdater;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class BCUMain {
+ public static void main(String[] args) {
+ System.out.println("Getting list of repositories...");
+ List plugins = PluginUpdater.GetPluginNames();
+ System.out.println("Removing non-Maven projects...");
+ plugins.removeIf(plugin -> !PluginUpdater.isMaven(plugin, "master"));
+ System.out.println(plugins.stream().collect(Collectors.joining("\n")));
+ for (String plugin : plugins) { //TODO: We don't want to apply it all at once, especially to unused/unowned repos
+ } //TODO: Add it to ButtonCore - or actually as a plugin or ButtonProcessor
+ }
+}
diff --git a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java
index b6a744f..f39e430 100755
--- a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java
+++ b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java
@@ -1,5 +1,6 @@
package buttondevteam.core;
+import buttondevteam.lib.PluginUpdater;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.ChatRoom;
@@ -11,6 +12,10 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
import java.util.logging.Logger;
public class MainPlugin extends JavaPlugin {
@@ -55,6 +60,20 @@ public class MainPlugin extends JavaPlugin {
logger.info("Saving player data...");
TBMCPlayerBase.savePlayers();
logger.info("Player data saved.");
+ new Thread(() -> {
+ File[] files = PluginUpdater.updatedir.listFiles();
+ if (files == null)
+ return;
+ System.out.println("Updating " + files.length + " plugins...");
+ for (File file : files) {
+ try {
+ Files.move(file.toPath(), new File("plugins").toPath(), StandardCopyOption.REPLACE_EXISTING)
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.println("Update complete!");
+ });
}
private boolean setupPermissions() {
diff --git a/ButtonCore/src/main/java/buttondevteam/lib/PluginUpdater.java b/ButtonCore/src/main/java/buttondevteam/lib/PluginUpdater.java
index ba5ea90..bde9b71 100755
--- a/ButtonCore/src/main/java/buttondevteam/lib/PluginUpdater.java
+++ b/ButtonCore/src/main/java/buttondevteam/lib/PluginUpdater.java
@@ -14,8 +14,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -24,11 +22,15 @@ public class PluginUpdater {
private PluginUpdater() {
}
- private static final File updatedir = new File("updateplugins");
+ public static final File updatedir = new File("TBMC", "pluginupdates");
/**
* See {@link TBMCCoreAPI#UpdatePlugin(String, CommandSender, String)}
*/
public static boolean UpdatePlugin(String name, CommandSender sender, String branch) {
+ if (!updatedir.exists() && !updatedir.mkdirs()) {
+ error(sender, "Failed to create update directory!");
+ return false;
+ }
info(sender, "Checking plugin name...");
List plugins = GetPluginNames();
String correctname = null;
@@ -64,9 +66,7 @@ public class PluginUpdater {
private static boolean updatePluginJitPack(CommandSender sender, String correctname,
String correctbranch) {
URL url;
- final boolean isWindows = System.getProperty("os.name").contains("Windows");
- File result = new File("plugins/" + correctname + (isWindows ? ".jar" : ".jar_tmp"));
- File finalresult = new File("plugins/" + correctname + ".jar");
+ File result = new File(updatedir, correctname + ".jar");
try {
url = new URL("https://jitpack.io/com/github/TBMCPlugins/"
+ (correctname.equals("ButtonCore") ? "ButtonCore/ButtonCore" : correctname) + "/"
@@ -78,8 +78,6 @@ public class PluginUpdater {
+ " is too small (smnaller than 25 bytes). Am I downloading from the right place?");
return false;
} else {
- if (!isWindows)
- Files.move(result.toPath(), finalresult.toPath(), StandardCopyOption.REPLACE_EXISTING);
info(sender, "Updating plugin " + correctname + " from " + correctbranch + " done!");
return true;
}
diff --git a/pom.xml b/pom.xml
index 672f423..1da127a 100755
--- a/pom.xml
+++ b/pom.xml
@@ -13,6 +13,7 @@
ButtonCore
ButtonProcessor
+ BuildConfigUpdater