MCore is now itself an mplugin.
This commit is contained in:
parent
c99c441490
commit
d56c87759a
@ -9,7 +9,6 @@ import org.bukkit.event.player.PlayerPreLoginEvent;
|
|||||||
|
|
||||||
import com.massivecraft.mcore4.persist.IClassManager;
|
import com.massivecraft.mcore4.persist.IClassManager;
|
||||||
import com.massivecraft.mcore4.persist.Persist;
|
import com.massivecraft.mcore4.persist.Persist;
|
||||||
import com.massivecraft.mcore4.util.PlayerUtil;
|
|
||||||
|
|
||||||
public class InternalListener implements Listener
|
public class InternalListener implements Listener
|
||||||
{
|
{
|
||||||
@ -27,8 +26,6 @@ public class InternalListener implements Listener
|
|||||||
{
|
{
|
||||||
String id = event.getName();
|
String id = event.getName();
|
||||||
|
|
||||||
PlayerUtil.getAllVisitorNames().add(id);
|
|
||||||
|
|
||||||
for (Persist instance : Persist.instances)
|
for (Persist instance : Persist.instances)
|
||||||
{
|
{
|
||||||
for (IClassManager<?> manager : instance.getClassManagers().values())
|
for (IClassManager<?> manager : instance.getClassManagers().values())
|
||||||
|
@ -2,46 +2,29 @@ package com.massivecraft.mcore4;
|
|||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
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.persist.Persist;
|
import com.massivecraft.mcore4.persist.Persist;
|
||||||
import com.massivecraft.mcore4.util.PlayerUtil;
|
import com.massivecraft.mcore4.util.PlayerUtil;
|
||||||
import com.massivecraft.mcore4.util.Txt;
|
|
||||||
import com.massivecraft.mcore4.xlib.gson.Gson;
|
import com.massivecraft.mcore4.xlib.gson.Gson;
|
||||||
import com.massivecraft.mcore4.xlib.gson.GsonBuilder;
|
import com.massivecraft.mcore4.xlib.gson.GsonBuilder;
|
||||||
import com.massivecraft.mcore4.xlib.mongodb.MongoURI;
|
import com.massivecraft.mcore4.xlib.mongodb.MongoURI;
|
||||||
|
|
||||||
public class MCore extends JavaPlugin
|
public class MCore extends MPlugin
|
||||||
{
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// STATIC
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static Random random = new Random();
|
public static Random random = new Random();
|
||||||
public static Gson gson = getGsonBuilder().create();
|
public static Gson gson = getMCoreGsonBuilder().create();
|
||||||
|
|
||||||
InternalListener listener;
|
public static GsonBuilder getMCoreGsonBuilder()
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable()
|
|
||||||
{
|
|
||||||
logPrefix = "["+this.getDescription().getName()+"] ";
|
|
||||||
|
|
||||||
// Setup PlayerUtil and it's events
|
|
||||||
new PlayerUtil(this);
|
|
||||||
|
|
||||||
// This is safe since all plugins using Persist should bukkit-depend this plugin.
|
|
||||||
Persist.instances.clear();
|
|
||||||
|
|
||||||
// Register events
|
|
||||||
this.listener = new InternalListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder getGsonBuilder()
|
|
||||||
{
|
{
|
||||||
return new GsonBuilder()
|
return new GsonBuilder()
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
@ -53,15 +36,22 @@ public class MCore extends JavaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// LOGGING
|
// NON STATIC :)
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
private static String logPrefix = null;
|
|
||||||
public static void log(Object... msg)
|
InternalListener listener;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
{
|
{
|
||||||
log(Level.INFO, msg);
|
// Setup PlayerUtil and it's events
|
||||||
}
|
new PlayerUtil(this);
|
||||||
public static void log(Level level, Object... msg)
|
|
||||||
{
|
// This is safe since all plugins using Persist should bukkit-depend this plugin.
|
||||||
Logger.getLogger("Minecraft").log(level, logPrefix + Txt.implode(msg, " "));
|
Persist.instances.clear();
|
||||||
|
|
||||||
|
// Register events
|
||||||
|
this.listener = new InternalListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public abstract class MPlugin extends JavaPlugin implements Listener
|
|||||||
|
|
||||||
public GsonBuilder getGsonBuilder()
|
public GsonBuilder getGsonBuilder()
|
||||||
{
|
{
|
||||||
return MCore.getGsonBuilder();
|
return MCore.getMCoreGsonBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -10,7 +10,6 @@ import org.bukkit.command.SimpleCommandMap;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.massivecraft.mcore4.Lang;
|
import com.massivecraft.mcore4.Lang;
|
||||||
import com.massivecraft.mcore4.MCore;
|
|
||||||
import com.massivecraft.mcore4.MPlugin;
|
import com.massivecraft.mcore4.MPlugin;
|
||||||
import com.massivecraft.mcore4.cmd.arg.IArgHandler;
|
import com.massivecraft.mcore4.cmd.arg.IArgHandler;
|
||||||
import com.massivecraft.mcore4.cmd.req.IReq;
|
import com.massivecraft.mcore4.cmd.req.IReq;
|
||||||
@ -461,7 +460,7 @@ public abstract class MCommand
|
|||||||
|
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
{
|
{
|
||||||
MCore.log(Level.SEVERE, "There is no ArgHandler for " + clazz.getName());
|
p().log(Level.SEVERE, "There is no ArgHandler for " + clazz.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
T ret = handler.parse(this.arg(idx), style, this.sender, p());
|
T ret = handler.parse(this.arg(idx), style, this.sender, p());
|
||||||
|
@ -29,11 +29,6 @@ public class PlayerUtil implements Listener
|
|||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the latest created instance of this class.
|
|
||||||
*/
|
|
||||||
private static PlayerUtil i = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We will use this folder later.
|
* We will use this folder later.
|
||||||
*/
|
*/
|
||||||
@ -57,8 +52,6 @@ public class PlayerUtil implements Listener
|
|||||||
|
|
||||||
public PlayerUtil(Plugin plugin)
|
public PlayerUtil(Plugin plugin)
|
||||||
{
|
{
|
||||||
if (i != null) return;
|
|
||||||
i = this;
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
populateCaseInsensitiveNameToCaseCorrectName();
|
populateCaseInsensitiveNameToCaseCorrectName();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user