diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..9a74be3 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.externalToolBuilders/New_Builder (1).launch b/.externalToolBuilders/New_Builder (1).launch new file mode 100644 index 0000000..a614572 --- /dev/null +++ b/.externalToolBuilders/New_Builder (1).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..6364fd6 --- /dev/null +++ b/.project @@ -0,0 +1,27 @@ + + + AutoPluginUpdate + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/New_Builder (1).launch + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/AutoPluginUpdate.jar b/AutoPluginUpdate.jar index e2b2e1e..db0e01e 100644 Binary files a/AutoPluginUpdate.jar and b/AutoPluginUpdate.jar differ diff --git a/src/sig/plugin/AutoPluginUpdate/AnnounceUpdateEvent.java b/src/sig/plugin/AutoPluginUpdate/AnnounceUpdateEvent.java index 742d8fa..ef30da5 100644 --- a/src/sig/plugin/AutoPluginUpdate/AnnounceUpdateEvent.java +++ b/src/sig/plugin/AutoPluginUpdate/AnnounceUpdateEvent.java @@ -16,6 +16,10 @@ public class AnnounceUpdateEvent extends Event{ return handlers; } + public static HandlerList getHandlerList() { + return handlers; + } + public String getAnnouncementMessage() { return announce_msg; } diff --git a/src/sig/plugin/AutoPluginUpdate/AutoPluginUpdate.java b/src/sig/plugin/AutoPluginUpdate/AutoPluginUpdate.java index c23da89..4e57569 100644 --- a/src/sig/plugin/AutoPluginUpdate/AutoPluginUpdate.java +++ b/src/sig/plugin/AutoPluginUpdate/AutoPluginUpdate.java @@ -4,6 +4,8 @@ import java.io.File; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -18,6 +20,7 @@ public class AutoPluginUpdate extends JavaPlugin implements Listener{ public AutoPluginUpdate plugin = this; public static File datafolder; public static boolean restarting_server=false; + public static boolean main_server=false; public final int LOG_ERROR=0; public final int LOG_WARNING=1; @@ -34,17 +37,33 @@ public class AutoPluginUpdate extends JavaPlugin implements Listener{ datafolder = getDataFolder(); log("Data folder is located at "+datafolder,LOG_DETAIL); + CheckIfMainServer(); + pluginupdater = new PluginManager(plugin); pluginupdater.AddPlugin("TwosideKeeper", "https://dl.dropboxusercontent.com/s/z5ram6vi3jipiit/TwosideKeeper.jar"); pluginupdater.AddPlugin("aPlugin", "https://dl.dropboxusercontent.com/u/62434995/aPlugin.jar"); + pluginupdater.AddPlugin("AutoPluginUpdate", "https://dl.dropboxusercontent.com/s/q59lndgromemv0p/AutoPluginUpdate.jar"); Bukkit.getPluginManager().registerEvents(this, this); - if (!restarting_server) { + if (!restarting_server && main_server) { Bukkit.getScheduler().runTaskTimerAsynchronously(this, pluginupdater, 6000l, 6000l); } } + private void CheckIfMainServer() { + File checkfile = new File("plugins/TwosideKeeper","config.yml"); + if (checkfile.exists()) { + FileConfiguration config = YamlConfiguration.loadConfiguration(checkfile); + int type = config.getInt("SERVER_TYPE"); + if (type==0) { + main_server=true; + log("Identified this server as the MAIN SERVER.",LOG_DETAIL); + log("Features Enabled.",LOG_DETAIL); + } + } + } + @Override public void onDisable() { @@ -52,14 +71,19 @@ public class AutoPluginUpdate extends JavaPlugin implements Listener{ @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void onPlayerJoin(PlayerJoinEvent ev) { - if (!restarting_server) { + if (!restarting_server && main_server) { Bukkit.getScheduler().runTaskAsynchronously(this, pluginupdater); } } @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void onPlayerLeave(PlayerQuitEvent ev) { - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new ShutdownServerForUpdate(),5); + if (main_server) { + if (Bukkit.getOnlinePlayers().size()==1 && restarting_server) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, ()->{BroadcastMessage(ChatColor.ITALIC+"Server is shutting down...");},3); + } + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new ShutdownServerForUpdate(),5); + } } private void log(String msg, int loglv) { @@ -81,6 +105,7 @@ public class AutoPluginUpdate extends JavaPlugin implements Listener{ public void run() { if (Bukkit.getOnlinePlayers().size()==0 && restarting_server) { Bukkit.savePlayers(); + BroadcastMessage(ChatColor.ITALIC+"Server is shutting down..."); for (int i=0;i