Added a message when shutting down.
This commit is contained in:
parent
0e3f6412ed
commit
e2dc6ea564
7
.classpath
Normal file
7
.classpath
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="D:/Documents/Test Server/craftbukkit-1.9.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
13
.externalToolBuilders/New_Builder (1).launch
Normal file
13
.externalToolBuilders/New_Builder (1).launch
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AutoPluginUpdate"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/AutoPluginUpdate/projectBuilder.xml}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/AutoPluginUpdate}"/>
|
||||
</launchConfiguration>
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/bin/
|
27
.project
Normal file
27
.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>AutoPluginUpdate</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/New_Builder (1).launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
.settings/org.eclipse.jdt.core.prefs
Normal file
11
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -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
|
Binary file not shown.
@ -16,6 +16,10 @@ public class AnnounceUpdateEvent extends Event{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public String getAnnouncementMessage() {
|
||||
return announce_msg;
|
||||
}
|
||||
|
@ -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,15 +71,20 @@ 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) {
|
||||
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) {
|
||||
switch (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<Bukkit.getWorlds().size();i++) {
|
||||
Bukkit.getWorlds().get(i).save();
|
||||
}
|
||||
|
@ -66,14 +66,14 @@ public class PluginManager implements Runnable{
|
||||
if (Bukkit.getOnlinePlayers().size()!=0) {
|
||||
AutoPluginUpdate.BroadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+". The server will restart in 3 minutes!\n\n"+ChatColor.GRAY+ChatColor.ITALIC+"If all players leave, the update will occur immediately.");
|
||||
} else {
|
||||
AutoPluginUpdate.BroadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+"."+ChatColor.GRAY+ChatColor.ITALIC+"If all players leave, the update will occur immediately.");
|
||||
AutoPluginUpdate.BroadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+".");
|
||||
}
|
||||
restarting=true;
|
||||
AutoPluginUpdate.restarting_server=true;
|
||||
//Save the new plugin hash.
|
||||
|
||||
} else {
|
||||
AutoPluginUpdate.BroadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+"."+ChatColor.GRAY+ChatColor.ITALIC+"If all players leave, the update will occur immediately.");
|
||||
AutoPluginUpdate.BroadcastMessage("The server has detected a new version of "+ChatColor.YELLOW+plugins.get(ii).name+".");
|
||||
}
|
||||
if (restarting) {
|
||||
AutoPluginUpdate.updateServer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user