Removal of many prefixes and deprecation of FaweLocation

- Removed some prefixes to help make upstream merging a bit easier.
- Replaced reflection code for titles with the regular bukkit api.
- Removed FAWELocation and FAWEPlayer where it wasn't needed.
- Deprecated FaweLocation since having it in the first place is very stupid.
- FAWEPlayer should also be deprecated soon because the majority of that code is redundant.
This commit is contained in:
MattBDev 2019-06-05 21:17:34 -04:00
parent bf5d2c2788
commit b42553116c
21 changed files with 161 additions and 507 deletions

View File

@ -23,7 +23,7 @@ public class PatternUtil {
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + arg); snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + arg);
return pattern; return pattern;
} catch (InputParseException e) { } catch (InputParseException e) {
fp.sendMessage(BBC.getPrefix() + e.getMessage()); fp.sendMessage(e.getMessage());
return null; return null;
} }
} }

View File

@ -66,21 +66,11 @@ public class BukkitPlayer extends FawePlayer<Player> {
@Override @Override
public void resetTitle() { public void resetTitle() {
sendTitle("",""); parent.resetTitle();
} }
public void sendTitle(String title, String sub) { public void sendTitle(String title, String sub) {
try { parent.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20);
Method methodSendTitle = Player.class.getDeclaredMethod("sendTitle", String.class, String.class, int.class, int.class, int.class);
methodSendTitle.invoke(parent, ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20);
return;
} catch (Throwable ignore) {
try {
Method methodSendTitle = Player.class.getDeclaredMethod("sendTitle", String.class, String.class);
methodSendTitle.invoke(parent, ChatColor.GOLD + title, ChatColor.GOLD + sub);
return;
} catch (Throwable ignore2) {}
}
if (console == null) { if (console == null) {
console = Bukkit.getConsoleSender(); console = Bukkit.getConsoleSender();
Bukkit.getServer().dispatchCommand(console, "gamerule sendCommandFeedback false"); Bukkit.getServer().dispatchCommand(console, "gamerule sendCommandFeedback false");

View File

@ -373,7 +373,7 @@ public class FaweAPI {
long value = aI - bI; long value = aI - bI;
return value == 0 ? 0 : value < 0 ? -1 : 1; return value == 0 ? 0 : value < 0 ? -1 : 1;
}); });
RegionWrapper bounds = new RegionWrapper(origin.x - radius, origin.x + radius, origin.z - radius, origin.z + radius); RegionWrapper bounds = new RegionWrapper(origin.getX() - radius, origin.getX() + radius, origin.getZ() - radius, origin.getZ() + radius);
RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512); RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512);
HashSet<RegionWrapper> regionSet = Sets.<RegionWrapper>newHashSet(bounds); HashSet<RegionWrapper> regionSet = Sets.<RegionWrapper>newHashSet(bounds);
ArrayList<DiskStorageHistory> result = new ArrayList<>(); ArrayList<DiskStorageHistory> result = new ArrayList<>();

View File

@ -67,9 +67,9 @@ public class Rollback extends FaweCommand {
long total = 0; long total = 0;
player.sendMessage("&d=| Username | Bounds | Distance | Changes | Age |="); player.sendMessage("&d=| Username | Bounds | Distance | Changes | Age |=");
for (DiskStorageHistory edit : edits) { for (DiskStorageHistory edit : edits) {
DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.x, origin.x, origin.z, origin.z), !player.hasPermission("fawe.rollback.deep")); DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.getX(), origin.getX(), origin.getZ(), origin.getZ()), !player.hasPermission("fawe.rollback.deep"));
RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ); RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ);
int distance = region.distance(origin.x, origin.z); int distance = region.distance(origin.getX(), origin.getZ());
String name = Fawe.imp().getName(edit.getUUID()); String name = Fawe.imp().getName(edit.getUUID());
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000; long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
total += edit.getBDFile().length(); total += edit.getBDFile().length();
@ -101,7 +101,7 @@ public class Rollback extends FaweCommand {
BBC.NO_PERM.send(player, "fawe.rollback.perform"); BBC.NO_PERM.send(player, "fawe.rollback.perform");
return false; return false;
} }
final List<DiskStorageHistory> edits = (List<DiskStorageHistory>) player.getMeta(FawePlayer.METADATA_KEYS.ROLLBACK); final List<DiskStorageHistory> edits = player.getMeta(FawePlayer.METADATA_KEYS.ROLLBACK);
player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK); player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK);
if (edits == null) { if (edits == null) {
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>"); BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>");
@ -148,7 +148,7 @@ public class Rollback extends FaweCommand {
} else { } else {
user = Fawe.imp().getUUID(split[1]); user = Fawe.imp().getUUID(split[1]);
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException ignored) {
} }
if (user == null) { if (user == null) {
player.sendMessage("&dInvalid user: " + split[1]); player.sendMessage("&dInvalid user: " + split[1]);

View File

@ -250,7 +250,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
this.player = player; this.player = player;
if (player != null) { if (player != null) {
FaweLocation pos = player.getLocation(); FaweLocation pos = player.getLocation();
this.chunkOffset = BlockVector2.at(1 + (pos.x >> 4), 1 + (pos.z >> 4)); this.chunkOffset = BlockVector2.at(1 + (pos.getX() >> 4), 1 + (pos.getZ() >> 4));
} }
} }
@ -292,8 +292,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int OZ = chunkOffset.getBlockZ(); int OZ = chunkOffset.getBlockZ();
FaweLocation position = player.getLocation(); FaweLocation position = player.getLocation();
int pcx = (position.x >> 4) - OX; int pcx = (position.getX() >> 4) - OX;
int pcz = (position.z >> 4) - OZ; int pcz = (position.getZ() >> 4) - OZ;
int scx = Math.max(0, pcx - 15); int scx = Math.max(0, pcx - 15);
int scz = Math.max(0, pcz - 15); int scz = Math.max(0, pcz - 15);
@ -902,8 +902,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int OZ = chunkOffset.getBlockZ(); int OZ = chunkOffset.getBlockZ();
FaweLocation position = player.getLocation(); FaweLocation position = player.getLocation();
int pcx = (position.x >> 4) - OX; int pcx = (position.getX() >> 4) - OX;
int pcz = (position.z >> 4) - OZ; int pcz = (position.getZ() >> 4) - OZ;
int scx = Math.max(0, pcx - 10); int scx = Math.max(0, pcx - 10);
int scz = Math.max(0, pcz - 10); int scz = Math.max(0, pcz - 10);

