test111
This commit is contained in:
parent
746416e3c9
commit
72a2864b7c
|
@ -1,6 +1,7 @@
|
|||
package com.yaohun.aurechargedata.data;
|
||||
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import com.yaohun.aurechargedata.util.UpdataTime;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.yaohun.aurechargedata.manage;
|
||||
|
||||
import com.yaohun.aurechargedata.Main;
|
||||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import com.yaohun.aurechargedata.util.UpdataTime;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -30,12 +33,59 @@ public class ConsumeManage {
|
|||
}
|
||||
}
|
||||
yml = YamlConfiguration.loadConfiguration(file);
|
||||
// 检查配置文件中是否包含 "RechargeData" 节点
|
||||
// 检查配置文件中是否包含 "ConsumeData" 节点
|
||||
if (yml.getConfigurationSection(dataKey) != null) {
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey+"."+name);
|
||||
dataHashMap.put(name,new PlayerData(name,section));
|
||||
boolean updated = false; // 标记是否进行了数据更新
|
||||
if(UpdataTime.isDayDataUpdata()){
|
||||
// 遍历 "ConsumeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".daydata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updated = true; // 标记数据已更新
|
||||
}
|
||||
if(UpdataTime.isMonthDataUpdata()){
|
||||
// 遍历 "ConsumeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".monthdata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updated = true; // 标记数据已更新
|
||||
}
|
||||
// 如果数据已更新,异步定时任务重新加载数据
|
||||
if(updated){
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 遍历 "ConsumeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
// 获取每位玩家的配置节
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey + "." + name);
|
||||
// 创建玩家数据对象并存入数据映射
|
||||
dataHashMap.put(name, new PlayerData(name, section));
|
||||
}
|
||||
cancel();// 取消定时任务
|
||||
}
|
||||
}.runTaskLaterAsynchronously(Main.plugin,20L);
|
||||
}else {
|
||||
// 数据未更新时直接加载数据
|
||||
// 遍历 "ConsumeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
// 获取每位玩家的配置节
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey + "." + name);
|
||||
// 创建玩家数据对象并存入数据映射
|
||||
dataHashMap.put(name, new PlayerData(name, section));
|
||||
}
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有消费记录的玩家: §a" + dataHashMap.size() + "名");
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package com.yaohun.aurechargedata.manage;
|
||||
|
||||
import com.yaohun.aurechargedata.Main;
|
||||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import com.yaohun.aurechargedata.util.UpdataTime;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -34,10 +37,57 @@ public class RechargeManage {
|
|||
yml = YamlConfiguration.loadConfiguration(file);
|
||||
// 检查配置文件中是否包含 "RechargeData" 节点
|
||||
if (yml.getConfigurationSection(dataKey) != null) {
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey+"."+name);
|
||||
dataHashMap.put(name,new PlayerData(name,section));
|
||||
boolean updated = false; // 标记是否进行了数据更新
|
||||
if(UpdataTime.isDayDataUpdata()){
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".daydata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updated = true; // 标记数据已更新
|
||||
}
|
||||
if(UpdataTime.isMonthDataUpdata()){
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".monthdata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updated = true; // 标记数据已更新
|
||||
}
|
||||
// 如果数据已更新,异步定时任务重新加载数据
|
||||
if(updated){
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
// 获取每位玩家的配置节
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey + "." + name);
|
||||
// 创建玩家数据对象并存入数据映射
|
||||
dataHashMap.put(name, new PlayerData(name, section));
|
||||
}
|
||||
cancel();// 取消定时任务
|
||||
}
|
||||
}.runTaskLaterAsynchronously(Main.plugin,20L);
|
||||
}else {
|
||||
// 数据未更新时直接加载数据
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
// 获取每位玩家的配置节
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey + "." + name);
|
||||
// 创建玩家数据对象并存入数据映射
|
||||
dataHashMap.put(name, new PlayerData(name, section));
|
||||
}
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有充值记录的玩家: §a" + dataHashMap.size() + "名");
|
||||
|
|
Loading…
Reference in New Issue
Block a user