mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-16 22:03:53 +00:00
Added greater coverage for CUI for region adjustments.
This commit is contained in:
@ -530,21 +530,34 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
if (selector != null) {
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionShapeEvent(selector.getTypeId()));
|
||||
dispatchCUISelection(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the selection information.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void dispatchCUISelection(LocalPlayer player) {
|
||||
if (!hasCUISupport) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionShapeEvent(selector.getTypeId()));
|
||||
|
||||
if (selector instanceof CUIPointBasedRegion) {
|
||||
Vector[] points = ((CUIPointBasedRegion) selector).getCUIPoints();
|
||||
int size = selector.getArea();
|
||||
|
||||
if (selector instanceof CUIPointBasedRegion) {
|
||||
Vector[] points = ((CUIPointBasedRegion) selector).getCUIPoints();
|
||||
int size = selector.getArea();
|
||||
|
||||
int i = 0;
|
||||
for (Vector pt : points) {
|
||||
if (pt != null) {
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPointEvent(i, pt, size));
|
||||
}
|
||||
i++;
|
||||
int i = 0;
|
||||
for (Vector pt : points) {
|
||||
if (pt != null) {
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPointEvent(i, pt, size));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,15 +122,15 @@ public class BukkitPlayer extends LocalPlayer {
|
||||
String[] params = event.getParameters();
|
||||
|
||||
if (params.length > 0) {
|
||||
printRaw("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()
|
||||
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()
|
||||
+ "|" + StringUtil.joinString(params, "|"));
|
||||
} else {
|
||||
printRaw("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId());
|
||||
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCUIHandshake() {
|
||||
printRaw("\u00A75\u00A76\u00A74\u00A75");
|
||||
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75");
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +160,8 @@ public class SelectionCommands {
|
||||
selector.selectPrimary(min);
|
||||
selector.selectSecondary(max);
|
||||
session.setRegionSelector(player.getWorld(), selector);
|
||||
|
||||
session.dispatchCUISelection(player);
|
||||
|
||||
player.print("Chunk selected: "
|
||||
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
|
||||
@ -268,6 +270,8 @@ public class SelectionCommands {
|
||||
session.getRegionSelector().learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
player.print("Region expanded " + (newSize - oldSize) + " blocks.");
|
||||
}
|
||||
|
||||
@ -315,6 +319,8 @@ public class SelectionCommands {
|
||||
session.getRegionSelector().learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
player.print("Region contracted " + (oldSize - newSize) + " blocks.");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -348,6 +354,8 @@ public class SelectionCommands {
|
||||
region.contract(dir.multiply(change));
|
||||
session.getRegionSelector().learnChanges();
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
player.print("Region shifted.");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -385,6 +393,8 @@ public class SelectionCommands {
|
||||
|
||||
session.getRegionSelector().learnChanges();
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
player.print("Region outset.");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -421,6 +431,8 @@ public class SelectionCommands {
|
||||
|
||||
session.getRegionSelector().learnChanges();
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
player.print("Region inset.");
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,17 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(1, pos, getArea()));
|
||||
}
|
||||
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
if (pos1 != null) {
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(0, pos1, getArea()));
|
||||
}
|
||||
if (pos2 != null) {
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(1, pos2, getArea()));
|
||||
}
|
||||
}
|
||||
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (pos1 == null) {
|
||||
|
@ -77,6 +77,9 @@ public class Polygonal2DRegionSelector implements RegionSelector {
|
||||
player.print("Added point #" + region.size() + " at " + pos + ".");
|
||||
}
|
||||
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
}
|
||||
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (pos1 == null) {
|
||||
throw new IncompleteRegionException();
|
||||
|
@ -68,6 +68,15 @@ public interface RegionSelector {
|
||||
public void explainSecondarySelection(LocalPlayer player,
|
||||
LocalSession session, Vector pos);
|
||||
|
||||
/**
|
||||
* The the player information about the region's changes. This may resend
|
||||
* all the defining region information if needed.
|
||||
*
|
||||
* @param player
|
||||
* @param session
|
||||
*/
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session);
|
||||
|
||||
/**
|
||||
* Get the primary position.
|
||||
*
|
||||
|
Reference in New Issue
Block a user