feat: 添加数据库保存

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-28 01:04:58 +08:00
parent 829351e576
commit 2b3313579c
4 changed files with 31 additions and 2 deletions

View File

@ -38,7 +38,7 @@ public class YumPluginLoader implements PluginLoader {
internal_loader = new JavaPluginLoader(instance);
}
public static void cleanJavaPluginLoaders() {
public static void replaceJavaPluginLoaders() {
final YumPluginLoader yumPluginLoader = new YumPluginLoader(Bukkit.getServer());
final PluginManager spm = Bukkit.getPluginManager();
try {

View File

@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.PluginHelper.bukkit.P;
import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.sql.DataBase;
public class ConfigManager {
public final static String ENABLE = "Enable";
@ -36,6 +37,10 @@ public class ConfigManager {
return config.getStringList("blacklist");
}
public DataBase getDataBase() {
return DataBase.create(P.instance, config.getConfigurationSection(""));
}
public List<String> getIgnoreList() {
return config.getStringList("ignorelist");
}

View File

@ -0,0 +1,20 @@
package pw.yumc.Yum.managers;
import cn.citycraft.PluginHelper.sql.DataBase;
import cn.citycraft.PluginHelper.sql.KeyValue;
import cn.citycraft.PluginHelper.sql.Type;
public class DataManager {
private static DataBase db = ConfigManager.i().getDataBase();
public static void init() {
db.createTables(TableName.cmd, new KeyValue("name", Type.VARCHAR.get()), null);
}
static class TableName {
public static String prefix = "monitor_";
public static String cmd = prefix + "cmd";
public static String event = prefix + "event";
public static String task = prefix + "task";
}
}

View File

@ -42,13 +42,17 @@ public class MonitorManager {
private final static Map<String, Long> event = new ConcurrentHashMap<>();
private final static Map<String, Long> cmd = new ConcurrentHashMap<>();
private final static DataBase db = null;
private static DataBase db;
private final static double um = 1000000.00;
private final static LogKit mlog = new LogKit("monitor.log");
private final static LogKit elog = new LogKit("error.log");
public MonitorManager() {
db = ConfigManager.i().getDataBase();
}
public static void addCmd(final String pname, final long time) {
add(pname, time, monitor, cmd);
}