update
This commit is contained in:
parent
f60464ffc6
commit
ec3a712212
|
@ -29,7 +29,7 @@ public class Main extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
rechargeManage.SaveData();
|
rechargeManage.saveData();
|
||||||
consumeManage.SaveData();
|
consumeManage.saveData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,15 +49,15 @@ public class RechargeExpansion extends PlaceholderExpansion {
|
||||||
public String onPlaceholderRequest(Player player, String identifier) {
|
public String onPlaceholderRequest(Player player, String identifier) {
|
||||||
if (identifier.equalsIgnoreCase("day")) {
|
if (identifier.equalsIgnoreCase("day")) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
int val = RechargeAPI.getRechargeData(playerName, TimeType.Daily);
|
int val = RechargeAPI.getRechargeData(playerName, TimeType.DAILY);
|
||||||
return String.valueOf(val);
|
return String.valueOf(val);
|
||||||
}else if (identifier.equalsIgnoreCase("month")) {
|
}else if (identifier.equalsIgnoreCase("month")) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
int val = RechargeAPI.getRechargeData(playerName, TimeType.Monthly);
|
int val = RechargeAPI.getRechargeData(playerName, TimeType.MONTHLY);
|
||||||
return String.valueOf(val);
|
return String.valueOf(val);
|
||||||
}else if (identifier.equalsIgnoreCase("me")) {
|
}else if (identifier.equalsIgnoreCase("me")) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
int val = RechargeAPI.getRechargeData(playerName, TimeType.Annual);
|
int val = RechargeAPI.getRechargeData(playerName, TimeType.ANNUAL);
|
||||||
return String.valueOf(val);
|
return String.valueOf(val);
|
||||||
} else {
|
} else {
|
||||||
String[] sp = identifier.split("_");
|
String[] sp = identifier.split("_");
|
||||||
|
|
|
@ -17,12 +17,12 @@ public abstract class RechargeAPI {
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 根据时间类型获取玩家的累积充值数据
|
// 根据时间类型获取玩家的累积充值数据
|
||||||
switch (timeType) {
|
switch (timeType) {
|
||||||
case Daily:
|
case DAILY:
|
||||||
return dataAPI.getValueData(TimeType.Daily); // 获取每日累积充值数据
|
return dataAPI.getValueData(TimeType.DAILY); // 获取每日累积充值数据
|
||||||
case Monthly:
|
case MONTHLY:
|
||||||
return dataAPI.getValueData(TimeType.Monthly); // 获取每月累积充值数据
|
return dataAPI.getValueData(TimeType.MONTHLY); // 获取每月累积充值数据
|
||||||
case Annual:
|
case ANNUAL:
|
||||||
return dataAPI.getValueData(TimeType.Annual); // 获取年度累积充值数据
|
return dataAPI.getValueData(TimeType.ANNUAL); // 获取年度累积充值数据
|
||||||
default:
|
default:
|
||||||
return -1; // 如果时间类型不匹配,则返回默认值或进行适当处理
|
return -1; // 如果时间类型不匹配,则返回默认值或进行适当处理
|
||||||
}
|
}
|
||||||
|
@ -32,40 +32,40 @@ public abstract class RechargeAPI {
|
||||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 设置玩家的每日、每月和年度充值数据为指定金额
|
// 设置玩家的每日、每月和年度充值数据为指定金额
|
||||||
dataAPI.setValueData(TimeType.Daily, money); // 设置每日充值数据
|
dataAPI.setValueData(TimeType.DAILY, money); // 设置每日充值数据
|
||||||
dataAPI.setValueData(TimeType.Monthly, money); // 设置每月充值数据
|
dataAPI.setValueData(TimeType.MONTHLY, money); // 设置每月充值数据
|
||||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, money); // 设置年度充值数据
|
||||||
}
|
}
|
||||||
// 增加累积充值金额
|
// 增加累积充值金额
|
||||||
public static void addRechargeData(String name, int money) {
|
public static void addRechargeData(String name, int money) {
|
||||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 向玩家的每日、每月和年度充值数据中添加指定金额
|
// 向玩家的每日、每月和年度充值数据中添加指定金额
|
||||||
dataAPI.addValueData(TimeType.Daily, money); // 增加每日充值数据
|
dataAPI.addValueData(TimeType.DAILY, money); // 增加每日充值数据
|
||||||
dataAPI.addValueData(TimeType.Monthly, money); // 增加每月充值数据
|
dataAPI.addValueData(TimeType.MONTHLY, money); // 增加每月充值数据
|
||||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
dataAPI.addValueData(TimeType.ANNUAL, money); // 增加年度充值数据
|
||||||
}
|
}
|
||||||
public static void takeRechargeData(String name, int money) {
|
public static void takeRechargeData(String name, int money) {
|
||||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 减少玩家的每日、每月和年度充值数据
|
// 减少玩家的每日、每月和年度充值数据
|
||||||
int currentDaily = dataAPI.getValueData(TimeType.Daily);
|
int currentDaily = dataAPI.getValueData(TimeType.DAILY);
|
||||||
if (currentDaily >= money) {
|
if (currentDaily >= money) {
|
||||||
dataAPI.setValueData(TimeType.Daily, currentDaily - money); // 减少每日充值数据
|
dataAPI.setValueData(TimeType.DAILY, currentDaily - money); // 减少每日充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Daily, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.DAILY, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
int currentMonthly = dataAPI.getValueData(TimeType.Monthly);
|
int currentMonthly = dataAPI.getValueData(TimeType.MONTHLY);
|
||||||
if (currentMonthly >= money) {
|
if (currentMonthly >= money) {
|
||||||
dataAPI.setValueData(TimeType.Monthly, currentMonthly - money); // 减少每月充值数据
|
dataAPI.setValueData(TimeType.MONTHLY, currentMonthly - money); // 减少每月充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Monthly, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.MONTHLY, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
int currentAnnual = dataAPI.getValueData(TimeType.ANNUAL);
|
||||||
if (currentAnnual >= money) {
|
if (currentAnnual >= money) {
|
||||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, currentAnnual - money); // 减少年度充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.ANNUAL, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,15 +74,15 @@ public abstract class RechargeAPI {
|
||||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 根据时间类型向玩家的充值数据中添加指定金额
|
// 根据时间类型向玩家的充值数据中添加指定金额
|
||||||
if (timeType == TimeType.Daily) {
|
if (timeType == TimeType.DAILY) {
|
||||||
dataAPI.addValueData(TimeType.Daily, money); // 增加每日充值数据
|
dataAPI.addValueData(TimeType.DAILY, money); // 增加每日充值数据
|
||||||
dataAPI.addValueData(TimeType.Monthly, money); // 增加每月充值数据
|
dataAPI.addValueData(TimeType.MONTHLY, money); // 增加每月充值数据
|
||||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
dataAPI.addValueData(TimeType.ANNUAL, money); // 增加年度充值数据
|
||||||
} else if (timeType == TimeType.Monthly) {
|
} else if (timeType == TimeType.MONTHLY) {
|
||||||
dataAPI.addValueData(TimeType.Monthly, money); // 增加每月充值数据
|
dataAPI.addValueData(TimeType.MONTHLY, money); // 增加每月充值数据
|
||||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
dataAPI.addValueData(TimeType.ANNUAL, money); // 增加年度充值数据
|
||||||
} else if (timeType == TimeType.Annual) {
|
} else if (timeType == TimeType.ANNUAL) {
|
||||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
dataAPI.addValueData(TimeType.ANNUAL, money); // 增加年度充值数据
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,15 +90,15 @@ public abstract class RechargeAPI {
|
||||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 根据时间类型设置玩家的累积充值数据
|
// 根据时间类型设置玩家的累积充值数据
|
||||||
if (timeType == TimeType.Daily) {
|
if (timeType == TimeType.DAILY) {
|
||||||
dataAPI.setValueData(TimeType.Daily, money); // 设置每日累积充值数据
|
dataAPI.setValueData(TimeType.DAILY, money); // 设置每日累积充值数据
|
||||||
dataAPI.setValueData(TimeType.Monthly, money); // 设置每月累积充值数据
|
dataAPI.setValueData(TimeType.MONTHLY, money); // 设置每月累积充值数据
|
||||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度累积充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, money); // 设置年度累积充值数据
|
||||||
} else if (timeType == TimeType.Monthly) {
|
} else if (timeType == TimeType.MONTHLY) {
|
||||||
dataAPI.setValueData(TimeType.Monthly, money); // 设置每月累积充值数据
|
dataAPI.setValueData(TimeType.MONTHLY, money); // 设置每月累积充值数据
|
||||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度累积充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, money); // 设置年度累积充值数据
|
||||||
} else if (timeType == TimeType.Annual) {
|
} else if (timeType == TimeType.ANNUAL) {
|
||||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度累积充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, money); // 设置年度累积充值数据
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,44 +106,44 @@ public abstract class RechargeAPI {
|
||||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||||
// 根据时间类型减少玩家的累积充值数据
|
// 根据时间类型减少玩家的累积充值数据
|
||||||
if (timeType == TimeType.Daily) {
|
if (timeType == TimeType.DAILY) {
|
||||||
int currentDaily = dataAPI.getValueData(TimeType.Daily);
|
int currentDaily = dataAPI.getValueData(TimeType.DAILY);
|
||||||
if (currentDaily >= money) {
|
if (currentDaily >= money) {
|
||||||
dataAPI.setValueData(TimeType.Daily, currentDaily - money); // 减少每日累积充值数据
|
dataAPI.setValueData(TimeType.DAILY, currentDaily - money); // 减少每日累积充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Daily, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.DAILY, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
int currentMonthly = dataAPI.getValueData(TimeType.Monthly);
|
int currentMonthly = dataAPI.getValueData(TimeType.MONTHLY);
|
||||||
if (currentMonthly >= money) {
|
if (currentMonthly >= money) {
|
||||||
dataAPI.setValueData(TimeType.Monthly, currentMonthly - money); // 减少每月累积充值数据
|
dataAPI.setValueData(TimeType.MONTHLY, currentMonthly - money); // 减少每月累积充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Monthly, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.MONTHLY, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
int currentAnnual = dataAPI.getValueData(TimeType.ANNUAL);
|
||||||
if (currentAnnual >= money) {
|
if (currentAnnual >= money) {
|
||||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度累积充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, currentAnnual - money); // 减少年度累积充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.ANNUAL, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
} else if (timeType == TimeType.Monthly) {
|
} else if (timeType == TimeType.MONTHLY) {
|
||||||
int currentMonthly = dataAPI.getValueData(TimeType.Monthly);
|
int currentMonthly = dataAPI.getValueData(TimeType.MONTHLY);
|
||||||
if (currentMonthly >= money) {
|
if (currentMonthly >= money) {
|
||||||
dataAPI.setValueData(TimeType.Monthly, currentMonthly - money); // 减少每月累积充值数据
|
dataAPI.setValueData(TimeType.MONTHLY, currentMonthly - money); // 减少每月累积充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Monthly, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.MONTHLY, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
int currentAnnual = dataAPI.getValueData(TimeType.ANNUAL);
|
||||||
if (currentAnnual >= money) {
|
if (currentAnnual >= money) {
|
||||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度累积充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, currentAnnual - money); // 减少年度累积充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.ANNUAL, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
} else if (timeType == TimeType.Annual) {
|
} else if (timeType == TimeType.ANNUAL) {
|
||||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
int currentAnnual = dataAPI.getValueData(TimeType.ANNUAL);
|
||||||
if (currentAnnual >= money) {
|
if (currentAnnual >= money) {
|
||||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度累积充值数据
|
dataAPI.setValueData(TimeType.ANNUAL, currentAnnual - money); // 减少年度累积充值数据
|
||||||
} else {
|
} else {
|
||||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
dataAPI.setValueData(TimeType.ANNUAL, 0); // 如果减少金额大于当前累积值,设为0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,9 @@ import java.util.List;
|
||||||
public class MainCmd implements CommandExecutor , TabCompleter {
|
public class MainCmd implements CommandExecutor , TabCompleter {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!sender.isOp()){return true;}
|
if (!sender.isOp()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
sender.sendMessage("§r");
|
sender.sendMessage("§r");
|
||||||
sender.sendMessage("§e------- ======= §6充值数据统计 §e======= -------");
|
sender.sendMessage("§e------- ======= §6充值数据统计 §e======= -------");
|
||||||
|
@ -51,8 +53,8 @@ public class MainCmd implements CommandExecutor , TabCompleter {
|
||||||
String playName = args[1];
|
String playName = args[1];
|
||||||
sender.sendMessage("§f[§c消息§f] §a玩家充值信息查询:");
|
sender.sendMessage("§f[§c消息§f] §a玩家充值信息查询:");
|
||||||
sender.sendMessage("§a玩家名称§f: §6"+playName);
|
sender.sendMessage("§a玩家名称§f: §6"+playName);
|
||||||
sender.sendMessage("§a本月充值§f: §e"+RechargeAPI.getRechargeData(playName,TimeType.Monthly)+"元");
|
sender.sendMessage("§a本月充值§f: §e"+RechargeAPI.getRechargeData(playName,TimeType.MONTHLY)+"元");
|
||||||
sender.sendMessage("§a累计充值§f: §e"+RechargeAPI.getRechargeData(playName,TimeType.Annual)+"元");
|
sender.sendMessage("§a累计充值§f: §e"+RechargeAPI.getRechargeData(playName,TimeType.ANNUAL)+"元");
|
||||||
sender.sendMessage("§a累计消费§f: §b0软");
|
sender.sendMessage("§a累计消费§f: §b0软");
|
||||||
sender.sendMessage("§a最后一次充值§f: §d"+RechargeAPI.getRechargePlayer(playName).getLastOperationShow());
|
sender.sendMessage("§a最后一次充值§f: §d"+RechargeAPI.getRechargePlayer(playName).getLastOperationShow());
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,28 +76,28 @@ public class MainCmd implements CommandExecutor , TabCompleter {
|
||||||
if (giveType.equalsIgnoreCase("cz")) {
|
if (giveType.equalsIgnoreCase("cz")) {
|
||||||
// 执行每日、每月和年度充值操作,默认为每日
|
// 执行每日、每月和年度充值操作,默认为每日
|
||||||
RechargeAPI.addRechargeData(playerName, amount);
|
RechargeAPI.addRechargeData(playerName, amount);
|
||||||
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.Daily);
|
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.DAILY);
|
||||||
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f每日 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f每日 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
||||||
RechargeEvent rechargeEvent = new RechargeEvent(playerName,amount);
|
RechargeEvent rechargeEvent = new RechargeEvent(playerName,amount);
|
||||||
Bukkit.getPluginManager().callEvent(rechargeEvent);
|
Bukkit.getPluginManager().callEvent(rechargeEvent);
|
||||||
} else if (giveType.equalsIgnoreCase("give")) {
|
} else if (giveType.equalsIgnoreCase("give")) {
|
||||||
// 执行每日、每月和年度充值操作,默认为每日
|
// 执行每日、每月和年度充值操作,默认为每日
|
||||||
RechargeAPI.addRechargeData(playerName, amount);
|
RechargeAPI.addRechargeData(playerName, amount);
|
||||||
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.Daily);
|
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.DAILY);
|
||||||
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f每日 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f每日 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
||||||
} else if (giveType.equalsIgnoreCase("givemonth")) {
|
} else if (giveType.equalsIgnoreCase("givemonth")) {
|
||||||
// 执行每月充值操作
|
// 执行每月充值操作
|
||||||
RechargeAPI.addRechargeData(playerName, amount, TimeType.Monthly);
|
RechargeAPI.addRechargeData(playerName, amount, TimeType.MONTHLY);
|
||||||
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.Monthly);
|
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.MONTHLY);
|
||||||
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f每月 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f每月 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
||||||
} else if (giveType.equalsIgnoreCase("giveannual")) {
|
} else if (giveType.equalsIgnoreCase("giveannual")) {
|
||||||
// 执行年度充值操作
|
// 执行年度充值操作
|
||||||
RechargeAPI.addRechargeData(playerName, amount, TimeType.Annual);
|
RechargeAPI.addRechargeData(playerName, amount, TimeType.ANNUAL);
|
||||||
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.Annual);
|
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.ANNUAL);
|
||||||
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f永久 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
sender.sendMessage("§7[§6累积充值§7] §f已增加 §6" + playerName + " §f永久 §b" + amount + "累计 §f已累积充值: §e" + setVal);
|
||||||
} else if (giveType.equalsIgnoreCase("take")) {
|
} else if (giveType.equalsIgnoreCase("take")) {
|
||||||
RechargeAPI.takeRechargeData(playerName,amount);
|
RechargeAPI.takeRechargeData(playerName,amount);
|
||||||
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.Annual);
|
int setVal = RechargeAPI.getRechargeData(playerName,TimeType.ANNUAL);
|
||||||
sender.sendMessage("§7[§6累积充值§7] §f已扣除 §6" + playerName + " §f永久 §c-" + amount + "累计 §f已累积充值: §e" + setVal);
|
sender.sendMessage("§7[§6累积充值§7] §f已扣除 §6" + playerName + " §f永久 §c-" + amount + "累计 §f已累积充值: §e" + setVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,20 +24,20 @@ public class PlayerData {
|
||||||
int value = section.getInt(dataKey); // 获取键对应的整数值
|
int value = section.getInt(dataKey); // 获取键对应的整数值
|
||||||
// 根据键名将值存储到不同的时间类型中
|
// 根据键名将值存储到不同的时间类型中
|
||||||
if (dataKey.equalsIgnoreCase("daydata")) {
|
if (dataKey.equalsIgnoreCase("daydata")) {
|
||||||
valueMap.put(TimeType.Daily, value); // 每日数据
|
valueMap.put(TimeType.DAILY, value); // 每日数据
|
||||||
} else if (dataKey.equalsIgnoreCase("monthdata")) {
|
} else if (dataKey.equalsIgnoreCase("monthdata")) {
|
||||||
valueMap.put(TimeType.Monthly, value); // 每月数据
|
valueMap.put(TimeType.MONTHLY, value); // 每月数据
|
||||||
} else if(dataKey.equalsIgnoreCase("annualData")){
|
} else if(dataKey.equalsIgnoreCase("annualData")){
|
||||||
valueMap.put(TimeType.Annual, value); // 年度数据
|
valueMap.put(TimeType.ANNUAL, value); // 年度数据
|
||||||
} else if(dataKey.equalsIgnoreCase("lastOperation")){
|
} else if(dataKey.equalsIgnoreCase("lastOperation")){
|
||||||
lastOperation = section.getLong(dataKey);
|
lastOperation = section.getLong(dataKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// 配置节为空时存入默认数据
|
// 配置节为空时存入默认数据
|
||||||
valueMap.put(TimeType.Daily, 0);
|
valueMap.put(TimeType.DAILY, 0);
|
||||||
valueMap.put(TimeType.Monthly, 0);
|
valueMap.put(TimeType.MONTHLY, 0);
|
||||||
valueMap.put(TimeType.Annual, 0);
|
valueMap.put(TimeType.ANNUAL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ public class PlayerData {
|
||||||
|
|
||||||
// 根据时间类型返回对应的数据键名
|
// 根据时间类型返回对应的数据键名
|
||||||
public String getTimeToString(TimeType timeType) {
|
public String getTimeToString(TimeType timeType) {
|
||||||
if (timeType == TimeType.Daily) {
|
if (timeType == TimeType.DAILY) {
|
||||||
return "daydata"; // 如果时间类型是每日,则返回对应的数据键名
|
return "daydata"; // 如果时间类型是每日,则返回对应的数据键名
|
||||||
} else if (timeType == TimeType.Monthly) {
|
} else if (timeType == TimeType.MONTHLY) {
|
||||||
return "monthdata"; // 如果时间类型是每月,则返回对应的数据键名
|
return "monthdata"; // 如果时间类型是每月,则返回对应的数据键名
|
||||||
}
|
}
|
||||||
return "annualData"; // 默认情况下返回年度数据键名
|
return "annualData"; // 默认情况下返回年度数据键名
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class ConsumeManage {
|
||||||
private HashMap<String, PlayerData> dataHashMap = new HashMap<>();
|
private HashMap<String, PlayerData> dataHashMap = new HashMap<>();
|
||||||
|
|
||||||
public ConsumeManage() {
|
public ConsumeManage() {
|
||||||
file = new File("plugins/AuRechargeData", "consume.yml");
|
file = new File(Main.plugin.getDataFolder(), "consume.yml");
|
||||||
// 如果文件不存在,则创建新文件
|
// 如果文件不存在,则创建新文件
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
try {
|
try {
|
||||||
|
@ -91,7 +91,7 @@ public class ConsumeManage {
|
||||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有消费记录的玩家: §a" + dataHashMap.size() + "名");
|
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有消费记录的玩家: §a" + dataHashMap.size() + "名");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveData(){
|
public void saveData() {
|
||||||
yml.set(dataKey, null);
|
yml.set(dataKey, null);
|
||||||
for (String name : dataHashMap.keySet()){
|
for (String name : dataHashMap.keySet()){
|
||||||
PlayerData playerData = dataHashMap.get(name);
|
PlayerData playerData = dataHashMap.get(name);
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class RechargeManage {
|
||||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有充值记录的玩家: §a" + dataHashMap.size() + "名");
|
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有充值记录的玩家: §a" + dataHashMap.size() + "名");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveData(){
|
public void saveData() {
|
||||||
yml.set(dataKey, null);
|
yml.set(dataKey, null);
|
||||||
for (String name : dataHashMap.keySet()){
|
for (String name : dataHashMap.keySet()){
|
||||||
PlayerData playerData = dataHashMap.get(name);
|
PlayerData playerData = dataHashMap.get(name);
|
||||||
|
@ -135,7 +135,7 @@ public class RechargeManage {
|
||||||
for (PlayerData playerData : dataHashMap.values()) {
|
for (PlayerData playerData : dataHashMap.values()) {
|
||||||
// 获取玩家名称和每月充值金额
|
// 获取玩家名称和每月充值金额
|
||||||
String playerName = playerData.getName();
|
String playerName = playerData.getName();
|
||||||
int monthlyRecharge = playerData.getValueData(TimeType.Monthly);
|
int monthlyRecharge = playerData.getValueData(TimeType.MONTHLY);
|
||||||
// 创建 PlayerMonthlyRecharge 对象,并添加到列表中
|
// 创建 PlayerMonthlyRecharge 对象,并添加到列表中
|
||||||
hashMap.put(playerName,monthlyRecharge);
|
hashMap.put(playerName,monthlyRecharge);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.yaohun.aurechargedata.util;
|
package com.yaohun.aurechargedata.util;
|
||||||
|
|
||||||
public enum TimeType {
|
public enum TimeType {
|
||||||
Annual,Monthly,Daily
|
ANNUAL,
|
||||||
|
MONTHLY,
|
||||||
|
DAILY
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public abstract class UpdataTime {
|
public class UpdataTime {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 获取 每日数据刷新的记录时间
|
* 获取 每日数据刷新的记录时间
|
||||||
|
|
Loading…
Reference in New Issue
Block a user