Removing most of the stupid map-references.

This commit is contained in:
Olof Larsson 2012-08-31 09:59:14 +02:00
parent bdb34e6d8e
commit 7e7435e614
2 changed files with 5 additions and 55 deletions

View File

@ -14,13 +14,10 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.massivecraft.mcore4.adapter.InventoryAdapter; import com.massivecraft.mcore4.adapter.InventoryAdapter;
import com.massivecraft.mcore4.adapter.ItemStackAdapter; import com.massivecraft.mcore4.adapter.ItemStackAdapter;
import com.massivecraft.mcore4.adapter.MongoURIAdapter; import com.massivecraft.mcore4.adapter.MongoURIAdapter;
import com.massivecraft.mcore4.cmd.Cmd;
import com.massivecraft.mcore4.lib.gson.Gson; import com.massivecraft.mcore4.lib.gson.Gson;
import com.massivecraft.mcore4.lib.gson.GsonBuilder; import com.massivecraft.mcore4.lib.gson.GsonBuilder;
import com.massivecraft.mcore4.lib.mongodb.MongoURI; import com.massivecraft.mcore4.lib.mongodb.MongoURI;
import com.massivecraft.mcore4.persist.One;
import com.massivecraft.mcore4.persist.Persist; import com.massivecraft.mcore4.persist.Persist;
import com.massivecraft.mcore4.util.LibLoader;
import com.massivecraft.mcore4.util.PlayerUtil; import com.massivecraft.mcore4.util.PlayerUtil;
import com.massivecraft.mcore4.util.Txt; import com.massivecraft.mcore4.util.Txt;
@ -42,45 +39,6 @@ public class MCore extends JavaPlugin
persistInstances.put(owner, new Persist()); persistInstances.put(owner, new Persist());
} }
// -------------------------------------------- //
// CMD
// -------------------------------------------- //
private static Map<Object, Cmd> cmdInstances = new HashMap<Object, Cmd>();
public static Map<Object, Cmd> getCmdInstances() { return cmdInstances; }
public static Cmd getCmd(Object owner) { return cmdInstances.get(owner); }
public static void removeCmd(Object owner) { cmdInstances.remove(owner); }
public static void createCmd(Object owner)
{
if (cmdInstances.containsKey(owner)) return;
cmdInstances.put(owner, new Cmd());
}
// -------------------------------------------- //
// ONE
// -------------------------------------------- //
private static Map<MPlugin, One> oneInstances = new HashMap<MPlugin, One>();
public static Map<MPlugin, One> getOneInstances() { return oneInstances; }
public static One getOne(MPlugin owner) { return oneInstances.get(owner); }
public static void removeOne(MPlugin owner) { oneInstances.remove(owner); }
public static void createOne(MPlugin owner)
{
if (oneInstances.containsKey(owner)) return;
oneInstances.put(owner, new One(owner));
}
// -------------------------------------------- //
// LIBLOADER
// -------------------------------------------- //
private static Map<MPlugin, LibLoader> libLoaderInstances = new HashMap<MPlugin, LibLoader>();
public static Map<MPlugin, LibLoader> getLibLoaderInstances() { return libLoaderInstances; }
public static LibLoader getLibLoader(MPlugin owner) { return libLoaderInstances.get(owner); }
public static void removeLibLoader(MPlugin owner) { libLoaderInstances.remove(owner); }
public static void createLibLoader(MPlugin owner)
{
if (libLoaderInstances.containsKey(owner)) return;
libLoaderInstances.put(owner, new LibLoader(owner));
}
// -------------------------------------------- // // -------------------------------------------- //
// DERP // DERP
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -43,17 +43,12 @@ public abstract class MPlugin extends JavaPlugin implements Listener
// Create Gson // Create Gson
this.gson = this.getGsonBuilder().create(); this.gson = this.getGsonBuilder().create();
// Create Tools
MCore.createCmd(this);
MCore.createPersist(this);
MCore.createOne(this);
MCore.createLibLoader(this);
// Assign tool pointers MCore.createPersist(this);
this.cmd = MCore.getCmd(this); this.cmd = new Cmd();
this.persist = MCore.getPersist(this); this.persist = MCore.getPersist(this);
this.one = MCore.getOne(this); this.one = new One(this);
this.lib = MCore.getLibLoader(this); this.lib = new LibLoader(this);
return true; return true;
} }
@ -69,11 +64,8 @@ public abstract class MPlugin extends JavaPlugin implements Listener
public void onDisable() public void onDisable()
{ {
MCore.getPersist(this).saveAll(); this.persist.saveAll();
MCore.removePersist(this); MCore.removePersist(this);
MCore.removeOne(this);
MCore.removeCmd(this);
MCore.removeLibLoader(this);
this.cmd = null; this.cmd = null;
this.persist = null; this.persist = null;