mirror of
https://github.com/MiniDay/HamsterCurrency-Parent.git
synced 2025-08-23 04:35:30 +08:00
Compare commits
5 Commits
2.0.6-SNAP
...
2.0.8-SNAP
Author | SHA1 | Date | |
---|---|---|---|
870a3789f2 | |||
eff200634d | |||
59f1e02a6c | |||
e6d95e0ba9 | |||
ca220775b6 |
@@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.hamster3</groupId>
|
||||
<artifactId>HamsterCurrency</artifactId>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<version>2.0.7-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'cn.hamster3'
|
||||
version '2.0.6-SNAPSHOT'
|
||||
version '2.0.8-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
@@ -19,7 +19,7 @@ dependencies {
|
||||
// https://mvnrepository.com/artifact/org.jetbrains/annotations
|
||||
compileOnly group: 'org.jetbrains', name: 'annotations', version: '22.0.0'
|
||||
compileOnly "cn.hamster3:HamsterService-Bukkit:2.6.2-SNAPSHOT"
|
||||
compileOnly "cn.hamster3:HamsterAPI:2.4.0-SNAPSHOT"
|
||||
compileOnly "cn.hamster3:HamsterAPI:2.4.3-SNAPSHOT"
|
||||
compileOnly "com.github.MilkBowl:VaultAPI:1.7"
|
||||
compileOnly "org.black_ixx:PlayerPoints:2.1.3"
|
||||
compileOnly "me.clip:placeholderapi:2.10.9"
|
||||
|
@@ -2,6 +2,7 @@ package cn.hamster3.currency.command;
|
||||
|
||||
import cn.hamster3.api.command.CommandExecutor;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.core.Message;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -11,7 +12,7 @@ public class ReloadCommand extends CommandExecutor {
|
||||
private final IDataManager dataManager;
|
||||
|
||||
public ReloadCommand(IDataManager dataManager) {
|
||||
super("reload", "重载服务器");
|
||||
super("reload", "重载服务器", "currency.reload");
|
||||
this.dataManager = dataManager;
|
||||
}
|
||||
|
||||
@@ -20,6 +21,11 @@ public class ReloadCommand extends CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionMessage() {
|
||||
return Message.notHasPermission.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
dataManager.reloadConfig();
|
||||
|
@@ -28,7 +28,6 @@ public class SQLDataManager implements IDataManager {
|
||||
private final HashSet<PlayerData> playerData;
|
||||
private final HashSet<CurrencyType> currencyTypes;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public SQLDataManager(HamsterCurrency plugin) throws SQLException, ClassNotFoundException {
|
||||
this.plugin = plugin;
|
||||
parser = new JsonParser();
|
||||
@@ -40,11 +39,11 @@ public class SQLDataManager implements IDataManager {
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS hamster_currency_player_data(" +
|
||||
"uuid VARCHAR(36) PRIMARY KEY," +
|
||||
"data TEXT" +
|
||||
");");
|
||||
") CHARACTER SET = utf8mb4;");
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS hamster_currency_settings(" +
|
||||
"title VARCHAR(64) PRIMARY KEY," +
|
||||
"data TEXT" +
|
||||
");");
|
||||
") CHARACTER SET = utf8mb4;");
|
||||
|
||||
statement.close();
|
||||
}
|
||||
@@ -69,7 +68,7 @@ public class SQLDataManager implements IDataManager {
|
||||
getLogUtils().error(e, "插件上传 pluginConfig 至数据库时遇到了一个异常: ");
|
||||
}
|
||||
loadConfig(config);
|
||||
ServiceMessageAPI.sendMessage("HamsterCurrency", "uploadConfigToSQL");
|
||||
ServiceMessageAPI.sendServiceMessage("HamsterCurrency", "uploadConfigToSQL");
|
||||
}
|
||||
|
||||
@SuppressWarnings("SwitchStatementWithTooFewBranches")
|
||||
@@ -100,7 +99,6 @@ public class SQLDataManager implements IDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void loadConfig(FileConfiguration config) {
|
||||
getLogUtils().info("加载配置文件...");
|
||||
currencyTypes.clear();
|
||||
@@ -154,7 +152,7 @@ public class SQLDataManager implements IDataManager {
|
||||
data.saveToJson().toString()
|
||||
));
|
||||
getLogUtils().info("已保存玩家 %s 的存档数据.", data.getUuid());
|
||||
ServiceMessageAPI.sendMessage("HamsterCurrency", "savedPlayerData", data.getUuid().toString());
|
||||
ServiceMessageAPI.sendServiceMessage("HamsterCurrency", "savedPlayerData", data.getUuid().toString());
|
||||
}
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -207,7 +205,7 @@ public class SQLDataManager implements IDataManager {
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
ServiceMessageAPI.sendMessage("HamsterCurrency", "reload");
|
||||
ServiceMessageAPI.sendServiceMessage("HamsterCurrency", "reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -260,7 +258,7 @@ public class SQLDataManager implements IDataManager {
|
||||
getLogUtils().error(e, "保存玩家 %s 的存档数据时出错!", data.getUuid());
|
||||
}
|
||||
getLogUtils().info("已保存玩家 %s 的存档数据.", data.getUuid());
|
||||
ServiceMessageAPI.sendMessage(
|
||||
ServiceMessageAPI.sendServiceMessage(
|
||||
"HamsterCurrency",
|
||||
"savedPlayerData",
|
||||
data.getUuid().toString()
|
||||
|
@@ -45,14 +45,13 @@ public class PlayerData {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public PlayerData(ConfigurationSection config) {
|
||||
uuid = UUID.fromString(config.getString("uuid"));
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||
if (player.getName() != null) {
|
||||
playerName = player.getName();
|
||||
} else {
|
||||
playerName = config.getString("playerName");
|
||||
playerName = config.getString("playerName").replace("\\'", "'");
|
||||
}
|
||||
playerCurrencies = new HashMap<>();
|
||||
ConfigurationSection playerCurrenciesConfig = config.getConfigurationSection("playerCurrencies");
|
||||
@@ -64,7 +63,7 @@ public class PlayerData {
|
||||
public JsonObject saveToJson() {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("uuid", uuid.toString());
|
||||
object.addProperty("playerName", playerName);
|
||||
object.addProperty("playerName", playerName.replace("'", "\\'"));
|
||||
JsonObject playerCurrenciesJson = new JsonObject();
|
||||
for (Map.Entry<String, Double> entry : playerCurrencies.entrySet()) {
|
||||
playerCurrenciesJson.addProperty(entry.getKey(), entry.getValue());
|
||||
|
@@ -38,6 +38,8 @@ permissions:
|
||||
default: op
|
||||
currency.set:
|
||||
default: op
|
||||
currency.reload:
|
||||
default: op
|
||||
currency.look:
|
||||
default: true
|
||||
currency.look.other:
|
||||
|
@@ -12,7 +12,6 @@ repositories {
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
||||
implementationShade
|
||||
implementation.extendsFrom implementationShade
|
||||
}
|
||||
|
Reference in New Issue
Block a user