mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-25 03:35:18 +01:00
Added ability to reload (also using 'dynmap reload').
This commit is contained in:
parent
ca9be50422
commit
2866eaa905
@ -7,4 +7,7 @@ public abstract class Component {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ public class ComponentManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
componentLookup.clear();
|
||||||
|
components.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public Iterable<Component> getComponents(Class<Component> c) {
|
public Iterable<Component> getComponents(Class<Component> c) {
|
||||||
List<Component> list = componentLookup.get(c.toString());
|
List<Component> list = componentLookup.get(c.toString());
|
||||||
if (list == null)
|
if (list == null)
|
||||||
|
@ -57,8 +57,6 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
public ComponentManager componentManager = new ComponentManager();
|
public ComponentManager componentManager = new ComponentManager();
|
||||||
public Events events = new Events();
|
public Events events = new Events();
|
||||||
|
|
||||||
public Timer timer;
|
|
||||||
|
|
||||||
public static File dataDirectory;
|
public static File dataDirectory;
|
||||||
public static File tilesDirectory;
|
public static File tilesDirectory;
|
||||||
|
|
||||||
@ -70,10 +68,11 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
return webServer;
|
return webServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
||||||
if (permissions == null)
|
if (permissions == null)
|
||||||
permissions = new OpPermissions(new String[] { "fullrender" });
|
permissions = new OpPermissions(new String[] { "fullrender", "reload" });
|
||||||
|
|
||||||
dataDirectory = this.getDataFolder();
|
dataDirectory = this.getDataFolder();
|
||||||
|
|
||||||
@ -109,6 +108,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
for(Component component : configuration.<Component>createInstances("components", new Class<?>[] { DynmapPlugin.class }, new Object[] { this })) {
|
for(Component component : configuration.<Component>createInstances("components", new Class<?>[] { DynmapPlugin.class }, new Object[] { this })) {
|
||||||
componentManager.add(component);
|
componentManager.add(component);
|
||||||
}
|
}
|
||||||
|
Log.info("Loaded " + componentManager.components.size() + " components.");
|
||||||
|
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
|
||||||
@ -151,7 +151,15 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
int componentCount = componentManager.components.size();
|
||||||
|
for(Component component : componentManager.components) {
|
||||||
|
component.dispose();
|
||||||
|
}
|
||||||
|
componentManager.clear();
|
||||||
|
Log.info("Unloaded " + componentCount + " components.");
|
||||||
|
|
||||||
mapManager.stopRendering();
|
mapManager.stopRendering();
|
||||||
|
|
||||||
if (webServer != null) {
|
if (webServer != null) {
|
||||||
@ -159,10 +167,6 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
webServer = null;
|
webServer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timer != null) {
|
|
||||||
timer.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.clearDebuggers();
|
Debug.clearDebuggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +279,8 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
"render",
|
"render",
|
||||||
"hide",
|
"hide",
|
||||||
"show",
|
"show",
|
||||||
"fullrender" }));
|
"fullrender",
|
||||||
|
"reload" }));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
@ -340,6 +345,12 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
mapManager.renderFullWorld(loc);
|
mapManager.renderFullWorld(loc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else if (c.equals("reload") && checkPlayerPermission(sender, "reload")) {
|
||||||
|
sender.sendMessage("Reloading Dynmap...");
|
||||||
|
onDisable();
|
||||||
|
onEnable();
|
||||||
|
sender.sendMessage("Dynmap reloaded");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -147,4 +147,10 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
|||||||
ChatEvent event = new ChatEvent("web", name, message);
|
ChatEvent event = new ChatEvent("web", name, message);
|
||||||
plugin.events.trigger("webchat", event);
|
plugin.events.trigger("webchat", event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
timer.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user