mirror of
https://github.com/MiniDay/HamsterCurrency-Parent.git
synced 2025-08-23 04:35:30 +08:00
Compare commits
3 Commits
91817db007
...
master
Author | SHA1 | Date | |
---|---|---|---|
054733ba8f | |||
16f5b7f49a | |||
aacfc4697b |
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'cn.hamster3'
|
||||
version '2.2.6'
|
||||
version '2.2.8'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
@@ -158,16 +158,18 @@ public class SQLDataManager implements IDataManager {
|
||||
if (data == null) {
|
||||
data = new PlayerData(uuid, name);
|
||||
playerData.put(data.getUuid(), data);
|
||||
}else {
|
||||
data.setPlayerName(name);
|
||||
}
|
||||
data.setPlayerCurrency(currencyType, money);
|
||||
getLogUtils().info("已从其他插件中加载了玩家 %s 的存档数据.", data.getUuid());
|
||||
getLogUtils().info("已从其他插件中加载了玩家 %s(%s) 的存档数据.", uuid, name);
|
||||
} catch (Exception e) {
|
||||
getLogUtils().error(e, "导入某一条数据时发生了一个错误: ");
|
||||
}
|
||||
}
|
||||
for (PlayerData data : playerData.values()) {
|
||||
statement.executeUpdate(String.format(
|
||||
"REPLACE INTO " + database + ".hamster_currency_player_data VALUES('%s', '%s');",
|
||||
"REPLACE INTO hamster_currency_player_data VALUES('%s', '%s');",
|
||||
data.getUuid().toString(),
|
||||
data.saveToJson().toString()
|
||||
));
|
||||
@@ -311,7 +313,7 @@ public class SQLDataManager implements IDataManager {
|
||||
|
||||
@Override
|
||||
public PlayerData getPlayerData(UUID uuid) {
|
||||
return playerData.computeIfAbsent(uuid, PlayerData::new);
|
||||
return playerData.get(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,7 +14,7 @@ import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
private final UUID uuid;
|
||||
private final String playerName;
|
||||
private String playerName;
|
||||
private final HashMap<String, Double> playerCurrencies;
|
||||
|
||||
public PlayerData(UUID uuid) {
|
||||
@@ -31,7 +31,7 @@ public class PlayerData {
|
||||
|
||||
public PlayerData(JsonObject object) {
|
||||
uuid = UUID.fromString(object.get("uuid").getAsString());
|
||||
if (object.has("playerName")) {
|
||||
if (object.has("playerName") && !object.get("playerName").isJsonNull()) {
|
||||
playerName = object.get("playerName").getAsString();
|
||||
} else {
|
||||
playerName = ServiceInfoAPI.getPlayerInfo(uuid).getPlayerName();
|
||||
@@ -91,6 +91,10 @@ public class PlayerData {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public void setPlayerCurrency(String type, double amount) {
|
||||
playerCurrencies.put(type, amount);
|
||||
}
|
||||
|
@@ -43,6 +43,9 @@ public class SQLListener extends CurrencyListener {
|
||||
break;
|
||||
}
|
||||
case "savedPlayerData": {
|
||||
if (ServiceInfoAPI.getLocalServerName().equals(info.getSenderInfo().getName())) {
|
||||
return;
|
||||
}
|
||||
if (ServiceInfoAPI.getLocalSenderInfo().equals(info.getSenderInfo())) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user