From 54589cd358fded03bd1a89ab21c67385af81e293 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Thu, 24 Nov 2011 07:47:22 +0800 Subject: [PATCH] Depcrecate the regions plugins (add warnings, disable when replacement plugins are active). Remove example configuration.txt entries. --- src/main/java/org/dynmap/ClientComponent.java | 10 +- .../org/dynmap/regions/RegionsComponent.java | 22 +++- src/main/resources/configuration.txt | 123 ------------------ 3 files changed, 27 insertions(+), 128 deletions(-) diff --git a/src/main/java/org/dynmap/ClientComponent.java b/src/main/java/org/dynmap/ClientComponent.java index 8d006976..7e4e1db8 100644 --- a/src/main/java/org/dynmap/ClientComponent.java +++ b/src/main/java/org/dynmap/ClientComponent.java @@ -9,17 +9,23 @@ import java.util.Map; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class ClientComponent extends Component { - + private boolean disabled; + public ClientComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) { super(plugin, configuration); plugin.events.addListener("buildclientconfiguration", new Event.Listener() { @Override public void triggered(JSONObject root) { - buildClientConfiguration(root); + if(!disabled) + buildClientConfiguration(root); } }); } + protected void disableComponent() { + disabled = true; + } + protected void buildClientConfiguration(JSONObject root) { JSONObject o = createClientConfiguration(); a(root, "components", o); diff --git a/src/main/java/org/dynmap/regions/RegionsComponent.java b/src/main/java/org/dynmap/regions/RegionsComponent.java index 5f5b4754..0456b0d1 100644 --- a/src/main/java/org/dynmap/regions/RegionsComponent.java +++ b/src/main/java/org/dynmap/regions/RegionsComponent.java @@ -24,16 +24,32 @@ public class RegionsComponent extends ClientComponent { private TownyConfigHandler towny; private FactionsConfigHandler factions; private String regiontype; + + private static String deprecated_ids[] = { "Residence", "Factions", "Towny", "WorldGuard" }; + private static String deprecated_new_plugins[] = { "dynmap-residence", "Dynmap-Factions", "Dynmap-Towny", "Dynmap-WorldGuard" }; public RegionsComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) { super(plugin, configuration); + + regiontype = configuration.getString("name", "WorldGuard"); + /* Check if a deprecated component */ + for(int i = 0; i < deprecated_ids.length; i++) { + if(regiontype.equals(deprecated_ids[i])) { /* If match */ + /* See if new plugin is installed - disable if it is */ + if(plugin.getServer().getPluginManager().getPlugin(deprecated_new_plugins[i]) != null) { + Log.info("Region component for '" + regiontype + "' disabled, replaced by '" + deprecated_new_plugins[i] + "' plugin, which is installed"); + disableComponent(); + return; + } + else { + Log.info("Region component for '" + regiontype + "' has been DEPRECATED - migrate to '" + deprecated_new_plugins[i] + "' plugin"); + } + } + } // For internal webserver. String fname = configuration.getString("filename", "regions.yml"); - regiontype = configuration.getString("name", "WorldGuard"); - - /* Load special handler for Towny */ if(regiontype.equals("Towny")) { towny = new TownyConfigHandler(configuration); diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 999879c0..7369b9ab 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -113,129 +113,6 @@ components: # timeout: 1800 # in seconds (1800 seconds = 30 minutes) # redirecturl: inactive.html # #showmessage: 'You were inactive for too long.' - - #- class: org.dynmap.regions.RegionsComponent - # type: regions - # name: WorldGuard - # useworldpath: true - # filename: regions.yml - # basenode: regions - # use3dregions: true - # regionstyle: - # strokeColor: "#FF0000" - # strokeOpacity: 0.8 - # strokeWeight: 3 - # fillColor: "#FF0000" - # fillOpacity: 0.35 - # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown - # visibleregions: - # - homebase - # - miningsite - # # Optional setting to hide specific regions, by name - # hiddenregions: - # - hiddenplace - # - secretsite - # # Optional per-region overrides for regionstyle (any defined replace those in regionstyle) - # customstyle: - # homebase: - # strokeColor: "#00FF00" - # # Optional - make layer hidden by default - # hidebydefault: true - # # Optional - ordering priority in layer menu (low goes before high - default is 0) - # layerprio: 1 - - #- class: org.dynmap.regions.RegionsComponent - # type: regions - # name: Residence - # useworldpath: false - # filename: res.yml - # basenode: Residences - # use3dregions: false - # infowindow: '
%regionname%
Owner %playerowners%
Flags
%flags%
' - # regionstyle: - # strokeColor: "#FF0000" - # strokeOpacity: 0.8 - # strokeWeight: 3 - # fillColor: "#FF0000" - # fillOpacity: 0.35 - # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown - # visibleregions: - # - homebase - # - miningsite - # - area.subzone1 - # # Optional setting to hide specific regions, by name - # hiddenregions: - # - hiddenplace - # - secretsite - # # Optional per-region overrides for regionstyle (any defined replace those in regionstyle) - # customstyle: - # homebase: - # strokeColor: "#00FF00" - # # Optional groups (subareas under a residence) overrides for regionstyle (any defined replace those in regionstyle) - # groupstyle: - # homebase: - # strokeColor: "#007F00" - # # Optional - make layer hidden by default - # hidebydefault: true - # # Optional - ordering priority in layer menu (low goes before high - default is 0) - # layerprio: 1 - - #- class: org.dynmap.regions.RegionsComponent - # type: regions - # name: Towny - # use3dregions: false - # infowindow: '
%regionname% (%nation%)
Mayor %playerowners%
Associates %playermanagers%
Flags
%flags%
' - # regionstyle: - # strokeColor: "#FF0000" - # strokeOpacity: 0.8 - # strokeWeight: 3 - # fillColor: "#FF0000" - # fillOpacity: 0.35 - # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown - # visibleregions: - # - homebase - # - miningsite - # # Optional setting to hide specific regions, by name - # hiddenregions: - # - hiddenplace - # - secretsite - # # Optional per-town overrides for regionstyle (any defined replace those in regionstyle) - # customstyle: - # homebase: - # strokeColor: "#00FF00" - # # Optional per-nation overrides for regionstyle (any defined replace those in regionstyle) - # groupstyle: - # MyNation: - # strokeColor: "#007F00" - # # Optional - make layer hidden by default - # hidebydefault: true - - #- class: org.dynmap.regions.RegionsComponent - # type: regions - # name: Factions - # use3dregions: false - # infowindow: '
%regionname%
Flags
%flags%
' - # regionstyle: - # strokeColor: "#FF0000" - # strokeOpacity: 0.8 - # strokeWeight: 3 - # fillColor: "#FF0000" - # fillOpacity: 0.35 - # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown - # visibleregions: - # - faction1 - # - faction2 - # # Optional setting to hide specific regions, by name - # hiddenregions: - # - hiddenfaction - # # Optional per-faction overrides for regionstyle (any defined replace those in regionstyle) - # customstyle: - # faction1: - # strokeColor: "#00FF00" - # # Optional - make layer hidden by default - # hidebydefault: true - # # Optional - ordering priority in layer menu (low goes before high - default is 0) - # layerprio: 1 #- class: org.dynmap.TestComponent # stuff: "This is some configuration-value"