Skip to content

Commit

Permalink
Minor improvements to the server side CUI
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Dec 26, 2018
1 parent 4cc8e9a commit a88f6b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 12 additions & 12 deletions worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java
Expand Up @@ -657,23 +657,25 @@ public void updateServerCUI(Actor actor) {
return; // If it's not enabled, ignore this. return; // If it's not enabled, ignore this.
} }


// Remove the old block.
if (cuiTemporaryBlock != null) {
player.sendFakeBlock(cuiTemporaryBlock, null);
cuiTemporaryBlock = null;
}

BaseBlock block = ServerCUIHandler.createStructureBlock(player); BaseBlock block = ServerCUIHandler.createStructureBlock(player);
if (block != null) { if (block != null) {
// If it's null, we don't need to do anything. The old was already removed. // If it's null, we don't need to do anything. The old was already removed.
Map<String, Tag> tags = block.getNbtData().getValue(); Map<String, Tag> tags = block.getNbtData().getValue();
cuiTemporaryBlock = BlockVector3.at( BlockVector3 tempCuiTemporaryBlock = BlockVector3.at(
((IntTag) tags.get("x")).getValue(), ((IntTag) tags.get("x")).getValue(),
((IntTag) tags.get("y")).getValue(), ((IntTag) tags.get("y")).getValue(),
((IntTag) tags.get("z")).getValue() ((IntTag) tags.get("z")).getValue()
); );

if (cuiTemporaryBlock != null && !tempCuiTemporaryBlock.equals(cuiTemporaryBlock)) {
// Update the existing block if it's the same location
player.sendFakeBlock(cuiTemporaryBlock, null);
}
cuiTemporaryBlock = tempCuiTemporaryBlock;
player.sendFakeBlock(cuiTemporaryBlock, block); player.sendFakeBlock(cuiTemporaryBlock, block);
} else if (cuiTemporaryBlock != null) {
// Remove the old block
player.sendFakeBlock(cuiTemporaryBlock, null);
cuiTemporaryBlock = null;
} }
} }


Expand Down Expand Up @@ -713,10 +715,8 @@ public void dispatchCUISetup(Actor actor) {
public void dispatchCUISelection(Actor actor) { public void dispatchCUISelection(Actor actor) {
checkNotNull(actor); checkNotNull(actor);


if (!hasCUISupport) { if (!hasCUISupport && useServerCUI) {
if (useServerCUI) { updateServerCUI(actor);
updateServerCUI(actor);
}
return; return;
} }


Expand Down
Expand Up @@ -228,6 +228,8 @@ public void learnChanges() {
public void clear() { public void clear() {
position1 = null; position1 = null;
position2 = null; position2 = null;
region.setPos1(BlockVector3.ZERO);
region.setPos2(BlockVector3.ZERO);
} }


@Override @Override
Expand Down

0 comments on commit a88f6b8

Please sign in to comment.