mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Merge pull request #434 from sk89q/bugfix/flushing-when-done-2
Flush / unbuffer more tools
This commit is contained in:
commit
d7c528247b
@ -79,15 +79,17 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
index = (index + 1) % currentProperty.getValues().size();
|
index = (index + 1) % currentProperty.getValues().size();
|
||||||
BlockState newBlock = block.with(currentProperty, currentProperty.getValues().get(index));
|
BlockState newBlock = block.with(currentProperty, currentProperty.getValues().get(index));
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
|
editSession.disableBuffering();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(clicked.toVector(), newBlock);
|
editSession.setBlock(clicked.toVector(), newBlock);
|
||||||
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Property<?>> properties = Lists.newArrayList(block.getStates().keySet());
|
List<Property<?>> properties = Lists.newArrayList(block.getStates().keySet());
|
||||||
|
@ -76,25 +76,25 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final EditSession editSession = session.createEditSession(player);
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
|
try {
|
||||||
try {
|
final Set<Vector> blockSet = bfs(world, clicked.toVector());
|
||||||
final Set<Vector> blockSet = bfs(world, clicked.toVector());
|
if (blockSet == null) {
|
||||||
if (blockSet == null) {
|
player.printError("That's not a floating tree.");
|
||||||
player.printError("That's not a floating tree.");
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Vector blockVector : blockSet) {
|
|
||||||
final BlockState otherState = editSession.getBlock(blockVector);
|
|
||||||
if (isTreeBlock(otherState.getBlockType())) {
|
|
||||||
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Vector blockVector : blockSet) {
|
||||||
|
final BlockState otherState = editSession.getBlock(blockVector);
|
||||||
|
if (isTreeBlock(otherState.getBlockType())) {
|
||||||
|
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
player.printError("Max blocks change limit reached.");
|
||||||
|
} finally {
|
||||||
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException e) {
|
|
||||||
player.printError("Max blocks change limit reached.");
|
|
||||||
} finally {
|
|
||||||
session.remember(editSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -69,15 +69,15 @@ public class FloodFillTool implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
|
try {
|
||||||
try {
|
recurse(editSession, clicked.toVector().toBlockVector(),
|
||||||
recurse(editSession, clicked.toVector().toBlockVector(),
|
clicked.toVector(), range, initialType, new HashSet<>());
|
||||||
clicked.toVector(), range, initialType, new HashSet<>());
|
} catch (MaxChangedBlocksException e) {
|
||||||
} catch (MaxChangedBlocksException e) {
|
player.printError("Max blocks change limit reached.");
|
||||||
player.printError("Max blocks change limit reached.");
|
} finally {
|
||||||
} finally {
|
session.remember(editSession);
|
||||||
session.remember(editSession);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -53,8 +53,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
Location pos = getTargetFace(player);
|
Location pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
try (EditSession eS = session.createEditSession(player)) {
|
||||||
try {
|
eS.disableBuffering();
|
||||||
BlockStateHolder applied = secondary.apply(pos.toVector());
|
BlockStateHolder applied = secondary.apply(pos.toVector());
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
eS.setBlock(pos.toVector(), secondary);
|
eS.setBlock(pos.toVector(), secondary);
|
||||||
@ -73,8 +73,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
Location pos = getTargetFace(player);
|
Location pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
try (EditSession eS = session.createEditSession(player)) {
|
||||||
try {
|
eS.disableBuffering();
|
||||||
BlockStateHolder applied = primary.apply(pos.toVector());
|
BlockStateHolder applied = primary.apply(pos.toVector());
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
eS.setBlock(pos.toVector(), primary);
|
eS.setBlock(pos.toVector(), primary);
|
||||||
|
@ -48,25 +48,25 @@ public class TreePlanter implements BlockTool {
|
|||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
|
try {
|
||||||
|
boolean successful = false;
|
||||||
|
|
||||||
try {
|
for (int i = 0; i < 10; i++) {
|
||||||
boolean successful = false;
|
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) {
|
||||||
|
successful = true;
|
||||||
for (int i = 0; i < 10; i++) {
|
break;
|
||||||
if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) {
|
}
|
||||||
successful = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!successful) {
|
||||||
|
player.printError("A tree can't go there.");
|
||||||
|
}
|
||||||
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
player.printError("Max. blocks changed reached.");
|
||||||
|
} finally {
|
||||||
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!successful) {
|
|
||||||
player.printError("A tree can't go there.");
|
|
||||||
}
|
|
||||||
} catch (MaxChangedBlocksException e) {
|
|
||||||
player.printError("Max. blocks changed reached.");
|
|
||||||
} finally {
|
|
||||||
session.remember(editSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user