充值数据统计
This commit is contained in:
parent
ec3a712212
commit
fcf61f966c
|
@ -3,14 +3,17 @@ package com.yaohun.aurechargedata;
|
|||
import com.yaohun.aurechargedata.api.RechargeAPI;
|
||||
import com.yaohun.aurechargedata.cmd.KpayToCmd;
|
||||
import com.yaohun.aurechargedata.cmd.MainCmd;
|
||||
import com.yaohun.aurechargedata.listener.CoinsConsumeEvent;
|
||||
import com.yaohun.aurechargedata.manage.ConsumeManage;
|
||||
import com.yaohun.aurechargedata.manage.RechargeManage;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import me.Demon.DemonPlugin.DemonAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
public static String version = "1.0.1";
|
||||
public static Main plugin;
|
||||
public static RechargeManage rechargeManage;
|
||||
public static ConsumeManage consumeManage;
|
||||
|
@ -18,13 +21,21 @@ public class Main extends JavaPlugin {
|
|||
public void onEnable() {
|
||||
plugin = this;
|
||||
saveDefaultConfig();
|
||||
rechargeManage = new RechargeManage();
|
||||
consumeManage = new ConsumeManage();
|
||||
getCommand("apayk").setExecutor(new KpayToCmd());
|
||||
getCommand("apay").setExecutor(new MainCmd());
|
||||
DemonAPI.sendConsoleMessage("§f[§6!§f] §aAuRechargeData ("+version+") §f开始加载");
|
||||
rechargeManage = new RechargeManage();
|
||||
consumeManage = new ConsumeManage();
|
||||
if (Bukkit.getPluginManager().getPlugin("DemonCoins") != null) {
|
||||
getServer().getPluginManager().registerEvents(new CoinsConsumeEvent(),this);
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §fDemonCoins §8> §6完成");
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new RechargeExpansion(this).register();
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §fPlaceholderAPI §8> §6完成");
|
||||
}
|
||||
DemonAPI.sendConsoleMessage("§f[§6!§f] §aAuRechargeData §f加载完成,祝你使用愉快!");
|
||||
DemonAPI.sendConsoleMessage("§f[§6!§f] §b极光像素工作室出品");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.yaohun.aurechargedata.listener;
|
||||
|
||||
import me.Demon.DemonCoins.evant.ConsumeEvent;
|
||||
import me.Demon.DemonCoins.evant.ConsumePointsEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class CoinsConsumeEvent implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onCoins(ConsumeEvent e){
|
||||
String name = e.getPlayerName();
|
||||
int money = e.getMoney();
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.yaohun.aurechargedata.Main;
|
|||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import com.yaohun.aurechargedata.util.UpdataTime;
|
||||
import me.Demon.DemonPlugin.DemonAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
@ -37,29 +38,11 @@ public class ConsumeManage {
|
|||
if (yml.getConfigurationSection(dataKey) != null) {
|
||||
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();
|
||||
}
|
||||
resetDayData();
|
||||
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();
|
||||
}
|
||||
resetMonthData();
|
||||
updated = true; // 标记数据已更新
|
||||
}
|
||||
// 如果数据已更新,异步定时任务重新加载数据
|
||||
|
@ -88,7 +71,33 @@ public class ConsumeManage {
|
|||
}
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有消费记录的玩家: §a" + dataHashMap.size() + "名");
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §f消费数据档案 §8> §6"+dataHashMap.size()+"条");
|
||||
}
|
||||
public void resetDayData(){
|
||||
// 遍历 "ConsumeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".daydata", null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §f每日消费 §8> §6已重置");
|
||||
}
|
||||
public void resetMonthData(){
|
||||
// 遍历 "ConsumeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".monthdata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §f每月消费 §8> §6已重置");
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.yaohun.aurechargedata.Main;
|
|||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import com.yaohun.aurechargedata.util.UpdataTime;
|
||||
import me.Demon.DemonPlugin.DemonAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
@ -38,34 +39,16 @@ public class RechargeManage {
|
|||
// 检查配置文件中是否包含 "RechargeData" 节点
|
||||
if (yml.getConfigurationSection(dataKey) != null) {
|
||||
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();
|
||||
}
|
||||
if (UpdataTime.isDayDataUpdata()) {
|
||||
resetDayData();
|
||||
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();
|
||||
}
|
||||
if (UpdataTime.isMonthDataUpdata()) {
|
||||
resetMonthData();
|
||||
updated = true; // 标记数据已更新
|
||||
}
|
||||
// 如果数据已更新,异步定时任务重新加载数据
|
||||
if(updated){
|
||||
if (updated) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -91,7 +74,34 @@ public class RechargeManage {
|
|||
}
|
||||
upDataMonthlyRechargesTop();
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有充值记录的玩家: §a" + dataHashMap.size() + "名");
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §f充值数据档案 §8> §6"+dataHashMap.size()+"条");
|
||||
}
|
||||
public void resetDayData(){
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".daydata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §f每日充值 §8> §6已重置");
|
||||
Bukkit.getConsoleSender().sendMessage("§6[AuRechargeData] §f每日充值数据已重置.");
|
||||
}
|
||||
public void resetMonthData(){
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
yml.set(dataKey+"."+name+".monthdata",null);// 将每位玩家的每日充值数据置为空
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DemonAPI.sendConsoleMessage("§f[§a!§f] §f每月充值 §8> §6已重置");
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
name: AuRechargeData
|
||||
main: com.yaohun.aurechargedata.Main
|
||||
version: 1.0.0
|
||||
version: _v
|
||||
depend:
|
||||
- DemonAPI
|
||||
- PlaceholderAPI
|
||||
commands:
|
||||
apay:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
name: AuRechargeData
|
||||
main: com.yaohun.aurechargedata.Main
|
||||
version: 1.0.0
|
||||
version: _v
|
||||
depend:
|
||||
- DemonAPI
|
||||
- PlaceholderAPI
|
||||
commands:
|
||||
apay:
|
||||
|
|
Loading…
Reference in New Issue
Block a user