1.2.1
This commit is contained in:
parent
183135cc58
commit
629aa7411e
|
@ -18,6 +18,9 @@ public class PlayerData {
|
|||
* 玩家数据类,用于管理玩家的奖励接收情况
|
||||
*/
|
||||
private final String playerName;
|
||||
private int roundAmount;
|
||||
|
||||
private int recordConsume;
|
||||
|
||||
/**
|
||||
* 存储玩家已接收的奖励列表
|
||||
|
@ -35,11 +38,34 @@ public class PlayerData {
|
|||
// 加载玩家的奖励数据文件
|
||||
File file = new File("plugins/AuData/ConsumeReward", playerName + ".yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
this.roundAmount = config.getInt("RoundAmount");
|
||||
this.recordConsume = config.getInt("RecordConsume");
|
||||
List<String> rewards = config.getStringList("RewardsReceive");
|
||||
// 使用 LinkedHashSet 保持插入顺序,避免重复
|
||||
this.rewardList = new LinkedHashSet<>(rewards);
|
||||
}
|
||||
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public int getRoundAmount() {
|
||||
return roundAmount;
|
||||
}
|
||||
|
||||
public void setRoundAmount(int roundAmount) {
|
||||
this.roundAmount = roundAmount;
|
||||
}
|
||||
|
||||
public int getRecordConsume() {
|
||||
return recordConsume;
|
||||
}
|
||||
|
||||
public void setRecordConsume(int recordConsume) {
|
||||
this.recordConsume = recordConsume;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查玩家是否已经接收了指定的奖励
|
||||
*
|
||||
|
|
|
@ -37,15 +37,19 @@ public class RewardGui implements Listener {
|
|||
Inventory inv = Bukkit.createInventory(null,54, Config.langData.getMessage("invTitle"));
|
||||
// 填充界面底部的玻璃物品
|
||||
for (int i = 0;i<9;i++){ inv.setItem(i, DemonAPI.glass(DemonAPI.getRandomInt(7,1),"§r")); }
|
||||
// 设置玩家数据展示位置
|
||||
inv.setItem(4, StackUtil.getDataInfo(playerName));
|
||||
// 获取玩家管理器和玩家数据
|
||||
PlayerManager playerManager = ConsumeReward.getPlayerManager();
|
||||
PlayerData playerData = playerManager.getPlayerData(playerName);
|
||||
// 设置玩家数据展示位置
|
||||
inv.setItem(4, StackUtil.getDataInfo(playerData));
|
||||
if(playerData.getRewardList().size() >= 16){
|
||||
inv.setItem(22, Config.getItemStack("resetStack"));
|
||||
} else {
|
||||
// 根据配置文件设置奖励展示位置
|
||||
for (RewardData rewardData : Config.getRewardDataList()) {
|
||||
inv.setItem(rewardData.getSlot(), StackUtil.getRewardGiftBox(playerData, rewardData));
|
||||
}
|
||||
}
|
||||
// 打开界面
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
@ -119,7 +123,8 @@ public class RewardGui implements Listener {
|
|||
message = message.replace("{itemName}", DemonAPI.getItemName(stack));
|
||||
Bukkit.broadcastMessage(message);
|
||||
// 发送奖励成功领取信息
|
||||
MessageUtil.sendMessageKey(player, "receivedSuccessfully", Sound.ENTITY_PLAYER_LEVELUP);
|
||||
String msg = Config.langData.getMessage("receivedSuccessfully");
|
||||
MessageUtil.sendMessage(player, msg.replace("{itemName}", DemonAPI.getItemName(stack)), Sound.ENTITY_PLAYER_LEVELUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class StackUtil {
|
|||
* @param playerName 玩家名
|
||||
* @return 包含玩家消费数据的物品堆
|
||||
*/
|
||||
public static ItemStack getDataInfo(String playerName){
|
||||
public static ItemStack getDataInfo(PlayerData playerData){
|
||||
// 获取配置中的数据信息物品堆模板
|
||||
ItemStack stack = Config.getItemStack("dataInfo");
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
|
@ -37,9 +37,19 @@ public class StackUtil {
|
|||
lore.set(i, line.replace("{name}", playerName));
|
||||
continue;
|
||||
}
|
||||
if(line.contains("{resetAmount}")){
|
||||
lore.set(i, line.replace("{resetAmount}", String.valueOf(playerData.getRoundAmount())));
|
||||
continue;
|
||||
}
|
||||
if(line.contains("{totalValue}")){
|
||||
int consumeValue = ConsumeAPI.getConsumeData(playerName, TimeType.ANNUAL);
|
||||
lore.set(i, line.replace("{totalValue}", String.valueOf(consumeValue)));
|
||||
continue;
|
||||
}
|
||||
if(line.contains("{consume}")){
|
||||
int consumeValue = ConsumeAPI.getConsumeData(playerName, TimeType.ANNUAL);
|
||||
lore.set(i, line.replace("{consume}", String.valueOf(consumeValue)));
|
||||
int recording = playerData.getRecordConsume();
|
||||
lore.set(i, line.replace("{consume}", String.valueOf(consumeValue - recording)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: AuConsumeReward
|
||||
main: com.yaohun.consumereward.ConsumeReward
|
||||
version: 1.2.0
|
||||
version: 1.2.1
|
||||
depend:
|
||||
- DemonAPI
|
||||
commands:
|
||||
|
|
Loading…
Reference in New Issue
Block a user