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

@ -201,7 +201,7 @@ public class BiomeCommands extends MethodCommands {
c.getAmount() / (double) size * 100,
data == null ? "Unknown" : data.getName(),
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)
+ "." + Integer.toString(chunkZ, 36) + ".dat";
player.print(BBC.getPrefix() + "Chunk: " + chunkX + ", " + chunkZ);
player.print(BBC.getPrefix() + "Old format: " + folder1 + "/" + folder2 + "/" + filename);
player.print(BBC.getPrefix() + "McRegion: region/" + McRegionChunkStore.getFilename(
player.print("Chunk: " + chunkX + ", " + chunkZ);
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
BlockVector2.at(chunkX, chunkZ)));
}
@ -94,7 +94,7 @@ public class ChunkCommands {
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
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")
@Logging(REGION)
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();
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
FileOutputStream out = 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")) {
try {
out = new FileOutputStream("worldedit-delchunks.bat");
@ -137,7 +137,7 @@ public class ChunkCommands {
writer.write("ECHO Complete.\r\n");
writer.write("PAUSE\r\n");
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) {
player.printError("Error occurred: " + e.getMessage());
} finally {
@ -169,8 +169,8 @@ public class ChunkCommands {
writer.write("echo Complete.\n");
writer.write("read -p \"Press any key to continue...\"\n");
writer.close();
player.print(BBC.getPrefix() + "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("worldedit-delchunks.sh written. Run it when no one is near the region.");
player.print("You will have to chmod it to be executable.");
} catch (IOException e) {
player.printError("Error occurred: " + e.getMessage());
} finally {
@ -182,7 +182,7 @@ public class ChunkCommands {
}
}
} 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, ", ")));
return;
} 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));
displayFailure(msg);
return;
@ -152,7 +152,7 @@ public abstract class HelpBuilder implements Runnable {
visited.add(args.getString(i));
isRootLevel = false;
} 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);
displayFailure(msg);
return;
@ -189,7 +189,7 @@ public abstract class HelpBuilder implements Runnable {
// Box
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 {
int end = Math.min(offset + perPage, aliases.size());
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));
if (!mayDisable && config.maxCalculationTimeout > -1) {
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;
}
}
@ -264,9 +264,9 @@ public class OptionsCommands {
session.setTimeout(limit);
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 {
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 {
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);
if (session.shouldUseServerCUI()) {
if ("on".equals(newState)) {
player.printError(BBC.getPrefix() + "Server CUI already enabled.");
player.printError("Server CUI already enabled.");
return;
}
session.setUseServerCUI(false);
session.updateServerCUI(player);
player.print(BBC.getPrefix() + "Server CUI disabled.");
player.print("Server CUI disabled.");
} else {
if ("off".equals(newState)) {
player.printError(BBC.getPrefix() + "Server CUI already disabled.");
player.printError("Server CUI already disabled.");
return;
}
session.setUseServerCUI(true);
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);
if (type != null) {
actor.print(BBC.getPrefix() + type.getId() + " (" + type.getName() + ")");
actor.print(type.getId() + " (" + type.getName() + ")");
} else {
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;
}
if (!blocksOnly && !itemsOnly) {
actor.print(BBC.getPrefix() + "Searching for: " + query);
actor.print("Searching for: " + query);
} 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;
} else if (blocksOnly) {
actor.print(BBC.getPrefix() + "Searching for blocks: " + query);
actor.print("Searching for blocks: " + query);
} else {
actor.print(BBC.getPrefix() + "Searching for items: " + query);
actor.print("Searching for items: " + query);
}
int found = 0;
for (ItemType searchType : ItemType.REGISTRY) {
if (found >= 15) {
actor.print(BBC.getPrefix() + "Too many results!");
actor.print("Too many results!");
break;
}
@ -363,7 +363,7 @@ public class OptionsCommands {
for (String alias : Sets.newHashSet(searchType.getId(), searchType.getName())) {
if (alias.contains(query)) {
actor.print(BBC.getPrefix() + searchType.getId() + " (" + searchType.getName() + ")");
actor.print(searchType.getId() + " (" + searchType.getName() + ")");
++found;
break;
}
@ -371,7 +371,7 @@ public class OptionsCommands {
}
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.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.exception.FaweException;
@ -115,14 +114,14 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.fix")
public void fixlighting(Player player) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation();
final Location loc = player.getLocation();
Region selection = fp.getSelection();
if (selection == null) {
final int cx = loc.x >> 4;
final int cz = loc.z >> 4;
final int cx = loc.getBlockX() >> 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));
}
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);
}
@ -135,9 +134,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.fix")
public void getlighting(Player player) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation();
final Location loc = player.getLocation();
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(
@ -149,14 +148,13 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.remove")
public void removelighting(Player player) {
FawePlayer fp = FawePlayer.wrap(player);
final FaweLocation loc = fp.getLocation();
Region selection = fp.getSelection();
if (selection == null) {
final int cx = loc.x >> 4;
final int cz = loc.z >> 4;
final int cx = player.getLocation().getBlockX() >> 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));
}
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);
}
@ -188,12 +186,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.set")
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
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);
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;
for (BlockVector2 chunk : region.getChunks()) {
@ -212,12 +207,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.light.set")
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
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);
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;
for (BlockVector2 chunk : region.getChunks()) {
@ -676,7 +668,7 @@ public class RegionCommands extends MethodCommands {
if (unit.getY() == 0) unit = unit.withY(1.0);
if (unit.getZ() == 0) unit = unit.withZ(1.0);
}
final Vector3 unit1 = unit;
fp.checkConfirmationRegion(() -> {
try {
@ -722,10 +714,10 @@ public class RegionCommands extends MethodCommands {
BBC.COMMAND_REGEN_2.send(player);
} else if (biome == null) {
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) {
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 {
BBC.COMMAND_REGEN_2.send(player);
}

View File

@ -302,7 +302,7 @@ public class SelectionCommands {
)
@CommandPermissions("worldedit.wand.toggle")
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
session.setToolControl(!session.isToolControlEnabled());
if (session.isToolControlEnabled()) {
@ -621,17 +621,17 @@ public class SelectionCommands {
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);
player.print(BBC.getPrefix() + msg);
player.print(msg);
index++;
}
// player.print(BBC.getPrefix() + "Cuboid dimensions (max - min): " + size);
// player.print(BBC.getPrefix() + "Offset: " + origin);
// player.print(BBC.getPrefix() + "Cuboid distance: " + size.distance(Vector.ONE));
// player.print(BBC.getPrefix() + "# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
// player.print("Cuboid dimensions (max - min): " + size);
// player.print("Offset: " + origin);
// player.print("Cuboid distance: " + size.distance(Vector.ONE));
// player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
//=======
// public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
// if (args.hasFlag('c')) {
@ -653,17 +653,17 @@ public class SelectionCommands {
.subtract(region.getMinimumPoint())
.add(1, 1, 1);
player.print(BBC.getPrefix() + "Type: " + session.getRegionSelector(player.getWorld())
player.print("Type: " + session.getRegionSelector(player.getWorld())
.getTypeName());
for (String line : session.getRegionSelector(player.getWorld())
.getInformationLines()) {
player.print(BBC.getPrefix() + line);
player.print(line);
}
player.print(BBC.getPrefix() + "Size: " + size);
player.print(BBC.getPrefix() + "Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print(BBC.getPrefix() + "# of blocks: " + region.getArea());
player.print("Size: " + size);
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print("# of blocks: " + region.getArea());
}
@ -713,7 +713,7 @@ public class SelectionCommands {
size = session.getSelection(player.getWorld()).getArea();
if (distributionData.size() <= 0) {
player.printError(BBC.getPrefix() + "No blocks counted.");
player.printError("No blocks counted.");
return;
}
BBC.SELECTION_DISTR.send(player, size);
@ -724,7 +724,7 @@ public class SelectionCommands {
String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100,
name);
player.print(BBC.getPrefix() + str);
player.print(str);
}
}
@ -751,37 +751,37 @@ public class SelectionCommands {
final RegionSelector selector;
if (typeName.equalsIgnoreCase("cuboid")) {
selector = new CuboidRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_CUBOID.s());
player.print(BBC.SEL_CUBOID.s());
} else if (typeName.equalsIgnoreCase("extend")) {
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")) {
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();
limit.ifPresent(integer -> player.print(BBC.getPrefix() + BBC.SEL_MAX.f(integer)));
player.print(BBC.getPrefix() + BBC.SEL_LIST.s());
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
player.print(BBC.SEL_LIST.s());
} else if (typeName.equalsIgnoreCase("ellipsoid")) {
selector = new EllipsoidRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_ELLIPSIOD.s());
player.print(BBC.SEL_ELLIPSIOD.s());
} else if (typeName.equalsIgnoreCase("sphere")) {
selector = new SphereRegionSelector(oldSelector);
player.print(BBC.getPrefix() + BBC.SEL_SPHERE.s());
player.print(BBC.SEL_SPHERE.s());
} else if (typeName.equalsIgnoreCase("cyl")) {
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")) {
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();
limit.ifPresent(integer -> player.print(BBC.getPrefix() + BBC.SEL_MAX.f(integer)));
player.print(BBC.getPrefix() + BBC.SEL_LIST.s());
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
player.print(BBC.SEL_LIST.s());
} else if (typeName.equalsIgnoreCase("polyhedral") || typeName.equalsIgnoreCase("polyhedron")) {
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();
limit.ifPresent(integer -> player.print(BBC.getPrefix() + BBC.SEL_MAX.f(integer)));
player.print(BBC.getPrefix() + BBC.SEL_LIST.s());
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
player.print(BBC.SEL_LIST.s());
} else if (typeName.startsWith("fuzzy") || typeName.startsWith("magic")) {
Mask mask;
if (typeName.length() > 6) {
@ -795,13 +795,13 @@ public class SelectionCommands {
mask = new IdMask(editSession);
}
selector = new FuzzyRegionSelector(player, editSession, mask);
player.print(BBC.getPrefix() + BBC.SEL_FUZZY.f());
player.print(BBC.getPrefix() + BBC.SEL_LIST.f());
player.print(BBC.SEL_FUZZY.f());
player.print(BBC.SEL_LIST.f());
} else {
CommandListBox box = new CommandListBox("Selection modes");
StyledFragment contents = box.getContents();
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 extend", "Fast cuboid selection mode");
@ -839,4 +839,4 @@ public class SelectionCommands {
}
}
}

View File

@ -8,6 +8,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -29,7 +30,7 @@ public class AreaPickaxe implements BlockTool {
}
@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 oy = clicked.getBlockY();
int oz = clicked.getBlockZ();
@ -63,4 +64,4 @@ public class AreaPickaxe implements BlockTool {
}
return true;
}
}
}