Removing most of the stupid map-references.
This commit is contained in:
parent
bdb34e6d8e
commit
7e7435e614
@ -14,13 +14,10 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import com.massivecraft.mcore4.adapter.InventoryAdapter;
|
||||
import com.massivecraft.mcore4.adapter.ItemStackAdapter;
|
||||
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.GsonBuilder;
|
||||
import com.massivecraft.mcore4.lib.mongodb.MongoURI;
|
||||
import com.massivecraft.mcore4.persist.One;
|
||||
import com.massivecraft.mcore4.persist.Persist;
|
||||
import com.massivecraft.mcore4.util.LibLoader;
|
||||
import com.massivecraft.mcore4.util.PlayerUtil;
|
||||
import com.massivecraft.mcore4.util.Txt;
|
||||
|
||||
@ -42,45 +39,6 @@ public class MCore extends JavaPlugin
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
|
@ -43,17 +43,12 @@ public abstract class MPlugin extends JavaPlugin implements Listener
|
||||
// Create Gson
|
||||
this.gson = this.getGsonBuilder().create();
|
||||
|
||||
// Create Tools
|
||||
MCore.createCmd(this);
|
||||
MCore.createPersist(this);
|
||||
MCore.createOne(this);
|
||||
MCore.createLibLoader(this);
|
||||
|
||||
// Assign tool pointers
|
||||
this.cmd = MCore.getCmd(this);
|
||||
MCore.createPersist(this);
|
||||
this.cmd = new Cmd();
|
||||
this.persist = MCore.getPersist(this);
|
||||
this.one = MCore.getOne(this);
|
||||
this.lib = MCore.getLibLoader(this);
|
||||
this.one = new One(this);
|
||||
this.lib = new LibLoader(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -69,11 +64,8 @@ public abstract class MPlugin extends JavaPlugin implements Listener
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
MCore.getPersist(this).saveAll();
|
||||
this.persist.saveAll();
|
||||
MCore.removePersist(this);
|
||||
MCore.removeOne(this);
|
||||
MCore.removeCmd(this);
|
||||
MCore.removeLibLoader(this);
|
||||
|
||||
this.cmd = null;
|
||||
this.persist = null;
|
||||
|
Loading…
Reference in New Issue
Block a user