View File

@ -1,23 +1,58 @@
package com.boydti.fawe.object; package com.boydti.fawe.object;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.math.*;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import jdk.nashorn.internal.ir.Block;
/** /**
* @deprecated This is likely to be removed in favor of {@link com.sk89q.worldedit.util.Location}.
*/ */
@Deprecated
public class FaweLocation { public class FaweLocation {
public final BlockVector3 vector;
@Deprecated
public final int x; public final int x;
public final int y; @Deprecated
public final int z; public final int z;
@Deprecated
public final int y;
public final String world; public final String world;
public FaweLocation(final String world, final int x, final int y, final int z) { public FaweLocation(final String world, final int x, final int y, final int z) {
this.world = world; this.world = world;
this.x = x; this.vector = BlockVector3.at(x,y,z);
this.y = y; this.x = vector.getX();
this.z = z; this.y = vector.getY();
this.z = vector.getZ();
}
/**
* Get the X coordinate.
*
* @return the x coordinate
*/
public int getX() {
return vector.getX();
}
/**
* Get the Y coordinate.
*
* @return the y coordinate
*/
public int getY() {
return vector.getY();
}
/**
* Get the Z coordinate.
*
* @return the z coordinate
*/
public int getZ() {
return vector.getZ();
} }
@Override @Override

View File

@ -11,12 +11,10 @@ import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue; import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.*; import com.boydti.fawe.util.*;
import com.boydti.fawe.wrappers.FakePlayer;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.*; import com.sk89q.worldedit.extension.platform.*;
@ -63,15 +61,9 @@ public abstract class FawePlayer<T> extends Metadatable {
* @return * @return
*/ */
public static <V> FawePlayer<V> wrap(Object obj) { public static <V> FawePlayer<V> wrap(Object obj) {
if (obj == null || (obj instanceof String && obj.equals("*"))) {
return FakePlayer.getConsole().toFawePlayer();
}
if (obj instanceof FawePlayer) { if (obj instanceof FawePlayer) {
return (FawePlayer<V>) obj; return (FawePlayer<V>) obj;
} }
if (obj instanceof FakePlayer) {
return ((FakePlayer) obj).toFawePlayer();
}
if (obj instanceof Player) { if (obj instanceof Player) {
Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj); Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj);
if (obj instanceof PlayerProxy) { if (obj instanceof PlayerProxy) {
@ -95,9 +87,7 @@ public abstract class FawePlayer<T> extends Metadatable {
if (existing != null) { if (existing != null) {
return existing; return existing;
} }
FakePlayer fake = new FakePlayer(actor.getName(), actor.getUniqueId(), actor); }
return fake.toFawePlayer();
}
if (obj.getClass().getName().contains("CraftPlayer") && !Fawe.imp().getPlatform().equals("bukkit")) { if (obj.getClass().getName().contains("CraftPlayer") && !Fawe.imp().getPlatform().equals("bukkit")) {
try { try {
Method methodGetHandle = obj.getClass().getDeclaredMethod("getHandle"); Method methodGetHandle = obj.getClass().getDeclaredMethod("getHandle");

View File

@ -75,8 +75,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
default BlockState getLazyBlock(int x, int y, int z) { default BlockState getLazyBlock(int x, int y, int z) {
int combinedId4Data = getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()); int combinedId4Data = getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId());
try { try {
BlockState state = BlockState.getFromInternalId(combinedId4Data); return BlockState.getFromInternalId(combinedId4Data);
return state;
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
return BlockTypes.AIR.getDefaultState(); return BlockTypes.AIR.getDefaultState();
@ -85,7 +84,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
@Override @Override
default <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException { default <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
return setBlock(x, y, z, block.getInternalId(), block instanceof BaseBlock ? ((BaseBlock)block).getNbtData() : null); return setBlock(x, y, z, block.getInternalId(), block instanceof BaseBlock ? block.getNbtData() : null);
} }
@Override @Override

View File

@ -214,8 +214,8 @@ public class SchemVis extends ImmutableVirtualWorld {
if (chunks.size() > 225) { if (chunks.size() > 225) {
synchronized (SchemVis.this) { synchronized (SchemVis.this) {
FaweLocation pos = player.getLocation(); FaweLocation pos = player.getLocation();
int centerX = pos.x >> 4; int centerX = pos.getX() >> 4;
int centerZ = pos.z >> 4; int centerZ = pos.getZ() >> 4;
ObjectIterator<Long2ObjectMap.Entry<MCAChunk>> iter = chunks.long2ObjectEntrySet().fastIterator(); ObjectIterator<Long2ObjectMap.Entry<MCAChunk>> iter = chunks.long2ObjectEntrySet().fastIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Long2ObjectMap.Entry<MCAChunk> entry = iter.next(); Long2ObjectMap.Entry<MCAChunk> entry = iter.next();
@ -274,7 +274,7 @@ public class SchemVis extends ImmutableVirtualWorld {
} }
private Map.Entry<File, Long> getEntry(File file, long position) { private Map.Entry<File, Long> getEntry(File file, long position) {
return new AbstractMap.SimpleEntry(file, position); return new AbstractMap.SimpleEntry<>(file, position);
} }
/** /**
@ -554,8 +554,8 @@ public class SchemVis extends ImmutableVirtualWorld {
int OZ = chunkOffset.getBlockZ(); int OZ = chunkOffset.getBlockZ();
FaweLocation position = player.getLocation(); FaweLocation position = player.getLocation();
int pcx = (position.x >> 4) - OX; int pcx = (position.getX() >> 4) - OX;
int pcz = (position.z >> 4) - OZ; int pcz = (position.getZ() >> 4) - OZ;
int scx = pcx - 15; int scx = pcx - 15;
int scz = pcz - 15; int scz = pcz - 15;
@ -564,9 +564,7 @@ public class SchemVis extends ImmutableVirtualWorld {
for (int cz = scz; cz <= ecz; cz++) { for (int cz = scz; cz <= ecz; cz++) {
for (int cx = scx; cx <= ecx; cx++) { for (int cx = scx; cx <= ecx; cx++) {
final int finalCX = cx; send(packetQueue, cx, cz);
final int finalCZ = cz;
send(packetQueue, finalCX, finalCZ);
} }
} }
} }
@ -607,8 +605,8 @@ public class SchemVis extends ImmutableVirtualWorld {
int OZ = chunkOffset.getBlockZ(); int OZ = chunkOffset.getBlockZ();
FaweLocation position = player.getLocation(); FaweLocation position = player.getLocation();
int pcx = (position.x >> 4) - OX; int pcx = (position.getX() >> 4) - OX;
int pcz = (position.z >> 4) - OZ; int pcz = (position.getZ() >> 4) - OZ;
int scx = pcx - 15; int scx = pcx - 15;
int scz = pcz - 15; int scz = pcz - 15;

View File

@ -90,7 +90,7 @@ public class WEManager {
return new Region[]{RegionWrapper.GLOBAL()}; return new Region[]{RegionWrapper.GLOBAL()};
} }
FaweLocation loc = player.getLocation(); FaweLocation loc = player.getLocation();
String world = loc.world; String world = player.getWorld().getName();
if (!world.equals(player.getMeta("lastMaskWorld"))) { if (!world.equals(player.getMeta("lastMaskWorld"))) {
player.deleteMeta("lastMaskWorld"); player.deleteMeta("lastMaskWorld");
player.deleteMeta("lastMask"); player.deleteMeta("lastMask");
@ -112,7 +112,7 @@ public class WEManager {
FaweMask mask = iter.next(); FaweMask mask = iter.next();
if (mask.isValid(player, type)) { if (mask.isValid(player, type)) {
Region region = mask.getRegion(); Region region = mask.getRegion();
if (region.contains(loc.x, loc.y, loc.z)) { if (region.contains(loc.vector)) {
regions.add(region); regions.add(region);
} else { } else {
removed = true; removed = true;
@ -144,12 +144,7 @@ public class WEManager {
} }
} }
} }
if (!tmpMasks.isEmpty()) { regions.addAll(backupRegions);
masks = tmpMasks;
regions = masks.stream().map(FaweMask::getRegion).collect(Collectors.toSet());
} else {
regions.addAll(backupRegions);
}
if (!masks.isEmpty()) { if (!masks.isEmpty()) {
player.setMeta("lastMask", masks); player.setMeta("lastMask", masks);
} else { } else {

View File

@ -1,313 +0,0 @@
package com.boydti.fawe.wrappers;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer;
import com.google.common.base.Charsets;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.*;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemTypes;
import java.util.UUID;
import javax.annotation.Nullable;
/**
* Only really useful for executing commands from console<br>
* - The API itself doesn't any fake player anywhere
*/
public class FakePlayer extends AbstractPlayerActor {
private static FakePlayer CONSOLE;
public static FakePlayer getConsole() {
if (CONSOLE == null) {
CONSOLE = new FakePlayer("#CONSOLE", null, null) {
@Override
public boolean hasPermission(String permission) {
return true;
}
};
}
return CONSOLE;
}
private final Actor parent;
private final String name;
private final UUID uuid;
private World world;
private Location pos;
public static FakePlayer wrap(String name, UUID uuid, Actor parent) {
if (parent != null && parent.getUniqueId().toString().equals("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be")) {
return getConsole();
}
return new FakePlayer(name, uuid, parent);
}
public FakePlayer(String name, UUID uuid, Actor parent) {
this.name = name;
this.uuid = uuid == null ? UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)) : uuid;
try {
this.world = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getWorlds().get(0);
} catch (NoCapablePlatformException e) {
this.world = NullWorld.getInstance();
}
this.pos = new Location(world, 0, 0, 0);
this.parent = parent;
}
private FawePlayer fp = null;
public FawePlayer toFawePlayer() {
if (fp != null) {
Fawe.get().register(fp);
return fp;
}
FawePlayer existing = Fawe.get().getCachedPlayer(getName());
if (existing != null) {
return fp = existing;
}
final Actor actor = this;
return fp = new FawePlayer(this) {
@Override
public void sendTitle(String head, String sub) {
}
@Override
public void resetTitle() {
}
@Override
public String getName() {
return actor.getName();
}
@Override
public UUID getUUID() {
return actor.getUniqueId();
}
@Override
public boolean hasPermission(String perm) {
return actor.hasPermission(perm) || (Boolean) getMeta("perm." + perm, false);
}
@Override
public void setPermission(String perm, boolean flag) {
setMeta("perm." + perm, true);
}
@Override
public void sendMessage(String message) {
actor.print(message);
}
@Override
public void executeCommand(String substring) {
CommandManager.getInstance().handleCommand(new CommandEvent(actor, substring));
}
@Override
public FaweLocation getLocation() {
Location loc = FakePlayer.this.getLocation();
String world;
if (loc.getExtent() instanceof World) {
world = ((World) loc.getExtent()).getName();
} else {
world = loc.getExtent().toString();
}
return new FaweLocation(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
@Override
public Player toWorldEditPlayer() {
return FakePlayer.this;
}
};
}
@Override
public World getWorld() {
return world;
}
@Override
public BaseItemStack getItemInHand(HandSide handSide) {
return new BaseItemStack(ItemTypes.AIR, 0);
}
@Override
public BaseBlock getBlockInHand(HandSide ignore) {
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
@Override
public void giveItem(BaseItemStack itemStack) {
}
@Override
public BlockBag getInventoryBlockBag() {
return null;
}
@Override
public void setPosition(Vector3 pos, float pitch, float yaw) {
//TODO: find replacement for following code
// if (pos instanceof Location) {
// Extent extent = ((Location) pos).getExtent();
// if (extent instanceof World) this.world = (World) extent;
// }
this.pos = new Location(world, pos, yaw, pitch);
}
@Nullable
@Override
public BaseEntity getState() {
return null;
}
@Override
public Location getLocation() {
return pos;
}
@Override
public String getName() {
if (parent != null) {
return parent.getName();
}
return name;
}
@Override
public void printRaw(String msg) {
if (parent != null) {
parent.printRaw(msg);
return;
}
Fawe.get().debugPlain(msg);
}
@Override
public void printDebug(String msg) {
if (parent != null) {
parent.printDebug(msg);
return;
}
Fawe.get().debugPlain(msg);
}
@Override
public void print(String msg) {
if (parent != null) {
parent.print(msg);
return;
}
Fawe.get().debugPlain(msg);
}
@Override
public void printError(String msg) {
if (parent != null) {
parent.printError(msg);
return;
}
Fawe.get().debugPlain(msg);
}
private FakeSessionKey key;
@Override
public SessionKey getSessionKey() {
if (parent != null) {
return parent.getSessionKey();
}
if (key == null) {
key = new FakeSessionKey(uuid, name);
}
return key;
}
@Nullable
@Override
public <T> T getFacet(Class<? extends T> cls) {
return null;
}
@Override
public UUID getUniqueId() {
if (parent != null) {
return parent.getUniqueId();
}
return uuid;
}
@Override
public String[] getGroups() {
if (parent != null) {
return parent.getGroups();
}
return new String[0];
}
@Override
public boolean hasPermission(String permission) {
if (parent != null) {
return parent.hasPermission(permission);
}
return true;
}
private static class FakeSessionKey implements SessionKey {
private final UUID uuid;
private final String name;
private FakeSessionKey(UUID uuid, String name) {
this.uuid = uuid;
this.name = name;
}
@Override
public UUID getUniqueId() {
return uuid;
}
@Nullable
@Override
public String getName() {
return name;
}
@Override
public boolean isActive() {
return true;
}
@Override
public boolean isPersistent() {
return true;
}
}
@Override
public boolean setLocation(Location location) {
this.pos = location;
return true;
}
}

View File

@ -612,7 +612,7 @@ public final class WorldEdit {
String ext = filename.substring(index + 1); String ext = filename.substring(index + 1);
if (!ext.equalsIgnoreCase("js")) { if (!ext.equalsIgnoreCase("js")) {
player.printError(BBC.getPrefix() + "Only .js scripts are currently supported"); player.printError("Only .js scripts are currently supported");
return; return;
} }
@ -625,7 +625,7 @@ public final class WorldEdit {
file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename); file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename);
if (file == null) { if (file == null) {
player.printError(BBC.getPrefix() + "Script does not exist: " + filename); player.printError("Script does not exist: " + filename);
return; return;
} }
} else { } else {
@ -638,7 +638,7 @@ public final class WorldEdit {
in.close(); in.close();
script = new String(data, 0, data.length, StandardCharsets.UTF_8); script = new String(data, 0, data.length, StandardCharsets.UTF_8);
} catch (IOException e) { } catch (IOException e) {
player.printError(BBC.getPrefix() + "Script read error: " + e.getMessage()); player.printError("Script read error: " + e.getMessage());
return; return;
} }
@ -651,8 +651,8 @@ public final class WorldEdit {
try { try {
engine = new RhinoCraftScriptEngine(); engine = new RhinoCraftScriptEngine();
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
player.printError(BBC.getPrefix() + "Failed to find an installed script engine."); player.printError("Failed to find an installed script engine.");
player.printError(BBC.getPrefix() + "Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation"); player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation");
return; return;
} }
@ -666,15 +666,15 @@ public final class WorldEdit {
try { try {
engine.evaluate(script, filename, vars); engine.evaluate(script, filename, vars);
} catch (ScriptException e) { } catch (ScriptException e) {
player.printError(BBC.getPrefix() + "Failed to execute:"); player.printError("Failed to execute:");
player.printRaw(e.getMessage()); player.printRaw(e.getMessage());
logger.warn(BBC.getPrefix() + "Failed to execute script", e); logger.warn("Failed to execute script", e);
} catch (NumberFormatException | WorldEditException e) { } catch (NumberFormatException | WorldEditException e) {
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
player.printError(BBC.getPrefix() + "Failed to execute (see console):"); player.printError("Failed to execute (see console):");
player.printRaw(e.getClass().getCanonicalName()); player.printRaw(e.getClass().getCanonicalName());
logger.warn(BBC.getPrefix() + "Failed to execute script", e); logger.warn("Failed to execute script", e);
} finally { } finally {
for (EditSession editSession : scriptContext.getEditSessions()) { for (EditSession editSession : scriptContext.getEditSessions()) {
editSession.flushSession(); editSession.flushSession();

View File

@ -201,7 +201,7 @@ public class BiomeCommands extends MethodCommands {
c.getAmount() / (double) size * 100, c.getAmount() / (double) size * 100,
data == null ? "Unknown" : data.getName(), data == null ? "Unknown" : data.getName(),
c.getID().getInternalId()); c.getID().getInternalId());
player.print(BBC.getPrefix() + str); player.print(str);
} }
} }

View File

@ -76,9 +76,9 @@ public class ChunkCommands {
String filename = "c." + Integer.toString(chunkX, 36) String filename = "c." + Integer.toString(chunkX, 36)
+ "." + Integer.toString(chunkZ, 36) + ".dat"; + "." + Integer.toString(chunkZ, 36) + ".dat";
player.print(BBC.getPrefix() + "Chunk: " + chunkX + ", " + chunkZ); player.print("Chunk: " + chunkX + ", " + chunkZ);
player.print(BBC.getPrefix() + "Old format: " + folder1 + "/" + folder2 + "/" + filename); player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
player.print(BBC.getPrefix() + "McRegion: region/" + McRegionChunkStore.getFilename( player.print("McRegion: region/" + McRegionChunkStore.getFilename(
BlockVector2.at(chunkX, chunkZ))); BlockVector2.at(chunkX, chunkZ)));
} }
@ -94,7 +94,7 @@ public class ChunkCommands {
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks(); Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
for (BlockVector2 chunk : chunks) { for (BlockVector2 chunk : chunks) {
player.print(BBC.getPrefix() + LegacyChunkStore.getFilename(chunk)); player.print(LegacyChunkStore.getFilename(chunk));
} }
} }
@ -108,14 +108,14 @@ public class ChunkCommands {
@CommandPermissions("worldedit.delchunks") @CommandPermissions("worldedit.delchunks")
@Logging(REGION) @Logging(REGION)
public void deleteChunks(Player player, LocalSession session) throws WorldEditException { public void deleteChunks(Player player, LocalSession session) throws WorldEditException {
player.print(BBC.getPrefix() + "Note that this command does not yet support the mcregion format."); player.print("Note that this command does not yet support the mcregion format.");
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks(); Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
FileOutputStream out = null; FileOutputStream out = null;
if (config.shellSaveType == null) { if (config.shellSaveType == null) {
player.printError(BBC.getPrefix() + "Shell script type must be configured: 'bat' or 'bash' expected."); player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
} else if (config.shellSaveType.equalsIgnoreCase("bat")) { } else if (config.shellSaveType.equalsIgnoreCase("bat")) {
try { try {
out = new FileOutputStream("worldedit-delchunks.bat"); out = new FileOutputStream("worldedit-delchunks.bat");
@ -137,7 +137,7 @@ public class ChunkCommands {
writer.write("ECHO Complete.\r\n"); writer.write("ECHO Complete.\r\n");
writer.write("PAUSE\r\n"); writer.write("PAUSE\r\n");
writer.close(); writer.close();
player.print(BBC.getPrefix() + "worldedit-delchunks.bat written. Run it when no one is near the region."); player.print("worldedit-delchunks.bat written. Run it when no one is near the region.");
} catch (IOException e) { } catch (IOException e) {
player.printError("Error occurred: " + e.getMessage()); player.printError("Error occurred: " + e.getMessage());
} finally { } finally {
@ -169,8 +169,8 @@ public class ChunkCommands {
writer.write("echo Complete.\n"); writer.write("echo Complete.\n");
writer.write("read -p \"Press any key to continue...\"\n"); writer.write("read -p \"Press any key to continue...\"\n");
writer.close(); writer.close();
player.print(BBC.getPrefix() + "worldedit-delchunks.sh written. Run it when no one is near the region."); player.print("worldedit-delchunks.sh written. Run it when no one is near the region.");
player.print(BBC.getPrefix() + "You will have to chmod it to be executable."); player.print("You will have to chmod it to be executable.");
} catch (IOException e) { } catch (IOException e) {
player.printError("Error occurred: " + e.getMessage()); player.printError("Error occurred: " + e.getMessage());
} finally { } finally {
@ -182,7 +182,7 @@ public class ChunkCommands {
} }
} }
} else { } else {
player.printError(BBC.getPrefix() + "Shell script type must be configured: 'bat' or 'bash' expected."); player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
} }
} }

View File

@ -143,7 +143,7 @@ public abstract class HelpBuilder implements Runnable {
displayFailure(BBC.HELP_SUGGEST.f(arg, StringMan.join(found, ", "))); displayFailure(BBC.HELP_SUGGEST.f(arg, StringMan.join(found, ", ")));
return; return;
} else { } else {
String msg = String.format(BBC.getPrefix() + "The sub-command '%s' under '%s' could not be found.", String msg = String.format("The sub-command '%s' under '%s' could not be found.",
command, Joiner.on(" ").join(visited)); command, Joiner.on(" ").join(visited));
displayFailure(msg); displayFailure(msg);
return; return;
@ -152,7 +152,7 @@ public abstract class HelpBuilder implements Runnable {
visited.add(args.getString(i)); visited.add(args.getString(i));
isRootLevel = false; isRootLevel = false;
} else { } else {
String msg = String.format(BBC.getPrefix() + "'%s' has no sub-commands. (Maybe '%s' is for a parameter?)", String msg = String.format("'%s' has no sub-commands. (Maybe '%s' is for a parameter?)",
Joiner.on(" ").join(visited), command); Joiner.on(" ").join(visited), command);
displayFailure(msg); displayFailure(msg);
return; return;
@ -189,7 +189,7 @@ public abstract class HelpBuilder implements Runnable {
// Box // Box
if (offset >= aliases.size()) { if (offset >= aliases.size()) {
displayFailure(String.format(BBC.getPrefix() + "There is no page %d (total number of pages is %d).", page + 1, pageTotal)); displayFailure(String.format("There is no page %d (total number of pages is %d).", page + 1, pageTotal));
} else { } else {
int end = Math.min(offset + perPage, aliases.size()); int end = Math.min(offset + perPage, aliases.size());
List<CommandMapping> subAliases = aliases.subList(offset, end); List<CommandMapping> subAliases = aliases.subList(offset, end);

View File

@ -256,7 +256,7 @@ public class OptionsCommands {
int limit = args.argsLength() == 0 ? config.calculationTimeout : Math.max(-1, args.getInteger(0)); int limit = args.argsLength() == 0 ? config.calculationTimeout : Math.max(-1, args.getInteger(0));
if (!mayDisable && config.maxCalculationTimeout > -1) { if (!mayDisable && config.maxCalculationTimeout > -1) {
if (limit > config.maxCalculationTimeout) { if (limit > config.maxCalculationTimeout) {
player.printError(BBC.getPrefix() + "Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms."); player.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
return; return;
} }
} }
@ -264,9 +264,9 @@ public class OptionsCommands {
session.setTimeout(limit); session.setTimeout(limit);
if (limit != config.calculationTimeout) { if (limit != config.calculationTimeout) {
player.print(BBC.getPrefix() + "Timeout time set to " + limit + " ms. (Use //timeout to go back to the default.)"); player.print("Timeout time set to " + limit + " ms. (Use //timeout to go back to the default.)");
} else { } else {
player.print(BBC.getPrefix() + "Timeout time set to " + limit + " ms."); player.print("Timeout time set to " + limit + " ms.");
} }
} }
@ -281,27 +281,27 @@ public class OptionsCommands {
public void drawSelection(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void drawSelection(Player player, LocalSession session, CommandContext args) throws WorldEditException {
if (!WorldEdit.getInstance().getConfiguration().serverSideCUI) { if (!WorldEdit.getInstance().getConfiguration().serverSideCUI) {
throw new DisallowedUsageException(BBC.getPrefix() + "This functionality is disabled in the configuration!"); throw new DisallowedUsageException("This functionality is disabled in the configuration!");
} }
String newState = args.getString(0, null); String newState = args.getString(0, null);
if (session.shouldUseServerCUI()) { if (session.shouldUseServerCUI()) {
if ("on".equals(newState)) { if ("on".equals(newState)) {
player.printError(BBC.getPrefix() + "Server CUI already enabled."); player.printError("Server CUI already enabled.");
return; return;
} }
session.setUseServerCUI(false); session.setUseServerCUI(false);
session.updateServerCUI(player); session.updateServerCUI(player);
player.print(BBC.getPrefix() + "Server CUI disabled."); player.print("Server CUI disabled.");
} else { } else {
if ("off".equals(newState)) { if ("off".equals(newState)) {
player.printError(BBC.getPrefix() + "Server CUI already disabled."); player.printError("Server CUI already disabled.");
return; return;
} }
session.setUseServerCUI(true); session.setUseServerCUI(true);
session.updateServerCUI(player); session.updateServerCUI(player);
player.print(BBC.getPrefix() + "Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32."); player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.");
} }
} }
@ -327,29 +327,29 @@ public class OptionsCommands {
ItemType type = ItemTypes.get(query); ItemType type = ItemTypes.get(query);
if (type != null) { if (type != null) {
actor.print(BBC.getPrefix() + type.getId() + " (" + type.getName() + ")"); actor.print(type.getId() + " (" + type.getName() + ")");
} else { } else {
if (query.length() <= 2) { if (query.length() <= 2) {
actor.printError(BBC.getPrefix() + "Enter a longer search string (len > 2)."); actor.printError("Enter a longer search string (len > 2).");
return; return;
} }
if (!blocksOnly && !itemsOnly) { if (!blocksOnly && !itemsOnly) {
actor.print(BBC.getPrefix() + "Searching for: " + query); actor.print("Searching for: " + query);
} else if (blocksOnly && itemsOnly) { } else if (blocksOnly && itemsOnly) {
actor.printError(BBC.getPrefix() + "You cannot use both the 'b' and 'i' flags simultaneously."); actor.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
return; return;
} else if (blocksOnly) { } else if (blocksOnly) {
actor.print(BBC.getPrefix() + "Searching for blocks: " + query); actor.print("Searching for blocks: " + query);
} else { } else {
actor.print(BBC.getPrefix() + "Searching for items: " + query); actor.print("Searching for items: " + query);
} }
int found = 0; int found = 0;
for (ItemType searchType : ItemType.REGISTRY) { for (ItemType searchType : ItemType.REGISTRY) {
if (found >= 15) { if (found >= 15) {
actor.print(BBC.getPrefix() + "Too many results!"); actor.print("Too many results!");
break; break;
} }
@ -363,7 +363,7 @@ public class OptionsCommands {
for (String alias : Sets.newHashSet(searchType.getId(), searchType.getName())) { for (String alias : Sets.newHashSet(searchType.getId(), searchType.getName())) {
if (alias.contains(query)) { if (alias.contains(query)) {
actor.print(BBC.getPrefix() + searchType.getId() + " (" + searchType.getName() + ")"); actor.print(searchType.getId() + " (" + searchType.getName() + ")");
++found; ++found;
break; break;
} }
@ -371,7 +371,7 @@ public class OptionsCommands {
} }
if (found == 0) { if (found == 0) {
actor.printError(BBC.getPrefix() + "No items found."); actor.printError("No items found.");
} }
} }
} }

View File

@ -23,7 +23,6 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
@ -115,14 +114,14 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.fix") @CommandPermissions("worldedit.light.fix")
public void fixlighting(Player player) throws WorldEditException { public void fixlighting(Player player) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation(); final Location loc = player.getLocation();
Region selection = fp.getSelection(); Region selection = fp.getSelection();
if (selection == null) { if (selection == null) {
final int cx = loc.x >> 4; final int cx = loc.getBlockX() >> 4;
final int cz = loc.z >> 4; final int cz = loc.getBlockZ() >> 4;
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.ALL); int count = FaweAPI.fixLighting(player.getWorld(), selection,null, FaweQueue.RelightMode.ALL);
BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count); BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count);
} }
@ -135,9 +134,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.fix") @CommandPermissions("worldedit.light.fix")
public void getlighting(Player player) throws WorldEditException { public void getlighting(Player player) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation(); final Location loc = player.getLocation();
FaweQueue queue = fp.getFaweQueue(false); FaweQueue queue = fp.getFaweQueue(false);
fp.sendMessage(BBC.getPrefix() + "Light: " + queue.getEmmittedLight(loc.x, loc.y, loc.z) + " | " + queue.getSkyLight(loc.x, loc.y, loc.z)); fp.sendMessage(BBC.getPrefix() + "Light: " + queue.getEmmittedLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) + " | " + queue.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
} }
@Command( @Command(
@ -149,14 +148,13 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.remove") @CommandPermissions("worldedit.light.remove")
public void removelighting(Player player) { public void removelighting(Player player) {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation();
Region selection = fp.getSelection(); Region selection = fp.getSelection();
if (selection == null) { if (selection == null) {
final int cx = loc.x >> 4; final int cx = player.getLocation().getBlockX() >> 4;
final int cz = loc.z >> 4; final int cz = player.getLocation().getBlockZ() >> 4;
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.NONE); int count = FaweAPI.fixLighting(player.getWorld(), selection, null, FaweQueue.RelightMode.NONE);
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count); BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
} }
@ -188,12 +186,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.set") @CommandPermissions("worldedit.light.set")
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) { public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation();
final int cx = loc.x >> 4;
final int cz = loc.z >> 4;
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false); final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
for (BlockVector3 pt : region) { for (BlockVector3 pt : region) {
queue.setBlockLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value); queue.setBlockLight(pt.getX(), pt.getY(), pt.getZ(), value);
} }
int count = 0; int count = 0;
for (BlockVector2 chunk : region.getChunks()) { for (BlockVector2 chunk : region.getChunks()) {
@ -212,12 +207,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.set") @CommandPermissions("worldedit.light.set")
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) { public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation();
final int cx = loc.x >> 4;
final int cz = loc.z >> 4;
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false); final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
for (BlockVector3 pt : region) { for (BlockVector3 pt : region) {
queue.setSkyLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value); queue.setSkyLight(pt.getX(), pt.getY(), pt.getZ(), value);
} }
int count = 0; int count = 0;
for (BlockVector2 chunk : region.getChunks()) { for (BlockVector2 chunk : region.getChunks()) {
@ -722,10 +714,10 @@ public class RegionCommands extends MethodCommands {
BBC.COMMAND_REGEN_2.send(player); BBC.COMMAND_REGEN_2.send(player);
} else if (biome == null) { } else if (biome == null) {
BBC.COMMAND_REGEN_0.send(player); BBC.COMMAND_REGEN_0.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player); if (!player.hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player);
} else if (seed == null) { } else if (seed == null) {
BBC.COMMAND_REGEN_1.send(player); BBC.COMMAND_REGEN_1.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player); if (!player.hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
} else { } else {
BBC.COMMAND_REGEN_2.send(player); BBC.COMMAND_REGEN_2.send(player);
} }

View File

@ -621,17 +621,17 @@ public class SelectionCommands {
long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ()); long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ());
String msg = String.format("%1$s: %2$s @ %3$s (%4$d blocks)", name, sizeStr, originStr, numBlocks); String msg = String.format("%1$s: %2$s @ %3$s (%4$d blocks)", name, sizeStr, originStr, numBlocks);
player.print(BBC.getPrefix() + msg); player.print(msg);
index++; index++;
} }
// player.print(BBC.getPrefix() + "Cuboid dimensions (max - min): " + size); // player.print("Cuboid dimensions (max - min): " + size);
// player.print(BBC.getPrefix() + "Offset: " + origin); // player.print("Offset: " + origin);
// player.print(BBC.getPrefix() + "Cuboid distance: " + size.distance(Vector.ONE)); // player.print("Cuboid distance: " + size.distance(Vector.ONE));
// player.print(BBC.getPrefix() + "# of blocks: " + (int) (size.getX() * size.getY() * size.getZ())); // player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
//======= //=======
// public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { // public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
// if (args.hasFlag('c')) { // if (args.hasFlag('c')) {
@ -653,17 +653,17 @@ public class SelectionCommands {
.subtract(region.getMinimumPoint()) .subtract(region.getMinimumPoint())
.add(1, 1, 1); .add(1, 1, 1);
player.print(BBC.getPrefix() + "Type: " + session.getRegionSelector(player.getWorld()) player.print("Type: " + session.getRegionSelector(player.getWorld())
.getTypeName()); .getTypeName());
for (String line : session.getRegionSelector(player.getWorld()) for (String line : session.getRegionSelector(player.getWorld())
.getInformationLines()) { .getInformationLines()) {
player.print(BBC.getPrefix() + line); player.print(line);
} }
player.print(BBC.getPrefix() + "Size: " + size); player.print("Size: " + size);
player.print(BBC.getPrefix() + "Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint())); player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print(BBC.getPrefix() + "# of blocks: " + region.getArea()); player.print("# of blocks: " + region.getArea());
} }
@ -713,7 +713,7 @@ public class SelectionCommands {
size = session.getSelection(player.getWorld()).getArea(); size = session.getSelection(player.getWorld()).getArea();
if (distributionData.size() <= 0) { if (distributionData.size() <= 0) {
player.printError(BBC.getPrefix() + "No blocks counted."); player.printError("No blocks counted.");
return; return;
} }
BBC.SELECTION_DISTR.send(player, size); BBC.SELECTION_DISTR.send(player, size);
@ -724,7 +724,7 @@ public class SelectionCommands {
String.valueOf(c.getAmount()), String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100, c.getAmount() / (double) size * 100,
name); name);
player.print(BBC.getPrefix() + str); player.print(str);
} }
} }
@ -751,37 +751,37 @@ public class SelectionCommands {
final RegionSelector selector; final RegionSelector selector;
if (typeName.equalsIgnoreCase("cuboid")) { if (typeName.equalsIgnoreCase("cuboid")) {
selector = new CuboidRegionSelector(oldSelector); selector = new CuboidRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_CUBOID.s()); player.print(BBC.SEL_CUBOID.s());
} else if (typeName.equalsIgnoreCase("extend")) { } else if (typeName.equalsIgnoreCase("extend")) {
selector = new ExtendingCuboidRegionSelector(oldSelector); selector = new ExtendingCuboidRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_CUBOID_EXTEND.s()); player.print(BBC.SEL_CUBOID_EXTEND.s());
} else if (typeName.equalsIgnoreCase("poly")) { } else if (typeName.equalsIgnoreCase("poly")) {
selector = new Polygonal2DRegionSelector(oldSelector); selector = new Polygonal2DRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_2D_POLYGON.s()); player.print(BBC.SEL_2D_POLYGON.s());
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
limit.ifPresent(integer -> player.print(BBC.getPrefix() + BBC.SEL_MAX.f(integer))); limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
player.print(BBC.getPrefix() + BBC.SEL_LIST.s()); player.print(BBC.SEL_LIST.s());
} else if (typeName.equalsIgnoreCase("ellipsoid")) { } else if (typeName.equalsIgnoreCase("ellipsoid")) {
selector = new EllipsoidRegionSelector(oldSelector); selector = new EllipsoidRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_ELLIPSIOD.s()); player.print(BBC.SEL_ELLIPSIOD.s());
} else if (typeName.equalsIgnoreCase("sphere")) { } else if (typeName.equalsIgnoreCase("sphere")) {
selector = new SphereRegionSelector(oldSelector); selector = new SphereRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_SPHERE.s()); player.print(BBC.SEL_SPHERE.s());
} else if (typeName.equalsIgnoreCase("cyl")) { } else if (typeName.equalsIgnoreCase("cyl")) {
selector = new CylinderRegionSelector(oldSelector); selector = new CylinderRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_CYLINDRICAL.s()); player.print(BBC.SEL_CYLINDRICAL.s());
} else if (typeName.equalsIgnoreCase("convex") || typeName.equalsIgnoreCase("hull")) { } else if (typeName.equalsIgnoreCase("convex") || typeName.equalsIgnoreCase("hull")) {
selector = new ConvexPolyhedralRegionSelector(oldSelector); selector = new ConvexPolyhedralRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_CONVEX_POLYHEDRAL.s()); player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
limit.ifPresent(integer -> player.print(BBC.getPrefix() + BBC.SEL_MAX.f(integer))); limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
player.print(BBC.getPrefix() + BBC.SEL_LIST.s()); player.print(BBC.SEL_LIST.s());
} else if (typeName.equalsIgnoreCase("polyhedral") || typeName.equalsIgnoreCase("polyhedron")) { } else if (typeName.equalsIgnoreCase("polyhedral") || typeName.equalsIgnoreCase("polyhedron")) {
selector = new PolyhedralRegionSelector(player.getWorld()); selector = new PolyhedralRegionSelector(player.getWorld());
player.print(BBC.getPrefix() + BBC.SEL_CONVEX_POLYHEDRAL.s()); player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
limit.ifPresent(integer -> player.print(BBC.getPrefix() + BBC.SEL_MAX.f(integer))); limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
player.print(BBC.getPrefix() + BBC.SEL_LIST.s()); player.print(BBC.SEL_LIST.s());
} else if (typeName.startsWith("fuzzy") || typeName.startsWith("magic")) { } else if (typeName.startsWith("fuzzy") || typeName.startsWith("magic")) {
Mask mask; Mask mask;
if (typeName.length() > 6) { if (typeName.length() > 6) {
@ -795,13 +795,13 @@ public class SelectionCommands {
mask = new IdMask(editSession); mask = new IdMask(editSession);
} }
selector = new FuzzyRegionSelector(player, editSession, mask); selector = new FuzzyRegionSelector(player, editSession, mask);
player.print(BBC.getPrefix() + BBC.SEL_FUZZY.f()); player.print(BBC.SEL_FUZZY.f());
player.print(BBC.getPrefix() + BBC.SEL_LIST.f()); player.print(BBC.SEL_LIST.f());
} else { } else {
CommandListBox box = new CommandListBox("Selection modes"); CommandListBox box = new CommandListBox("Selection modes");
StyledFragment contents = box.getContents(); StyledFragment contents = box.getContents();
StyledFragment tip = contents.createFragment(Style.RED); StyledFragment tip = contents.createFragment(Style.RED);
tip.append(BBC.getPrefix() + BBC.SEL_MODES.s()).newLine(); tip.append(BBC.SEL_MODES.s()).newLine();
box.appendCommand("//sel cuboid", "Select two corners of a cuboid"); box.appendCommand("//sel cuboid", "Select two corners of a cuboid");
box.appendCommand("//sel extend", "Fast cuboid selection mode"); box.appendCommand("//sel extend", "Fast cuboid selection mode");

View File

@ -8,6 +8,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -29,7 +30,7 @@ public class AreaPickaxe implements BlockTool {
} }
@Override @Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
int ox = clicked.getBlockX(); int ox = clicked.getBlockX();
int oy = clicked.getBlockY(); int oy = clicked.getBlockY();
int oz = clicked.getBlockZ(); int oz = clicked.getBlockZ();

View File

@ -32,37 +32,14 @@ import com.boydti.fawe.object.task.ThrowableSupplier;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.chat.UsageMessage; import com.boydti.fawe.util.chat.UsageMessage;
import com.boydti.fawe.wrappers.FakePlayer;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.*;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.BiomeCommands; import com.sk89q.worldedit.command.*;
import com.sk89q.worldedit.command.BrushCommands;
import com.sk89q.worldedit.command.BrushOptionsCommands;
import com.sk89q.worldedit.command.ChunkCommands;
import com.sk89q.worldedit.command.ClipboardCommands;
import com.sk89q.worldedit.command.GenerationCommands;
import com.sk89q.worldedit.command.HistoryCommands;
import com.sk89q.worldedit.command.NavigationCommands;
import com.sk89q.worldedit.command.OptionsCommands;
import com.sk89q.worldedit.command.RegionCommands;
import com.sk89q.worldedit.command.SchematicCommands;
import com.sk89q.worldedit.command.ScriptingCommands;
import com.sk89q.worldedit.command.SelectionCommands;
import com.sk89q.worldedit.command.SnapshotCommands;
import com.sk89q.worldedit.command.SnapshotUtilCommands;
import com.sk89q.worldedit.command.SuperPickaxeCommands;
import com.sk89q.worldedit.command.ToolCommands;
import com.sk89q.worldedit.command.UtilityCommands;
import com.sk89q.worldedit.command.WorldEditCommands;
import com.sk89q.worldedit.command.argument.ReplaceParser; import com.sk89q.worldedit.command.argument.ReplaceParser;
import com.sk89q.worldedit.command.argument.TreeGeneratorParser; import com.sk89q.worldedit.command.argument.TreeGeneratorParser;
import com.sk89q.worldedit.command.composition.ApplyCommand; import com.sk89q.worldedit.command.composition.ApplyCommand;
@ -76,19 +53,11 @@ import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.factory.Deform; import com.sk89q.worldedit.function.factory.Deform;
import com.sk89q.worldedit.function.factory.Deform.Mode; import com.sk89q.worldedit.function.factory.Deform.Mode;
import com.sk89q.worldedit.internal.command.ActorAuthorizer; import com.sk89q.worldedit.internal.command.*;
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
import com.sk89q.worldedit.internal.command.UserCommandCompleter;
import com.sk89q.worldedit.internal.command.WorldEditBinding;
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
import com.sk89q.worldedit.scripting.CommandScriptLoader; import com.sk89q.worldedit.scripting.CommandScriptLoader;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.command.CallableProcessor; import com.sk89q.worldedit.util.command.*;
import com.sk89q.worldedit.util.command.CommandCallable;
import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.InvalidUsageException;
import com.sk89q.worldedit.util.command.composition.ProvidedValue; import com.sk89q.worldedit.util.command.composition.ProvidedValue;
import com.sk89q.worldedit.util.command.fluent.CommandGraph; import com.sk89q.worldedit.util.command.fluent.CommandGraph;
import com.sk89q.worldedit.util.command.fluent.DispatcherNode; import com.sk89q.worldedit.util.command.fluent.DispatcherNode;
@ -404,9 +373,6 @@ public final class CommandManager {
if (!dispatcher.contains(split[0])) { if (!dispatcher.contains(split[0])) {
return; return;
} }
if (!actor.isPlayer()) {
actor = FakePlayer.wrap(actor.getName(), actor.getUniqueId(), actor);
}
LocalSession session = worldEdit.getSessionManager().get(actor); LocalSession session = worldEdit.getSessionManager().get(actor);
Request.request().setSession(session); Request.request().setSession(session);
if (actor instanceof Entity) { if (actor instanceof Entity) {

View File

@ -51,6 +51,7 @@ public class BlockVector3 {
// thread-safe initialization idiom // thread-safe initialization idiom
private static final class YzxOrderComparator { private static final class YzxOrderComparator {
private static final Comparator<BlockVector3> YZX_ORDER = (a, b) -> { private static final Comparator<BlockVector3> YZX_ORDER = (a, b) -> {
//noinspection SuspiciousNameCombination
return ComparisonChain.start() return ComparisonChain.start()
.compare(a.y, b.y) .compare(a.y, b.y)
.compare(a.z, b.z) .compare(a.z, b.z)