Merge branch 'master' of github.com:MassiveCraft/Factions

This commit is contained in:
Brettflan 2011-10-11 09:44:12 -05:00
commit d37a4d6ff7
4 changed files with 38 additions and 28 deletions

View File

@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.massivecraft.factions.cmd.*; import com.massivecraft.factions.cmd.*;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
@ -93,32 +92,31 @@ public class P extends MPlugin
} }
// Register events // Register events
PluginManager pm = this.getServer().getPluginManager(); this.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest);
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest, this); this.registerEvent(Event.Type.PLAYER_CHAT, this.chatEarlyListener, Event.Priority.Lowest);
pm.registerEvent(Event.Type.PLAYER_CHAT, this.chatEarlyListener, Event.Priority.Lowest, this); this.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.High);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.High, this); this.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.ENDERMAN_PICKUP, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.ENDERMAN_PICKUP, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.ENDERMAN_PLACE, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.ENDERMAN_PLACE, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.ENTITY_TARGET, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.ENTITY_TARGET, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PAINTING_BREAK, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PAINTING_BREAK, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.PAINTING_PLACE, this.entityListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.PAINTING_PLACE, this.entityListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, this.blockListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, this.blockListener, Event.Priority.Normal, this); this.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, this.blockListener, Event.Priority.Normal);
pm.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, this.blockListener, Event.Priority.Normal, this);
postEnable(); postEnable();
} }

View File

@ -10,6 +10,7 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -112,6 +113,15 @@ public abstract class MPlugin extends JavaPlugin
this.getServer().getPluginManager().disablePlugin(this); this.getServer().getPluginManager().disablePlugin(this);
} }
// -------------------------------------------- //
// Register Event convenience method
// -------------------------------------------- //
public void registerEvent(Event.Type type, Listener listener, Event.Priority priority)
{
Bukkit.getServer().getPluginManager().registerEvent(type, listener, priority, this);
}
// -------------------------------------------- // // -------------------------------------------- //
// Some inits... // Some inits...
// You are supposed to override these in the plugin if you aren't satisfied with the defaults // You are supposed to override these in the plugin if you aren't satisfied with the defaults

View File

@ -136,11 +136,13 @@ public class Persist {
// LOAD BY TYPE // LOAD BY TYPE
@SuppressWarnings("unchecked")
public <T> T load(Type typeOfT, String name) public <T> T load(Type typeOfT, String name)
{ {
return (T) load(typeOfT, getFile(name)); return (T) load(typeOfT, getFile(name));
} }
@SuppressWarnings("unchecked")
public <T> T load(Type typeOfT, File file) public <T> T load(Type typeOfT, File file)
{ {
String content = DiscUtil.readCatch(file); String content = DiscUtil.readCatch(file);