Depcrecate the regions plugins (add warnings, disable when replacement plugins are active). Remove example configuration.txt entries.

This commit is contained in:
Mike Primm 2011-11-24 07:47:22 +08:00 committed by mikeprimm
parent 0a790b6014
commit 54589cd358
3 changed files with 27 additions and 128 deletions

View File

@ -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<JSONObject>() {
@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);

View File

@ -25,15 +25,31 @@ public class RegionsComponent extends ClientComponent {
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);

View File

@ -114,129 +114,6 @@ components:
# 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: '<div class="infowindow"><span style="font-size:120%;">%regionname%</span><br /> Owner <span style="font-weight:bold;">%playerowners%</span><br />Flags<br /><span style="font-weight:bold;">%flags%</span></div>'
# 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: '<div class="infowindow"><span style="font-size:120%;">%regionname% (%nation%)</span><br /> Mayor <span style="font-weight:bold;">%playerowners%</span><br /> Associates <span style="font-weight:bold;">%playermanagers%</span><br/>Flags<br /><span style="font-weight:bold;">%flags%</span></div>'
# 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: '<div class="infowindow"><span style="font-size:120%;">%regionname%</span><br />Flags<br /><span style="font-weight:bold;">%flags%</span></div>'
# 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"