Merge remote-tracking branch 'origin/master' into CustomFactionEvents

This commit is contained in:
donington 2012-03-09 17:49:10 -05:00
commit 88bdadcb2b
3 changed files with 31 additions and 21 deletions

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions;
import java.util.*; import java.util.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.EntityType;
import com.massivecraft.factions.struct.FFlag; import com.massivecraft.factions.struct.FFlag;
import com.massivecraft.factions.struct.FPerm; import com.massivecraft.factions.struct.FPerm;
@ -155,7 +155,7 @@ public class Conf
//public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class); //public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
// TODO: Rename to monsterCreatureTypes // TODO: Rename to monsterCreatureTypes
public static transient Set<CreatureType> monsters = EnumSet.noneOf(CreatureType.class); public static transient Set<EntityType> monsters = EnumSet.noneOf(EntityType.class);
// Spout features // Spout features
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
@ -268,20 +268,20 @@ public class Conf
materialsEditTools.add(Material.WATER_BUCKET); materialsEditTools.add(Material.WATER_BUCKET);
materialsEditTools.add(Material.LAVA_BUCKET); materialsEditTools.add(Material.LAVA_BUCKET);
monsters.add(CreatureType.BLAZE); monsters.add(EntityType.BLAZE);
monsters.add(CreatureType.CAVE_SPIDER); monsters.add(EntityType.CAVE_SPIDER);
monsters.add(CreatureType.CREEPER); monsters.add(EntityType.CREEPER);
monsters.add(CreatureType.ENDERMAN); monsters.add(EntityType.ENDERMAN);
monsters.add(CreatureType.ENDER_DRAGON); monsters.add(EntityType.ENDER_DRAGON);
monsters.add(CreatureType.GHAST); monsters.add(EntityType.GHAST);
monsters.add(CreatureType.GIANT); monsters.add(EntityType.GIANT);
monsters.add(CreatureType.MAGMA_CUBE); monsters.add(EntityType.MAGMA_CUBE);
monsters.add(CreatureType.PIG_ZOMBIE); monsters.add(EntityType.PIG_ZOMBIE);
monsters.add(CreatureType.SILVERFISH); monsters.add(EntityType.SILVERFISH);
monsters.add(CreatureType.SKELETON); monsters.add(EntityType.SKELETON);
monsters.add(CreatureType.SLIME); monsters.add(EntityType.SLIME);
monsters.add(CreatureType.SPIDER); monsters.add(EntityType.SPIDER);
monsters.add(CreatureType.ZOMBIE); monsters.add(EntityType.ZOMBIE);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -78,6 +78,7 @@ public class P extends MPlugin
public void onEnable() public void onEnable()
{ {
if ( ! preEnable()) return; if ( ! preEnable()) return;
this.loadSuccessful = false;
// Load Conf from disk // Load Conf from disk
Conf.load(); Conf.load();
@ -112,6 +113,7 @@ public class P extends MPlugin
getServer().getPluginManager().registerEvents(serverListener, this); getServer().getPluginManager().registerEvents(serverListener, this);
postEnable(); postEnable();
this.loadSuccessful = true;
} }
@Override @Override
@ -132,9 +134,13 @@ public class P extends MPlugin
@Override @Override
public void onDisable() public void onDisable()
{
// only save data if plugin actually completely loaded successfully
if (this.loadSuccessful)
{ {
Board.save(); Board.save();
Conf.save(); Conf.save();
}
EssentialsFeatures.unhookChat(); EssentialsFeatures.unhookChat();
if (AutoLeaveTask != null) if (AutoLeaveTask != null)
{ {

View File

@ -34,6 +34,7 @@ public abstract class MPlugin extends JavaPlugin
public Gson gson; public Gson gson;
private Integer saveTask = null; private Integer saveTask = null;
private boolean autoSave = true; private boolean autoSave = true;
protected boolean loadSuccessful = false;
public boolean getAutoSave() {return this.autoSave;} public boolean getAutoSave() {return this.autoSave;}
public void setAutoSave(boolean val) {this.autoSave = val;} public void setAutoSave(boolean val) {this.autoSave = val;}
@ -82,6 +83,7 @@ public abstract class MPlugin extends JavaPlugin
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks); saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
} }
loadSuccessful = true;
return true; return true;
} }
@ -97,6 +99,8 @@ public abstract class MPlugin extends JavaPlugin
this.getServer().getScheduler().cancelTask(saveTask); this.getServer().getScheduler().cancelTask(saveTask);
saveTask = null; saveTask = null;
} }
// only save data if plugin actually loaded successfully
if (loadSuccessful)
EM.saveAllToDisc(); EM.saveAllToDisc();
log("Disabled"); log("Disabled");
} }