2010-10-11 08:22:47 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
2011-01-01 01:06:42 +00:00
|
|
|
* WorldEdit
|
2010-10-11 08:22:47 +00:00
|
|
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-01-01 01:06:42 +00:00
|
|
|
package com.sk89q.worldedit;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.bags.BlockBag;
|
2010-10-20 00:10:02 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BlockType;
|
2010-10-11 08:22:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author sk89q
|
|
|
|
*/
|
2011-01-01 18:34:36 +00:00
|
|
|
public abstract class LocalPlayer {
|
2010-10-11 08:22:47 +00:00
|
|
|
/**
|
2011-01-01 01:06:42 +00:00
|
|
|
* Directions.
|
2010-10-11 08:22:47 +00:00
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public enum DIRECTION {
|
|
|
|
NORTH,
|
|
|
|
NORTH_EAST,
|
|
|
|
EAST,
|
|
|
|
SOUTH_EAST,
|
|
|
|
SOUTH,
|
|
|
|
SOUTH_WEST,
|
|
|
|
WEST,
|
|
|
|
NORTH_WEST
|
|
|
|
};
|
2010-10-14 18:59:45 +00:00
|
|
|
|
2011-01-01 01:06:42 +00:00
|
|
|
/**
|
|
|
|
* Server.
|
|
|
|
*/
|
|
|
|
protected ServerInterface server;
|
|
|
|
|
2010-10-14 18:59:45 +00:00
|
|
|
/**
|
2010-11-05 23:42:16 +00:00
|
|
|
* Construct the object.
|
2011-01-01 18:33:18 +00:00
|
|
|
*
|
|
|
|
* @param server
|
2010-10-14 18:59:45 +00:00
|
|
|
*/
|
2011-01-01 18:34:36 +00:00
|
|
|
protected LocalPlayer(ServerInterface server) {
|
2011-01-01 18:33:18 +00:00
|
|
|
this.server = server;
|
2010-10-14 18:59:45 +00:00
|
|
|
}
|
2011-01-01 01:06:42 +00:00
|
|
|
|
2010-10-13 18:26:07 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the player is holding a pick axe.
|
|
|
|
*
|
|
|
|
* @return whether a pick axe is held
|
|
|
|
*/
|
|
|
|
public boolean isHoldingPickAxe() {
|
|
|
|
int item = getItemInHand();
|
2010-11-05 06:07:47 +00:00
|
|
|
return item == 257 || item == 270 || item == 274 || item == 278
|
2010-10-13 18:26:07 +00:00
|
|
|
|| item == 285;
|
|
|
|
}
|
|
|
|
|
2010-10-11 08:22:47 +00:00
|
|
|
/**
|
|
|
|
* Find a position for the player to stand that is not inside a block.
|
|
|
|
* Blocks above the player will be iteratively tested until there is
|
|
|
|
* a series of two free blocks. The player will be teleported to
|
|
|
|
* that free position.
|
2010-10-20 00:10:02 +00:00
|
|
|
*
|
|
|
|
* @param searchPos search position
|
2010-10-11 08:22:47 +00:00
|
|
|
*/
|
2011-01-09 17:25:24 +00:00
|
|
|
public void findFreePosition(WorldVector searchPos) {
|
|
|
|
LocalWorld world = searchPos.getWorld();
|
2010-10-20 00:10:02 +00:00
|
|
|
int x = searchPos.getBlockX();
|
2010-11-06 08:28:45 +00:00
|
|
|
int y = Math.max(0, searchPos.getBlockY());
|
2010-10-11 08:22:47 +00:00
|
|
|
int origY = y;
|
2010-10-20 00:10:02 +00:00
|
|
|
int z = searchPos.getBlockZ();
|
2010-10-11 08:22:47 +00:00
|
|
|
|
|
|
|
byte free = 0;
|
|
|
|
|
|
|
|
while (y <= 129) {
|
2011-01-08 19:26:27 +00:00
|
|
|
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
2010-10-11 08:22:47 +00:00
|
|
|
free++;
|
|
|
|
} else {
|
|
|
|
free = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (free == 2) {
|
|
|
|
if (y - 1 != origY) {
|
2010-10-14 08:31:05 +00:00
|
|
|
setPosition(new Vector(x + 0.5, y - 1, z + 0.5));
|
2010-10-11 08:22:47 +00:00
|
|
|
}
|
2010-11-17 06:17:50 +00:00
|
|
|
|
|
|
|
return;
|
2010-10-11 08:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-20 00:10:02 +00:00
|
|
|
/**
|
|
|
|
* Find a position for the player to stand that is not inside a block.
|
|
|
|
* Blocks above the player will be iteratively tested until there is
|
|
|
|
* a series of two free blocks. The player will be teleported to
|
|
|
|
* that free position.
|
|
|
|
*/
|
|
|
|
public void findFreePosition() {
|
2011-01-09 17:25:24 +00:00
|
|
|
findFreePosition(getBlockIn());
|
2010-10-20 00:10:02 +00:00
|
|
|
}
|
|
|
|
|
2010-10-13 05:06:46 +00:00
|
|
|
/**
|
|
|
|
* Go up one level to the next free space above.
|
|
|
|
*
|
|
|
|
* @return true if a spot was found
|
|
|
|
*/
|
|
|
|
public boolean ascendLevel() {
|
2010-10-16 23:56:59 +00:00
|
|
|
Vector pos = getBlockIn();
|
2010-10-14 08:31:05 +00:00
|
|
|
int x = pos.getBlockX();
|
2010-11-06 08:28:45 +00:00
|
|
|
int y = Math.max(0, pos.getBlockY());
|
2010-10-14 08:31:05 +00:00
|
|
|
int z = pos.getBlockZ();
|
2011-01-01 18:33:18 +00:00
|
|
|
LocalWorld world = getPosition().getWorld();
|
2010-10-13 05:06:46 +00:00
|
|
|
|
|
|
|
byte free = 0;
|
|
|
|
byte spots = 0;
|
|
|
|
|
|
|
|
while (y <= 129) {
|
2011-01-08 19:26:27 +00:00
|
|
|
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
2010-10-13 05:06:46 +00:00
|
|
|
free++;
|
|
|
|
} else {
|
|
|
|
free = 0;
|
|
|
|
}
|
|
|
|
|
2010-10-16 23:56:59 +00:00
|
|
|
if (free == 2) {
|
2010-10-13 05:06:46 +00:00
|
|
|
spots++;
|
2010-10-16 23:56:59 +00:00
|
|
|
if (spots == 2) {
|
2011-01-08 19:26:27 +00:00
|
|
|
int type = world.getBlockType(new Vector(x, y - 2, z));
|
2010-10-17 00:15:17 +00:00
|
|
|
|
|
|
|
// Don't get put in lava!
|
|
|
|
if (type == 10 || type == 11) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-13 05:06:46 +00:00
|
|
|
setPosition(new Vector(x + 0.5, y - 1, z + 0.5));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Go up one level to the next free space above.
|
|
|
|
*
|
|
|
|
* @return true if a spot was found
|
|
|
|
*/
|
|
|
|
public boolean descendLevel() {
|
2010-10-17 00:08:56 +00:00
|
|
|
Vector pos = getBlockIn();
|
2010-10-14 08:31:05 +00:00
|
|
|
int x = pos.getBlockX();
|
2010-11-06 08:28:45 +00:00
|
|
|
int y = Math.max(0, pos.getBlockY() - 1);
|
2010-10-14 08:31:05 +00:00
|
|
|
int z = pos.getBlockZ();
|
2011-01-01 18:33:18 +00:00
|
|
|
LocalWorld world = getPosition().getWorld();
|
2010-10-13 05:06:46 +00:00
|
|
|
|
|
|
|
byte free = 0;
|
|
|
|
|
2010-10-17 00:08:56 +00:00
|
|
|
while (y >= 1) {
|
2011-01-08 19:26:27 +00:00
|
|
|
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
2010-10-13 05:06:46 +00:00
|
|
|
free++;
|
|
|
|
} else {
|
|
|
|
free = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (free == 2) {
|
2010-10-17 00:08:56 +00:00
|
|
|
// So we've found a spot, but we have to drop the player
|
|
|
|
// lightly and also check to see if there's something to
|
|
|
|
// stand upon
|
|
|
|
while (y >= 0) {
|
2011-01-08 19:26:27 +00:00
|
|
|
int type = world.getBlockType(new Vector(x, y, z));
|
2010-10-17 00:15:17 +00:00
|
|
|
|
|
|
|
// Don't want to end up in lava
|
|
|
|
if (type != 0 && type != 10 && type != 11) {
|
2010-10-17 00:08:56 +00:00
|
|
|
// Found a block!
|
|
|
|
setPosition(new Vector(x + 0.5, y + 1, z + 0.5));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-10-13 05:06:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-20 00:10:02 +00:00
|
|
|
/**
|
|
|
|
* Ascend to the ceiling above.
|
|
|
|
*
|
|
|
|
* @param clearance
|
|
|
|
* @return whether the player was moved
|
|
|
|
*/
|
|
|
|
public boolean ascendToCeiling(int clearance) {
|
|
|
|
Vector pos = getBlockIn();
|
|
|
|
int x = pos.getBlockX();
|
2010-11-06 08:28:45 +00:00
|
|
|
int initialY = Math.max(0, pos.getBlockY());
|
|
|
|
int y = Math.max(0, pos.getBlockY() + 2);
|
2010-10-20 00:10:02 +00:00
|
|
|
int z = pos.getBlockZ();
|
2011-01-01 18:33:18 +00:00
|
|
|
LocalWorld world = getPosition().getWorld();
|
2010-10-20 00:10:02 +00:00
|
|
|
|
2010-10-20 03:36:57 +00:00
|
|
|
// No free space above
|
2011-01-08 19:26:27 +00:00
|
|
|
if (world.getBlockType(new Vector(x, y, z)) != 0) {
|
2010-10-20 00:10:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (y <= 127) {
|
|
|
|
// Found a ceiling!
|
2011-01-08 19:26:27 +00:00
|
|
|
if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
2010-10-20 03:36:57 +00:00
|
|
|
int platformY = Math.max(initialY, y - 3 - clearance);
|
2011-01-08 19:26:27 +00:00
|
|
|
world.setBlockType(new Vector(x, platformY, z),
|
2010-10-20 00:10:02 +00:00
|
|
|
BlockType.GLASS.getID());
|
2010-10-20 03:36:57 +00:00
|
|
|
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
|
2010-10-20 00:10:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-07 04:47:50 +00:00
|
|
|
/**
|
|
|
|
* Just go up.
|
|
|
|
*
|
|
|
|
* @param distance
|
|
|
|
* @return whether the player was moved
|
|
|
|
*/
|
|
|
|
public boolean ascendUpwards(int distance) {
|
|
|
|
Vector pos = getBlockIn();
|
|
|
|
int x = pos.getBlockX();
|
|
|
|
int initialY = Math.max(0, pos.getBlockY());
|
|
|
|
int y = Math.max(0, pos.getBlockY() + 1);
|
|
|
|
int z = pos.getBlockZ();
|
|
|
|
int maxY = Math.min(128, initialY + distance);
|
2011-01-01 18:33:18 +00:00
|
|
|
LocalWorld world = getPosition().getWorld();
|
2010-11-07 04:47:50 +00:00
|
|
|
|
|
|
|
while (y <= 129) {
|
2011-01-08 19:26:27 +00:00
|
|
|
if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
2010-11-07 04:47:50 +00:00
|
|
|
break; // Hit something
|
|
|
|
} else if (y > maxY + 1) {
|
|
|
|
break;
|
|
|
|
} else if (y == maxY + 1) {
|
2011-01-08 19:26:27 +00:00
|
|
|
world.setBlockType(new Vector(x, y - 2, z),
|
2010-11-07 04:47:50 +00:00
|
|
|
BlockType.GLASS.getID());
|
|
|
|
setPosition(new Vector(x + 0.5, y - 1, z + 0.5));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-05 23:42:16 +00:00
|
|
|
/**
|
|
|
|
* Get the point of the block that is being stood in.
|
|
|
|
*
|
|
|
|
* @return point
|
|
|
|
*/
|
2011-01-01 18:33:18 +00:00
|
|
|
public WorldVector getBlockIn() {
|
2011-01-08 18:52:48 +00:00
|
|
|
WorldVector pos = getPosition();
|
|
|
|
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(),
|
|
|
|
pos.getY(), pos.getZ());
|
2010-11-05 23:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the point of the block that is being stood upon.
|
|
|
|
*
|
|
|
|
* @return point
|
|
|
|
*/
|
2011-01-01 18:33:18 +00:00
|
|
|
public WorldVector getBlockOn() {
|
|
|
|
WorldVector pos = getPosition();
|
2011-01-08 18:52:48 +00:00
|
|
|
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(),
|
|
|
|
pos.getY() - 1, pos.getZ());
|
2010-11-05 23:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the point of the block being looked at. May return null.
|
|
|
|
*
|
|
|
|
* @param range
|
|
|
|
* @return point
|
|
|
|
*/
|
2011-01-01 18:33:18 +00:00
|
|
|
public abstract WorldVector getBlockTrace(int range);
|
2010-11-05 23:42:16 +00:00
|
|
|
|
2010-11-10 09:54:07 +00:00
|
|
|
/**
|
|
|
|
* Get the point of the block being looked at. May return null.
|
|
|
|
*
|
|
|
|
* @param range
|
|
|
|
* @return point
|
|
|
|
*/
|
2011-01-01 18:33:18 +00:00
|
|
|
public abstract WorldVector getSolidBlockTrace(int range);
|
2010-11-10 09:54:07 +00:00
|
|
|
|
2010-11-05 23:42:16 +00:00
|
|
|
/**
|
2011-01-01 01:06:42 +00:00
|
|
|
* Get the player's cardinal direction (N, W, NW, etc.). May return null.
|
2010-11-05 23:42:16 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
2011-01-01 18:34:36 +00:00
|
|
|
public LocalPlayer.DIRECTION getCardinalDirection() {
|
2010-11-05 23:42:16 +00:00
|
|
|
// From hey0's code
|
|
|
|
double rot = (getYaw() - 90) % 360;
|
|
|
|
if (rot < 0) {
|
|
|
|
rot += 360.0;
|
|
|
|
}
|
2011-01-01 01:06:42 +00:00
|
|
|
return getDirection(rot);
|
2010-11-05 23:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-01 01:06:42 +00:00
|
|
|
* Returns direction according to rotation. May return null.
|
|
|
|
*
|
|
|
|
* @param rot
|
2010-11-05 23:42:16 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-01-01 18:34:36 +00:00
|
|
|
private static LocalPlayer.DIRECTION getDirection(double rot) {
|
2011-01-01 01:06:42 +00:00
|
|
|
if (0 <= rot && rot < 22.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.NORTH;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (22.5 <= rot && rot < 67.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.NORTH_EAST;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (67.5 <= rot && rot < 112.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.EAST;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (112.5 <= rot && rot < 157.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.SOUTH_EAST;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (157.5 <= rot && rot < 202.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.SOUTH;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (202.5 <= rot && rot < 247.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.SOUTH_WEST;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (247.5 <= rot && rot < 292.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.WEST;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (292.5 <= rot && rot < 337.5) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.NORTH_WEST;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else if (337.5 <= rot && rot < 360.0) {
|
2011-01-01 18:34:36 +00:00
|
|
|
return LocalPlayer.DIRECTION.NORTH;
|
2011-01-01 01:06:42 +00:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-05 23:42:16 +00:00
|
|
|
/**
|
|
|
|
* Get the ID of the item that the player is holding.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract int getItemInHand();
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the player.
|
|
|
|
*
|
|
|
|
* @return String
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract String getName();
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
2011-01-01 01:06:42 +00:00
|
|
|
* Get the player's position.
|
2010-11-05 23:42:16 +00:00
|
|
|
*
|
2011-01-01 01:06:42 +00:00
|
|
|
* @return point
|
2010-11-05 23:42:16 +00:00
|
|
|
*/
|
2011-01-01 18:33:18 +00:00
|
|
|
public abstract WorldVector getPosition();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the player's world.
|
|
|
|
*
|
|
|
|
* @return point
|
|
|
|
*/
|
|
|
|
public abstract LocalWorld getWorld();
|
2011-01-01 01:06:42 +00:00
|
|
|
|
2010-11-05 23:42:16 +00:00
|
|
|
/**
|
|
|
|
* Get the player's view pitch.
|
|
|
|
*
|
|
|
|
* @return pitch
|
|
|
|
*/
|
|
|
|
/**
|
2011-01-01 01:06:42 +00:00
|
|
|
* Get the player's view pitch.
|
2010-11-05 23:42:16 +00:00
|
|
|
*
|
2011-01-01 01:06:42 +00:00
|
|
|
* @return pitch
|
2010-11-05 23:42:16 +00:00
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract double getPitch();
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the player's view yaw.
|
|
|
|
*
|
|
|
|
* @return yaw
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Get the player's view yaw.
|
|
|
|
*
|
|
|
|
* @return yaw
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract double getYaw();
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gives the player an item.
|
|
|
|
*
|
|
|
|
* @param type
|
|
|
|
* @param amt
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract void giveItem(int type, int amt);
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pass through the wall that you are looking at.
|
|
|
|
*
|
|
|
|
* @param range
|
|
|
|
* @return whether the player was pass through
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract boolean passThroughForwardWall(int range);
|
2010-11-05 23:42:16 +00:00
|
|
|
|
2010-11-27 03:33:28 +00:00
|
|
|
/**
|
|
|
|
* Print a message.
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract void printRaw(String msg);
|
2010-11-27 03:33:28 +00:00
|
|
|
|
2010-11-05 23:42:16 +00:00
|
|
|
/**
|
|
|
|
* Print a WorldEdit message.
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract void print(String msg);
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a WorldEdit error.
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract void printError(String msg);
|
2010-11-05 23:42:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the player.
|
|
|
|
*
|
|
|
|
* @param pos
|
|
|
|
* @param pitch
|
|
|
|
* @param yaw
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract void setPosition(Vector pos, float pitch, float yaw);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the player.
|
|
|
|
*
|
|
|
|
* @param pos
|
|
|
|
*/
|
|
|
|
public void setPosition(Vector pos) {
|
|
|
|
setPosition(pos, (float)getPitch(), (float)getYaw());
|
2010-11-05 23:42:16 +00:00
|
|
|
}
|
2010-11-06 07:51:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a player's list of groups.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
public abstract String[] getGroups();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get this player's block bag.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract BlockBag getInventoryBlockBag();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a player has permission.
|
|
|
|
*
|
|
|
|
* @param perm
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract boolean hasPermission(String perm);
|
2011-01-02 05:50:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the player can destroy bedrock.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public boolean canDestroyBedrock() {
|
|
|
|
return hasPermission("worldeditbedrock");
|
|
|
|
}
|
2011-01-01 01:06:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if equal.
|
|
|
|
*
|
|
|
|
* @param other
|
|
|
|
* @return whether the other object is equivalent
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
2011-01-01 18:34:36 +00:00
|
|
|
if (!(other instanceof LocalPlayer)) {
|
2011-01-01 01:06:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-01 18:34:36 +00:00
|
|
|
LocalPlayer other2 = (LocalPlayer)other;
|
2011-01-01 01:06:42 +00:00
|
|
|
return other2.getName().equals(getName());
|
2010-11-27 03:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-01 01:06:42 +00:00
|
|
|
* Gets the hash code.
|
|
|
|
*
|
|
|
|
* @return hash code
|
2010-11-27 03:37:37 +00:00
|
|
|
*/
|
2011-01-01 01:06:42 +00:00
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return getName().hashCode();
|
2010-11-06 07:51:35 +00:00
|
|
|
}
|
2010-10-11 08:22:47 +00:00
|
|
|
}
|