geforkt von Mirrors/FastAsyncWorldEdit
Updated for Bukkit's new events system
Dieser Commit ist enthalten in:
Ursprung
ad9d85e50f
Commit
edc955c5b6
2
pom.xml
2
pom.xml
@ -48,7 +48,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.0.1-R1</version>
|
<version>1.1-R1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Archive reading library for snapshots -->
|
<!-- Archive reading library for snapshots -->
|
||||||
|
@ -1,60 +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.bukkit;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event.Priority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles all events thrown in relation to a Player
|
|
||||||
*/
|
|
||||||
public class WorldEditCriticalPlayerListener extends PlayerListener {
|
|
||||||
/**
|
|
||||||
* Plugin.
|
|
||||||
*/
|
|
||||||
private WorldEditPlugin plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the object;
|
|
||||||
*
|
|
||||||
* @param plugin
|
|
||||||
*/
|
|
||||||
public WorldEditCriticalPlayerListener(WorldEditPlugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
|
|
||||||
plugin.registerEvent("PLAYER_JOIN", this, Priority.Lowest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a player joins a server
|
|
||||||
*
|
|
||||||
* @param event Relevant event details
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BukkitPlayer wrapPlayer(Player player) {
|
|
||||||
return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
* Copyright (C) 2012 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
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -15,19 +15,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event.Result;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
@ -39,7 +41,7 @@ import java.util.regex.Pattern;
|
|||||||
/**
|
/**
|
||||||
* Handles all events thrown in relation to a Player
|
* Handles all events thrown in relation to a Player
|
||||||
*/
|
*/
|
||||||
public class WorldEditPlayerListener extends PlayerListener {
|
public class WorldEditListener implements Listener {
|
||||||
|
|
||||||
private WorldEditPlugin plugin;
|
private WorldEditPlugin plugin;
|
||||||
private boolean ignoreLeftClickAir = false;
|
private boolean ignoreLeftClickAir = false;
|
||||||
@ -56,13 +58,13 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin
|
||||||
*/
|
*/
|
||||||
public WorldEditPlayerListener(WorldEditPlugin plugin) {
|
public WorldEditListener(WorldEditPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
plugin.registerEvent("PLAYER_QUIT", this);
|
@EventHandler(event = PlayerJoinEvent.class, priority = EventPriority.LOWEST)
|
||||||
plugin.registerEvent("PLAYER_INTERACT", this);
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
plugin.registerEvent("PLAYER_COMMAND_PREPROCESS", this, Event.Priority.Low);
|
plugin.wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
|
||||||
plugin.registerEvent("PLAYER_CHAT", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +72,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
@Override
|
@EventHandler(event = PlayerQuitEvent.class)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
|
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
|
||||||
}
|
}
|
||||||
@ -80,7 +82,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
@Override
|
@EventHandler(event = PlayerCommandPreprocessEvent.class, priority = EventPriority.LOW)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@ -101,9 +103,9 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
@Override
|
@EventHandler(event = PlayerInteractEvent.class)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (event.useItemInHand() == Event.Result.DENY) {
|
if (event.useItemInHand() == Result.DENY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +167,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(event = PlayerChatEvent.class)
|
||||||
public void onPlayerChat(PlayerChatEvent event) {
|
public void onPlayerChat(PlayerChatEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
@ -103,7 +103,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
api = new WorldEditAPI(this);
|
api = new WorldEditAPI(this);
|
||||||
|
|
||||||
// Now we can register events!
|
// Now we can register events!
|
||||||
registerEvents();
|
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
|
||||||
|
|
||||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
|
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
|
||||||
new SessionTimer(controller, getServer()), 120, 120);
|
new SessionTimer(controller, getServer()), 120, 120);
|
||||||
@ -134,40 +134,6 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
getPermissionsResolver().load();
|
getPermissionsResolver().load();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the events used by WorldEdit.
|
|
||||||
*/
|
|
||||||
protected void registerEvents() {
|
|
||||||
new WorldEditPlayerListener(this);
|
|
||||||
new WorldEditCriticalPlayerListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an event.
|
|
||||||
*
|
|
||||||
* @param typeName
|
|
||||||
* @param listener
|
|
||||||
* @param priority
|
|
||||||
*/
|
|
||||||
public void registerEvent(String typeName, Listener listener, Priority priority) {
|
|
||||||
try {
|
|
||||||
Event.Type type = Event.Type.valueOf(typeName);
|
|
||||||
getServer().getPluginManager().registerEvent(type, listener, priority, this);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
logger.info("WorldEdit: Unable to register missing event type " + typeName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an event at normal priority.
|
|
||||||
*
|
|
||||||
* @param typeName
|
|
||||||
* @param listener
|
|
||||||
*/
|
|
||||||
public void registerEvent(String typeName, Listener listener) {
|
|
||||||
registerEvent(typeName, listener, Event.Priority.Normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a default configuration file from the .jar.
|
* Create a default configuration file from the .jar.
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren