Renamed SMWorldEdit to WorldEdit to prevent confusion.

This commit is contained in:
sk89q 2010-11-03 16:46:47 -07:00
parent 8670ef7554
commit 28f76f869c
8 changed files with 1331 additions and 1331 deletions

View File

@ -1,6 +1,6 @@
// $Id$ // $Id$
/* /*
* WorldEdit * WorldEditLibrary
* Copyright (C) 2010 sk89q <http://www.sk89q.com> * Copyright (C) 2010 sk89q <http://www.sk89q.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -96,7 +96,7 @@ public class EditSession {
* Default constructor. There is no maximum blocks limit. * Default constructor. There is no maximum blocks limit.
*/ */
public EditSession() { public EditSession() {
server = WorldEdit.getServer(); server = WorldEditLibrary.getServer();
} }
/** /**
@ -108,7 +108,7 @@ public class EditSession {
} }
this.maxBlocks = maxBlocks; this.maxBlocks = maxBlocks;
server = WorldEdit.getServer(); server = WorldEditLibrary.getServer();
} }
/** /**

View File

@ -26,7 +26,7 @@ import java.util.HashMap;
* *
* @author sk89q * @author sk89q
*/ */
public class SMServerInterface implements ServerInterface { public class HmodServerInterface implements ServerInterface {
/** /**
* Set block type. * Set block type.
* *

View File

@ -1,6 +1,6 @@
// $Id$ // $Id$
/* /*
* WorldEdit * WorldEditLibrary
* Copyright (C) 2010 sk89q <http://www.sk89q.com> * Copyright (C) 2010 sk89q <http://www.sk89q.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -24,15 +24,15 @@ import com.sk89q.worldedit.*;
* *
* @author sk89q * @author sk89q
*/ */
public class SMWorldEditListener extends PluginListener { public class HmodWorldEditListener extends PluginListener {
/** /**
* *
* @param player * @param player
*/ */
@Override @Override
public void onDisconnect(Player player) { public void onDisconnect(Player player) {
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEditLibrary worldEdit = WorldEditLibrary.getInstance();
worldEdit.removeSession(new SMWorldEditPlayer(player)); worldEdit.removeSession(new HmodWorldEditPlayer(player));
} }
/** /**
@ -47,8 +47,8 @@ public class SMWorldEditListener extends PluginListener {
@Override @Override
public boolean onBlockCreate(Player modPlayer, Block blockPlaced, public boolean onBlockCreate(Player modPlayer, Block blockPlaced,
Block blockClicked, int itemInHand) { Block blockClicked, int itemInHand) {
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEditLibrary worldEdit = WorldEditLibrary.getInstance();
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer); WorldEditPlayer player = new HmodWorldEditPlayer(modPlayer);
if (itemInHand != 271) { return false; } if (itemInHand != 271) { return false; }
if (!canUseCommand(modPlayer, "//pos2")) { return false; } if (!canUseCommand(modPlayer, "//pos2")) { return false; }
@ -82,8 +82,8 @@ public class SMWorldEditListener extends PluginListener {
if (!canUseCommand(modPlayer, "//pos1") if (!canUseCommand(modPlayer, "//pos1")
&& !canUseCommand(modPlayer, "//")) { return false; } && !canUseCommand(modPlayer, "//")) { return false; }
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEditLibrary worldEdit = WorldEditLibrary.getInstance();
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer); WorldEditPlayer player = new HmodWorldEditPlayer(modPlayer);
WorldEditSession session = worldEdit.getSession(player); WorldEditSession session = worldEdit.getSession(player);
if (player.getItemInHand() == 271) { if (player.getItemInHand() == 271) {
@ -114,12 +114,12 @@ public class SMWorldEditListener extends PluginListener {
if (session.hasSuperPickAxe()) { if (session.hasSuperPickAxe()) {
Vector pos = new Vector(blockClicked.getX(), Vector pos = new Vector(blockClicked.getX(),
blockClicked.getY(), blockClicked.getZ()); blockClicked.getY(), blockClicked.getZ());
if (WorldEdit.getServer().getBlockType(pos) == 7 if (WorldEditLibrary.getServer().getBlockType(pos) == 7
&& !canUseCommand(modPlayer, "/worldeditbedrock")) { && !canUseCommand(modPlayer, "/worldeditbedrock")) {
return true; return true;
} }
WorldEdit.getServer().setBlockType(pos, 0); WorldEditLibrary.getServer().setBlockType(pos, 0);
return true; return true;
} }
@ -136,7 +136,7 @@ public class SMWorldEditListener extends PluginListener {
*/ */
@Override @Override
public boolean onCommand(Player modPlayer, String[] split) { public boolean onCommand(Player modPlayer, String[] split) {
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEditLibrary worldEdit = WorldEditLibrary.getInstance();
try { try {
// Legacy /, command // Legacy /, command
@ -146,7 +146,7 @@ public class SMWorldEditListener extends PluginListener {
if (worldEdit.getCommands().containsKey(split[0].toLowerCase())) { if (worldEdit.getCommands().containsKey(split[0].toLowerCase())) {
if (canUseCommand(modPlayer, split[0])) { if (canUseCommand(modPlayer, split[0])) {
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer); WorldEditPlayer player = new HmodWorldEditPlayer(modPlayer);
WorldEditSession session = worldEdit.getSession(player); WorldEditSession session = worldEdit.getSession(player);
EditSession editSession = EditSession editSession =
new EditSession(session.getBlockChangeLimit()); new EditSession(session.getBlockChangeLimit());

View File

@ -24,7 +24,7 @@ import com.sk89q.worldedit.ServerInterface;
* *
* @author sk89q * @author sk89q
*/ */
public class SMWorldEditPlayer extends WorldEditPlayer { public class HmodWorldEditPlayer extends WorldEditPlayer {
private Player player; private Player player;
/** /**
@ -32,7 +32,7 @@ public class SMWorldEditPlayer extends WorldEditPlayer {
* *
* @param player * @param player
*/ */
public SMWorldEditPlayer(Player player) { public HmodWorldEditPlayer(Player player) {
super(); super();
this.player = player; this.player = player;
} }

View File

@ -1,114 +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.snapshots.SnapshotRepository;
import java.util.Map;
import java.util.HashSet;
import com.sk89q.worldedit.ServerInterface;
/**
* Entry point for the plugin for hey0's mod.
*
* @author sk89q
*/
public class SMWorldEdit extends Plugin {
/**
* WorldEdit's properties file.
*/
private PropertiesFile properties;
/**
* WorldEdit instance.
*/
private static final WorldEdit worldEdit =
WorldEdit.setup(new SMServerInterface());
/**
* Listener for the plugin system.
*/
private static final SMWorldEditListener listener =
new SMWorldEditListener();
/**
* 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);
}
/**
* Enables the plugin.
*/
@Override
public void enable() {
if (properties == null) {
properties = new PropertiesFile("worldedit.properties");
} else {
properties.load();
}
// Get allowed blocks
HashSet<Integer> allowedBlocks = new HashSet<Integer>();
for (String b : properties.getString("allowed-blocks",
WorldEdit.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());
}
}
/**
* Disables the plugin.
*/
@Override
public void disable() {
for (String key : worldEdit.getCommands().keySet()) {
etc.getInstance().removeCommand(key);
}
worldEdit.clearSessions();
}
}

File diff suppressed because it is too large Load Diff

1249
src/WorldEditLibrary.java Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// $Id$ // $Id$
/* /*
* WorldEdit * WorldEditLibrary
* Copyright (C) 2010 sk89q <http://www.sk89q.com> * Copyright (C) 2010 sk89q <http://www.sk89q.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -35,7 +35,7 @@ public abstract class WorldEditPlayer {
* Construct the player. * Construct the player.
*/ */
public WorldEditPlayer() { public WorldEditPlayer() {
server = WorldEdit.getServer(); server = WorldEditLibrary.getServer();
} }
/** /**
@ -107,14 +107,14 @@ public abstract class WorldEditPlayer {
public abstract String getCardinalDirection(); public abstract String getCardinalDirection();
/** /**
* Print a WorldEdit message. * Print a WorldEditLibrary message.
* *
* @param msg * @param msg
*/ */
public abstract void print(String msg); public abstract void print(String msg);
/** /**
* Print a WorldEdit error. * Print a WorldEditLibrary error.
* *
* @param msg * @param msg
*/ */