3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-14 15:10:05 +01:00

Dropped WorldEdit prefix from session and player classes; changed them to "Local".

Dieser Commit ist enthalten in:
sk89q 2011-01-01 10:34:36 -08:00
Ursprung ac4e6e8ddf
Commit d534432a2f
5 geänderte Dateien mit 66 neuen und 66 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,7 @@
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface; import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditPlayer; import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.WorldVector; import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
@ -29,7 +29,7 @@ import com.sk89q.worldedit.blocks.BlockType;
* *
* @author sk89q * @author sk89q
*/ */
public class HMPlayer extends WorldEditPlayer { public class HMPlayer extends LocalPlayer {
/** /**
* Stores the player. * Stores the player.
*/ */

Datei anzeigen

@ -224,11 +224,11 @@ public class HMWorldEditListener extends PluginListener {
* @param player * @param player
* @return * @return
*/ */
public WorldEditSession _bridgeSession(Player player) { public LocalSession _bridgeSession(Player player) {
return controller.getBridgeSession(wrapPlayer(player)); return controller.getBridgeSession(wrapPlayer(player));
} }
private WorldEditPlayer wrapPlayer(Player player) { private LocalPlayer wrapPlayer(Player player) {
return new HMPlayer(server, player); return new HMPlayer(server, player);
} }
} }

Datei anzeigen

@ -26,7 +26,7 @@ import com.sk89q.worldedit.blocks.BlockType;
* *
* @author sk89q * @author sk89q
*/ */
public abstract class WorldEditPlayer { public abstract class LocalPlayer {
/** /**
* Directions. * Directions.
*/ */
@ -51,7 +51,7 @@ public abstract class WorldEditPlayer {
* *
* @param server * @param server
*/ */
protected WorldEditPlayer(ServerInterface server) { protected LocalPlayer(ServerInterface server) {
this.server = server; this.server = server;
} }
@ -310,7 +310,7 @@ public abstract class WorldEditPlayer {
* *
* @return * @return
*/ */
public WorldEditPlayer.DIRECTION getCardinalDirection() { public LocalPlayer.DIRECTION getCardinalDirection() {
// From hey0's code // From hey0's code
double rot = (getYaw() - 90) % 360; double rot = (getYaw() - 90) % 360;
if (rot < 0) { if (rot < 0) {
@ -325,25 +325,25 @@ public abstract class WorldEditPlayer {
* @param rot * @param rot
* @return * @return
*/ */
private static WorldEditPlayer.DIRECTION getDirection(double rot) { private static LocalPlayer.DIRECTION getDirection(double rot) {
if (0 <= rot && rot < 22.5) { if (0 <= rot && rot < 22.5) {
return WorldEditPlayer.DIRECTION.NORTH; return LocalPlayer.DIRECTION.NORTH;
} else if (22.5 <= rot && rot < 67.5) { } else if (22.5 <= rot && rot < 67.5) {
return WorldEditPlayer.DIRECTION.NORTH_EAST; return LocalPlayer.DIRECTION.NORTH_EAST;
} else if (67.5 <= rot && rot < 112.5) { } else if (67.5 <= rot && rot < 112.5) {
return WorldEditPlayer.DIRECTION.EAST; return LocalPlayer.DIRECTION.EAST;
} else if (112.5 <= rot && rot < 157.5) { } else if (112.5 <= rot && rot < 157.5) {
return WorldEditPlayer.DIRECTION.SOUTH_EAST; return LocalPlayer.DIRECTION.SOUTH_EAST;
} else if (157.5 <= rot && rot < 202.5) { } else if (157.5 <= rot && rot < 202.5) {
return WorldEditPlayer.DIRECTION.SOUTH; return LocalPlayer.DIRECTION.SOUTH;
} else if (202.5 <= rot && rot < 247.5) { } else if (202.5 <= rot && rot < 247.5) {
return WorldEditPlayer.DIRECTION.SOUTH_WEST; return LocalPlayer.DIRECTION.SOUTH_WEST;
} else if (247.5 <= rot && rot < 292.5) { } else if (247.5 <= rot && rot < 292.5) {
return WorldEditPlayer.DIRECTION.WEST; return LocalPlayer.DIRECTION.WEST;
} else if (292.5 <= rot && rot < 337.5) { } else if (292.5 <= rot && rot < 337.5) {
return WorldEditPlayer.DIRECTION.NORTH_WEST; return LocalPlayer.DIRECTION.NORTH_WEST;
} else if (337.5 <= rot && rot < 360.0) { } else if (337.5 <= rot && rot < 360.0) {
return WorldEditPlayer.DIRECTION.NORTH; return LocalPlayer.DIRECTION.NORTH;
} else { } else {
return null; return null;
} }
@ -486,10 +486,10 @@ public abstract class WorldEditPlayer {
*/ */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (!(other instanceof WorldEditPlayer)) { if (!(other instanceof LocalPlayer)) {
return false; return false;
} }
WorldEditPlayer other2 = (WorldEditPlayer)other; LocalPlayer other2 = (LocalPlayer)other;
return other2.getName().equals(getName()); return other2.getName().equals(getName());
} }

Datei anzeigen

@ -29,7 +29,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
* *
* @author sk89q * @author sk89q
*/ */
public class WorldEditSession { public class LocalSession {
/** /**
* List of super pick axe modes. * List of super pick axe modes.
*/ */
@ -326,7 +326,7 @@ public class WorldEditSession {
* @return position * @return position
* @throws IncompleteRegionException * @throws IncompleteRegionException
*/ */
public Vector getPlacementPosition(WorldEditPlayer player) public Vector getPlacementPosition(LocalPlayer player)
throws IncompleteRegionException { throws IncompleteRegionException {
if (!placeAtPos1) { if (!placeAtPos1) {
return player.getBlockIn(); return player.getBlockIn();
@ -350,7 +350,7 @@ public class WorldEditSession {
* @param player * @param player
* @return * @return
*/ */
public BlockBag getBlockBag(WorldEditPlayer player) { public BlockBag getBlockBag(LocalPlayer player) {
if (!useInventory) { if (!useInventory) {
return null; return null;
} }

Datei anzeigen

@ -67,8 +67,8 @@ public class WorldEditController {
* without any WorldEdit abilities or never use WorldEdit in a session will * without any WorldEdit abilities or never use WorldEdit in a session will
* not have a session object generated for them. * not have a session object generated for them.
*/ */
private HashMap<WorldEditPlayer,WorldEditSession> sessions = private HashMap<LocalPlayer,LocalSession> sessions =
new HashMap<WorldEditPlayer,WorldEditSession>(); new HashMap<LocalPlayer,LocalSession>();
/** /**
* List of commands. These are checked when onCommand() is called, so * List of commands. These are checked when onCommand() is called, so
@ -184,11 +184,11 @@ public class WorldEditController {
* @param player * @param player
* @return * @return
*/ */
public WorldEditSession getSession(WorldEditPlayer player) { public LocalSession getSession(LocalPlayer player) {
if (sessions.containsKey(player)) { if (sessions.containsKey(player)) {
return sessions.get(player); return sessions.get(player);
} else { } else {
WorldEditSession session = new WorldEditSession(); LocalSession session = new LocalSession();
if (!player.hasPermission("/worldeditnomax") if (!player.hasPermission("/worldeditnomax")
&& maxChangeLimit > -1) { && maxChangeLimit > -1) {
if (defaultChangeLimit < 0) { if (defaultChangeLimit < 0) {
@ -216,7 +216,7 @@ public class WorldEditController {
* @param player * @param player
* @return * @return
*/ */
public boolean hasSession(WorldEditPlayer player) { public boolean hasSession(LocalPlayer player) {
return sessions.containsKey(player); return sessions.containsKey(player);
} }
@ -405,8 +405,8 @@ public class WorldEditController {
* @throws InsufficientArgumentsException * @throws InsufficientArgumentsException
* @throws DisallowedItemException * @throws DisallowedItemException
*/ */
public boolean performCommand(WorldEditPlayer player, public boolean performCommand(LocalPlayer player,
WorldEditSession session, EditSession editSession, String[] split) LocalSession session, EditSession editSession, String[] split)
throws WorldEditException throws WorldEditException
{ {
if (logComands) { if (logComands) {
@ -622,17 +622,17 @@ public class WorldEditController {
checkArgs(split, 1, 2, split[0]); checkArgs(split, 1, 2, split[0]);
if (split[1].equalsIgnoreCase("single")) { if (split[1].equalsIgnoreCase("single")) {
session.setSuperPickaxeMode(WorldEditSession.SuperPickaxeMode.SINGLE); session.setSuperPickaxeMode(LocalSession.SuperPickaxeMode.SINGLE);
player.print("Mode set to single block."); player.print("Mode set to single block.");
} else if (split[1].equalsIgnoreCase("recursive") } else if (split[1].equalsIgnoreCase("recursive")
|| split[1].equalsIgnoreCase("area")) { || split[1].equalsIgnoreCase("area")) {
if (split.length == 3) { if (split.length == 3) {
int size = Math.max(1, Integer.parseInt(split[2])); int size = Math.max(1, Integer.parseInt(split[2]));
if (size <= maxSuperPickaxeSize) { if (size <= maxSuperPickaxeSize) {
WorldEditSession.SuperPickaxeMode mode = LocalSession.SuperPickaxeMode mode =
split[1].equalsIgnoreCase("recursive") ? split[1].equalsIgnoreCase("recursive") ?
WorldEditSession.SuperPickaxeMode.SAME_TYPE_RECURSIVE : LocalSession.SuperPickaxeMode.SAME_TYPE_RECURSIVE :
WorldEditSession.SuperPickaxeMode.SAME_TYPE_AREA; LocalSession.SuperPickaxeMode.SAME_TYPE_AREA;
session.setSuperPickaxeMode(mode); session.setSuperPickaxeMode(mode);
session.setSuperPickaxeRange(size); session.setSuperPickaxeRange(size);
player.print("Mode set to " + split[1].toLowerCase() + "."); player.print("Mode set to " + split[1].toLowerCase() + ".");
@ -653,21 +653,21 @@ public class WorldEditController {
checkArgs(split, 1, 1, split[0]); checkArgs(split, 1, 1, split[0]);
if (split[1].equalsIgnoreCase("none")) { if (split[1].equalsIgnoreCase("none")) {
session.setTool(WorldEditSession.Tool.NONE); session.setTool(LocalSession.Tool.NONE);
player.print("No tool equipped. -3 XP, +10 Manliness"); player.print("No tool equipped. -3 XP, +10 Manliness");
} else if (split[1].equalsIgnoreCase("tree")) { } else if (split[1].equalsIgnoreCase("tree")) {
if (!canUseCommand(player, "/treetool")) { if (!canUseCommand(player, "/treetool")) {
player.printError("You do not have the /treetool permission."); player.printError("You do not have the /treetool permission.");
return true; return true;
} }
session.setTool(WorldEditSession.Tool.TREE); session.setTool(LocalSession.Tool.TREE);
player.print("Tree planting tool equipped. +5 XP"); player.print("Tree planting tool equipped. +5 XP");
} else if (split[1].equalsIgnoreCase("info")) { } else if (split[1].equalsIgnoreCase("info")) {
if (!canUseCommand(player, "/infotool")) { if (!canUseCommand(player, "/infotool")) {
player.printError("You do not have the /infotool permission."); player.printError("You do not have the /infotool permission.");
return true; return true;
} }
session.setTool(WorldEditSession.Tool.INFO); session.setTool(LocalSession.Tool.INFO);
player.print("Block information tool equipped."); player.print("Block information tool equipped.");
} else { } else {
player.printError("Unknown tool."); player.printError("Unknown tool.");
@ -1591,25 +1591,25 @@ public class WorldEditController {
* @param dir * @param dir
* @return * @return
*/ */
public Vector getDirection(WorldEditPlayer player, String dirStr) public Vector getDirection(LocalPlayer player, String dirStr)
throws UnknownDirectionException { throws UnknownDirectionException {
int xm = 0; int xm = 0;
int ym = 0; int ym = 0;
int zm = 0; int zm = 0;
WorldEditPlayer.DIRECTION dir = null; LocalPlayer.DIRECTION dir = null;
if (dirStr.equals("me")) { if (dirStr.equals("me")) {
dir = player.getCardinalDirection(); dir = player.getCardinalDirection();
} }
if (dirStr.charAt(0) == 'u' || dir == WorldEditPlayer.DIRECTION.WEST) { if (dirStr.charAt(0) == 'u' || dir == LocalPlayer.DIRECTION.WEST) {
zm += 1; zm += 1;
} else if (dirStr.charAt(0) == 'e' || dir == WorldEditPlayer.DIRECTION.EAST) { } else if (dirStr.charAt(0) == 'e' || dir == LocalPlayer.DIRECTION.EAST) {
zm -= 1; zm -= 1;
} else if (dirStr.charAt(0) == 's' || dir == WorldEditPlayer.DIRECTION.SOUTH) { } else if (dirStr.charAt(0) == 's' || dir == LocalPlayer.DIRECTION.SOUTH) {
xm += 1; xm += 1;
} else if (dirStr.charAt(0) == 'n' || dir == WorldEditPlayer.DIRECTION.NORTH) { } else if (dirStr.charAt(0) == 'n' || dir == LocalPlayer.DIRECTION.NORTH) {
xm -= 1; xm -= 1;
} else if (dirStr.charAt(0) == 'u') { } else if (dirStr.charAt(0) == 'u') {
ym += 1; ym += 1;
@ -1631,21 +1631,21 @@ public class WorldEditController {
* @return * @return
*/ */
public CuboidClipboard.FlipDirection getFlipDirection( public CuboidClipboard.FlipDirection getFlipDirection(
WorldEditPlayer player, String dirStr) LocalPlayer player, String dirStr)
throws UnknownDirectionException { throws UnknownDirectionException {
WorldEditPlayer.DIRECTION dir = null; LocalPlayer.DIRECTION dir = null;
if (dirStr.equals("me")) { if (dirStr.equals("me")) {
dir = player.getCardinalDirection(); dir = player.getCardinalDirection();
} }
if (dirStr.charAt(0) == 'w' || dir == WorldEditPlayer.DIRECTION.EAST) { if (dirStr.charAt(0) == 'w' || dir == LocalPlayer.DIRECTION.EAST) {
return CuboidClipboard.FlipDirection.WEST_EAST; return CuboidClipboard.FlipDirection.WEST_EAST;
} else if (dirStr.charAt(0) == 'e' || dir == WorldEditPlayer.DIRECTION.EAST) { } else if (dirStr.charAt(0) == 'e' || dir == LocalPlayer.DIRECTION.EAST) {
return CuboidClipboard.FlipDirection.WEST_EAST; return CuboidClipboard.FlipDirection.WEST_EAST;
} else if (dirStr.charAt(0) == 's' || dir == WorldEditPlayer.DIRECTION.SOUTH) { } else if (dirStr.charAt(0) == 's' || dir == LocalPlayer.DIRECTION.SOUTH) {
return CuboidClipboard.FlipDirection.NORTH_SOUTH; return CuboidClipboard.FlipDirection.NORTH_SOUTH;
} else if (dirStr.charAt(0) == 'n' || dir == WorldEditPlayer.DIRECTION.SOUTH) { } else if (dirStr.charAt(0) == 'n' || dir == LocalPlayer.DIRECTION.SOUTH) {
return CuboidClipboard.FlipDirection.NORTH_SOUTH; return CuboidClipboard.FlipDirection.NORTH_SOUTH;
} else if (dirStr.charAt(0) == 'u') { } else if (dirStr.charAt(0) == 'u') {
return CuboidClipboard.FlipDirection.UP_DOWN; return CuboidClipboard.FlipDirection.UP_DOWN;
@ -1661,7 +1661,7 @@ public class WorldEditController {
* *
* @param player * @param player
*/ */
public void removeSession(WorldEditPlayer player) { public void removeSession(LocalPlayer player) {
sessions.remove(player); sessions.remove(player);
} }
@ -1689,7 +1689,7 @@ public class WorldEditController {
* *
* @param player * @param player
*/ */
public void handleDisconnect(WorldEditPlayer player) { public void handleDisconnect(LocalPlayer player) {
removeSession(player); removeSession(player);
} }
@ -1698,7 +1698,7 @@ public class WorldEditController {
* *
* @param player * @param player
*/ */
public void handleArmSwing(WorldEditPlayer player) { public void handleArmSwing(LocalPlayer player) {
if (!canUseCommand(player, "//")) if (!canUseCommand(player, "//"))
return; return;
} }
@ -1711,14 +1711,14 @@ public class WorldEditController {
* @return false if you want the action to go through * @return false if you want the action to go through
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean handleBlockRightClick(WorldEditPlayer player, Vector clicked) { public boolean handleBlockRightClick(LocalPlayer player, Vector clicked) {
int itemInHand = player.getItemInHand(); int itemInHand = player.getItemInHand();
// This prevents needless sessions from being created // This prevents needless sessions from being created
if (!hasSession(player) && !(itemInHand == wandItem && if (!hasSession(player) && !(itemInHand == wandItem &&
canUseCommand(player, "//pos2"))) { return false; } canUseCommand(player, "//pos2"))) { return false; }
WorldEditSession session = getSession(player); LocalSession session = getSession(player);
if (itemInHand == wandItem && session.isToolControlEnabled() if (itemInHand == wandItem && session.isToolControlEnabled()
&& canUseCommand(player, "//pos2")) { && canUseCommand(player, "//pos2")) {
@ -1732,7 +1732,7 @@ public class WorldEditController {
return true; return true;
} else if (player.isHoldingPickAxe() } else if (player.isHoldingPickAxe()
&& session.getTool() == WorldEditSession.Tool.TREE) { && session.getTool() == LocalSession.Tool.TREE) {
EditSession editSession = EditSession editSession =
new EditSession(server, player.getWorld(), session.getBlockChangeLimit()); new EditSession(server, player.getWorld(), session.getBlockChangeLimit());
@ -1746,7 +1746,7 @@ public class WorldEditController {
return true; return true;
} else if (player.isHoldingPickAxe() } else if (player.isHoldingPickAxe()
&& session.getTool() == WorldEditSession.Tool.INFO) { && session.getTool() == LocalSession.Tool.INFO) {
BaseBlock block = (new EditSession(server, player.getWorld(), 0)).rawGetBlock(clicked); BaseBlock block = (new EditSession(server, player.getWorld(), 0)).rawGetBlock(clicked);
player.print("\u00A79@" + clicked + ": " + "\u00A7e" player.print("\u00A79@" + clicked + ": " + "\u00A7e"
@ -1773,11 +1773,11 @@ public class WorldEditController {
* @param clicked * @param clicked
* @return false if you want the action to go through * @return false if you want the action to go through
*/ */
public boolean handleBlockLeftClick(WorldEditPlayer player, Vector clicked) { public boolean handleBlockLeftClick(LocalPlayer player, Vector clicked) {
if (!canUseCommand(player, "//pos1") if (!canUseCommand(player, "//pos1")
&& !canUseCommand(player, "//")) { return false; } && !canUseCommand(player, "//")) { return false; }
WorldEditSession session = getSession(player); LocalSession session = getSession(player);
if (player.getItemInHand() == wandItem) { if (player.getItemInHand() == wandItem) {
if (session.isToolControlEnabled()) { if (session.isToolControlEnabled()) {
@ -1812,7 +1812,7 @@ public class WorldEditController {
// Single block super pickaxe // Single block super pickaxe
if (session.getSuperPickaxeMode() == if (session.getSuperPickaxeMode() ==
WorldEditSession.SuperPickaxeMode.SINGLE) { LocalSession.SuperPickaxeMode.SINGLE) {
if (server.getBlockType(world, clicked) == 7 && !canBedrock) { if (server.getBlockType(world, clicked) == 7 && !canBedrock) {
return true; return true;
} else if (server.getBlockType(world, clicked) == 46) { } else if (server.getBlockType(world, clicked) == 46) {
@ -1827,7 +1827,7 @@ public class WorldEditController {
// Area super pickaxe // Area super pickaxe
} else if (session.getSuperPickaxeMode() == } else if (session.getSuperPickaxeMode() ==
WorldEditSession.SuperPickaxeMode.SAME_TYPE_AREA) { LocalSession.SuperPickaxeMode.SAME_TYPE_AREA) {
int ox = clicked.getBlockX(); int ox = clicked.getBlockX();
int oy = clicked.getBlockY(); int oy = clicked.getBlockY();
int oz = clicked.getBlockZ(); int oz = clicked.getBlockZ();
@ -1857,7 +1857,7 @@ public class WorldEditController {
// Area super pickaxe // Area super pickaxe
} else if (session.getSuperPickaxeMode() == } else if (session.getSuperPickaxeMode() ==
WorldEditSession.SuperPickaxeMode.SAME_TYPE_RECURSIVE) { LocalSession.SuperPickaxeMode.SAME_TYPE_RECURSIVE) {
int size = session.getSuperPickaxeRange(); int size = session.getSuperPickaxeRange();
int initialType = server.getBlockType(world, clicked); int initialType = server.getBlockType(world, clicked);
@ -1923,7 +1923,7 @@ public class WorldEditController {
* @param split * @param split
* @return whether the command was processed * @return whether the command was processed
*/ */
public boolean handleCommand(WorldEditPlayer player, String[] split) { public boolean handleCommand(LocalPlayer player, String[] split) {
try { try {
// Legacy /, command // Legacy /, command
if (split[0].equals("/,")) { if (split[0].equals("/,")) {
@ -1943,7 +1943,7 @@ public class WorldEditController {
} }
if (canUseCommand(player, split[0])) { if (canUseCommand(player, split[0])) {
WorldEditSession session = getSession(player); LocalSession session = getSession(player);
BlockBag blockBag = session.getBlockBag(player); BlockBag blockBag = session.getBlockBag(player);
EditSession editSession = EditSession editSession =
@ -2009,7 +2009,7 @@ public class WorldEditController {
* @param blockBag * @param blockBag
* @param editSession * @param editSession
*/ */
private static void flushBlockBag(WorldEditPlayer player, private static void flushBlockBag(LocalPlayer player,
EditSession editSession) { EditSession editSession) {
BlockBag blockBag = editSession.getBlockBag(); BlockBag blockBag = editSession.getBlockBag();
@ -2051,7 +2051,7 @@ public class WorldEditController {
* @param command * @param command
* @return * @return
*/ */
private boolean canUseCommand(WorldEditPlayer player, String command) { private boolean canUseCommand(LocalPlayer player, String command) {
// Allow the /worldeditselect permission // Allow the /worldeditselect permission
if (command.equalsIgnoreCase("//pos1") if (command.equalsIgnoreCase("//pos1")
|| command.equalsIgnoreCase("//pos2") || command.equalsIgnoreCase("//pos2")
@ -2097,11 +2097,11 @@ public class WorldEditController {
* @param player * @param player
* @return * @return
*/ */
public WorldEditSession getBridgeSession(WorldEditPlayer player) { public LocalSession getBridgeSession(LocalPlayer player) {
if (sessions.containsKey(player)) { if (sessions.containsKey(player)) {
return sessions.get(player); return sessions.get(player);
} else { } else {
WorldEditSession session = new WorldEditSession(); LocalSession session = new LocalSession();
session.setBlockChangeLimit(defaultChangeLimit); session.setBlockChangeLimit(defaultChangeLimit);
sessions.put(player, session); sessions.put(player, session);
return session; return session;