mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Remove all raw usages of BSH, improve API generics
This commit is contained in:
@ -40,7 +40,6 @@ import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
*/
|
||||
public class NavigationCommands {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,6 @@ import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -57,7 +57,8 @@ import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
@ -638,7 +639,7 @@ public class SelectionCommands {
|
||||
context.setSession(session);
|
||||
context.setRestricted(false);
|
||||
|
||||
Set<BlockStateHolder> searchBlocks = we.getBlockFactory().parseFromListInput(args.getString(0), context);
|
||||
Set<BaseBlock> searchBlocks = we.getBlockFactory().parseFromListInput(args.getString(0), context);
|
||||
int count = editSession.countBlocks(session.getSelection(player.getWorld()), searchBlocks);
|
||||
player.print("Counted: " + count);
|
||||
}
|
||||
@ -659,14 +660,14 @@ public class SelectionCommands {
|
||||
public void distr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException, CommandException {
|
||||
|
||||
int size;
|
||||
boolean useData = args.hasFlag('d');
|
||||
List<Countable<BlockStateHolder>> distribution;
|
||||
boolean separateStates = args.hasFlag('d');
|
||||
List<Countable<BlockState>> distribution;
|
||||
|
||||
if (args.hasFlag('c')) {
|
||||
// TODO: Update for new clipboard
|
||||
throw new CommandException("Needs to be re-written again");
|
||||
} else {
|
||||
distribution = editSession.getBlockDistribution(session.getSelection(player.getWorld()), !useData);
|
||||
distribution = editSession.getBlockDistribution(session.getSelection(player.getWorld()), separateStates);
|
||||
size = session.getSelection(player.getWorld()).getArea();
|
||||
}
|
||||
|
||||
@ -677,10 +678,10 @@ public class SelectionCommands {
|
||||
|
||||
player.print("# total blocks: " + size);
|
||||
|
||||
for (Countable<BlockStateHolder> c : distribution) {
|
||||
for (Countable<BlockState> c : distribution) {
|
||||
String name = c.getID().getBlockType().getName();
|
||||
String str;
|
||||
if (useData) {
|
||||
if (separateStates) {
|
||||
str = String.format("%-7s (%.3f%%) %s #%s",
|
||||
String.valueOf(c.getAmount()),
|
||||
c.getAmount() / (double) size * 100,
|
||||
|
@ -64,7 +64,7 @@ import com.sk89q.worldedit.util.formatting.component.Code;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -250,7 +250,7 @@ public class UtilityCommands {
|
||||
context.setRestricted(false);
|
||||
context.setPreferringWildcard(false);
|
||||
|
||||
BlockStateHolder block = we.getBlockFactory().parseFromInput(args.getString(0), context);
|
||||
BaseBlock block = we.getBlockFactory().parseFromInput(args.getString(0), context);
|
||||
int size = Math.max(1, args.getInteger(1, 50));
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
@ -272,7 +272,7 @@ public class UtilityCommands {
|
||||
|
||||
int size = Math.max(1, args.getInteger(0));
|
||||
int affected;
|
||||
Set<BlockStateHolder> from;
|
||||
Set<BaseBlock> from;
|
||||
Pattern to;
|
||||
|
||||
ParserContext context = new ParserContext();
|
||||
|
@ -68,7 +68,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
if (block.getStates().keySet().isEmpty()) {
|
||||
player.printError("That block's data cannot be cycled!");
|
||||
} else {
|
||||
Property currentProperty = selectedProperties.get(player.getUniqueId());
|
||||
Property<?> currentProperty = selectedProperties.get(player.getUniqueId());
|
||||
|
||||
if (currentProperty == null || (forward && block.getState(currentProperty) == null)) {
|
||||
currentProperty = block.getStates().keySet().stream().findFirst().get();
|
||||
@ -79,7 +79,9 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
block.getState(currentProperty);
|
||||
int index = currentProperty.getValues().indexOf(block.getState(currentProperty));
|
||||
index = (index + 1) % currentProperty.getValues().size();
|
||||
BlockState newBlock = block.with(currentProperty, currentProperty.getValues().get(index));
|
||||
@SuppressWarnings("unchecked")
|
||||
Property<Object> objProp = (Property<Object>) currentProperty;
|
||||
BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index));
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
editSession.disableBuffering();
|
||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
* A mode that replaces one block.
|
||||
@ -73,7 +73,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||
BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector().toBlockPoint());
|
||||
BlockState targetBlock = player.getWorld().getBlock(clicked.toVector().toBlockPoint());
|
||||
|
||||
if (targetBlock != null) {
|
||||
pattern = new BlockPattern(targetBlock);
|
||||
|
@ -29,7 +29,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
* A tool that can place (or remove) blocks at a distance.
|
||||
@ -57,7 +57,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
try (EditSession eS = session.createEditSession(player)) {
|
||||
eS.disableBuffering();
|
||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||
BlockStateHolder applied = secondary.apply(blockPoint);
|
||||
BaseBlock applied = secondary.apply(blockPoint);
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
eS.setBlock(blockPoint, secondary);
|
||||
} else {
|
||||
@ -78,7 +78,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
try (EditSession eS = session.createEditSession(player)) {
|
||||
eS.disableBuffering();
|
||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||
BlockStateHolder applied = primary.apply(blockPoint);
|
||||
BaseBlock applied = primary.apply(blockPoint);
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
eS.setBlock(blockPoint, primary);
|
||||
} else {
|
||||
|
@ -28,7 +28,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
* Looks up information about a block.
|
||||
@ -46,7 +46,7 @@ public class QueryTool implements BlockTool {
|
||||
World world = (World) clicked.getExtent();
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||
BlockStateHolder block = editSession.getFullBlock(blockPoint);
|
||||
BaseBlock block = editSession.getFullBlock(blockPoint);
|
||||
|
||||
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||
+ block.getBlockType().getName() + "\u00A77" + " ("
|
||||
|
@ -23,7 +23,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -44,10 +44,10 @@ public class GravityBrush implements Brush {
|
||||
for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||
for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||
double y = startY;
|
||||
final List<BlockStateHolder> blockTypes = new ArrayList<>();
|
||||
final List<BlockState> blockTypes = new ArrayList<>();
|
||||
for (; y > position.getBlockY() - size; --y) {
|
||||
final BlockVector3 pt = BlockVector3.at(x, y, z);
|
||||
final BlockStateHolder block = editSession.getBlock(pt);
|
||||
final BlockState block = editSession.getBlock(pt);
|
||||
if (!block.getBlockType().getMaterial().isAir()) {
|
||||
blockTypes.add(block);
|
||||
editSession.setBlock(pt, BlockTypes.AIR.getDefaultState());
|
||||
|
Reference in New Issue
Block a user