mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-04 16:48:21 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 988fe600ce | |||
| 52df1863f4 | |||
| 4c46af55d0 |
@@ -9,13 +9,13 @@
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
<easyplugin.version>1.1.2</easyplugin.version>
|
||||
<easyplugin.version>1.1.3</easyplugin.version>
|
||||
</properties>
|
||||
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<artifactId>ultradepository</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.2</version>
|
||||
|
||||
<name>UltraDepository</name>
|
||||
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||
|
||||
@@ -38,28 +38,25 @@ public class UltraDepository extends EasyPlugin {
|
||||
@Override
|
||||
protected void load() {
|
||||
instance = this;
|
||||
|
||||
log("加载配置文件...");
|
||||
ConfigManager.initConfig();
|
||||
|
||||
GUI.initialize(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean initialize() {
|
||||
|
||||
log("初始化存储方式...");
|
||||
StorageMethod storageMethod = PluginConfig.STORAGE_METHOD.get();
|
||||
if (storageMethod == null) {
|
||||
log("初始化存储方式失败,放弃加载");
|
||||
log("加载配置文件...");
|
||||
if (!ConfigManager.initialize()) {
|
||||
log("初始化配置文件失败,放弃加载。");
|
||||
return false;
|
||||
}
|
||||
|
||||
storage = storageMethod.createStorage();
|
||||
log("初始化存储方式...");
|
||||
StorageMethod storageMethod = PluginConfig.STORAGE_METHOD.getOptional().orElse(StorageMethod.YAML);
|
||||
log(" 正在使用 " + storageMethod.name() + " 进行数据存储");
|
||||
|
||||
storage = storageMethod.createStorage();
|
||||
if (!storage.initialize()) {
|
||||
error("存储初始化失败,请检查配置文件。");
|
||||
error("初始化存储失败,请检查配置文件。");
|
||||
storage.shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -79,6 +76,7 @@ public class UltraDepository extends EasyPlugin {
|
||||
log("加载仓库管理器...");
|
||||
depositoryManager = new DepositoryManager();
|
||||
getDepositoryManager().loadDepositories();
|
||||
GUI.initialize(this);
|
||||
|
||||
log("注册监听器...");
|
||||
regListener(new UserListener());
|
||||
|
||||
@@ -117,7 +117,7 @@ public class UserData {
|
||||
|
||||
|
||||
public Date getDate() {
|
||||
return new Date(DateIntUtil.getDateMillis(getDateInt()));
|
||||
return DateIntUtil.getDate(getDateInt());
|
||||
}
|
||||
|
||||
public int getDateInt() {
|
||||
|
||||
@@ -9,12 +9,17 @@ public class ConfigManager {
|
||||
private static FileConfig pluginConfiguration;
|
||||
private static FileConfig messageConfiguration;
|
||||
|
||||
public static void initConfig() {
|
||||
public static boolean initialize() {
|
||||
try {
|
||||
pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
|
||||
messageConfiguration = new FileConfig(UltraDepository.getInstance(), "messages.yml");
|
||||
|
||||
FileConfig.pluginConfiguration = () -> pluginConfiguration;
|
||||
FileConfig.messageConfiguration = () -> messageConfiguration;
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static FileConfig getPluginConfig() {
|
||||
@@ -26,13 +31,21 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
try {
|
||||
getPluginConfig().reload();
|
||||
getMessageConfig().reload();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveConfig() {
|
||||
try {
|
||||
getPluginConfig().save();
|
||||
getMessageConfig().save();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,14 @@ public class DateIntUtil {
|
||||
}
|
||||
|
||||
public static long getDateMillis(int dateInt) {
|
||||
return getDate(dateInt).getTime();
|
||||
}
|
||||
|
||||
public static Date getDate(int dateInt) {
|
||||
try {
|
||||
return getFormat().parse(Integer.toString(dateInt)).getTime();
|
||||
} catch (ParseException e) {
|
||||
return System.currentTimeMillis();
|
||||
return (Date) getFormat().parse(Integer.toString(dateInt));
|
||||
} catch (ParseException | NumberFormatException e) {
|
||||
return new Date(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user