Minor startup fixes
This commit is contained in:
parent
390ad76fa6
commit
26fa7e8b95
@ -71,6 +71,10 @@ public class Factions extends MPlugin
|
|||||||
public Aspect getAspect() { return this.aspect; }
|
public Aspect getAspect() { return this.aspect; }
|
||||||
public Multiverse getMultiverse() { return this.getAspect().getMultiverse(); }
|
public Multiverse getMultiverse() { return this.getAspect().getMultiverse(); }
|
||||||
|
|
||||||
|
// Database Initialized
|
||||||
|
private boolean databaseInitialized;
|
||||||
|
public boolean isDatabaseInitialized() { return this.databaseInitialized; }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -96,11 +100,17 @@ public class Factions extends MPlugin
|
|||||||
MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
|
MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
|
||||||
|
|
||||||
// Initialize Collections
|
// Initialize Collections
|
||||||
|
this.databaseInitialized = false;
|
||||||
|
|
||||||
MConfColl.get().init();
|
MConfColl.get().init();
|
||||||
FPlayerColls.get().init();
|
FPlayerColls.get().init();
|
||||||
FactionColls.get().init();
|
FactionColls.get().init();
|
||||||
BoardColls.get().init();
|
BoardColls.get().init();
|
||||||
|
|
||||||
|
FactionColls.get().reindexFPlayers();
|
||||||
|
|
||||||
|
this.databaseInitialized = true;
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
this.outerCmdFactions = new CmdFactions();
|
this.outerCmdFactions = new CmdFactions();
|
||||||
this.outerCmdFactions.register(this);
|
this.outerCmdFactions.register(this);
|
||||||
|
@ -6,6 +6,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.massivecraft.factions.Const;
|
import com.massivecraft.factions.Const;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.RelationParticipator;
|
import com.massivecraft.factions.RelationParticipator;
|
||||||
@ -18,6 +20,7 @@ import com.massivecraft.mcore.store.Entity;
|
|||||||
import com.massivecraft.mcore.usys.Aspect;
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
import com.massivecraft.mcore.util.DiscUtil;
|
import com.massivecraft.mcore.util.DiscUtil;
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.util.SenderUtil;
|
||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||||
|
|
||||||
public class BoardColls extends Colls<BoardColl, Board> implements BoardInterface
|
public class BoardColls extends Colls<BoardColl, Board> implements BoardInterface
|
||||||
@ -66,6 +69,11 @@ public class BoardColls extends Colls<BoardColl, Board> implements BoardInterfac
|
|||||||
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SenderUtil.isNonplayer(o))
|
||||||
|
{
|
||||||
|
return this.getForWorld(Bukkit.getWorlds().get(0).getName());
|
||||||
|
}
|
||||||
|
|
||||||
String worldName = MUtil.extract(String.class, "worldName", o);
|
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||||
if (worldName == null) return null;
|
if (worldName == null) return null;
|
||||||
return this.getForWorld(worldName);
|
return this.getForWorld(worldName);
|
||||||
|
@ -231,7 +231,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
// Next we must be attached and inited
|
// Next we must be attached and inited
|
||||||
if (!this.attached()) return;
|
if (!this.attached()) return;
|
||||||
if (!this.getColl().inited()) return;
|
if (!this.getColl().inited()) return;
|
||||||
if (!FactionColls.get().get(this).inited()) return;
|
if (!Factions.get().isDatabaseInitialized()) return;
|
||||||
|
|
||||||
// Spout Derp
|
// Spout Derp
|
||||||
SpoutFeatures.updateTitle(this, null);
|
SpoutFeatures.updateTitle(this, null);
|
||||||
|
@ -30,7 +30,7 @@ public class FPlayerColl extends SenderColl<FPlayer>
|
|||||||
|
|
||||||
// If inited ...
|
// If inited ...
|
||||||
if (!this.inited()) return ret;
|
if (!this.inited()) return ret;
|
||||||
if (!FactionColls.get().getForUniverse(this.getUniverse()).inited()) return ret;
|
if (!Factions.get().isDatabaseInitialized()) return ret;
|
||||||
|
|
||||||
// ... update the index.
|
// ... update the index.
|
||||||
Faction faction = entity.getFaction();
|
Faction faction = entity.getFaction();
|
||||||
|
@ -5,6 +5,8 @@ import java.lang.reflect.Type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.massivecraft.factions.Const;
|
import com.massivecraft.factions.Const;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.mcore.MCore;
|
import com.massivecraft.mcore.MCore;
|
||||||
@ -14,6 +16,7 @@ import com.massivecraft.mcore.store.Entity;
|
|||||||
import com.massivecraft.mcore.usys.Aspect;
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
import com.massivecraft.mcore.util.DiscUtil;
|
import com.massivecraft.mcore.util.DiscUtil;
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.util.SenderUtil;
|
||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||||
|
|
||||||
public class FPlayerColls extends Colls<FPlayerColl, FPlayer>
|
public class FPlayerColls extends Colls<FPlayerColl, FPlayer>
|
||||||
@ -62,6 +65,11 @@ public class FPlayerColls extends Colls<FPlayerColl, FPlayer>
|
|||||||
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SenderUtil.isNonplayer(o))
|
||||||
|
{
|
||||||
|
return this.getForWorld(Bukkit.getWorlds().get(0).getName());
|
||||||
|
}
|
||||||
|
|
||||||
String worldName = MUtil.extract(String.class, "worldName", o);
|
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||||
if (worldName == null) return null;
|
if (worldName == null) return null;
|
||||||
return this.getForWorld(worldName);
|
return this.getForWorld(worldName);
|
||||||
@ -88,12 +96,15 @@ public class FPlayerColls extends Colls<FPlayerColl, FPlayer>
|
|||||||
Type type = new TypeToken<Map<String, FPlayer>>(){}.getType();
|
Type type = new TypeToken<Map<String, FPlayer>>(){}.getType();
|
||||||
Map<String, FPlayer> id2fplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
Map<String, FPlayer> id2fplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
||||||
|
|
||||||
|
// The Coll
|
||||||
|
FPlayerColl coll = this.getForUniverse(MCore.DEFAULT);
|
||||||
|
|
||||||
// Set the data
|
// Set the data
|
||||||
for (Entry<String, FPlayer> entry : id2fplayer.entrySet())
|
for (Entry<String, FPlayer> entry : id2fplayer.entrySet())
|
||||||
{
|
{
|
||||||
String playerId = entry.getKey();
|
String playerId = entry.getKey();
|
||||||
FPlayer fplayer = entry.getValue();
|
FPlayer fplayer = entry.getValue();
|
||||||
FPlayerColls.get().getForUniverse(MCore.DEFAULT).create(playerId).load(fplayer);
|
coll.attach(fplayer, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark as migrated
|
// Mark as migrated
|
||||||
|
@ -39,9 +39,9 @@ public class FactionColl extends Coll<Faction>
|
|||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
this.createDefaultFactions();
|
this.createDefaultFactions();
|
||||||
this.reindexFPlayers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
protected synchronized String attach(Faction faction, Object oid, boolean noteChange)
|
protected synchronized String attach(Faction faction, Object oid, boolean noteChange)
|
||||||
{
|
{
|
||||||
@ -51,13 +51,18 @@ public class FactionColl extends Coll<Faction>
|
|||||||
// TODO: Can this be done here?
|
// TODO: Can this be done here?
|
||||||
// TODO: Or will it be a to heavy operation to do this often?
|
// TODO: Or will it be a to heavy operation to do this often?
|
||||||
|
|
||||||
|
//System.out.println("faction "+faction);
|
||||||
|
//System.out.println("faction.getId() "+faction.getId());
|
||||||
|
// TODO: Why does this happen for Wilderness?
|
||||||
|
if (faction.getId() == null) return ret;
|
||||||
|
|
||||||
if (!Money.exists(faction))
|
if (!Money.exists(faction))
|
||||||
{
|
{
|
||||||
Money.set(faction, 0);
|
Money.set(faction, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Faction detachId(Object oid)
|
public Faction detachId(Object oid)
|
||||||
@ -77,6 +82,10 @@ public class FactionColl extends Coll<Faction>
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INDEX
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void reindexFPlayers()
|
public void reindexFPlayers()
|
||||||
{
|
{
|
||||||
for (Faction faction : this.getAll())
|
for (Faction faction : this.getAll())
|
||||||
|
@ -5,6 +5,8 @@ import java.lang.reflect.Type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.massivecraft.factions.Const;
|
import com.massivecraft.factions.Const;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.mcore.MCore;
|
import com.massivecraft.mcore.MCore;
|
||||||
@ -14,6 +16,7 @@ import com.massivecraft.mcore.store.Entity;
|
|||||||
import com.massivecraft.mcore.usys.Aspect;
|
import com.massivecraft.mcore.usys.Aspect;
|
||||||
import com.massivecraft.mcore.util.DiscUtil;
|
import com.massivecraft.mcore.util.DiscUtil;
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.util.SenderUtil;
|
||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
|
||||||
|
|
||||||
public class FactionColls extends Colls<FactionColl, Faction>
|
public class FactionColls extends Colls<FactionColl, Faction>
|
||||||
@ -62,6 +65,11 @@ public class FactionColls extends Colls<FactionColl, Faction>
|
|||||||
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SenderUtil.isNonplayer(o))
|
||||||
|
{
|
||||||
|
return this.getForWorld(Bukkit.getWorlds().get(0).getName());
|
||||||
|
}
|
||||||
|
|
||||||
String worldName = MUtil.extract(String.class, "worldName", o);
|
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||||
if (worldName == null) return null;
|
if (worldName == null) return null;
|
||||||
return this.getForWorld(worldName);
|
return this.getForWorld(worldName);
|
||||||
@ -88,17 +96,31 @@ public class FactionColls extends Colls<FactionColl, Faction>
|
|||||||
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
|
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
|
||||||
Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
|
||||||
|
|
||||||
|
// The Coll
|
||||||
|
FactionColl coll = this.getForUniverse(MCore.DEFAULT);
|
||||||
|
|
||||||
// Set the data
|
// Set the data
|
||||||
for (Entry<String, Faction> entry : id2faction.entrySet())
|
for (Entry<String, Faction> entry : id2faction.entrySet())
|
||||||
{
|
{
|
||||||
String factionId = entry.getKey();
|
String factionId = entry.getKey();
|
||||||
Faction faction = entry.getValue();
|
Faction faction = entry.getValue();
|
||||||
|
coll.attach(faction, factionId);
|
||||||
this.getForUniverse(MCore.DEFAULT).create(factionId).load(faction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark as migrated
|
// Mark as migrated
|
||||||
oldFile.renameTo(newFile);
|
oldFile.renameTo(newFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INDEX
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public void reindexFPlayers()
|
||||||
|
{
|
||||||
|
for (FactionColl coll : this.getColls())
|
||||||
|
{
|
||||||
|
coll.reindexFPlayers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import java.util.Set;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
import com.massivecraft.mcore.MCore;
|
|
||||||
import com.massivecraft.mcore.store.Entity;
|
import com.massivecraft.mcore.store.Entity;
|
||||||
|
|
||||||
public class MConf extends Entity<MConf>
|
public class MConf extends Entity<MConf>
|
||||||
@ -16,9 +15,10 @@ public class MConf extends Entity<MConf>
|
|||||||
// META
|
// META
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
protected static transient MConf i;
|
||||||
public static MConf get()
|
public static MConf get()
|
||||||
{
|
{
|
||||||
return MConfColl.get().get(MCore.INSTANCE);
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -28,7 +28,8 @@ public class MConfColl extends Coll<MConf>
|
|||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
super.init();
|
super.init();
|
||||||
this.get(MCore.INSTANCE);
|
|
||||||
|
MConf.i = this.get(MCore.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
|
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
|
||||||
|
|
||||||
FPlayer me = FPlayer.get(name);
|
FPlayer me = FPlayer.get(player);
|
||||||
if (me.isUsingAdminMode()) return true;
|
if (me.isUsingAdminMode()) return true;
|
||||||
|
|
||||||
Faction factionHere = BoardColls.get().getFactionAt(ps);
|
Faction factionHere = BoardColls.get().getFactionAt(ps);
|
||||||
|
Loading…
Reference in New Issue
Block a user