From 45655e1189880505d040530b8ab2e261a6543c0f Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Fri, 30 Dec 2011 11:59:33 +0100 Subject: [PATCH] Added a legacy type id system to CUI. Selection types can send fallback typeids and information now, for older WECUI versions to use. --- src/main/java/com/sk89q/worldedit/LocalSession.java | 4 ++++ .../sk89q/worldedit/regions/CuboidRegionSelector.java | 4 ++++ .../worldedit/regions/Polygonal2DRegionSelector.java | 4 ++++ .../java/com/sk89q/worldedit/regions/RegionSelector.java | 9 ++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/LocalSession.java b/src/main/java/com/sk89q/worldedit/LocalSession.java index a3a9ac961..05c2a1fb7 100644 --- a/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -570,6 +570,10 @@ public class LocalSession { return; } + final String legacyTypeId = selector.getLegacyTypeId(); + if (legacyTypeId != null) { + player.dispatchCUIEvent(new SelectionShapeEvent(legacyTypeId)); + } player.dispatchCUIEvent(new SelectionShapeEvent(selector.getTypeId())); if (selector instanceof CUIPointBasedRegion) { diff --git a/src/main/java/com/sk89q/worldedit/regions/CuboidRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/CuboidRegionSelector.java index f83cb4b89..b42149070 100644 --- a/src/main/java/com/sk89q/worldedit/regions/CuboidRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/CuboidRegionSelector.java @@ -177,6 +177,10 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion return "cuboid"; } + public String getLegacyTypeId() { + return null; + } + public void describeCUI(LocalPlayer player) { if (pos1 != null) { player.dispatchCUIEvent(new SelectionPointEvent(0, pos1, getArea())); diff --git a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java index 79311fb38..5db2d59bc 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java @@ -178,6 +178,10 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR return "polygon2d"; } + public String getLegacyTypeId() { + return null; + } + public int getArea() { return region.getArea(); } diff --git a/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java index 1da9965d3..935928405 100644 --- a/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java @@ -132,12 +132,19 @@ public interface RegionSelector { public String getTypeName(); /** - * Get a lowecase space-less ID. + * Get a lowercase space-less ID. * * @return */ public String getTypeId(); + /** + * Gets an alternative ID, for which this region selector also sends data. + * + * @return + */ + public String getLegacyTypeId(); + /** * Get lines of information about the selection. *