mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Moved all the classes around again (re-coupled with Hmod).
This commit is contained in:
parent
6c71e6046b
commit
138787c1e2
@ -42,11 +42,6 @@ import java.util.Random;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class EditSession {
|
public class EditSession {
|
||||||
/**
|
|
||||||
* Server interface.
|
|
||||||
*/
|
|
||||||
protected ServerInterface server;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the original blocks before modification.
|
* Stores the original blocks before modification.
|
||||||
*/
|
*/
|
||||||
@ -75,13 +70,6 @@ public class EditSession {
|
|||||||
*/
|
*/
|
||||||
private static Random prng = new Random();
|
private static Random prng = new Random();
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor. There is no maximum blocks limit.
|
|
||||||
*/
|
|
||||||
public EditSession() {
|
|
||||||
server = WorldEditController.getServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object with a maximum number of blocks.
|
* Construct the object with a maximum number of blocks.
|
||||||
*/
|
*/
|
||||||
@ -90,8 +78,6 @@ public class EditSession {
|
|||||||
throw new IllegalArgumentException("Max blocks must be >= -1");
|
throw new IllegalArgumentException("Max blocks must be >= -1");
|
||||||
}
|
}
|
||||||
this.maxBlocks = maxBlocks;
|
this.maxBlocks = maxBlocks;
|
||||||
|
|
||||||
server = WorldEditController.getServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,15 +93,15 @@ public class EditSession {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean result = server.setBlockType(pt, block.getID());
|
boolean result = ServerInterface.setBlockType(pt, block.getID());
|
||||||
if (block.getID() != 0) {
|
if (block.getID() != 0) {
|
||||||
server.setBlockData(pt, block.getData());
|
ServerInterface.setBlockData(pt, block.getData());
|
||||||
|
|
||||||
// Signs
|
// Signs
|
||||||
if (block instanceof SignBlock) {
|
if (block instanceof SignBlock) {
|
||||||
SignBlock signBlock = (SignBlock)block;
|
SignBlock signBlock = (SignBlock)block;
|
||||||
String[] text = signBlock.getText();
|
String[] text = signBlock.getText();
|
||||||
server.setSignText(pt, text);
|
ServerInterface.setSignText(pt, text);
|
||||||
// Chests
|
// Chests
|
||||||
} else if (block instanceof ChestBlock) {
|
} else if (block instanceof ChestBlock) {
|
||||||
ChestBlock chestBlock = (ChestBlock)block;
|
ChestBlock chestBlock = (ChestBlock)block;
|
||||||
@ -124,10 +110,10 @@ public class EditSession {
|
|||||||
for (byte i = 0; i <= 26; i++) {
|
for (byte i = 0; i <= 26; i++) {
|
||||||
Countable<BaseItem> item = items.get(i);
|
Countable<BaseItem> item = items.get(i);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
server.setChestSlot(pt, i, item.getID(),
|
ServerInterface.setChestSlot(pt, i, item.getID(),
|
||||||
item.getAmount());
|
item.getAmount());
|
||||||
} else {
|
} else {
|
||||||
server.setChestSlot(pt, i, blankItem, 0);
|
ServerInterface.setChestSlot(pt, i, blankItem, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,16 +214,16 @@ public class EditSession {
|
|||||||
* @return BaseBlock
|
* @return BaseBlock
|
||||||
*/
|
*/
|
||||||
public BaseBlock rawGetBlock(Vector pt) {
|
public BaseBlock rawGetBlock(Vector pt) {
|
||||||
int type = server.getBlockType(pt);
|
int type = ServerInterface.getBlockType(pt);
|
||||||
int data = server.getBlockData(pt);
|
int data = ServerInterface.getBlockData(pt);
|
||||||
|
|
||||||
// Sign
|
// Sign
|
||||||
if (type == 63 || type == 68) {
|
if (type == 63 || type == 68) {
|
||||||
String[] text = server.getSignText(pt);
|
String[] text = ServerInterface.getSignText(pt);
|
||||||
return new SignBlock(type, data, text);
|
return new SignBlock(type, data, text);
|
||||||
// Chest
|
// Chest
|
||||||
} else if (type == 54) {
|
} else if (type == 54) {
|
||||||
Map<Byte,Countable<BaseItem>> items = server.getChestContents(pt);
|
Map<Byte,Countable<BaseItem>> items = ServerInterface.getChestContents(pt);
|
||||||
return new ChestBlock(data, items);
|
return new ChestBlock(data, items);
|
||||||
} else {
|
} else {
|
||||||
return new BaseBlock(type, data);
|
return new BaseBlock(type, data);
|
||||||
|
@ -1,206 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldEdit
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event listener for Hey0's server mod plugin.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HmodWorldEditListener extends PluginListener {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Player player) {
|
|
||||||
WorldEditController worldEdit = WorldEditController.getInstance();
|
|
||||||
worldEdit.removeSession(new HmodWorldEditPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called on right click.
|
|
||||||
*
|
|
||||||
* @param modPlayer
|
|
||||||
* @param blockPlaced
|
|
||||||
* @param blockClicked
|
|
||||||
* @param itemInHand
|
|
||||||
* @return false if you want the action to go through
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onBlockCreate(Player modPlayer, Block blockPlaced,
|
|
||||||
Block blockClicked, int itemInHand) {
|
|
||||||
WorldEditController worldEdit = WorldEditController.getInstance();
|
|
||||||
WorldEditPlayer player = new HmodWorldEditPlayer(modPlayer);
|
|
||||||
|
|
||||||
if (itemInHand != 271) { return false; }
|
|
||||||
if (!canUseCommand(modPlayer, "//pos2")) { return false; }
|
|
||||||
|
|
||||||
WorldEditSession session = worldEdit.getSession(player);
|
|
||||||
|
|
||||||
if (session.isToolControlEnabled()) {
|
|
||||||
Vector cur = Vector.toBlockPoint(blockClicked.getX(),
|
|
||||||
blockClicked.getY(),
|
|
||||||
blockClicked.getZ());
|
|
||||||
|
|
||||||
session.setPos2(cur);
|
|
||||||
player.print("Second edit position set.");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called on left click.
|
|
||||||
*
|
|
||||||
* @param modPlayer
|
|
||||||
* @param blockClicked
|
|
||||||
* @param itemInHand
|
|
||||||
* @return false if you want the action to go through
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onBlockDestroy(Player modPlayer, Block blockClicked) {
|
|
||||||
if (!canUseCommand(modPlayer, "//pos1")
|
|
||||||
&& !canUseCommand(modPlayer, "//")) { return false; }
|
|
||||||
|
|
||||||
WorldEditController worldEdit = WorldEditController.getInstance();
|
|
||||||
WorldEditPlayer player = new HmodWorldEditPlayer(modPlayer);
|
|
||||||
WorldEditSession session = worldEdit.getSession(player);
|
|
||||||
|
|
||||||
if (player.getItemInHand() == 271) {
|
|
||||||
if (session.isToolControlEnabled()) {
|
|
||||||
Vector cur = Vector.toBlockPoint(blockClicked.getX(),
|
|
||||||
blockClicked.getY(),
|
|
||||||
blockClicked.getZ());
|
|
||||||
|
|
||||||
// Bug workaround
|
|
||||||
if (cur.getBlockX() == 0 && cur.getBlockY() == 0
|
|
||||||
&& cur.getBlockZ() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (session.getPos1().equals(cur)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (IncompleteRegionException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
session.setPos1(cur);
|
|
||||||
player.print("First edit position set.");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (player.isHoldingPickAxe()) {
|
|
||||||
if (session.hasSuperPickAxe()) {
|
|
||||||
Vector pos = new Vector(blockClicked.getX(),
|
|
||||||
blockClicked.getY(), blockClicked.getZ());
|
|
||||||
if (WorldEditController.getServer().getBlockType(pos) == 7
|
|
||||||
&& !canUseCommand(modPlayer, "/worldeditbedrock")) {
|
|
||||||
return true;
|
|
||||||
} else if (WorldEditController.getServer().getBlockType(pos) == 46) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldEditController.getServer().setBlockType(pos, 0);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param modPlayer
|
|
||||||
* @param split
|
|
||||||
* @return whether the command was processed
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(Player modPlayer, String[] split) {
|
|
||||||
WorldEditController worldEdit = WorldEditController.getInstance();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Legacy /, command
|
|
||||||
if (split[0].equals("/,")) {
|
|
||||||
split[0] = "//";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (worldEdit.getCommands().containsKey(split[0].toLowerCase())) {
|
|
||||||
if (canUseCommand(modPlayer, split[0])) {
|
|
||||||
WorldEditPlayer player = new HmodWorldEditPlayer(modPlayer);
|
|
||||||
WorldEditSession session = worldEdit.getSession(player);
|
|
||||||
EditSession editSession =
|
|
||||||
new EditSession(session.getBlockChangeLimit());
|
|
||||||
editSession.enableQueue();
|
|
||||||
|
|
||||||
try {
|
|
||||||
return worldEdit.performCommand(player, session, editSession, split);
|
|
||||||
} finally {
|
|
||||||
session.remember(editSession);
|
|
||||||
editSession.flushQueue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "Number expected; string given.");
|
|
||||||
} catch (IncompleteRegionException e2) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "The edit region has not been fully defined.");
|
|
||||||
} catch (UnknownItemException e3) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "Block name was not recognized.");
|
|
||||||
} catch (DisallowedItemException e4) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "Block not allowed (see WorldEdit configuration).");
|
|
||||||
} catch (MaxChangedBlocksException e5) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "The maximum number of blocks changed ("
|
|
||||||
+ e5.getBlockLimit() + ") in an instance was reached.");
|
|
||||||
} catch (UnknownDirectionException ue) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "Unknown direction: " + ue.getDirection());
|
|
||||||
} catch (InsufficientArgumentsException e6) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + e6.getMessage());
|
|
||||||
} catch (EmptyClipboardException ec) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "Your clipboard is empty.");
|
|
||||||
} catch (WorldEditException e7) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + e7.getMessage());
|
|
||||||
} catch (Throwable excp) {
|
|
||||||
modPlayer.sendMessage(Colors.Rose + "Please report this error: [See console]");
|
|
||||||
modPlayer.sendMessage(excp.getClass().getName() + ": " + excp.getMessage());
|
|
||||||
excp.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if the player can use a command or /worldedit.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param command
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean canUseCommand(Player player, String command) {
|
|
||||||
return player.canUseCommand(command.replace("air", ""))
|
|
||||||
|| player.canUseCommand("/worldedit");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,239 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldEdit
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HmodWorldEditPlayer extends WorldEditPlayer {
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a WorldEditPlayer.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
public HmodWorldEditPlayer(Player player) {
|
|
||||||
super();
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of the player.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return player.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the point of the block that is being stood upon.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public Vector getBlockOn() {
|
|
||||||
return Vector.toBlockPoint(player.getX(), player.getY() - 1, player.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the point of the block that is being stood in.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public Vector getBlockIn() {
|
|
||||||
return Vector.toBlockPoint(player.getX(), player.getY(), player.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the point of the block being looked at. May return null.
|
|
||||||
*
|
|
||||||
* @param range
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public Vector getBlockTrace(int range) {
|
|
||||||
HitBlox hitBlox = new HitBlox(player, range, 0.2);
|
|
||||||
Block block = hitBlox.getTargetBlock();
|
|
||||||
if (block == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Vector(block.getX(), block.getY(), block.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pass through the wall that you are looking at.
|
|
||||||
*
|
|
||||||
* @param range
|
|
||||||
* @return whether the player was pass through
|
|
||||||
*/
|
|
||||||
public boolean passThroughForwardWall(int range) {
|
|
||||||
boolean foundNext = false;
|
|
||||||
int searchDist = 0;
|
|
||||||
|
|
||||||
HitBlox hitBlox = new HitBlox(player, range, 0.2);
|
|
||||||
Block block;
|
|
||||||
|
|
||||||
while ((block = hitBlox.getNextBlock()) != null) {
|
|
||||||
searchDist++;
|
|
||||||
|
|
||||||
if (searchDist > 20) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (block.getType() == 0) {
|
|
||||||
if (foundNext) {
|
|
||||||
Vector v = new Vector(block.getX(), block.getY() - 1, block.getZ());
|
|
||||||
|
|
||||||
if (server.getBlockType(v) == 0) {
|
|
||||||
setPosition(v.add(0.5, 0, 0.5));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
foundNext = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's position.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public Vector getPosition() {
|
|
||||||
return new Vector(player.getX(), player.getY(), player.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's view pitch.
|
|
||||||
*
|
|
||||||
* @return pitch
|
|
||||||
*/
|
|
||||||
public double getPitch() {
|
|
||||||
return player.getPitch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's view yaw.
|
|
||||||
*
|
|
||||||
* @return yaw
|
|
||||||
*/
|
|
||||||
public double getYaw() {
|
|
||||||
return player.getRotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ID of the item that the player is holding.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getItemInHand() {
|
|
||||||
return player.getItemInHand();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's cardinal direction (N, W, NW, etc.).
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getCardinalDirection() {
|
|
||||||
// From hey0's code
|
|
||||||
double rot = (getYaw() - 90) % 360;
|
|
||||||
if (rot < 0) {
|
|
||||||
rot += 360.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return etc.getCompassPointForDirection(rot).toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a WorldEdit message.
|
|
||||||
*
|
|
||||||
* @param msg
|
|
||||||
*/
|
|
||||||
public void print(String msg) {
|
|
||||||
player.sendMessage(Colors.LightPurple + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a WorldEdit error.
|
|
||||||
*
|
|
||||||
* @param msg
|
|
||||||
*/
|
|
||||||
public void printError(String msg) {
|
|
||||||
player.sendMessage(Colors.Rose + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move the player.
|
|
||||||
*
|
|
||||||
* @param pos
|
|
||||||
* @param pitch
|
|
||||||
* @param yaw
|
|
||||||
*/
|
|
||||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
|
||||||
Location loc = new Location();
|
|
||||||
loc.x = pos.getX();
|
|
||||||
loc.y = pos.getY();
|
|
||||||
loc.z = pos.getZ();
|
|
||||||
loc.rotX = (float)yaw;
|
|
||||||
loc.rotY = (float)pitch;
|
|
||||||
player.teleportTo(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the player an item.
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param amt
|
|
||||||
*/
|
|
||||||
public void giveItem(int type, int amt) {
|
|
||||||
player.giveItem(type, amt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if equal.
|
|
||||||
*
|
|
||||||
* @param other
|
|
||||||
* @return whether the other object is equivalent
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
if (!(other instanceof WorldEditPlayer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
WorldEditPlayer other2 = (WorldEditPlayer)other;
|
|
||||||
return other2.getName().equals(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the hash code.
|
|
||||||
*
|
|
||||||
* @return hash code
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return getName().hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,7 +26,7 @@ import java.util.HashMap;
|
|||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class HmodServerInterface implements ServerInterface {
|
public class ServerInterface {
|
||||||
/**
|
/**
|
||||||
* Set block type.
|
* Set block type.
|
||||||
*
|
*
|
||||||
@ -34,7 +34,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param type
|
* @param type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setBlockType(Vector pt, int type) {
|
public static boolean setBlockType(Vector pt, int type) {
|
||||||
// Can't set colored cloth or crash
|
// Can't set colored cloth or crash
|
||||||
if ((type >= 21 && type <= 34) || type == 36) {
|
if ((type >= 21 && type <= 34) || type == 36) {
|
||||||
return false;
|
return false;
|
||||||
@ -49,7 +49,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getBlockType(Vector pt) {
|
public static int getBlockType(Vector pt) {
|
||||||
return etc.getServer().getBlockIdAt(pt.getBlockX(), pt.getBlockY(),
|
return etc.getServer().getBlockIdAt(pt.getBlockX(), pt.getBlockY(),
|
||||||
pt.getBlockZ());
|
pt.getBlockZ());
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param data
|
* @param data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void setBlockData(Vector pt, int data) {
|
public static void setBlockData(Vector pt, int data) {
|
||||||
etc.getServer().setBlockData(pt.getBlockX(), pt.getBlockY(),
|
etc.getServer().setBlockData(pt.getBlockX(), pt.getBlockY(),
|
||||||
pt.getBlockZ(), data);
|
pt.getBlockZ(), data);
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getBlockData(Vector pt) {
|
public static int getBlockData(Vector pt) {
|
||||||
return etc.getServer().getBlockData(pt.getBlockX(), pt.getBlockY(),
|
return etc.getServer().getBlockData(pt.getBlockX(), pt.getBlockY(),
|
||||||
pt.getBlockZ());
|
pt.getBlockZ());
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @param text
|
* @param text
|
||||||
*/
|
*/
|
||||||
public void setSignText(Vector pt, String[] text) {
|
public static void setSignText(Vector pt, String[] text) {
|
||||||
Sign signData = (Sign)etc.getServer().getComplexBlock(
|
Sign signData = (Sign)etc.getServer().getComplexBlock(
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||||
if (signData == null) {
|
if (signData == null) {
|
||||||
@ -101,7 +101,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String[] getSignText(Vector pt) {
|
public static String[] getSignText(Vector pt) {
|
||||||
Sign signData = (Sign)etc.getServer().getComplexBlock(
|
Sign signData = (Sign)etc.getServer().getComplexBlock(
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||||
if (signData == null) {
|
if (signData == null) {
|
||||||
@ -120,7 +120,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<Byte,Countable<BaseItem>> getChestContents(Vector pt) {
|
public static Map<Byte,Countable<BaseItem>> getChestContents(Vector pt) {
|
||||||
ComplexBlock cblock = etc.getServer().getComplexBlock(
|
ComplexBlock cblock = etc.getServer().getComplexBlock(
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ public class HmodServerInterface implements ServerInterface {
|
|||||||
* @param amount
|
* @param amount
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setChestSlot(Vector pt, byte slot, BaseItem item, int amount) {
|
public static boolean setChestSlot(Vector pt, byte slot, BaseItem item, int amount) {
|
||||||
ComplexBlock cblock = etc.getServer().getComplexBlock(
|
ComplexBlock cblock = etc.getServer().getComplexBlock(
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||||
|
|
@ -17,15 +17,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
import java.util.logging.Level;
|
||||||
import java.util.Map;
|
import java.util.logging.Logger;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
import java.util.jar.Attributes;
|
import java.util.jar.Attributes;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for the plugin for hey0's mod.
|
* Entry point for the plugin for hey0's mod.
|
||||||
@ -37,20 +34,10 @@ public class WorldEdit extends Plugin {
|
|||||||
* Logger.
|
* Logger.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
/**
|
|
||||||
* WorldEditLibrary's properties file.
|
|
||||||
*/
|
|
||||||
private PropertiesFile properties;
|
|
||||||
/**
|
/**
|
||||||
* WorldEditLibrary instance.
|
* WorldEditLibrary instance.
|
||||||
*/
|
*/
|
||||||
private static final WorldEditController worldEdit =
|
private static final WorldEditListener listener = new WorldEditListener();
|
||||||
WorldEditController.setup(new HmodServerInterface());
|
|
||||||
/**
|
|
||||||
* Listener for the plugin system.
|
|
||||||
*/
|
|
||||||
private static final HmodWorldEditListener listener =
|
|
||||||
new HmodWorldEditListener();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the plugin.
|
* Initializes the plugin.
|
||||||
@ -70,7 +57,7 @@ public class WorldEdit extends Plugin {
|
|||||||
loader.addListener(PluginLoader.Hook.LOGIN, listener, this,
|
loader.addListener(PluginLoader.Hook.LOGIN, listener, this,
|
||||||
PluginListener.Priority.MEDIUM);
|
PluginListener.Priority.MEDIUM);
|
||||||
|
|
||||||
logger.log(Level.INFO, "WorldEdit version " + getWorldEditVersion() + " loaded.");
|
logger.log(Level.INFO, "WorldEdit version " + getVersion() + " loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,37 +65,8 @@ public class WorldEdit extends Plugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if (properties == null) {
|
listener.loadConfiguration();
|
||||||
properties = new PropertiesFile("worldedit.properties");
|
listener.registerCommands();
|
||||||
} else {
|
|
||||||
properties.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get allowed blocks
|
|
||||||
HashSet<Integer> allowedBlocks = new HashSet<Integer>();
|
|
||||||
for (String b : properties.getString("allowed-blocks",
|
|
||||||
WorldEditController.getDefaultAllowedBlocks()).split(",")) {
|
|
||||||
try {
|
|
||||||
allowedBlocks.add(Integer.parseInt(b));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
worldEdit.setAllowedBlocks(allowedBlocks);
|
|
||||||
|
|
||||||
worldEdit.setDefaultChangeLimit(
|
|
||||||
Math.max(-1, properties.getInt("max-blocks-changed", -1)));
|
|
||||||
|
|
||||||
String snapshotsDir = properties.getString("snapshots-dir", "");
|
|
||||||
if (!snapshotsDir.trim().equals("")) {
|
|
||||||
worldEdit.setSnapshotRepository(new SnapshotRepository(snapshotsDir));
|
|
||||||
}
|
|
||||||
|
|
||||||
String shellSaveType = properties.getString("shell-save-type", "").trim();
|
|
||||||
worldEdit.setShellSaveType(shellSaveType.equals("") ? null : shellSaveType);
|
|
||||||
|
|
||||||
for (Map.Entry<String,String> entry : worldEdit.getCommands().entrySet()) {
|
|
||||||
etc.getInstance().addCommand(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,11 +74,8 @@ public class WorldEdit extends Plugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
for (String key : worldEdit.getCommands().keySet()) {
|
listener.deregisterCommands();
|
||||||
etc.getInstance().removeCommand(key);
|
listener.clearSessions();
|
||||||
}
|
|
||||||
|
|
||||||
worldEdit.clearSessions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,7 +83,7 @@ public class WorldEdit extends Plugin {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getWorldEditVersion() {
|
private String getVersion() {
|
||||||
try {
|
try {
|
||||||
String classContainer = WorldEdit.class.getProtectionDomain()
|
String classContainer = WorldEdit.class.getProtectionDomain()
|
||||||
.getCodeSource().getLocation().toString();
|
.getCodeSource().getLocation().toString();
|
||||||
|
@ -17,65 +17,64 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
import java.util.Map;
|
||||||
import com.sk89q.worldedit.snapshots.Snapshot;
|
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
import com.sk89q.worldedit.blocks.*;
|
|
||||||
import com.sk89q.worldedit.data.*;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.snapshots.InvalidSnapshotException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import com.sk89q.worldedit.*;
|
||||||
|
import com.sk89q.worldedit.blocks.*;
|
||||||
|
import com.sk89q.worldedit.data.*;
|
||||||
|
import com.sk89q.worldedit.snapshots.*;
|
||||||
|
import com.sk89q.worldedit.regions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin base.
|
* Plugin base.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class WorldEditController {
|
public class WorldEditListener extends PluginListener {
|
||||||
/**
|
/**
|
||||||
* WorldEditLibrary instance.
|
* Logger.
|
||||||
*/
|
*/
|
||||||
private static WorldEditController instance;
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
/**
|
|
||||||
* Server interface.
|
|
||||||
*/
|
|
||||||
private ServerInterface server;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of default allowed blocks.
|
* Default list of allowed block types.
|
||||||
*/
|
*/
|
||||||
private final static Integer[] DEFAULT_ALLOWED_BLOCKS = {
|
private final static Integer[] DEFAULT_ALLOWED_BLOCKS = {
|
||||||
0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||||
20, 35, 41, 42, 43, 44, 45, 47, 48, 49, 52, 53, 54, 56, 57, 58, 60,
|
20, 35, 41, 42, 43, 44, 45, 47, 48, 49, 52, 53, 54, 56, 57, 58, 60,
|
||||||
61, 62, 67, 73, 78, 79, 80, 82, 85, 86, 87, 88, 89, 91
|
61, 62, 67, 73, 78, 79, 80, 82, 85, 86, 87, 88, 89, 91
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* WorldEditLibrary's properties file.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
private PropertiesFile properties;
|
||||||
/**
|
/**
|
||||||
* Stores the WorldEditLibrary sessions of players.
|
* Stores a list of WorldEdit sessions, keyed by players' names. Sessions
|
||||||
|
* persist only for the user's session. On disconnect, the session will be
|
||||||
|
* removed. Sessions are created only when they are needed and those
|
||||||
|
* without any WorldEdit abilities or never use WorldEdit in a session will
|
||||||
|
* not have a session object generated for them.
|
||||||
*/
|
*/
|
||||||
private HashMap<WorldEditPlayer,WorldEditSession> sessions =
|
private HashMap<WorldEditPlayer,WorldEditSession> sessions =
|
||||||
new HashMap<WorldEditPlayer,WorldEditSession>();
|
new HashMap<WorldEditPlayer,WorldEditSession>();
|
||||||
/**
|
/**
|
||||||
* Stores the commands.
|
* List of commands. These are checked when onCommand() is called, so
|
||||||
|
* the list must know about every command. On plugin load, the commands
|
||||||
|
* will be loaded into help. On unload, they will be removed.
|
||||||
*/
|
*/
|
||||||
private HashMap<String,String> commands = new HashMap<String,String>();
|
private HashMap<String,String> commands = new HashMap<String,String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of the blocks that can be used. If null, all blocks can be used.
|
* List of allowed blocks.
|
||||||
*/
|
*/
|
||||||
private HashSet<Integer> allowedBlocks;
|
private HashSet<Integer> allowedBlocks;
|
||||||
/**
|
/**
|
||||||
* Default block change limit. -1 for no limit.
|
* Default maximum number of blocks that can be changed in one operation.
|
||||||
*/
|
*/
|
||||||
private int defaultChangeLimit = -1;
|
private int defaultChangeLimit = -1;
|
||||||
/**
|
/**
|
||||||
@ -83,45 +82,15 @@ public class WorldEditController {
|
|||||||
*/
|
*/
|
||||||
private String shellSaveType;
|
private String shellSaveType;
|
||||||
/**
|
/**
|
||||||
* Stores the snapshot repository. May be null;
|
* Snapshot repository used for restoring from backups. This may be null
|
||||||
|
* if snapshot restoration is not configured.
|
||||||
*/
|
*/
|
||||||
private SnapshotRepository snapshotRepo;
|
private SnapshotRepository snapshotRepo;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up an instance.
|
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static WorldEditController setup(ServerInterface server) {
|
|
||||||
WorldEditController worldEdit = new WorldEditController();
|
|
||||||
worldEdit.server = server;
|
|
||||||
instance = worldEdit;
|
|
||||||
return worldEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get WorldEditLibrary instance.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static WorldEditController getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get server interface.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static ServerInterface getServer() {
|
|
||||||
return instance.server;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance of the plugin.
|
* Construct an instance of the plugin.
|
||||||
*/
|
*/
|
||||||
private WorldEditController() {
|
public WorldEditListener() {
|
||||||
// Note: Commands should only have the phrase 'air' at the end
|
// Note: Commands should only have the phrase 'air' at the end
|
||||||
// for now (see SMWorldEditListener.canUseCommand)
|
// for now (see SMWorldEditListener.canUseCommand)
|
||||||
commands.put("//pos1", "Set editing position #1");
|
commands.put("//pos1", "Set editing position #1");
|
||||||
@ -193,7 +162,7 @@ public class WorldEditController {
|
|||||||
return sessions.get(player);
|
return sessions.get(player);
|
||||||
} else {
|
} else {
|
||||||
WorldEditSession session = new WorldEditSession();
|
WorldEditSession session = new WorldEditSession();
|
||||||
session.setBlockChangeLimit(getDefaultChangeLimit());
|
session.setBlockChangeLimit(defaultChangeLimit);
|
||||||
sessions.put(player, session);
|
sessions.put(player, session);
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
@ -1166,25 +1135,6 @@ public class WorldEditController {
|
|||||||
sessions.clear();
|
sessions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the list of commands.
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*/
|
|
||||||
public HashMap<String,String> getCommands() {
|
|
||||||
return commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the list of allowed blocks. Provided null to use the default list.
|
|
||||||
*
|
|
||||||
* @param allowedBlocks
|
|
||||||
*/
|
|
||||||
public void setAllowedBlocks(HashSet<Integer> allowedBlocks) {
|
|
||||||
this.allowedBlocks = allowedBlocks != null ? allowedBlocks
|
|
||||||
: new HashSet<Integer>(Arrays.asList(DEFAULT_ALLOWED_BLOCKS));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a comma-delimited list of the default allowed blocks.
|
* Get a comma-delimited list of the default allowed blocks.
|
||||||
*
|
*
|
||||||
@ -1197,49 +1147,228 @@ public class WorldEditController {
|
|||||||
}
|
}
|
||||||
return b.substring(0, b.length() - 1);
|
return b.substring(0, b.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the defaultChangeLimit
|
*
|
||||||
|
* @param player
|
||||||
*/
|
*/
|
||||||
public int getDefaultChangeLimit() {
|
@Override
|
||||||
return defaultChangeLimit;
|
public void onDisconnect(Player player) {
|
||||||
|
removeSession(new WorldEditPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default limit on the number of blocks that can be changed
|
* Called on right click.
|
||||||
* in one operation.
|
*
|
||||||
*
|
* @param modPlayer
|
||||||
* @param defaultChangeLimit the defaultChangeLimit to set
|
* @param blockPlaced
|
||||||
|
* @param blockClicked
|
||||||
|
* @param itemInHand
|
||||||
|
* @return false if you want the action to go through
|
||||||
*/
|
*/
|
||||||
public void setDefaultChangeLimit(int defaultChangeLimit) {
|
@Override
|
||||||
this.defaultChangeLimit = defaultChangeLimit;
|
public boolean onBlockCreate(Player modPlayer, Block blockPlaced,
|
||||||
|
Block blockClicked, int itemInHand) {
|
||||||
|
WorldEditPlayer player = new WorldEditPlayer(modPlayer);
|
||||||
|
|
||||||
|
if (itemInHand != 271) { return false; }
|
||||||
|
if (!canUseCommand(modPlayer, "//pos2")) { return false; }
|
||||||
|
|
||||||
|
WorldEditSession session = getSession(player);
|
||||||
|
|
||||||
|
if (session.isToolControlEnabled()) {
|
||||||
|
Vector cur = Vector.toBlockPoint(blockClicked.getX(),
|
||||||
|
blockClicked.getY(),
|
||||||
|
blockClicked.getZ());
|
||||||
|
|
||||||
|
session.setPos2(cur);
|
||||||
|
player.print("Second edit position set.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the snapshotRepo
|
* Called on left click.
|
||||||
|
*
|
||||||
|
* @param modPlayer
|
||||||
|
* @param blockClicked
|
||||||
|
* @param itemInHand
|
||||||
|
* @return false if you want the action to go through
|
||||||
*/
|
*/
|
||||||
public SnapshotRepository getSnapshotRepo() {
|
@Override
|
||||||
return snapshotRepo;
|
public boolean onBlockDestroy(Player modPlayer, Block blockClicked) {
|
||||||
|
if (!canUseCommand(modPlayer, "//pos1")
|
||||||
|
&& !canUseCommand(modPlayer, "//")) { return false; }
|
||||||
|
|
||||||
|
WorldEditPlayer player = new WorldEditPlayer(modPlayer);
|
||||||
|
WorldEditSession session = getSession(player);
|
||||||
|
|
||||||
|
if (player.getItemInHand() == 271) {
|
||||||
|
if (session.isToolControlEnabled()) {
|
||||||
|
Vector cur = Vector.toBlockPoint(blockClicked.getX(),
|
||||||
|
blockClicked.getY(),
|
||||||
|
blockClicked.getZ());
|
||||||
|
|
||||||
|
// Bug workaround
|
||||||
|
if (cur.getBlockX() == 0 && cur.getBlockY() == 0
|
||||||
|
&& cur.getBlockZ() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (session.getPos1().equals(cur)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (IncompleteRegionException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
session.setPos1(cur);
|
||||||
|
player.print("First edit position set.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (player.isHoldingPickAxe()) {
|
||||||
|
if (session.hasSuperPickAxe()) {
|
||||||
|
Vector pos = new Vector(blockClicked.getX(),
|
||||||
|
blockClicked.getY(), blockClicked.getZ());
|
||||||
|
if (ServerInterface.getBlockType(pos) == 7
|
||||||
|
&& !canUseCommand(modPlayer, "/worldeditbedrock")) {
|
||||||
|
return true;
|
||||||
|
} else if (ServerInterface.getBlockType(pos) == 46) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerInterface.setBlockType(pos, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param snapshotRepo the snapshotRepo to set
|
*
|
||||||
|
* @param ply
|
||||||
|
* @param split
|
||||||
|
* @return whether the command was processed
|
||||||
*/
|
*/
|
||||||
public void setSnapshotRepository(SnapshotRepository snapshotRepo) {
|
@Override
|
||||||
this.snapshotRepo = snapshotRepo;
|
public boolean onCommand(Player ply, String[] split) {
|
||||||
|
try {
|
||||||
|
// Legacy /, command
|
||||||
|
if (split[0].equals("/,")) {
|
||||||
|
split[0] = "//";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commands.containsKey(split[0].toLowerCase())) {
|
||||||
|
if (canUseCommand(ply, split[0])) {
|
||||||
|
WorldEditPlayer player = new WorldEditPlayer(ply);
|
||||||
|
WorldEditSession session = getSession(player);
|
||||||
|
EditSession editSession =
|
||||||
|
new EditSession(session.getBlockChangeLimit());
|
||||||
|
editSession.enableQueue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
return performCommand(player, session, editSession, split);
|
||||||
|
} finally {
|
||||||
|
session.remember(editSession);
|
||||||
|
editSession.flushQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ply.sendMessage(Colors.Rose + "Number expected; string given.");
|
||||||
|
} catch (IncompleteRegionException e2) {
|
||||||
|
ply.sendMessage(Colors.Rose + "The edit region has not been fully defined.");
|
||||||
|
} catch (UnknownItemException e3) {
|
||||||
|
ply.sendMessage(Colors.Rose + "Block name was not recognized.");
|
||||||
|
} catch (DisallowedItemException e4) {
|
||||||
|
ply.sendMessage(Colors.Rose + "Block not allowed (see WorldEdit configuration).");
|
||||||
|
} catch (MaxChangedBlocksException e5) {
|
||||||
|
ply.sendMessage(Colors.Rose + "The maximum number of blocks changed ("
|
||||||
|
+ e5.getBlockLimit() + ") in an instance was reached.");
|
||||||
|
} catch (UnknownDirectionException ue) {
|
||||||
|
ply.sendMessage(Colors.Rose + "Unknown direction: " + ue.getDirection());
|
||||||
|
} catch (InsufficientArgumentsException e6) {
|
||||||
|
ply.sendMessage(Colors.Rose + e6.getMessage());
|
||||||
|
} catch (EmptyClipboardException ec) {
|
||||||
|
ply.sendMessage(Colors.Rose + "Your clipboard is empty.");
|
||||||
|
} catch (WorldEditException e7) {
|
||||||
|
ply.sendMessage(Colors.Rose + e7.getMessage());
|
||||||
|
} catch (Throwable excp) {
|
||||||
|
ply.sendMessage(Colors.Rose + "Please report this error: [See console]");
|
||||||
|
ply.sendMessage(excp.getClass().getName() + ": " + excp.getMessage());
|
||||||
|
excp.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the shellSaveType
|
* Checks to see if the player can use a command or /worldedit.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param command
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getShellSaveType() {
|
private boolean canUseCommand(Player player, String command) {
|
||||||
return shellSaveType;
|
return player.canUseCommand(command.replace("air", ""))
|
||||||
|
|| player.canUseCommand("/worldedit");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param shellSaveType the shellSaveType to set
|
* Loads the configuration.
|
||||||
*/
|
*/
|
||||||
public void setShellSaveType(String shellSaveType) {
|
public void loadConfiguration() {
|
||||||
this.shellSaveType = shellSaveType;
|
if (properties == null) {
|
||||||
|
properties = new PropertiesFile("worldedit.properties");
|
||||||
|
} else {
|
||||||
|
properties.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get allowed blocks
|
||||||
|
allowedBlocks = new HashSet<Integer>();
|
||||||
|
for (String b : properties.getString("allowed-blocks",
|
||||||
|
WorldEditListener.getDefaultAllowedBlocks()).split(",")) {
|
||||||
|
try {
|
||||||
|
allowedBlocks.add(Integer.parseInt(b));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultChangeLimit = Math.max(-1, properties.getInt("max-blocks-changed", -1));
|
||||||
|
|
||||||
|
String snapshotsDir = properties.getString("snapshots-dir", "");
|
||||||
|
if (!snapshotsDir.trim().equals("")) {
|
||||||
|
snapshotRepo = new SnapshotRepository(snapshotsDir);
|
||||||
|
} else {
|
||||||
|
snapshotRepo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type = properties.getString("shell-save-type", "").trim();
|
||||||
|
shellSaveType = type.equals("") ? null : type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register commands with help.
|
||||||
|
*/
|
||||||
|
public void registerCommands() {
|
||||||
|
for (Map.Entry<String,String> entry : commands.entrySet()) {
|
||||||
|
etc.getInstance().addCommand(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De-register commands.
|
||||||
|
*/
|
||||||
|
public void deregisterCommands() {
|
||||||
|
for (String key : commands.keySet()) {
|
||||||
|
etc.getInstance().removeCommand(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,76 +18,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public abstract class WorldEditPlayer {
|
public class WorldEditPlayer {
|
||||||
/**
|
/**
|
||||||
* Server interface.
|
* Stores the player.
|
||||||
*/
|
*/
|
||||||
protected ServerInterface server;
|
private Player player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the player.
|
* Construct the object.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
*/
|
*/
|
||||||
public WorldEditPlayer() {
|
public WorldEditPlayer(Player player) {
|
||||||
server = WorldEditController.getServer();
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of the player.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public abstract String getName();
|
|
||||||
/**
|
|
||||||
* Get the point of the block that is being stood upon.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public abstract Vector getBlockOn();
|
|
||||||
/**
|
|
||||||
* Get the point of the block that is being stood in.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public abstract Vector getBlockIn();
|
|
||||||
/**
|
|
||||||
* Get the point of the block being looked at. May return null.
|
|
||||||
*
|
|
||||||
* @param range
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public abstract Vector getBlockTrace(int range);
|
|
||||||
/**
|
|
||||||
* Get the player's position.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public abstract Vector getPosition();
|
|
||||||
/**
|
|
||||||
* Get the player's view pitch.
|
|
||||||
*
|
|
||||||
* @return pitch
|
|
||||||
*/
|
|
||||||
public abstract double getPitch();
|
|
||||||
/**
|
|
||||||
* Get the player's view yaw.
|
|
||||||
*
|
|
||||||
* @return yaw
|
|
||||||
*/
|
|
||||||
public abstract double getYaw();
|
|
||||||
/**
|
|
||||||
* Get the ID of the item that the player is holding.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract int getItemInHand();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the player is holding a pick axe.
|
* Returns true if the player is holding a pick axe.
|
||||||
*
|
*
|
||||||
@ -99,36 +50,6 @@ public abstract class WorldEditPlayer {
|
|||||||
|| item == 285;
|
|| item == 285;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's cardinal direction (N, W, NW, etc.).
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract String getCardinalDirection();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a WorldEditLibrary message.
|
|
||||||
*
|
|
||||||
* @param msg
|
|
||||||
*/
|
|
||||||
public abstract void print(String msg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a WorldEditLibrary error.
|
|
||||||
*
|
|
||||||
* @param msg
|
|
||||||
*/
|
|
||||||
public abstract void printError(String msg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move the player.
|
|
||||||
*
|
|
||||||
* @param pos
|
|
||||||
* @param pitch
|
|
||||||
* @param yaw
|
|
||||||
*/
|
|
||||||
public abstract void setPosition(Vector pos, float pitch, float yaw);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the player.
|
* Move the player.
|
||||||
*
|
*
|
||||||
@ -182,14 +103,6 @@ public abstract class WorldEditPlayer {
|
|||||||
findFreePosition(getBlockIn());
|
findFreePosition(getBlockIn());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pass through the wall that you are looking at.
|
|
||||||
*
|
|
||||||
* @param range
|
|
||||||
* @return whether a wall was passed through
|
|
||||||
*/
|
|
||||||
public abstract boolean passThroughForwardWall(int range);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go up one level to the next free space above.
|
* Go up one level to the next free space above.
|
||||||
*
|
*
|
||||||
@ -205,7 +118,7 @@ public abstract class WorldEditPlayer {
|
|||||||
byte spots = 0;
|
byte spots = 0;
|
||||||
|
|
||||||
while (y <= 129) {
|
while (y <= 129) {
|
||||||
if (server.getBlockType(new Vector(x, y, z)) == 0) {
|
if (ServerInterface.getBlockType(new Vector(x, y, z)) == 0) {
|
||||||
free++;
|
free++;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
@ -214,7 +127,7 @@ public abstract class WorldEditPlayer {
|
|||||||
if (free == 2) {
|
if (free == 2) {
|
||||||
spots++;
|
spots++;
|
||||||
if (spots == 2) {
|
if (spots == 2) {
|
||||||
int type = server.getBlockType(new Vector(x, y - 2, z));
|
int type = ServerInterface.getBlockType(new Vector(x, y - 2, z));
|
||||||
|
|
||||||
// Don't get put in lava!
|
// Don't get put in lava!
|
||||||
if (type == 10 || type == 11) {
|
if (type == 10 || type == 11) {
|
||||||
@ -246,7 +159,7 @@ public abstract class WorldEditPlayer {
|
|||||||
byte free = 0;
|
byte free = 0;
|
||||||
|
|
||||||
while (y >= 1) {
|
while (y >= 1) {
|
||||||
if (server.getBlockType(new Vector(x, y, z)) == 0) {
|
if (ServerInterface.getBlockType(new Vector(x, y, z)) == 0) {
|
||||||
free++;
|
free++;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
@ -257,7 +170,7 @@ public abstract class WorldEditPlayer {
|
|||||||
// lightly and also check to see if there's something to
|
// lightly and also check to see if there's something to
|
||||||
// stand upon
|
// stand upon
|
||||||
while (y >= 0) {
|
while (y >= 0) {
|
||||||
int type = server.getBlockType(new Vector(x, y, z));
|
int type = ServerInterface.getBlockType(new Vector(x, y, z));
|
||||||
|
|
||||||
// Don't want to end up in lava
|
// Don't want to end up in lava
|
||||||
if (type != 0 && type != 10 && type != 11) {
|
if (type != 0 && type != 10 && type != 11) {
|
||||||
@ -292,15 +205,15 @@ public abstract class WorldEditPlayer {
|
|||||||
int z = pos.getBlockZ();
|
int z = pos.getBlockZ();
|
||||||
|
|
||||||
// No free space above
|
// No free space above
|
||||||
if (server.getBlockType(new Vector(x, y, z)) != 0) {
|
if (ServerInterface.getBlockType(new Vector(x, y, z)) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (y <= 127) {
|
while (y <= 127) {
|
||||||
// Found a ceiling!
|
// Found a ceiling!
|
||||||
if (server.getBlockType(new Vector(x, y, z)) != 0) {
|
if (ServerInterface.getBlockType(new Vector(x, y, z)) != 0) {
|
||||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||||
server.setBlockType(new Vector(x, platformY, z),
|
ServerInterface.setBlockType(new Vector(x, platformY, z),
|
||||||
BlockType.GLASS.getID());
|
BlockType.GLASS.getID());
|
||||||
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
|
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
|
||||||
return true;
|
return true;
|
||||||
@ -312,14 +225,6 @@ public abstract class WorldEditPlayer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the player an item.
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param amt
|
|
||||||
*/
|
|
||||||
public abstract void giveItem(int type, int amt);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if equal.
|
* Returns true if equal.
|
||||||
*
|
*
|
||||||
@ -344,4 +249,193 @@ public abstract class WorldEditPlayer {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getName().hashCode();
|
return getName().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the point of the block that is being stood in.
|
||||||
|
*
|
||||||
|
* @return point
|
||||||
|
*/
|
||||||
|
public Vector getBlockIn() {
|
||||||
|
return Vector.toBlockPoint(player.getX(), player.getY(), player.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the point of the block that is being stood upon.
|
||||||
|
*
|
||||||
|
* @return point
|
||||||
|
*/
|
||||||
|
public Vector getBlockOn() {
|
||||||
|
return Vector.toBlockPoint(player.getX(), player.getY() - 1, player.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the point of the block being looked at. May return null.
|
||||||
|
*
|
||||||
|
* @param range
|
||||||
|
* @return point
|
||||||
|
*/
|
||||||
|
public Vector getBlockTrace(int range) {
|
||||||
|
HitBlox hitBlox = new HitBlox(player, range, 0.2);
|
||||||
|
Block block = hitBlox.getTargetBlock();
|
||||||
|
if (block == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Vector(block.getX(), block.getY(), block.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's cardinal direction (N, W, NW, etc.).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCardinalDirection() {
|
||||||
|
// From hey0's code
|
||||||
|
double rot = (getYaw() - 90) % 360;
|
||||||
|
if (rot < 0) {
|
||||||
|
rot += 360.0;
|
||||||
|
}
|
||||||
|
return etc.getCompassPointForDirection(rot).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID of the item that the player is holding.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Get the ID of the item that the player is holding.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getItemInHand() {
|
||||||
|
return player.getItemInHand();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the player.
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's view pitch.
|
||||||
|
*
|
||||||
|
* @return pitch
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Get the player's view pitch.
|
||||||
|
*
|
||||||
|
* @return pitch
|
||||||
|
*/
|
||||||
|
public double getPitch() {
|
||||||
|
return player.getPitch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's position.
|
||||||
|
*
|
||||||
|
* @return point
|
||||||
|
*/
|
||||||
|
public Vector getPosition() {
|
||||||
|
return new Vector(player.getX(), player.getY(), player.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's view yaw.
|
||||||
|
*
|
||||||
|
* @return yaw
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Get the player's view yaw.
|
||||||
|
*
|
||||||
|
* @return yaw
|
||||||
|
*/
|
||||||
|
public double getYaw() {
|
||||||
|
return player.getRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives the player an item.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param amt
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Gives the player an item.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param amt
|
||||||
|
*/
|
||||||
|
public void giveItem(int type, int amt) {
|
||||||
|
player.giveItem(type, amt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass through the wall that you are looking at.
|
||||||
|
*
|
||||||
|
* @param range
|
||||||
|
* @return whether the player was pass through
|
||||||
|
*/
|
||||||
|
public boolean passThroughForwardWall(int range) {
|
||||||
|
boolean foundNext = false;
|
||||||
|
int searchDist = 0;
|
||||||
|
HitBlox hitBlox = new HitBlox(player, range, 0.2);
|
||||||
|
Block block;
|
||||||
|
while ((block = hitBlox.getNextBlock()) != null) {
|
||||||
|
searchDist++;
|
||||||
|
if (searchDist > 20) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (block.getType() == 0) {
|
||||||
|
if (foundNext) {
|
||||||
|
Vector v = new Vector(block.getX(), block.getY() - 1, block.getZ());
|
||||||
|
if (ServerInterface.getBlockType(v) == 0) {
|
||||||
|
setPosition(v.add(0.5, 0, 0.5));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foundNext = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a WorldEdit message.
|
||||||
|
*
|
||||||
|
* @param msg
|
||||||
|
*/
|
||||||
|
public void print(String msg) {
|
||||||
|
player.sendMessage(Colors.LightPurple + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a WorldEdit error.
|
||||||
|
*
|
||||||
|
* @param msg
|
||||||
|
*/
|
||||||
|
public void printError(String msg) {
|
||||||
|
player.sendMessage(Colors.Rose + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the player.
|
||||||
|
*
|
||||||
|
* @param pos
|
||||||
|
* @param pitch
|
||||||
|
* @param yaw
|
||||||
|
*/
|
||||||
|
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||||
|
Location loc = new Location();
|
||||||
|
loc.x = pos.getX();
|
||||||
|
loc.y = pos.getY();
|
||||||
|
loc.z = pos.getZ();
|
||||||
|
loc.rotX = (float) yaw;
|
||||||
|
loc.rotY = (float) pitch;
|
||||||
|
player.teleportTo(loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldEdit
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public interface ServerInterface {
|
|
||||||
/**
|
|
||||||
* Set block type.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean setBlockType(Vector pt, int type);
|
|
||||||
/**
|
|
||||||
* Get block type.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getBlockType(Vector pt);
|
|
||||||
/**
|
|
||||||
* Set block data.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param data
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void setBlockData(Vector pt, int data);
|
|
||||||
/**
|
|
||||||
* Get block data.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getBlockData(Vector pt);
|
|
||||||
/**
|
|
||||||
* Set sign text.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param text
|
|
||||||
*/
|
|
||||||
public void setSignText(Vector pt, String[] text);
|
|
||||||
/**
|
|
||||||
* Get sign text.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getSignText(Vector pt);
|
|
||||||
/**
|
|
||||||
* Gets the contents of chests.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Map<Byte,Countable<BaseItem>> getChestContents(Vector pt);
|
|
||||||
/**
|
|
||||||
* Sets a chest slot.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param slot
|
|
||||||
* @param item
|
|
||||||
* @param amount
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean setChestSlot(Vector pt, byte slot, BaseItem item, int amount);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user