Made SNOW_FORM be registered programatically so it can be used on CraftBukkit versions lacking that.

This commit is contained in:
sk89q 2011-06-22 08:46:37 -07:00
parent b62ada53c3
commit 87a43e8e8f

View File

@ -37,6 +37,9 @@
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.*; import com.sk89q.worldguard.blacklist.events.*;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import java.util.logging.Logger;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*; import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
/** /**
@ -45,6 +48,10 @@
* @author sk89q * @author sk89q
*/ */
public class WorldGuardBlockListener extends BlockListener { public class WorldGuardBlockListener extends BlockListener {
/**
* Logger for messages.
*/
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
private WorldGuardPlugin plugin; private WorldGuardPlugin plugin;
@ -72,11 +79,21 @@ public void registerEvents() {
pm.registerEvent(Event.Type.BLOCK_BURN, this, Priority.High, plugin); pm.registerEvent(Event.Type.BLOCK_BURN, this, Priority.High, plugin);
pm.registerEvent(Event.Type.SIGN_CHANGE, this, Priority.High, plugin); pm.registerEvent(Event.Type.SIGN_CHANGE, this, Priority.High, plugin);
pm.registerEvent(Event.Type.REDSTONE_CHANGE, this, Priority.High, plugin); pm.registerEvent(Event.Type.REDSTONE_CHANGE, this, Priority.High, plugin);
pm.registerEvent(Event.Type.SNOW_FORM, this, Priority.High, plugin); registerEventSafe("SNOW_FORM", Priority.High);
pm.registerEvent(Event.Type.LEAVES_DECAY, this, Priority.High, plugin); pm.registerEvent(Event.Type.LEAVES_DECAY, this, Priority.High, plugin);
pm.registerEvent(Event.Type.BLOCK_FORM, this, Priority.High, plugin); pm.registerEvent(Event.Type.BLOCK_FORM, this, Priority.High, plugin);
pm.registerEvent(Event.Type.BLOCK_SPREAD, this, Priority.High, plugin); pm.registerEvent(Event.Type.BLOCK_SPREAD, this, Priority.High, plugin);
} }
private void registerEventSafe(String typeName, Priority priority) {
try {
Event.Type type = Event.Type.valueOf(typeName);
PluginManager pm = plugin.getServer().getPluginManager();
pm.registerEvent(type, this, priority, plugin);
} catch (IllegalArgumentException e) {
logger.info("WorldGuard: Unable to register missing event type " + typeName);
}
}
/** /**
* Get the world configuration given a world. * Get the world configuration given a world.