mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Cleanup and a few bugfixes
This commit is contained in:
parent
a2e23fedf7
commit
b5b55a2775
@ -41,14 +41,17 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
Player player = server.getPlayer(name);
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return false; // Permissions are only registered for online players
|
||||
if ( player.hasPermission("*") || player.hasPermission(permission))
|
||||
}
|
||||
if ( player.hasPermission("*") || player.hasPermission(permission)) {
|
||||
return true;
|
||||
}
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
while (dotPos > -1) {
|
||||
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*"))
|
||||
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) {
|
||||
return true;
|
||||
}
|
||||
dotPos = permission.lastIndexOf(".", dotPos - 1);
|
||||
}
|
||||
return false;
|
||||
@ -60,22 +63,25 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
public boolean inGroup(String name, String group) {
|
||||
Player player = server.getPlayer(name);
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return player.hasPermission(GROUP_PREFIX + group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String name) {
|
||||
Player player = server.getPlayer(name);
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return new String[0];
|
||||
}
|
||||
List<String> groupNames = new ArrayList<String>();
|
||||
for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) {
|
||||
String perm = permAttach.getPermission();
|
||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue()))
|
||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
|
||||
continue;
|
||||
}
|
||||
groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length()));
|
||||
}
|
||||
return groupNames.toArray(new String[0]);
|
||||
return groupNames.toArray(new String[groupNames.size()]);
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,9 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
if (plugin == null) {
|
||||
throw new MissingPluginException();
|
||||
}
|
||||
if (!checkRealNijiPerms(ignoreBridges))
|
||||
if (!checkRealNijiPerms(ignoreBridges)) {
|
||||
throw new MissingPluginException();
|
||||
}
|
||||
|
||||
try {
|
||||
api = (Permissions)plugin;
|
||||
@ -129,11 +130,13 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public static boolean checkRealNijiPerms(boolean ignoreBridges) {
|
||||
if (!ignoreBridges)
|
||||
if (!ignoreBridges) {
|
||||
return true;
|
||||
}
|
||||
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
|
||||
if (permsCommand == null)
|
||||
if (permsCommand == null) {
|
||||
return false;
|
||||
}
|
||||
return permsCommand.getPlugin().getDescription().getName().equals("Permissions");
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,10 @@ public class PermissionsExResolver implements PermissionsResolver {
|
||||
public PermissionsExResolver(Server server) throws MissingPluginException {
|
||||
this.server = server;
|
||||
manager = server.getServicesManager().load(PermissionManager.class);
|
||||
if (manager == null)
|
||||
if (manager == null) {
|
||||
throw new MissingPluginException();
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
|
@ -76,6 +76,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
loadConfig(new File("wepif.yml"));
|
||||
findResolver();
|
||||
}
|
||||
|
||||
public void findResolver() {
|
||||
if (tryPluginPermissionsResolver()) return;
|
||||
if (tryNijiPermissions()) return;
|
||||
@ -132,8 +133,9 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
private boolean tryDinnerPerms() {
|
||||
if (!permsConfig.getBoolean("dinnerperms", true))
|
||||
if (!permsConfig.getBoolean("dinnerperms", true)) {
|
||||
return false;
|
||||
}
|
||||
perms = new DinnerPermsResolver(server);
|
||||
logger.info(name + ": Using the Bukkit Permissions API.");
|
||||
return true;
|
||||
|
@ -133,8 +133,9 @@ public class CommandContext {
|
||||
throw new CommandException("Value flag '" + flagName + "' already given");
|
||||
}
|
||||
|
||||
if (nextArg >= argList.size())
|
||||
if (nextArg >= argList.size()) {
|
||||
throw new CommandException("No value specified for the '-"+flagName+"' flag.");
|
||||
}
|
||||
|
||||
// If it is a value flag, read another argument and add it
|
||||
this.valueFlags.put(flagName, argList.get(nextArg++));
|
||||
@ -217,8 +218,9 @@ public class CommandContext {
|
||||
|
||||
public String getFlag(char ch, String def) {
|
||||
final String value = valueFlags.get(ch);
|
||||
if (value == null)
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@ -229,8 +231,9 @@ public class CommandContext {
|
||||
|
||||
public int getFlagInteger(char ch, int def) throws NumberFormatException {
|
||||
final String value = valueFlags.get(ch);
|
||||
if (value == null)
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
@ -241,8 +244,9 @@ public class CommandContext {
|
||||
|
||||
public double getFlagDouble(char ch, double def) throws NumberFormatException {
|
||||
final String value = valueFlags.get(ch);
|
||||
if (value == null)
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return Double.parseDouble(value);
|
||||
}
|
||||
|
@ -422,7 +422,8 @@ public abstract class CommandsManager<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public void invokeMethod(Method parent, String[] args, T player, Method method, Object instance, Object[] methodArgs, int level) throws CommandException {
|
||||
public void invokeMethod(Method parent, String[] args, T player, Method method,
|
||||
Object instance, Object[] methodArgs, int level) throws CommandException {
|
||||
try {
|
||||
method.invoke(instance, methodArgs);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -2386,6 +2386,7 @@ public class EditSession {
|
||||
setBlockIfAir(pos.add(-1, h, -1), log);
|
||||
}
|
||||
setBlockIfAir(pos.add(-1, 0, -1), pumpkin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,9 @@ public class HeightMap {
|
||||
int[] newData = new int[data.length];
|
||||
System.arraycopy(data, 0, newData, 0, data.length);
|
||||
|
||||
for (int i = 0; i < iterations; ++i)
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
newData = filter.filter(newData, width, height);
|
||||
}
|
||||
|
||||
return apply(newData);
|
||||
}
|
||||
|
@ -240,8 +240,7 @@ public abstract class LocalPlayer {
|
||||
// Found a ceiling!
|
||||
if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||
world.setBlockType(new Vector(x, platformY, z),
|
||||
BlockID.GLASS);
|
||||
world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS);
|
||||
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
|
||||
return true;
|
||||
}
|
||||
@ -273,8 +272,7 @@ public abstract class LocalPlayer {
|
||||
} else if (y > maxY + 1) {
|
||||
break;
|
||||
} else if (y == maxY + 1) {
|
||||
world.setBlockType(new Vector(x, y - 2, z),
|
||||
BlockID.GLASS);
|
||||
world.setBlockType(new Vector(x, y - 2, z), BlockID.GLASS);
|
||||
setPosition(new Vector(x + 0.5, y - 1, z + 0.5));
|
||||
return true;
|
||||
}
|
||||
@ -351,10 +349,12 @@ public abstract class LocalPlayer {
|
||||
* @return
|
||||
*/
|
||||
public PlayerDirection getCardinalDirection() {
|
||||
if (getPitch() > 67.5)
|
||||
if (getPitch() > 67.5) {
|
||||
return PlayerDirection.DOWN;
|
||||
if (getPitch() < -67.5)
|
||||
}
|
||||
if (getPitch() < -67.5) {
|
||||
return PlayerDirection.UP;
|
||||
}
|
||||
|
||||
// From hey0's code
|
||||
double rot = (getYaw() - 90) % 360;
|
||||
|
@ -36,7 +36,6 @@ import com.sk89q.worldedit.tools.Tool;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.cui.CUIPointBasedRegion;
|
||||
import com.sk89q.worldedit.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
||||
@ -66,8 +65,7 @@ public class LocalSession {
|
||||
private boolean toolControl = true;
|
||||
private boolean superPickaxe = false;
|
||||
private BlockTool pickaxeMode = new SinglePickaxe();
|
||||
private Map<Integer, Tool> tools
|
||||
= new HashMap<Integer, Tool>();
|
||||
private Map<Integer, Tool> tools = new HashMap<Integer, Tool>();
|
||||
private int maxBlocksChanged = -1;
|
||||
private boolean useInventory;
|
||||
private Snapshot snapshot;
|
||||
@ -122,7 +120,7 @@ public class LocalSession {
|
||||
*/
|
||||
public void remember(EditSession editSession) {
|
||||
// Don't store anything if no changes were made
|
||||
if (editSession.size() == 0) { return; }
|
||||
if (editSession.size() == 0) return;
|
||||
|
||||
// Destroy any sessions after this undo point
|
||||
while (historyPointer < history.size()) {
|
||||
@ -480,10 +478,6 @@ public class LocalSession {
|
||||
public void setTool(int item, Tool tool) throws InvalidToolBindException {
|
||||
if (item > 0 && item < 255) {
|
||||
throw new InvalidToolBindException(item, "Blocks can't be used");
|
||||
/* } else if (item == ItemType.COAL.getID() || item == ItemType.LIGHTSTONE_DUST.getID()) {
|
||||
throw new InvalidToolBindException(item, "Item is not usuable");
|
||||
// let people deal with craftbook themselves, not everyone uses it
|
||||
*/
|
||||
} else if (item == config.wandItem) {
|
||||
throw new InvalidToolBindException(item, "Already used for the wand");
|
||||
} else if (item == config.navigationWand) {
|
||||
@ -562,10 +556,6 @@ public class LocalSession {
|
||||
* @param player
|
||||
*/
|
||||
public void dispatchCUISetup(LocalPlayer player) {
|
||||
if (!hasCUISupport) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selector != null) {
|
||||
dispatchCUISelection(player);
|
||||
}
|
||||
@ -581,8 +571,7 @@ public class LocalSession {
|
||||
return;
|
||||
}
|
||||
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionShapeEvent(selector.getTypeId()));
|
||||
player.dispatchCUIEvent(new SelectionShapeEvent(selector.getTypeId()));
|
||||
|
||||
if (selector instanceof CUIPointBasedRegion) {
|
||||
((CUIPointBasedRegion) selector).describeCUI(player);
|
||||
|
@ -206,8 +206,8 @@ public abstract class LocalWorld {
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public abstract boolean generateRedwoodTree(EditSession editSession,
|
||||
Vector pt) throws MaxChangedBlocksException;
|
||||
public abstract boolean generateRedwoodTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
|
||||
/**
|
||||
* Generate a tall redwood tree at a location.
|
||||
@ -217,8 +217,8 @@ public abstract class LocalWorld {
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public abstract boolean generateTallRedwoodTree(EditSession editSession,
|
||||
Vector pt) throws MaxChangedBlocksException;
|
||||
public abstract boolean generateTallRedwoodTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
|
||||
/**
|
||||
* Drop an item.
|
||||
|
@ -79,8 +79,7 @@ public class WorldEdit {
|
||||
* without any WorldEdit abilities or never use WorldEdit in a session will
|
||||
* not have a session object generated for them.
|
||||
*/
|
||||
private HashMap<String,LocalSession> sessions =
|
||||
new HashMap<String,LocalSession>();
|
||||
private HashMap<String,LocalSession> sessions = new HashMap<String,LocalSession>();
|
||||
|
||||
/**
|
||||
* Initialize statically.
|
||||
@ -113,13 +112,14 @@ public class WorldEdit {
|
||||
final Logging loggingAnnotation = method.getAnnotation(Logging.class);
|
||||
|
||||
final Logging.LogMode logMode;
|
||||
if (loggingAnnotation == null)
|
||||
if (loggingAnnotation == null) {
|
||||
logMode = null;
|
||||
else
|
||||
} else {
|
||||
logMode = loggingAnnotation.value();
|
||||
}
|
||||
|
||||
String msg = "WorldEdit: " + player.getName() + "(in " + player.getWorld().getName() + ")"
|
||||
+ ": " + StringUtil.joinString(args, " ");
|
||||
String msg = "WorldEdit: " + player.getName() + " (in \"" + player.getWorld().getName()
|
||||
+ "\")" + ": " + StringUtil.joinString(args, " ");
|
||||
if (logMode != null) {
|
||||
Vector position = player.getPosition();
|
||||
final LocalSession session = getSession(player);
|
||||
@ -690,8 +690,7 @@ public class WorldEdit {
|
||||
}
|
||||
|
||||
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
|
||||
throw new InvalidFilenameException(filename,
|
||||
"Invalid characters or extension missing");
|
||||
throw new InvalidFilenameException(filename, "Invalid characters or extension missing");
|
||||
}
|
||||
|
||||
f = new File(dir, filename);
|
||||
@ -1044,6 +1043,7 @@ public class WorldEdit {
|
||||
&& player.hasPermission("worldedit.navigation.jumpto")) {
|
||||
// Bug workaround
|
||||
// Blocks this from being used after the thru function
|
||||
// @TODO do this right or make craftbukkit do it right
|
||||
if (!session.canUseJumpto()){
|
||||
session.toggleJumptoBlock();
|
||||
return false;
|
||||
@ -1085,8 +1085,9 @@ public class WorldEdit {
|
||||
}
|
||||
// Bug workaround, so it wont do the Jumpto compass function
|
||||
// Right after this teleport
|
||||
if (session.canUseJumpto())
|
||||
if (session.canUseJumpto()) {
|
||||
session.toggleJumptoBlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ public class BukkitUtil {
|
||||
}
|
||||
|
||||
private static final Map<World,LocalWorld> wlw = new HashMap<World,LocalWorld>();
|
||||
|
||||
public static LocalWorld getLocalWorld(World w) {
|
||||
LocalWorld lw = wlw.get(w);
|
||||
if (lw == null) {
|
||||
|
@ -159,7 +159,10 @@ public class ChunkCommands {
|
||||
player.printError("Error occurred: " + e.getMessage());
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try { out.close(); } catch (IOException ie) {}
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ie) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -45,14 +45,19 @@ public class ScriptingCommands {
|
||||
public static void execute(CommandContext args, WorldEdit we,
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
// @TODO: Check for worldedit.scripting.execute.<script> permission
|
||||
|
||||
String[] scriptArgs = args.getSlice(1);
|
||||
String name = args.getString(0);
|
||||
|
||||
session.setLastScript(args.getString(0));
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
return;
|
||||
}
|
||||
|
||||
session.setLastScript(name);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, args.getString(0), "js",
|
||||
File f = we.getSafeOpenFile(player, dir, name, "js",
|
||||
new String[] {"js"});
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
@ -70,10 +75,14 @@ public class ScriptingCommands {
|
||||
public static void executeLast(CommandContext args, WorldEdit we,
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
// @TODO: Check for worldedit.scripting.execute.<script> permission
|
||||
|
||||
String lastScript = session.getLastScript();
|
||||
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastScript == null) {
|
||||
player.printError("Use /cs with a script name first.");
|
||||
return;
|
||||
|
@ -350,16 +350,14 @@ public class SelectionCommands {
|
||||
reverseChange = args.getInteger(1) * -1;
|
||||
dir = we.getDirection(player, "me");
|
||||
} catch (NumberFormatException e) {
|
||||
dir = we.getDirection(player,
|
||||
args.getString(1).toLowerCase());
|
||||
dir = we.getDirection(player, args.getString(1).toLowerCase());
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Both reverse amount and direction
|
||||
reverseChange = args.getInteger(1) * -1;
|
||||
dir = we.getDirection(player,
|
||||
args.getString(2).toLowerCase());
|
||||
dir = we.getDirection(player, args.getString(2).toLowerCase());
|
||||
break;
|
||||
default:
|
||||
dir = we.getDirection(player, "me");
|
||||
@ -398,8 +396,7 @@ public class SelectionCommands {
|
||||
|
||||
int change = args.getInteger(0);
|
||||
if (args.argsLength() == 2) {
|
||||
dir = we.getDirection(player,
|
||||
args.getString(1).toLowerCase());
|
||||
dir = we.getDirection(player, args.getString(1).toLowerCase());
|
||||
} else {
|
||||
dir = we.getDirection(player, "me");
|
||||
}
|
||||
|
@ -197,8 +197,7 @@ public class UtilityCommands {
|
||||
we.checkMaxRadius(size);
|
||||
int height = args.argsLength() > 1 ? Math.min(128, args.getInteger(1) + 2) : 128;
|
||||
|
||||
int affected = editSession.removeBelow(
|
||||
session.getPlacementPosition(player), size, height);
|
||||
int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
|
||||
player.print(affected + " block(s) have been removed.");
|
||||
}
|
||||
|
||||
@ -219,8 +218,7 @@ public class UtilityCommands {
|
||||
int size = Math.max(1, args.getInteger(1, 50));
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.removeNear(
|
||||
session.getPlacementPosition(player), block.getType(), size);
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getType(), size);
|
||||
player.print(affected + " block(s) have been removed.");
|
||||
}
|
||||
|
||||
@ -340,8 +338,7 @@ public class UtilityCommands {
|
||||
: defaultRadius;
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.removeNear(
|
||||
session.getPlacementPosition(player), 51, size);
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size);
|
||||
player.print(affected + " block(s) have been removed.");
|
||||
}
|
||||
|
||||
@ -359,8 +356,7 @@ public class UtilityCommands {
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
|
||||
int radius = args.argsLength() > 0 ?
|
||||
Math.max(1, args.getInteger(0)) : -1;
|
||||
int radius = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : -1;
|
||||
|
||||
Vector origin = session.getPlacementPosition(player);
|
||||
int killed = player.getWorld().killMobs(origin, radius, args.hasFlag('p'));
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.cui;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public interface CUIPointBasedRegion {
|
||||
public void describeCUI(LocalPlayer player);
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.cui;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public class SelectionMinMaxEvent implements CUIEvent {
|
||||
|
||||
protected int min;
|
||||
|
@ -151,6 +151,7 @@ public final class BlockData {
|
||||
case 2: return 0 | open;
|
||||
case 3: return 1 | open;
|
||||
}
|
||||
break;
|
||||
|
||||
case BlockID.PISTON_BASE:
|
||||
case BlockID.PISTON_STICKY_BASE:
|
||||
@ -162,12 +163,11 @@ public final class BlockData {
|
||||
case 4: return 2 | rest;
|
||||
case 5: return 3 | rest;
|
||||
}
|
||||
break;
|
||||
|
||||
case BlockID.BROWN_MUSHROOM_CAP:
|
||||
case BlockID.RED_MUSHROOM_CAP:
|
||||
if (data >= 10)
|
||||
return data;
|
||||
|
||||
if (data >= 10) return data;
|
||||
return (data * 3) % 10;
|
||||
|
||||
case BlockID.VINE:
|
||||
@ -317,12 +317,11 @@ public final class BlockData {
|
||||
case 2: return 4 | rest;
|
||||
case 3: return 5 | rest;
|
||||
}
|
||||
break;
|
||||
|
||||
case BlockID.BROWN_MUSHROOM_CAP:
|
||||
case BlockID.RED_MUSHROOM_CAP:
|
||||
if (data >= 10)
|
||||
return data;
|
||||
|
||||
if (data >= 10) return data;
|
||||
return (data * 7) % 10;
|
||||
|
||||
case BlockID.VINE:
|
||||
@ -363,11 +362,9 @@ public final class BlockData {
|
||||
case NORTH_SOUTH:
|
||||
flipX = 1;
|
||||
break;
|
||||
|
||||
case WEST_EAST:
|
||||
flipZ = 1;
|
||||
break;
|
||||
|
||||
case UP_DOWN:
|
||||
flipY = 1;
|
||||
break;
|
||||
@ -389,10 +386,10 @@ public final class BlockData {
|
||||
|
||||
case BlockID.MINECART_TRACKS:
|
||||
switch (data) {
|
||||
case 6: return data + flipX + 3*flipZ;
|
||||
case 6: return data + flipX + flipZ * 3;
|
||||
case 7: return data - flipX + flipZ;
|
||||
case 8: return data + flipX - flipZ;
|
||||
case 9: return data - flipX - 3*flipZ;
|
||||
case 9: return data - flipX - flipZ * 3;
|
||||
}
|
||||
/* FALL-THROUGH */
|
||||
|
||||
@ -402,15 +399,12 @@ public final class BlockData {
|
||||
case 0:
|
||||
case 1:
|
||||
return data;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return data ^ flipX;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
return data ^ flipZ;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@ -422,7 +416,6 @@ public final class BlockData {
|
||||
case 0:
|
||||
case 1:
|
||||
return data ^ flipX;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return data ^ flipZ;
|
||||
@ -433,10 +426,10 @@ public final class BlockData {
|
||||
case BlockID.IRON_DOOR:
|
||||
data ^= flipY << 3;
|
||||
switch (data & 0x3) {
|
||||
case 0: return data + flipX + 3*flipZ;
|
||||
case 0: return data + flipX + flipZ * 3;
|
||||
case 1: return data - flipX + flipZ;
|
||||
case 2: return data + flipX - flipZ;
|
||||
case 3: return data - flipX - 3*flipZ;
|
||||
case 3: return data - flipX - flipZ * 3;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -444,7 +437,6 @@ public final class BlockData {
|
||||
switch (direction) {
|
||||
case NORTH_SOUTH:
|
||||
return (16 - data) & 0xf;
|
||||
|
||||
case WEST_EAST:
|
||||
return (8 - data) & 0xf;
|
||||
}
|
||||
@ -459,7 +451,6 @@ public final class BlockData {
|
||||
case 2:
|
||||
case 3:
|
||||
return data ^ flipZ;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
return data ^ flipX;
|
||||
@ -474,7 +465,6 @@ public final class BlockData {
|
||||
case 0:
|
||||
case 2:
|
||||
return data ^ (flipZ << 1);
|
||||
|
||||
case 1:
|
||||
case 3:
|
||||
return data ^ (flipX << 1);
|
||||
@ -486,7 +476,6 @@ public final class BlockData {
|
||||
case 0:
|
||||
case 1:
|
||||
return data ^ flipZ;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return data ^ flipX;
|
||||
@ -500,11 +489,9 @@ public final class BlockData {
|
||||
case 0:
|
||||
case 1:
|
||||
return data ^ flipY;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return data ^ flipZ;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
return data ^ flipX;
|
||||
@ -519,28 +506,22 @@ public final class BlockData {
|
||||
case 7:
|
||||
data += 2 * flipX;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
data -= 2 * flipX;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (data) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
data += 6*flipZ;
|
||||
break;
|
||||
|
||||
return data + 6 * flipZ;
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
data -= 6*flipZ;
|
||||
break;
|
||||
return data - 6 * flipZ;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case BlockID.VINE:
|
||||
@ -550,12 +531,10 @@ public final class BlockData {
|
||||
bit1 = 0x2;
|
||||
bit2 = 0x8;
|
||||
break;
|
||||
|
||||
case WEST_EAST:
|
||||
bit1 = 0x1;
|
||||
bit2 = 0x4;
|
||||
break;
|
||||
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
@ -570,7 +549,6 @@ public final class BlockData {
|
||||
case 0:
|
||||
case 2:
|
||||
return data ^ 2 * flipZ;
|
||||
|
||||
case 1:
|
||||
case 3:
|
||||
return data ^ 2 * flipX;
|
||||
|
@ -66,8 +66,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
|
||||
player.print("First position set to " + pos1 + ".");
|
||||
}
|
||||
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(0, pos, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
|
||||
}
|
||||
|
||||
public void explainSecondarySelection(LocalPlayer player,
|
||||
@ -79,18 +78,15 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
|
||||
player.print("Second position set to " + pos2 + ".");
|
||||
}
|
||||
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(1, pos, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
|
||||
}
|
||||
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
if (pos1 != null) {
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(0, pos1, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
|
||||
}
|
||||
if (pos2 != null) {
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPointEvent(1, pos2, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos2, getArea()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,12 +147,12 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
|
||||
}
|
||||
|
||||
public void describeCUI(LocalPlayer player) {
|
||||
if (pos1 != null)
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPointEvent(0, pos1, getArea()));
|
||||
if (pos2 != null)
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPointEvent(1, pos2, getArea()));
|
||||
if (pos1 != null) {
|
||||
player.dispatchCUIEvent(new SelectionPointEvent(0, pos1, getArea()));
|
||||
}
|
||||
if (pos2 != null) {
|
||||
player.dispatchCUIEvent(new SelectionPointEvent(1, pos2, getArea()));
|
||||
}
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
|
@ -30,7 +30,6 @@ import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.cui.CUIPointBasedRegion;
|
||||
import com.sk89q.worldedit.cui.SelectionMinMaxEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionPoint2DEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionShapeEvent;
|
||||
|
||||
/**
|
||||
@ -83,15 +82,12 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
|
||||
public void explainSecondarySelection(LocalPlayer player,
|
||||
LocalSession session, Vector pos) {
|
||||
player.print("Added point #" + region.size() + " at " + pos + ".");
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
@ -153,11 +149,9 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
|
||||
public void describeCUI(LocalPlayer player) {
|
||||
List<BlockVector2D> points = region.getPoints();
|
||||
for (int id = 0; id < points.size(); id++) {
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPoint2DEvent(id, points.get(id), getArea()));
|
||||
player.dispatchCUIEvent(new SelectionPoint2DEvent(id, points.get(id), getArea()));
|
||||
}
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
player.dispatchCUIEvent(new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ public class ClipboardBrush implements Brush {
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||
throws MaxChangedBlocksException {
|
||||
clipboard.place(editSession,
|
||||
pos.subtract(clipboard.getSize().divide(2)), noAir);
|
||||
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user