2010-09-28 08:12:34 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
2010-11-03 23:46:47 +00:00
|
|
|
* WorldEditLibrary
|
2010-09-28 08:12:34 +00:00
|
|
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-11-05 23:42:16 +00:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2010-09-28 08:12:34 +00:00
|
|
|
|
2011-01-01 01:40:07 +00:00
|
|
|
import com.sk89q.worldedit.ServerInterface;
|
|
|
|
|
2010-09-30 06:41:05 +00:00
|
|
|
/**
|
2010-11-03 23:46:47 +00:00
|
|
|
* Entry point for the plugin for hey0's mod.
|
|
|
|
*
|
2010-09-30 06:41:05 +00:00
|
|
|
* @author sk89q
|
|
|
|
*/
|
2010-11-03 23:46:47 +00:00
|
|
|
public class WorldEdit extends Plugin {
|
2010-11-04 00:05:05 +00:00
|
|
|
/**
|
|
|
|
* Logger.
|
|
|
|
*/
|
2010-11-06 05:37:16 +00:00
|
|
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
2010-10-14 18:59:45 +00:00
|
|
|
/**
|
2010-11-03 23:46:47 +00:00
|
|
|
* WorldEditLibrary instance.
|
2010-10-14 18:59:45 +00:00
|
|
|
*/
|
2011-01-01 14:17:43 +00:00
|
|
|
private static HMWorldEditListener listener;
|
2010-12-26 04:52:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WorldEdit version, fetched from the .jar's manifest. Used to print the
|
|
|
|
* WorldEdit version in various places.
|
|
|
|
*/
|
|
|
|
private String version;
|
2010-10-02 23:28:02 +00:00
|
|
|
|
2010-10-12 20:51:25 +00:00
|
|
|
/**
|
2010-11-03 23:46:47 +00:00
|
|
|
* Initializes the plugin.
|
2010-10-20 23:15:20 +00:00
|
|
|
*/
|
2010-11-03 23:46:47 +00:00
|
|
|
@Override
|
|
|
|
public void initialize() {
|
|
|
|
PluginLoader loader = etc.getLoader();
|
2010-10-02 23:28:02 +00:00
|
|
|
|
2011-01-01 14:17:43 +00:00
|
|
|
ServerInterface.setup(new HMServerInterface());
|
|
|
|
|
|
|
|
listener = new HMWorldEditListener();
|
|
|
|
|
2010-11-03 23:46:47 +00:00
|
|
|
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);
|
2010-11-17 07:24:30 +00:00
|
|
|
loader.addListener(PluginLoader.Hook.ARM_SWING, listener, this,
|
|
|
|
PluginListener.Priority.MEDIUM);
|
2010-11-04 00:05:05 +00:00
|
|
|
|
2010-11-07 06:32:03 +00:00
|
|
|
logger.log(Level.INFO, "WorldEdit version " + getVersion() + " loaded");
|
2010-10-14 18:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-11-03 23:46:47 +00:00
|
|
|
* Enables the plugin.
|
2010-10-14 18:59:45 +00:00
|
|
|
*/
|
2010-11-03 23:46:47 +00:00
|
|
|
@Override
|
|
|
|
public void enable() {
|
2010-11-05 23:42:16 +00:00
|
|
|
listener.loadConfiguration();
|
|
|
|
listener.registerCommands();
|
2010-10-20 23:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-11-03 23:46:47 +00:00
|
|
|
* Disables the plugin.
|
2010-10-20 23:15:20 +00:00
|
|
|
*/
|
2010-11-03 23:46:47 +00:00
|
|
|
@Override
|
|
|
|
public void disable() {
|
2010-11-05 23:42:16 +00:00
|
|
|
listener.deregisterCommands();
|
|
|
|
listener.clearSessions();
|
2010-10-28 17:27:30 +00:00
|
|
|
}
|
2010-11-04 00:05:05 +00:00
|
|
|
|
|
|
|
/**
|
2010-12-26 04:52:56 +00:00
|
|
|
* Get the CraftBook version.
|
|
|
|
*
|
2010-11-04 00:05:05 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2010-12-26 04:52:56 +00:00
|
|
|
public String getVersion() {
|
|
|
|
if (version != null) {
|
|
|
|
return version;
|
2010-11-04 00:05:05 +00:00
|
|
|
}
|
2010-12-26 04:52:56 +00:00
|
|
|
|
|
|
|
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;
|
2010-11-04 00:05:05 +00:00
|
|
|
}
|
2010-11-06 00:54:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the listener.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
2011-01-01 01:40:07 +00:00
|
|
|
public HMWorldEditListener getListener() {
|
2010-11-06 00:54:18 +00:00
|
|
|
return listener;
|
|
|
|
}
|
2010-09-28 08:12:34 +00:00
|
|
|
}
|