Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 11:00:04 +01:00
Removed hMod files, simplified configuration and usage.
Dieser Commit ist enthalten in:
Ursprung
a86a96f2d0
Commit
d70a6e3de7
27
INSTALL.txt
27
INSTALL.txt
@ -1,27 +0,0 @@
|
|||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
Bukkit:
|
|
||||||
|
|
||||||
1. Create a "plugins" folder inside your server folder.
|
|
||||||
|
|
||||||
2. Copy WorldEdit.jar into "plugins".
|
|
||||||
|
|
||||||
3. Restart your server.
|
|
||||||
|
|
||||||
You may want to copy config.yml into plugins/WorldEdit/config.yml
|
|
||||||
(you will have to create that folder). Edit it to fit your needs.
|
|
||||||
|
|
||||||
hMod:
|
|
||||||
|
|
||||||
1. Create a "plugins" folder inside your "bin" folder.
|
|
||||||
|
|
||||||
2. Copy WorldEdit.jar into "plugins".
|
|
||||||
|
|
||||||
3. Add "WorldEdit" to the "plugins" line of your server.properties file.
|
|
||||||
If it's not already there, add the line. The line should look like this:
|
|
||||||
|
|
||||||
plugins=WorldEdit
|
|
||||||
|
|
||||||
If you have multiple plugins, separate plugin names with commas.
|
|
||||||
Do NOT place jnbt.jar into server.properties.
|
|
19
README.txt
19
README.txt
@ -13,4 +13,23 @@ files, and much more.
|
|||||||
For usage help, see:
|
For usage help, see:
|
||||||
http://github.com/sk89q/worldedit/wiki/Usage
|
http://github.com/sk89q/worldedit/wiki/Usage
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Bukkit:
|
||||||
|
|
||||||
|
1. Create a "plugins" folder inside your server folder.
|
||||||
|
|
||||||
|
2. Copy WorldEdit.jar into "plugins".
|
||||||
|
|
||||||
|
3. Restart your server.
|
||||||
|
|
||||||
|
Default configuration files will be created in plugins/WorldEdit/
|
||||||
|
when WorldEdit is first started. Be sure to edit them and use
|
||||||
|
/reload WorldGuard until you are satisfied (remember to remove the
|
||||||
|
/reload permission from everyone when you are done).
|
||||||
|
|
||||||
|
Thanks
|
||||||
|
------
|
||||||
|
|
||||||
Thanks to grum for writing the terrain smoother.
|
Thanks to grum for writing the terrain smoother.
|
20
build.xml
20
build.xml
@ -18,8 +18,6 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<fileset dir="${lib.dir}">
|
<fileset dir="${lib.dir}">
|
||||||
<include name="truezip.jar" />
|
<include name="truezip.jar" />
|
||||||
<include name="Minecraft_Mod.jar" />
|
|
||||||
<include name="minecraft_server.jar" />
|
|
||||||
<include name="minecraft_server_cb.jar" />
|
<include name="minecraft_server_cb.jar" />
|
||||||
<include name="CraftBukkit.jar" />
|
<include name="CraftBukkit.jar" />
|
||||||
<include name="Bukkit.jar" />
|
<include name="Bukkit.jar" />
|
||||||
@ -35,10 +33,13 @@
|
|||||||
<attribute name="Implementation-Title" value="WorldEdit"/>
|
<attribute name="Implementation-Title" value="WorldEdit"/>
|
||||||
<attribute name="Implementation-Version" value="${version}"/>
|
<attribute name="Implementation-Version" value="${version}"/>
|
||||||
<attribute name="WorldEdit-Version" value="${version}"/>
|
<attribute name="WorldEdit-Version" value="${version}"/>
|
||||||
<attribute name="Class-Path" value="truezip.jar"/>
|
<attribute name="Class-Path" value="truezip.jar WorldEdit/truezip.jar"/>
|
||||||
<!--<attribute name="Main-Class" value="com.sk89q.worldedit.cli.Main"/>-->
|
<!--<attribute name="Main-Class" value="com.sk89q.worldedit.cli.Main"/>-->
|
||||||
</manifest>
|
</manifest>
|
||||||
|
<replace file="${build.dir}/plugin.yml" token="WEVERSIONMACRO" value="${version}"/>
|
||||||
<copy tofile="${build.dir}/plugin.yml" file="plugin.yml"/>
|
<copy tofile="${build.dir}/plugin.yml" file="plugin.yml"/>
|
||||||
|
<mkdir dir="${build.dir}/defaults"/>
|
||||||
|
<copy tofile="${build.dir}/defaults/config.yml" file="config.yml"/>
|
||||||
<jar jarfile="${dist.dir}/WorldEdit.jar" basedir="${build.dir}" manifest="manifest.mf" />
|
<jar jarfile="${dist.dir}/WorldEdit.jar" basedir="${build.dir}" manifest="manifest.mf" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -54,15 +55,10 @@
|
|||||||
<antcall target="jar"/>
|
<antcall target="jar"/>
|
||||||
<delete dir="${release.dir}"/>
|
<delete dir="${release.dir}"/>
|
||||||
<mkdir dir="${release.dir}"/>
|
<mkdir dir="${release.dir}"/>
|
||||||
<copy todir="${release.dir}">
|
<copy tofile="${release.dir}/CHANGELOG.txt" file="CHANGELOG.txt"/>
|
||||||
<fileset dir="."/>
|
<copy tofile="${release.dir}/LICENSE.txt" file="LICENSE.txt"/>
|
||||||
<globmapper from="*.txt" to="*.txt"/>
|
<copy tofile="${release.dir}/NOTICE.txt" file="NOTICE.txt"/>
|
||||||
</copy>
|
<copy tofile="${release.dir}/README.txt" file="README.txt"/>
|
||||||
<copy tofile="${release.dir}/config.yml" file="config.yml"/>
|
|
||||||
<copy tofile="${release.dir}/worldedit.updatr" file="worldedit.updatr"/>
|
|
||||||
<replace file="${release.dir}/worldedit.updatr" token="%version%" value="${version}"/>
|
|
||||||
<copy tofile="${release.dir}/plugin.yml" file="plugin.yml"/>
|
|
||||||
<replace file="${release.dir}/plugin.yml" token="WEVERSIONMACRO" value="${version}"/>
|
|
||||||
<copy tofile="${release.dir}/WorldEdit.jar" file="${dist.dir}/WorldEdit.jar"/>
|
<copy tofile="${release.dir}/WorldEdit.jar" file="${dist.dir}/WorldEdit.jar"/>
|
||||||
<zip destfile="${release.dir}/worldedit-${version}.zip" basedir="${release.dir}" excludes="*.zip plugin.yml"/>
|
<zip destfile="${release.dir}/worldedit-${version}.zip" basedir="${release.dir}" excludes="*.zip plugin.yml"/>
|
||||||
<mkdir dir="${release.dir}/src"/>
|
<mkdir dir="${release.dir}/src"/>
|
||||||
|
37
config.yml
37
config.yml
@ -1,3 +1,20 @@
|
|||||||
|
#
|
||||||
|
# WorldEdit's configuration file
|
||||||
|
#
|
||||||
|
# About editing this file:
|
||||||
|
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If
|
||||||
|
# you use an editor like Notepad++ (recommended for Windows users), you
|
||||||
|
# must configure it to "replace tabs with spaces." In Notepad++, this can
|
||||||
|
# be changed in Settings > Preferences > Language Menu.
|
||||||
|
# - Don't get rid of the indents. They are indented so some entries are
|
||||||
|
# in categories (like "max-blocks-changed" is in the "limits"
|
||||||
|
# category.
|
||||||
|
# - If you want to check the format of this file before putting it
|
||||||
|
# into WorldEdit, paste it into http://yaml-online-parser.appspot.com/
|
||||||
|
# and see if it gives "ERROR:".
|
||||||
|
# - Lines starting with # are commentsand so they are ignored.
|
||||||
|
#
|
||||||
|
|
||||||
limits:
|
limits:
|
||||||
max-blocks-changed:
|
max-blocks-changed:
|
||||||
default: -1
|
default: -1
|
||||||
@ -6,32 +23,40 @@ limits:
|
|||||||
max-super-pickaxe-size: 5
|
max-super-pickaxe-size: 5
|
||||||
max-brush-radius: 5
|
max-brush-radius: 5
|
||||||
disallowed-blocks: [6, 7, 14, 15, 16, 21, 22, 23, 24, 25, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83]
|
disallowed-blocks: [6, 7, 14, 15, 16, 21, 22, 23, 24, 25, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83]
|
||||||
|
|
||||||
use-inventory:
|
use-inventory:
|
||||||
enable: false
|
enable: false
|
||||||
allow-override: true
|
allow-override: true
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
log-commands: false
|
log-commands: false
|
||||||
file: worldedit.log
|
file: worldedit.log
|
||||||
|
|
||||||
super-pickaxe:
|
super-pickaxe:
|
||||||
drop-items: true
|
drop-items: true
|
||||||
many-drop-items: false
|
many-drop-items: false
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
directory:
|
directory:
|
||||||
|
|
||||||
shell-save-type:
|
shell-save-type:
|
||||||
no-double-slash: false
|
no-double-slash: false
|
||||||
debug: false
|
debug: false
|
||||||
|
|
||||||
|
# Change sk89q to your name (or sk89q will be able to use WorldEdit
|
||||||
|
# on your server!). Check the documentation to see how to configure this
|
||||||
|
#
|
||||||
|
# NOTE: The /reload permission is given to everyone below (only applies to
|
||||||
|
# WorldEdit) so that you can reload WorldEdit with /reload WorldEdit
|
||||||
|
# until your configuration work is done
|
||||||
permissions:
|
permissions:
|
||||||
groups:
|
groups:
|
||||||
default:
|
default:
|
||||||
permissions:
|
permissions:
|
||||||
- /worldeditselect
|
- /reload
|
||||||
example:
|
|
||||||
permissions:
|
|
||||||
- /worldeditselect
|
- /worldeditselect
|
||||||
users:
|
users:
|
||||||
sk89q:
|
sk89q:
|
||||||
groups:
|
|
||||||
- example
|
|
||||||
permissions:
|
permissions:
|
||||||
- /reload
|
|
||||||
- /worldedit
|
- /worldedit
|
||||||
|
- /reload
|
@ -1,123 +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 java.io.IOException;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.logging.FileHandler;
|
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import com.sk89q.util.StringUtil;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
|
||||||
import com.sk89q.worldedit.LogFormat;
|
|
||||||
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for hMod.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HMConfiguration extends LocalConfiguration {
|
|
||||||
/**
|
|
||||||
* Logger.
|
|
||||||
*/
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Properties file.
|
|
||||||
*/
|
|
||||||
private PropertiesFile properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the object.
|
|
||||||
*/
|
|
||||||
public HMConfiguration() {
|
|
||||||
properties = new PropertiesFile("worldedit.properties");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the configuration.
|
|
||||||
*/
|
|
||||||
public void load() {
|
|
||||||
try {
|
|
||||||
properties.load();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.warning("worldedit.properties could not be loaded: "
|
|
||||||
+ e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = properties.getBoolean("debug-profile", profile);
|
|
||||||
wandItem = properties.getInt("wand-item", wandItem);
|
|
||||||
defaultChangeLimit = Math.max(-1, properties.getInt(
|
|
||||||
"default-max-blocks-changed", defaultChangeLimit));
|
|
||||||
maxChangeLimit = Math.max(-1,
|
|
||||||
properties.getInt("max-blocks-changed", maxChangeLimit));
|
|
||||||
maxRadius = Math.max(-1, properties.getInt("max-radius", maxRadius));
|
|
||||||
maxSuperPickaxeSize = Math.max(1, properties.getInt(
|
|
||||||
"max-super-pickaxe-size", maxSuperPickaxeSize));
|
|
||||||
registerHelp = properties.getBoolean("register-help", registerHelp);
|
|
||||||
logComands = properties.getBoolean("log-commands", logComands);
|
|
||||||
superPickaxeDrop = properties.getBoolean("super-pickaxe-drop-items",
|
|
||||||
superPickaxeDrop);
|
|
||||||
superPickaxeManyDrop = properties.getBoolean(
|
|
||||||
"super-pickaxe-many-drop-items", superPickaxeManyDrop);
|
|
||||||
noDoubleSlash = properties.getBoolean("no-double-slash", noDoubleSlash);
|
|
||||||
useInventory = properties.getBoolean("use-inventory", useInventory);
|
|
||||||
useInventoryOverride = properties.getBoolean("use-inventory-override",
|
|
||||||
useInventoryOverride);
|
|
||||||
maxBrushRadius = properties.getInt("max-brush-radius", maxBrushRadius);
|
|
||||||
|
|
||||||
// Get disallowed blocks
|
|
||||||
disallowedBlocks = new HashSet<Integer>();
|
|
||||||
String defdisallowedBlocks = StringUtil.joinString(defaultDisallowedBlocks, ",", 0);
|
|
||||||
for (String b : properties.getString("disallowed-blocks",
|
|
||||||
defdisallowedBlocks).split(",")) {
|
|
||||||
try {
|
|
||||||
disallowedBlocks.add(Integer.parseInt(b));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
String logFile = properties.getString("log-file", "");
|
|
||||||
if (!logFile.equals("")) {
|
|
||||||
try {
|
|
||||||
FileHandler handler = new FileHandler(logFile, true);
|
|
||||||
handler.setFormatter(new LogFormat());
|
|
||||||
logger.addHandler(handler);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.log(Level.WARNING, "Could not use log file " + logFile + ": "
|
|
||||||
+ e.getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (Handler handler : logger.getHandlers()) {
|
|
||||||
logger.removeHandler(handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,269 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldEditLibrary
|
|
||||||
* 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.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.WorldVector;
|
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HMPlayer extends LocalPlayer {
|
|
||||||
/**
|
|
||||||
* Stores the player.
|
|
||||||
*/
|
|
||||||
private Player player;
|
|
||||||
/**
|
|
||||||
* World.
|
|
||||||
*/
|
|
||||||
private HMWorld world;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the object.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
public HMPlayer(ServerInterface server, HMWorld world, Player player) {
|
|
||||||
super(server);
|
|
||||||
this.player = player;
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move the player.
|
|
||||||
*
|
|
||||||
* @param pos
|
|
||||||
*/
|
|
||||||
public void setPosition(Vector pos) {
|
|
||||||
setPosition(pos, (float)getPitch(), (float)getYaw());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the point of the block being looked at. May return null.
|
|
||||||
*
|
|
||||||
* @param range
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public WorldVector getBlockTrace(int range) {
|
|
||||||
HitBlox hitBlox = new HitBlox(player,range, 0.2);
|
|
||||||
Block block = hitBlox.getTargetBlock();
|
|
||||||
if (block == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new WorldVector(world, block.getX(), block.getY(), block.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the point of the block being looked at. May return null.
|
|
||||||
*
|
|
||||||
* @param range
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public WorldVector getSolidBlockTrace(int range) {
|
|
||||||
HitBlox hitBlox = new HitBlox(player,range, 0.2);
|
|
||||||
Block block = null;
|
|
||||||
|
|
||||||
while (hitBlox.getNextBlock() != null
|
|
||||||
&& BlockType.canPassThrough(hitBlox.getCurBlock().getType()));
|
|
||||||
|
|
||||||
block = hitBlox.getCurBlock();
|
|
||||||
|
|
||||||
if (block == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new WorldVector(world, block.getX(), block.getY(), block.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
public double getPitch() {
|
|
||||||
return player.getPitch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's position.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public WorldVector getPosition() {
|
|
||||||
return new WorldVector(world, player.getX(), player.getY(), player.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's world.
|
|
||||||
*
|
|
||||||
* @return point
|
|
||||||
*/
|
|
||||||
public LocalWorld getWorld() {
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player's view yaw.
|
|
||||||
*
|
|
||||||
* @return yaw
|
|
||||||
*/
|
|
||||||
public double getYaw() {
|
|
||||||
return player.getRotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
LocalWorld world = getPosition().getWorld();
|
|
||||||
Block block;
|
|
||||||
while ((block = hitBlox.getNextBlock()) != null) {
|
|
||||||
searchDist++;
|
|
||||||
if (searchDist > 20) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (BlockType.canPassThrough(block.getType())) {
|
|
||||||
if (foundNext) {
|
|
||||||
Vector v = new Vector(block.getX(), block.getY() - 1, block.getZ());
|
|
||||||
if (BlockType.canPassThrough(world.getBlockType(v))) {
|
|
||||||
setPosition(v.add(0.5, 0, 0.5));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
foundNext = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a message.
|
|
||||||
*
|
|
||||||
* @param msg
|
|
||||||
*/
|
|
||||||
public void printRaw(String msg) {
|
|
||||||
player.sendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a player's list of groups.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getGroups() {
|
|
||||||
return player.getGroups();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a player has permission.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean hasPermission(String perm) {
|
|
||||||
return player.canUseCommand("/" + perm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get this player's block bag.
|
|
||||||
*/
|
|
||||||
public BlockBag getInventoryBlockBag() {
|
|
||||||
return new HMPlayerInventoryBlockBag(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the player
|
|
||||||
*/
|
|
||||||
public Player getPlayerObject() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,203 +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.bags.*;
|
|
||||||
|
|
||||||
public class HMPlayerInventoryBlockBag extends BlockBag {
|
|
||||||
/**
|
|
||||||
* Player instance.
|
|
||||||
*/
|
|
||||||
private Player player;
|
|
||||||
/**
|
|
||||||
* The player's inventory;
|
|
||||||
*/
|
|
||||||
private Item[] items;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the object.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
public HMPlayerInventoryBlockBag(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads inventory on first use.
|
|
||||||
*/
|
|
||||||
private void loadInventory() {
|
|
||||||
if (items == null) {
|
|
||||||
items = player.getInventory().getContents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a block.
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
public void fetchBlock(int id) throws BlockBagException {
|
|
||||||
if (id == 0) {
|
|
||||||
throw new IllegalArgumentException("Can't fetch air block");
|
|
||||||
}
|
|
||||||
|
|
||||||
loadInventory();
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
|
|
||||||
for (int slot = 0; slot < items.length; slot++) {
|
|
||||||
Item item = items[slot];
|
|
||||||
|
|
||||||
if (item == null) continue;
|
|
||||||
|
|
||||||
if (item.getItemId() == id) {
|
|
||||||
int amount = item.getAmount();
|
|
||||||
|
|
||||||
// Unlimited
|
|
||||||
if (amount < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amount > 1) {
|
|
||||||
item.setAmount(amount - 1);
|
|
||||||
found = true;
|
|
||||||
} else {
|
|
||||||
items[slot] = null;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
} else {
|
|
||||||
throw new OutOfBlocksException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a block.
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
public void storeBlock(int id) throws BlockBagException {
|
|
||||||
if (id == 0) {
|
|
||||||
throw new IllegalArgumentException("Can't store air block");
|
|
||||||
}
|
|
||||||
|
|
||||||
loadInventory();
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
int freeSlot = -1;
|
|
||||||
|
|
||||||
for (int slot = 0; slot < items.length; slot++) {
|
|
||||||
Item item = items[slot];
|
|
||||||
|
|
||||||
// Delay using up a free slot until we know there are no stacks
|
|
||||||
// of this item to merge into
|
|
||||||
if (item == null) {
|
|
||||||
if (freeSlot == -1) {
|
|
||||||
freeSlot = slot;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.getItemId() == id) {
|
|
||||||
int amount = item.getAmount();
|
|
||||||
|
|
||||||
// Unlimited
|
|
||||||
if (amount < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amount < 64) {
|
|
||||||
item.setAmount(amount + 1);
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found && freeSlot > -1) {
|
|
||||||
items[freeSlot] = new Item(id, 1);
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
} else {
|
|
||||||
throw new OutOfSpaceException(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flush any changes. This is called at the end.
|
|
||||||
*/
|
|
||||||
public void flushChanges() {
|
|
||||||
if (items != null) {
|
|
||||||
setContents(player.getInventory(), items);
|
|
||||||
items = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a position to be used a source.
|
|
||||||
*
|
|
||||||
* @param pos
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void addSourcePosition(Vector pos) {
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds a position to be used a source.
|
|
||||||
*
|
|
||||||
* @param pos
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void addSingleSourcePosition(Vector pos) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the contents of an ItemArray.
|
|
||||||
*
|
|
||||||
* @param itemArray
|
|
||||||
* @param contents
|
|
||||||
*/
|
|
||||||
private static void setContents(Inventory itemArray, Item[] contents) {
|
|
||||||
int size = itemArray.getContentsSize();
|
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (contents[i] == null) {
|
|
||||||
itemArray.removeItem(i);
|
|
||||||
} else {
|
|
||||||
itemArray.setSlot(contents[i], i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +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.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HMServerInterface extends ServerInterface {
|
|
||||||
/**
|
|
||||||
* Resolves an item name to its ID.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int resolveItem(String name) {
|
|
||||||
return etc.getDataSource().getItem(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a mob type is valid.
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isValidMobType(String type) {
|
|
||||||
return Mob.isValid(type);
|
|
||||||
}
|
|
||||||
}
|
|
368
src/HMWorld.java
368
src/HMWorld.java
@ -1,368 +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 java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* World for hMod.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HMWorld extends LocalWorld {
|
|
||||||
/**
|
|
||||||
* Logger.
|
|
||||||
*/
|
|
||||||
private final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set block type.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean setBlockType(Vector pt, int type) {
|
|
||||||
// Can't set colored cloth or crash
|
|
||||||
if ((type >= 21 && type <= 34) || type == 36) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return etc.getServer().setBlockAt(type, pt.getBlockX(), pt.getBlockY(),
|
|
||||||
pt.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get block type.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getBlockType(Vector pt) {
|
|
||||||
return etc.getServer().getBlockIdAt(pt.getBlockX(), pt.getBlockY(),
|
|
||||||
pt.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set block data.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param data
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void setBlockData(Vector pt, int data) {
|
|
||||||
etc.getServer().setBlockData(pt.getBlockX(), pt.getBlockY(),
|
|
||||||
pt.getBlockZ(), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get block data.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getBlockData(Vector pt) {
|
|
||||||
return etc.getServer().getBlockData(pt.getBlockX(), pt.getBlockY(),
|
|
||||||
pt.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set sign text.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param text
|
|
||||||
*/
|
|
||||||
public void setSignText(Vector pt, String[] text) {
|
|
||||||
Sign signData = (Sign)etc.getServer().getComplexBlock(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
if (signData == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (byte i = 0; i < 4; i++) {
|
|
||||||
signData.setText(i, text[i]);
|
|
||||||
}
|
|
||||||
signData.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sign text.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getSignText(Vector pt) {
|
|
||||||
Sign signData = (Sign)etc.getServer().getComplexBlock(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
if (signData == null) {
|
|
||||||
return new String[]{"", "", "", ""};
|
|
||||||
}
|
|
||||||
String[] text = new String[4];
|
|
||||||
for (byte i = 0; i < 4; i++) {
|
|
||||||
text[i] = signData.getText(i);
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the contents of chests. Will return null if the chest does not
|
|
||||||
* really exist or it is the second block for a double chest.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public BaseItemStack[] getChestContents(Vector pt) {
|
|
||||||
ComplexBlock cblock = etc.getServer().getOnlyComplexBlock(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
|
|
||||||
BaseItemStack[] items;
|
|
||||||
Item[] nativeItems;
|
|
||||||
|
|
||||||
if (cblock instanceof Chest) {
|
|
||||||
Chest chest = (Chest)cblock;
|
|
||||||
nativeItems = chest.getContents();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
items = new BaseItemStack[nativeItems.length];
|
|
||||||
|
|
||||||
for (byte i = 0; i < nativeItems.length; i++) {
|
|
||||||
Item item = nativeItems[i];
|
|
||||||
|
|
||||||
if (item != null) {
|
|
||||||
items[i] = new BaseItemStack((short)item.getItemId(),
|
|
||||||
item.getAmount(), (short)item.getDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a chest slot.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param contents
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean setChestContents(Vector pt,
|
|
||||||
BaseItemStack[] contents) {
|
|
||||||
|
|
||||||
ComplexBlock cblock = etc.getServer().getOnlyComplexBlock(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
|
|
||||||
if (cblock instanceof Chest) {
|
|
||||||
Chest chest = (Chest)cblock;
|
|
||||||
Item[] nativeItems = new Item[contents.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < contents.length; i++) {
|
|
||||||
BaseItemStack item = contents[i];
|
|
||||||
|
|
||||||
if (item != null) {
|
|
||||||
Item nativeItem =
|
|
||||||
new Item(item.getID(), item.getAmount());
|
|
||||||
nativeItem.setDamage(item.getDamage());
|
|
||||||
nativeItems[i] = nativeItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setContents(chest, nativeItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear a chest's contents.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
*/
|
|
||||||
public boolean clearChest(Vector pt) {
|
|
||||||
ComplexBlock cblock = etc.getServer().getOnlyComplexBlock(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
|
|
||||||
if (cblock instanceof Chest) {
|
|
||||||
Chest chest = (Chest)cblock;
|
|
||||||
chest.clearContents();
|
|
||||||
chest.update();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the contents of an ItemArray.
|
|
||||||
*
|
|
||||||
* @param itemArray
|
|
||||||
* @param contents
|
|
||||||
*/
|
|
||||||
private void setContents(ItemArray<?> itemArray, Item[] contents) {
|
|
||||||
int size = contents.length;
|
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (contents[i] == null) {
|
|
||||||
itemArray.removeItem(i);
|
|
||||||
} else {
|
|
||||||
itemArray.setSlot(contents[i].getItemId(),
|
|
||||||
contents[i].getAmount(), contents[i].getDamage(), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set mob spawner mob type.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param mobType
|
|
||||||
*/
|
|
||||||
public void setMobSpawnerType(Vector pt, String mobType) {
|
|
||||||
ComplexBlock cblock = etc.getServer().getComplexBlock(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
|
|
||||||
if (!(cblock instanceof MobSpawner)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MobSpawner mobSpawner = (MobSpawner)cblock;
|
|
||||||
mobSpawner.setSpawn(mobType);
|
|
||||||
mobSpawner.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get mob spawner mob type. May return an empty string.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param mobType
|
|
||||||
*/
|
|
||||||
public String getMobSpawnerType(Vector pt) {
|
|
||||||
try {
|
|
||||||
return MinecraftServerInterface.getMobSpawnerType(pt);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
logger.severe("Failed to get mob spawner type (do you need to update WorldEdit due to a Minecraft update?): "
|
|
||||||
+ t.getMessage());
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a tree at a location.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean generateTree(EditSession editSession, Vector pt) {
|
|
||||||
try {
|
|
||||||
return MinecraftServerInterface.generateTree(editSession, pt);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
logger.log(Level.SEVERE,
|
|
||||||
"Failed to create tree (do you need to update WorldEdit " +
|
|
||||||
"due to a Minecraft update?)", t);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a big tree at a location.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean generateBigTree(EditSession editSession, Vector pt) {
|
|
||||||
try {
|
|
||||||
return MinecraftServerInterface.generateBigTree(editSession, pt);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
logger.log(Level.SEVERE,
|
|
||||||
"Failed to create big tree (do you need to update WorldEdit " +
|
|
||||||
"due to a Minecraft update?)", t);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drop an item.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param type
|
|
||||||
* @param count
|
|
||||||
* @param times
|
|
||||||
*/
|
|
||||||
public void dropItem(Vector pt, int type, int count) {
|
|
||||||
etc.getServer().dropItem(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(),
|
|
||||||
type, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drop an item.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param type
|
|
||||||
* @param count
|
|
||||||
* @param times
|
|
||||||
*/
|
|
||||||
public void dropItem(Vector pt, int type) {
|
|
||||||
etc.getServer().dropItem(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(),
|
|
||||||
type, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Kill mobs in an area.
|
|
||||||
*
|
|
||||||
* @param origin
|
|
||||||
* @param radius
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int killMobs(Vector origin, int radius) {
|
|
||||||
int killed = 0;
|
|
||||||
|
|
||||||
for (Mob mob : etc.getServer().getMobList()) {
|
|
||||||
Vector mobPos = new Vector(mob.getX(), mob.getY(), mob.getZ());
|
|
||||||
if (mob.getHealth() > 0
|
|
||||||
&& (radius == -1 || mobPos.distance(origin) <= radius)) {
|
|
||||||
mob.setHealth(0);
|
|
||||||
killed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Mob mob : etc.getServer().getAnimalList()) {
|
|
||||||
Vector mobPos = new Vector(mob.getX(), mob.getY(), mob.getZ());
|
|
||||||
if (mob.getHealth() > 0
|
|
||||||
&& (radius == -1 || mobPos.distance(origin) <= radius)) {
|
|
||||||
mob.setHealth(0);
|
|
||||||
killed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return killed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return other instanceof HMWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,175 +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 java.util.Map;
|
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The event listener for WorldEdit in hMod.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class HMWorldEditListener extends PluginListener {
|
|
||||||
/**
|
|
||||||
* Main WorldEdit controller.
|
|
||||||
*/
|
|
||||||
private WorldEditController controller;
|
|
||||||
/**
|
|
||||||
* Configuration.
|
|
||||||
*/
|
|
||||||
private LocalConfiguration config;
|
|
||||||
/**
|
|
||||||
* A copy of the server instance. This is where all world<->WorldEdit calls
|
|
||||||
* will go through.
|
|
||||||
*/
|
|
||||||
private ServerInterface server;
|
|
||||||
/**
|
|
||||||
* A copy of a world, not that hMod/MC supports multiple worlds.
|
|
||||||
*/
|
|
||||||
private HMWorld world;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an instance.
|
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
*/
|
|
||||||
public HMWorldEditListener(ServerInterface server) {
|
|
||||||
this.server = server;
|
|
||||||
|
|
||||||
config = new HMConfiguration();
|
|
||||||
controller = new WorldEditController(server, config);
|
|
||||||
world = new HMWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Player player) {
|
|
||||||
controller.handleDisconnect(wrapPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called on arm swing.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
public void onArmSwing(Player player) {
|
|
||||||
controller.handleArmSwing(wrapPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called on right click.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param blockPlaced
|
|
||||||
* @param blockClicked
|
|
||||||
* @param itemInHand
|
|
||||||
* @return false if you want the action to go through
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean onBlockCreate(Player player, Block blockPlaced,
|
|
||||||
Block blockClicked, int itemInHand) {
|
|
||||||
WorldVector pos = new WorldVector(world, blockClicked.getX(),
|
|
||||||
blockClicked.getY(), blockClicked.getZ());
|
|
||||||
return controller.handleBlockRightClick(wrapPlayer(player), pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called on left click.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param blockClicked
|
|
||||||
* @param itemInHand
|
|
||||||
* @return false if you want the action to go through
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onBlockDestroy(Player player, Block blockClicked) {
|
|
||||||
WorldVector pos = new WorldVector(world, blockClicked.getX(),
|
|
||||||
blockClicked.getY(), blockClicked.getZ());
|
|
||||||
return controller.handleBlockLeftClick(wrapPlayer(player), pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param split
|
|
||||||
* @return whether the command was processed
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(Player player, String[] split) {
|
|
||||||
return controller.handleCommand(wrapPlayer(player), split);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the configuration.
|
|
||||||
*/
|
|
||||||
public void loadConfiguration() {
|
|
||||||
config.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register commands with help.
|
|
||||||
*/
|
|
||||||
public void registerCommands() {
|
|
||||||
if (config.registerHelp) {
|
|
||||||
for (Map.Entry<String,String> entry : controller.getCommands().entrySet()) {
|
|
||||||
etc.getInstance().addCommand(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* De-register commands.
|
|
||||||
*/
|
|
||||||
public void deregisterCommands() {
|
|
||||||
for (String key : controller.getCommands().keySet()) {
|
|
||||||
etc.getInstance().removeCommand(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear sessions.
|
|
||||||
*/
|
|
||||||
public void clearSessions() {
|
|
||||||
controller.clearSessions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the WorldEditLibrary session for a player. Used for the bridge.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public LocalSession _bridgeSession(Player player) {
|
|
||||||
return controller.getBridgeSession(wrapPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrap a hMod player for WorldEdit.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private LocalPlayer wrapPlayer(Player player) {
|
|
||||||
return new HMPlayer(server, world, player);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,128 +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 java.util.logging.Logger;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
import sun.reflect.ReflectionFactory;
|
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class MinecraftServerInterface {
|
|
||||||
/**
|
|
||||||
* Logger.
|
|
||||||
*/
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
|
||||||
/**
|
|
||||||
* Random generator.
|
|
||||||
*/
|
|
||||||
private static Random random = new Random();
|
|
||||||
/**
|
|
||||||
* Proxy for the tree generator.
|
|
||||||
*/
|
|
||||||
private static MinecraftSetBlockProxy proxy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform world generation at a location.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static boolean performWorldGen(EditSession editSession, Vector pt,
|
|
||||||
bt worldGen) {
|
|
||||||
if (proxy == null) {
|
|
||||||
try {
|
|
||||||
proxy = createNoConstructor(MinecraftSetBlockProxy.class);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
logger.log(Level.WARNING, "setBlock() proxy class failed to construct",
|
|
||||||
t);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
proxy.setEditSession(editSession);
|
|
||||||
|
|
||||||
bt gen = worldGen;
|
|
||||||
return gen.a(proxy, random,
|
|
||||||
pt.getBlockX(), pt.getBlockY() + 1, pt.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a tree at a location.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean generateTree(EditSession editSession, Vector pt) {
|
|
||||||
return performWorldGen(editSession, pt, new kl());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a big tree at a location.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean generateBigTree(EditSession editSession, Vector pt) {
|
|
||||||
return performWorldGen(editSession, pt, new ib());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get mob spawner mob type. May return an empty string.
|
|
||||||
*
|
|
||||||
* @param pt
|
|
||||||
* @param mobType
|
|
||||||
*/
|
|
||||||
public static String getMobSpawnerType(Vector pt) {
|
|
||||||
bg o = etc.getMCServer().e.l(
|
|
||||||
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
||||||
|
|
||||||
if (o != null && o instanceof cq) {
|
|
||||||
String type = ((cq)o).f;
|
|
||||||
return type != null ? type : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate a class without calling its constructor.
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* @param clazz
|
|
||||||
* @return
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private static <T> T createNoConstructor(Class<T> clazz) throws Throwable {
|
|
||||||
try {
|
|
||||||
ReflectionFactory factory = ReflectionFactory.getReflectionFactory();
|
|
||||||
Constructor objectConstructor = Object.class.getDeclaredConstructor();
|
|
||||||
Constructor c = factory.newConstructorForSerialization(
|
|
||||||
clazz, objectConstructor
|
|
||||||
);
|
|
||||||
return clazz.cast(c.newInstance());
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +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.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Proxy class to catch calls to set blocks.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class MinecraftSetBlockProxy extends ff {
|
|
||||||
/**
|
|
||||||
* Edit session.
|
|
||||||
*/
|
|
||||||
private EditSession editSession;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor that should NOT be called.
|
|
||||||
*
|
|
||||||
* @param editSession
|
|
||||||
*/
|
|
||||||
public MinecraftSetBlockProxy(EditSession editSession) {
|
|
||||||
super(null, "", (long)0, null);
|
|
||||||
throw new IllegalStateException("MinecraftSetBlockProxy constructor called (BAD)");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to set a block.
|
|
||||||
*
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
* @param z
|
|
||||||
* @param blockType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean a(int x, int y, int z, int blockType) {
|
|
||||||
try {
|
|
||||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(blockType));
|
|
||||||
} catch (MaxChangedBlocksException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to get a block.
|
|
||||||
*
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
* @param z
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int a(int x, int y, int z) {
|
|
||||||
return editSession.getBlock(new Vector(x, y, z)).getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public EditSession getEditSession() {
|
|
||||||
return editSession;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param editSession
|
|
||||||
*/
|
|
||||||
public void setEditSession(EditSession editSession) {
|
|
||||||
this.editSession = editSession;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldEditLibrary
|
|
||||||
* 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 java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entry point for the plugin for hey0's mod.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class WorldEdit extends Plugin {
|
|
||||||
/**
|
|
||||||
* Logger.
|
|
||||||
*/
|
|
||||||
private static final Logger logger = Logger
|
|
||||||
.getLogger("Minecraft.WorldEdit");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The event listener for WorldEdit an hMod. Configuration and such is
|
|
||||||
* also loaded here as well, although the core of the WorldEdit is
|
|
||||||
* actually in com.sk89q.worldedit.WorldEditController and is merely
|
|
||||||
* loaded by this listener.
|
|
||||||
*/
|
|
||||||
private final HMWorldEditListener listener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WorldEdit version, fetched from the .jar's manifest.
|
|
||||||
*/
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance of the plugin.
|
|
||||||
*/
|
|
||||||
public WorldEdit() {
|
|
||||||
listener = new HMWorldEditListener(new HMServerInterface());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the plugin.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void initialize() {
|
|
||||||
PluginLoader loader = etc.getLoader();
|
|
||||||
|
|
||||||
loader.addListener(PluginLoader.Hook.BLOCK_CREATED, listener, this,
|
|
||||||
PluginListener.Priority.MEDIUM);
|
|
||||||
loader.addListener(PluginLoader.Hook.BLOCK_DESTROYED, listener, this,
|
|
||||||
PluginListener.Priority.MEDIUM);
|
|
||||||
loader.addListener(PluginLoader.Hook.COMMAND, listener, this,
|
|
||||||
PluginListener.Priority.MEDIUM);
|
|
||||||
loader.addListener(PluginLoader.Hook.DISCONNECT, listener, this,
|
|
||||||
PluginListener.Priority.MEDIUM);
|
|
||||||
loader.addListener(PluginLoader.Hook.LOGIN, listener, this,
|
|
||||||
PluginListener.Priority.MEDIUM);
|
|
||||||
loader.addListener(PluginLoader.Hook.ARM_SWING, listener, this,
|
|
||||||
PluginListener.Priority.MEDIUM);
|
|
||||||
|
|
||||||
logger.log(Level.INFO, "WorldEdit version " + getVersion() + " loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables the plugin.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void enable() {
|
|
||||||
listener.loadConfiguration();
|
|
||||||
listener.registerCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables the plugin.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void disable() {
|
|
||||||
listener.deregisterCommands();
|
|
||||||
listener.clearSessions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the WorldEdit version.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getVersion() {
|
|
||||||
if (version != null) {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
Package p = WorldEdit.class.getPackage();
|
|
||||||
|
|
||||||
if (p == null) {
|
|
||||||
p = Package.getPackage("com.sk89q.worldedit");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p == null) {
|
|
||||||
version = "(unknown)";
|
|
||||||
} else {
|
|
||||||
version = p.getImplementationVersion();
|
|
||||||
|
|
||||||
if (version == null) {
|
|
||||||
version = "(unknown)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the listener for the WorldEdit bridge.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public HMWorldEditListener getListener() {
|
|
||||||
return listener;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +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 java.lang.reflect.*;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEditNotInstalled;
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to access WorldEdit from another plugin.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class WorldEditBridge {
|
|
||||||
/**
|
|
||||||
* Invokes an object's method through reflection.
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @param args
|
|
||||||
* @param types
|
|
||||||
* @return
|
|
||||||
* @throws InvocationTargetException
|
|
||||||
* @throws IllegalAccessException
|
|
||||||
* @throws NoSuchMethodException
|
|
||||||
*/
|
|
||||||
private static Object invokeMethod(Object obj, String name, Object[] args,
|
|
||||||
Class<?> ... types) throws InvocationTargetException, IllegalAccessException,
|
|
||||||
NoSuchMethodException {
|
|
||||||
Method method = obj.getClass().getDeclaredMethod(name, types);
|
|
||||||
return method.invoke(obj, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invokes a method through reflection.
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
* @throws InvocationTargetException
|
|
||||||
* @throws IllegalAccessException
|
|
||||||
* @throws NoSuchMethodException
|
|
||||||
*/
|
|
||||||
private static Object invokeMethod(Object obj, String name)
|
|
||||||
throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
|
|
||||||
Method method = obj.getClass().getDeclaredMethod(name, new Class[]{});
|
|
||||||
return method.invoke(obj, new Object[]{});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a point from the currently selected region.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param methodName
|
|
||||||
* @return
|
|
||||||
* @throws WorldEditNotInstalled
|
|
||||||
* @throws IncompleteRegionException
|
|
||||||
*/
|
|
||||||
private static Vector getRegionPoint(Player player, String methodName)
|
|
||||||
throws WorldEditNotInstalled, IncompleteRegionException {
|
|
||||||
Plugin plugin = etc.getLoader().getPlugin("WorldEdit");
|
|
||||||
if (plugin == null) {
|
|
||||||
throw new WorldEditNotInstalled();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Object listener = invokeMethod(plugin, "getListener");
|
|
||||||
Object session = invokeMethod(listener, "_bridgeSession",
|
|
||||||
new Object[]{ player }, Player.class);
|
|
||||||
Object region = invokeMethod(session, "getRegion");
|
|
||||||
Object minPoint = invokeMethod(region, methodName);
|
|
||||||
int x = (Integer)invokeMethod(minPoint, "getBlockX");
|
|
||||||
int y = (Integer)invokeMethod(minPoint, "getBlockY");
|
|
||||||
int z = (Integer)invokeMethod(minPoint, "getBlockZ");
|
|
||||||
return new Vector(x, y, z);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
String exceptionName = e.getTargetException().getClass().getCanonicalName();
|
|
||||||
if (exceptionName.equals("com.sk89q.worldedit.IncompleteRegionException")) {
|
|
||||||
throw new IncompleteRegionException();
|
|
||||||
}
|
|
||||||
throw new WorldEditNotInstalled();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new WorldEditNotInstalled();
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new WorldEditNotInstalled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the selection minimum point.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
* @throws WorldEditNotInstalled
|
|
||||||
* @throws IncompleteRegionException
|
|
||||||
*/
|
|
||||||
public static Vector getRegionMinimumPoint(Player player)
|
|
||||||
throws WorldEditNotInstalled, IncompleteRegionException {
|
|
||||||
return getRegionPoint(player, "getMinimumPoint");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the selection maximum point.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
* @throws WorldEditNotInstalled
|
|
||||||
* @throws IncompleteRegionException
|
|
||||||
*/
|
|
||||||
public static Vector getRegionMaximumPoint(Player player)
|
|
||||||
throws WorldEditNotInstalled, IncompleteRegionException {
|
|
||||||
return getRegionPoint(player, "getMaximumPoint");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -20,6 +20,9 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -56,6 +59,10 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
logger.info("WorldEdit " + desc.getVersion() + " loaded.");
|
logger.info("WorldEdit " + desc.getVersion() + " loaded.");
|
||||||
|
|
||||||
|
folder.mkdirs();
|
||||||
|
|
||||||
|
createDefaultConfiguration("config.yml");
|
||||||
|
|
||||||
config = new BukkitConfiguration(getConfiguration(), logger);
|
config = new BukkitConfiguration(getConfiguration(), logger);
|
||||||
perms = new ConfigurationPermissionsResolver(getConfiguration());
|
perms = new ConfigurationPermissionsResolver(getConfiguration());
|
||||||
loadConfiguration();
|
loadConfiguration();
|
||||||
@ -85,6 +92,42 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
blockListener, Priority.Normal, this);
|
blockListener, Priority.Normal, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createDefaultConfiguration(String name) {
|
||||||
|
File actual = new File(getDataFolder(), name);
|
||||||
|
if (!actual.exists()) {
|
||||||
|
|
||||||
|
InputStream input =
|
||||||
|
WorldEditPlugin.class.getResourceAsStream("/defaults/" + name);
|
||||||
|
if (input != null) {
|
||||||
|
FileOutputStream output = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
output = new FileOutputStream(actual);
|
||||||
|
byte[] buf = new byte[8192];
|
||||||
|
int length = 0;
|
||||||
|
while ((length = input.read(buf)) > 0) {
|
||||||
|
output.write(buf, 0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("WorldEdit: Default configuration file written: "
|
||||||
|
+ name);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (input != null)
|
||||||
|
input.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (output != null)
|
||||||
|
output.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void loadConfiguration() {
|
public void loadConfiguration() {
|
||||||
getConfiguration().load();
|
getConfiguration().load();
|
||||||
config.load();
|
config.load();
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# This file determines some group-based WorldEdit restrictions.
|
|
||||||
# If a player is in two groups that are listed here, the group with the
|
|
||||||
# more lenient permissions will take precedence.
|
|
||||||
#
|
|
||||||
# Format:
|
|
||||||
# groupname:limit
|
|
||||||
#
|
|
||||||
|
|
||||||
#users:4
|
|
||||||
#admins:-1
|
|
@ -1,94 +0,0 @@
|
|||||||
#
|
|
||||||
# WorldEdit configuration
|
|
||||||
# To reload WorldEdit's configuration, use /reloadplugin WorldEdit, although
|
|
||||||
# be aware that it will also clear your history and selection.
|
|
||||||
#
|
|
||||||
|
|
||||||
# The ID of the item to use for WorldEdit's "wand." The wand allows you to
|
|
||||||
# select points by left clicking or right clicking a block with it. The
|
|
||||||
# default wand object is a wooden axe. Those with permission to use the
|
|
||||||
# //wand command can also spawn this item for themselves.
|
|
||||||
wand-item=271
|
|
||||||
|
|
||||||
# WorldEdit can limit the number of blocks that can be changed in one
|
|
||||||
# operation, failing the operation prematurely if the limit is hit. This
|
|
||||||
# limit can be controlled on the fly with the //limit command, but you
|
|
||||||
# can adjust the default limit that users start with. Use -1 to not
|
|
||||||
# set a default limit.
|
|
||||||
default-max-blocks-changed=-1
|
|
||||||
|
|
||||||
# Set an upper bound for the max block change limit that users can set with
|
|
||||||
# the //limit command. Note that the "default" max blocks changed limit
|
|
||||||
# cannot override this. To exempt certain users from this restriction, give
|
|
||||||
# them the /worldeditnomax permission. Use -1 to disable.
|
|
||||||
max-blocks-changed=-1
|
|
||||||
|
|
||||||
# Limit the maximum radius for various commands that use a size or radius
|
|
||||||
# parameter. Use -1 to disable.
|
|
||||||
max-radius=-1
|
|
||||||
|
|
||||||
# Maximum brush size with the brush tool.
|
|
||||||
max-brush-radius=6
|
|
||||||
|
|
||||||
# Maximum size that one of the alternate area super pickaxe modes can use.
|
|
||||||
max-super-pickaxe-size=5
|
|
||||||
|
|
||||||
# Add commands to hMod's help system.
|
|
||||||
register-help=true
|
|
||||||
|
|
||||||
# Print used commands to console.
|
|
||||||
log-commands=false
|
|
||||||
|
|
||||||
# Log commands used to file. The above must be enabled.
|
|
||||||
log-file=
|
|
||||||
|
|
||||||
# Allows using single slashes for all commands instead of double slashes.
|
|
||||||
no-double-slash=false
|
|
||||||
|
|
||||||
# Drop items when the super pickaxe is used.
|
|
||||||
super-pickaxe-drop-items=true
|
|
||||||
|
|
||||||
# Drop items when one of the area super pickaxe modes are used. Note that
|
|
||||||
# this may drop an excessive number of blocks if turned on.
|
|
||||||
super-pickaxe-many-drop-items=false
|
|
||||||
|
|
||||||
# List of blocks that can not be set with WorldEdit. There are ways to
|
|
||||||
# bypass this list (such as by stacking an existing block) as this list is
|
|
||||||
# only to prevent mistakes. Some blocks, such as cacti, should never be
|
|
||||||
# used (setting a region to cacti blocks will cause severe lag).
|
|
||||||
disallowed-blocks=6,7,14,15,16,21,22,23,24,25,26,27,28,29,39,31,32,33,34,36,37,38,39,40,46,50,51,56,59,69,73,74,75,76,77,81,83
|
|
||||||
|
|
||||||
# Directory to load backups from for //restore. See documentation.
|
|
||||||
snapshots-dir=
|
|
||||||
|
|
||||||
# Used for /delchunks. See documentation.
|
|
||||||
shell-save-type=
|
|
||||||
|
|
||||||
# Get blocks from a player's inventory when a block is needed and also
|
|
||||||
# put blocks into a player's inventory with a block is replaced with air.
|
|
||||||
# When a block cannot be fetched (if, for example, the player has no more
|
|
||||||
# of that block), the operation will still continue but be unable to set
|
|
||||||
# any further blocks (at least of that type). Players will be given a list
|
|
||||||
# of missing block types at the end. If there are any missing blocks that
|
|
||||||
# do not require another block (such as a torch, which requires a wall or
|
|
||||||
# floor), the operation will abort before these dependent blocks are
|
|
||||||
# placed. In the case of failure, //undo and //redo can be utilized to
|
|
||||||
# repeat an operation. When a block is placed into a player's inventory
|
|
||||||
# as a result of a block being removed, it will be the mined block, or
|
|
||||||
# no block in some cases. Glass and bookshelf books are given. Water and
|
|
||||||
# lava blocks are not given and are not needed for setting. Note that
|
|
||||||
# chests will not copy correctly and instead drop their items when they
|
|
||||||
# are removed, preventing the copying and pasting of chests in order to
|
|
||||||
# duplicate items. Inventory usage is programmed into a very low level of
|
|
||||||
# WorldEdit, and so all operations will use it.
|
|
||||||
use-inventory=false
|
|
||||||
|
|
||||||
# Enable the use of the /worldeditunlimited permission to have certain
|
|
||||||
# players be exempt from the inventory requirement (if it is enabled.
|
|
||||||
use-inventory-override=false
|
|
||||||
|
|
||||||
# Prints how long each command takes for completion. This is for debugging
|
|
||||||
# and it is not particularly useful to most people.
|
|
||||||
debug-profile=false
|
|
||||||
|
|
||||||
#EOF
|
|
@ -1,5 +0,0 @@
|
|||||||
name = WorldEdit
|
|
||||||
version = %version%
|
|
||||||
url = updatr.update.sk89q.com/worldedit.updatr
|
|
||||||
file = cloud.github.com/downloads/sk89q/worldedit/worldedit-%version%.zip
|
|
||||||
notes =
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren