mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Fixed load/unload re-registering listeners. This is War v1.6 PREVIEW 3.
This commit is contained in:
parent
f56c5571dd
commit
8fcd24da2c
@ -38,6 +38,7 @@ import com.tommytony.war.utils.*;
|
||||
public class War extends JavaPlugin {
|
||||
public static PermissionHandler permissionHandler;
|
||||
public static War war;
|
||||
private static boolean loadedOnce = false;
|
||||
|
||||
// general
|
||||
private WarPlayerListener playerListener = new WarPlayerListener();
|
||||
@ -88,7 +89,6 @@ public class War extends JavaPlugin {
|
||||
* @see War.loadWar()
|
||||
*/
|
||||
public void onEnable() {
|
||||
War.war = this;
|
||||
this.loadWar();
|
||||
}
|
||||
|
||||
@ -109,27 +109,31 @@ public class War extends JavaPlugin {
|
||||
this.logger = this.getServer().getLogger();
|
||||
this.setupPermissions();
|
||||
|
||||
// Register hooks
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.INVENTORY_OPEN, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Priority.Normal, this);
|
||||
|
||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.High, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, this.entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
|
||||
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Priority.Normal, this);
|
||||
|
||||
|
||||
if(!loadedOnce) {
|
||||
loadedOnce = true; // This prevented multiple hookups of the same listener
|
||||
|
||||
// Register hooks
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.INVENTORY_OPEN, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Priority.Normal, this);
|
||||
|
||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.High, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, this.entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
|
||||
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Priority.Normal, this);
|
||||
}
|
||||
|
||||
// Load files from disk or create them (using these defaults)
|
||||
this.getDefaultLoadout().put(0, new ItemStack(Material.STONE_SWORD, 1, (byte) 8));
|
||||
this.getDefaultLoadout().put(1, new ItemStack(Material.BOW, 1, (byte) 8));
|
||||
@ -137,7 +141,7 @@ public class War extends JavaPlugin {
|
||||
this.getDefaultLoadout().put(3, new ItemStack(Material.IRON_PICKAXE, 1, (byte) 8));
|
||||
this.getDefaultLoadout().put(4, new ItemStack(Material.STONE_SPADE, 1, (byte) 8));
|
||||
this.getDefaultReward().put( 0, new ItemStack(Material.CAKE, 1));
|
||||
|
||||
|
||||
WarMapper.load();
|
||||
this.log("War v" + this.desc.getVersion() + " is on.", Level.INFO);
|
||||
}
|
||||
@ -150,6 +154,8 @@ public class War extends JavaPlugin {
|
||||
warzone.unload();
|
||||
}
|
||||
this.warzones.clear();
|
||||
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
|
||||
if (this.warHub != null) {
|
||||
this.warHub.getVolume().resetBlocks();
|
||||
|
@ -15,8 +15,9 @@ public class LoadWarCommand extends AbstractZoneMakerCommand {
|
||||
if (this.args.length != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
War.war.loadWar();
|
||||
|
||||
this.msg("War loaded.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class UnloadWarCommand extends AbstractZoneMakerCommand {
|
||||
}
|
||||
|
||||
War.war.unloadWar();
|
||||
|
||||
this.msg("War unloaded.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user