From 97a49d4492c0043165585f78666f0b690ecbafbe Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 5 Nov 2010 17:54:18 -0700 Subject: [PATCH] Added class to access WorldEdit from other plugins. --- src/WorldEdit.java | 9 ++++++ src/WorldEditListener.java | 19 ++++++++++++ .../worldedit/WorldEditNotInstalled.java | 29 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/com/sk89q/worldedit/WorldEditNotInstalled.java diff --git a/src/WorldEdit.java b/src/WorldEdit.java index 91f70bc04..bb532b063 100644 --- a/src/WorldEdit.java +++ b/src/WorldEdit.java @@ -96,4 +96,13 @@ public class WorldEdit extends Plugin { return "(unknown)"; } } + + /** + * Returns the listener. + * + * @return + */ + public WorldEditListener getListener() { + return listener; + } } diff --git a/src/WorldEditListener.java b/src/WorldEditListener.java index 11a1bada0..4c5aa5527 100644 --- a/src/WorldEditListener.java +++ b/src/WorldEditListener.java @@ -1371,4 +1371,23 @@ public class WorldEditListener extends PluginListener { etc.getInstance().removeCommand(key); } } + + /** + * Gets the WorldEditLibrary session for a player. Used for the bridge. + * + * @param player + * @return + */ + public WorldEditSession _bridgeSession(Player pl) { + WorldEditPlayer player = new WorldEditPlayer(pl); + + if (sessions.containsKey(player)) { + return sessions.get(player); + } else { + WorldEditSession session = new WorldEditSession(); + session.setBlockChangeLimit(defaultChangeLimit); + sessions.put(player, session); + return session; + } + } } diff --git a/src/com/sk89q/worldedit/WorldEditNotInstalled.java b/src/com/sk89q/worldedit/WorldEditNotInstalled.java new file mode 100644 index 000000000..8da44fdca --- /dev/null +++ b/src/com/sk89q/worldedit/WorldEditNotInstalled.java @@ -0,0 +1,29 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010 sk89q + * + * 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 . +*/ + +package com.sk89q.worldedit; + +/** + * Raised when WorldEdit is not installed. + * + * @author Albert + */ +public class WorldEditNotInstalled extends WorldEditException { + +}