test111
This commit is contained in:
parent
e1a3d0d045
commit
746416e3c9
28
.gitignore
vendored
28
.gitignore
vendored
|
@ -1,26 +1,2 @@
|
|||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
/.idea/
|
||||
/target/
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
13
.idea/compiler.xml
Normal file
13
.idea/compiler.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="AuRechargeData" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
25
.idea/jarRepositories.xml
Normal file
25
.idea/jarRepositories.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="public-rpg" />
|
||||
<option name="name" value="public-rpg" />
|
||||
<option name="url" value="https://repo.aurora-pixels.com/repository/public-rpg/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,7 +1,9 @@
|
|||
package com.yaohun.aurechargedata;
|
||||
|
||||
import com.yaohun.aurechargedata.api.RechargeAPI;
|
||||
import com.yaohun.aurechargedata.manage.ConsumeManage;
|
||||
import com.yaohun.aurechargedata.manage.RechargeManage;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
@ -12,6 +14,7 @@ public class Main extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
saveDefaultConfig();
|
||||
rechargeManage = new RechargeManage();
|
||||
consumeManage = new ConsumeManage();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package com.yaohun.aurechargedata.api;
|
||||
|
||||
public class ConsumeAPI {
|
||||
}
|
130
src/main/java/com/yaohun/aurechargedata/api/RechargeAPI.java
Normal file
130
src/main/java/com/yaohun/aurechargedata/api/RechargeAPI.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
package com.yaohun.aurechargedata.api;
|
||||
|
||||
import com.yaohun.aurechargedata.Main;
|
||||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.manage.RechargeManage;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public abstract class RechargeAPI {
|
||||
|
||||
public static void setRechargeData(String name, int money) {
|
||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||
// 设置玩家的每日、每月和年度充值数据为指定金额
|
||||
dataAPI.setValueData(TimeType.Daily, money); // 设置每日充值数据
|
||||
dataAPI.setValueData(TimeType.Monthly, money); // 设置每月充值数据
|
||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度充值数据
|
||||
}
|
||||
// 增加累积充值金额
|
||||
public static void addRechargeData(String name, int money) {
|
||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||
// 向玩家的每日、每月和年度充值数据中添加指定金额
|
||||
dataAPI.addValueData(TimeType.Daily, money); // 增加每日充值数据
|
||||
dataAPI.addValueData(TimeType.Monthly, money); // 增加每月充值数据
|
||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
||||
}
|
||||
public static void takeRechargeData(String name, int money) {
|
||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||
// 减少玩家的每日、每月和年度充值数据
|
||||
int currentDaily = dataAPI.getValueData(TimeType.Daily);
|
||||
if (currentDaily >= money) {
|
||||
dataAPI.setValueData(TimeType.Daily, currentDaily - money); // 减少每日充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Daily, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
int currentMonthly = dataAPI.getValueData(TimeType.Monthly);
|
||||
if (currentMonthly >= money) {
|
||||
dataAPI.setValueData(TimeType.Monthly, currentMonthly - money); // 减少每月充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Monthly, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
||||
if (currentAnnual >= money) {
|
||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
}
|
||||
|
||||
// 增加累积充值金额
|
||||
public static void addRechargeData(String name,int money,TimeType timeType) {
|
||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||
// 根据时间类型向玩家的充值数据中添加指定金额
|
||||
if (timeType == TimeType.Daily) {
|
||||
dataAPI.addValueData(TimeType.Daily, money); // 增加每日充值数据
|
||||
dataAPI.addValueData(TimeType.Monthly, money); // 增加每月充值数据
|
||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
||||
} else if (timeType == TimeType.Monthly) {
|
||||
dataAPI.addValueData(TimeType.Monthly, money); // 增加每月充值数据
|
||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
||||
} else if (timeType == TimeType.Annual) {
|
||||
dataAPI.addValueData(TimeType.Annual, money); // 增加年度充值数据
|
||||
}
|
||||
}
|
||||
|
||||
public void setRechargeData(String name, int money, TimeType timeType) {
|
||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||
// 根据时间类型设置玩家的累积充值数据
|
||||
if (timeType == TimeType.Daily) {
|
||||
dataAPI.setValueData(TimeType.Daily, money); // 设置每日累积充值数据
|
||||
dataAPI.setValueData(TimeType.Monthly, money); // 设置每月累积充值数据
|
||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度累积充值数据
|
||||
} else if (timeType == TimeType.Monthly) {
|
||||
dataAPI.setValueData(TimeType.Monthly, money); // 设置每月累积充值数据
|
||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度累积充值数据
|
||||
} else if (timeType == TimeType.Annual) {
|
||||
dataAPI.setValueData(TimeType.Annual, money); // 设置年度累积充值数据
|
||||
}
|
||||
}
|
||||
|
||||
public void takeRechargeData(String name, int money, TimeType timeType) {
|
||||
RechargeManage manage = Main.rechargeManage; // 获取充值管理实例
|
||||
PlayerData dataAPI = manage.getPlayerData(name); // 获取玩家的充值数据实例
|
||||
// 根据时间类型减少玩家的累积充值数据
|
||||
if (timeType == TimeType.Daily) {
|
||||
int currentDaily = dataAPI.getValueData(TimeType.Daily);
|
||||
if (currentDaily >= money) {
|
||||
dataAPI.setValueData(TimeType.Daily, currentDaily - money); // 减少每日累积充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Daily, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
int currentMonthly = dataAPI.getValueData(TimeType.Monthly);
|
||||
if (currentMonthly >= money) {
|
||||
dataAPI.setValueData(TimeType.Monthly, currentMonthly - money); // 减少每月累积充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Monthly, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
||||
if (currentAnnual >= money) {
|
||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度累积充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
} else if (timeType == TimeType.Monthly) {
|
||||
int currentMonthly = dataAPI.getValueData(TimeType.Monthly);
|
||||
if (currentMonthly >= money) {
|
||||
dataAPI.setValueData(TimeType.Monthly, currentMonthly - money); // 减少每月累积充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Monthly, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
||||
if (currentAnnual >= money) {
|
||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度累积充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
} else if (timeType == TimeType.Annual) {
|
||||
int currentAnnual = dataAPI.getValueData(TimeType.Annual);
|
||||
if (currentAnnual >= money) {
|
||||
dataAPI.setValueData(TimeType.Annual, currentAnnual - money); // 减少年度累积充值数据
|
||||
} else {
|
||||
dataAPI.setValueData(TimeType.Annual, 0); // 如果减少金额大于当前累积值,设为0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.yaohun.aurechargedata.data;
|
||||
|
||||
public class DayData {
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.yaohun.aurechargedata.data;
|
||||
|
||||
public class MonthData {
|
||||
}
|
75
src/main/java/com/yaohun/aurechargedata/data/PlayerData.java
Normal file
75
src/main/java/com/yaohun/aurechargedata/data/PlayerData.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package com.yaohun.aurechargedata.data;
|
||||
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
private String name; // 玩家名称
|
||||
private HashMap<TimeType, Integer> valueMap; // 存储时间类型和对应值的映射
|
||||
|
||||
// 构造函数,从配置节中加载玩家数据
|
||||
public PlayerData(String name, ConfigurationSection section) {
|
||||
this.name = name; // 设置玩家名称
|
||||
this.valueMap = new HashMap<>(); // 创建一个新的映射
|
||||
// 如果配置节不为空,则加载数据
|
||||
if (section != null) {
|
||||
// 遍历配置节中的所有键
|
||||
for (String dataKey : section.getKeys(false)) {
|
||||
int value = section.getInt(dataKey); // 获取键对应的整数值
|
||||
// 根据键名将值存储到不同的时间类型中
|
||||
if (dataKey.equalsIgnoreCase("daydata")) {
|
||||
valueMap.put(TimeType.Daily, value); // 每日数据
|
||||
} else if (dataKey.equalsIgnoreCase("monthdata")) {
|
||||
valueMap.put(TimeType.Monthly, value); // 每月数据
|
||||
} else {
|
||||
valueMap.put(TimeType.Annual, value); // 年度数据
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// 配置节为空时存入默认数据
|
||||
valueMap.put(TimeType.Daily, 0);
|
||||
valueMap.put(TimeType.Monthly, 0);
|
||||
valueMap.put(TimeType.Annual, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取玩家名称
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
// 根据时间类型获取对应的值,如果值不存在返回 -1
|
||||
public int getValueData(TimeType timeType) {
|
||||
return valueMap.getOrDefault(timeType, -1);
|
||||
}
|
||||
|
||||
// 设置特定时间类型的值
|
||||
public void setValueData(TimeType timeType, Integer amount) {
|
||||
valueMap.put(timeType, amount);
|
||||
}
|
||||
|
||||
// 增加特定时间类型的值
|
||||
public void addValueData(TimeType timeType, Integer amount) {
|
||||
Integer currentValue = valueMap.getOrDefault(timeType, 0);
|
||||
int newAmount = currentValue + amount;
|
||||
valueMap.put(timeType, newAmount);
|
||||
}
|
||||
|
||||
public HashMap<TimeType, Integer> getValueMap() {
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
// 根据时间类型返回对应的数据键名
|
||||
public String getTimeToString(TimeType timeType) {
|
||||
if (timeType == TimeType.Daily) {
|
||||
return "daydata"; // 如果时间类型是每日,则返回对应的数据键名
|
||||
} else if (timeType == TimeType.Monthly) {
|
||||
return "monthdata"; // 如果时间类型是每月,则返回对应的数据键名
|
||||
}
|
||||
return "annualData"; // 默认情况下返回年度数据键名
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.yaohun.aurechargedata.data;
|
||||
|
||||
public class TermData {
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package com.yaohun.aurechargedata.manage;
|
||||
|
||||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
|
@ -12,51 +16,42 @@ public class ConsumeManage {
|
|||
private File file;
|
||||
private FileConfiguration yml;
|
||||
private String dataKey = "ConsumeData";
|
||||
private HashMap<String,Double> consumeData = new HashMap<>();
|
||||
private HashMap<String, Double> dayDataMap = new HashMap<>();
|
||||
private HashMap<String, Double> monthDataMap = new HashMap<>();
|
||||
private HashMap<String, PlayerData> dataHashMap = new HashMap<>();
|
||||
|
||||
public ConsumeManage(){
|
||||
file = new File("plugins/AuRechargeData", "consume.yml");
|
||||
// 如果文件不存在,则创建新文件
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.getParentFile().mkdirs(); // 确保父文件夹存在
|
||||
file.createNewFile(); // 创建新文件
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
yml = YamlConfiguration.loadConfiguration(file);
|
||||
// 检查配置文件中是否包含 "RechargeData" 节点
|
||||
if (yml.getConfigurationSection(dataKey) != null) {
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
// 构建键路径前缀
|
||||
String str = dataKey+"." + name + ".";
|
||||
// 获取每日充值数据并存储到 dayDataMap
|
||||
double day = yml.getDouble(str + "daydata");
|
||||
dayDataMap.put(name, day);
|
||||
// 获取每月充值数据并存储到 monthDataMap
|
||||
double month = yml.getDouble(str + "monthdata");
|
||||
monthDataMap.put(name, month);
|
||||
// 获取长期充值数据并存储到 rechargeData
|
||||
double term = yml.getDouble(str + "longTermData");
|
||||
consumeData.put(name, term);
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey+"."+name);
|
||||
dataHashMap.put(name,new PlayerData(name,section));
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有消费记录的玩家: §a" + dataHashMap.size() + "名");
|
||||
}
|
||||
|
||||
public void SaveData(){
|
||||
yml.set(dataKey,null);
|
||||
// 保存 dayDataMap 到配置文件
|
||||
for (Map.Entry<String, Double> entry : dayDataMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
double dayData = entry.getValue();
|
||||
yml.set(dataKey+"." + name + ".daydata", dayData);
|
||||
}
|
||||
// 保存 monthDataMap 到配置文件
|
||||
for (Map.Entry<String, Double> entry : monthDataMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
double monthData = entry.getValue();
|
||||
yml.set(dataKey+"." + name + ".monthdata", monthData);
|
||||
}
|
||||
// 保存 rechargeData 到配置文件
|
||||
for (Map.Entry<String, Double> entry : consumeData.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
double longTermData = entry.getValue();
|
||||
yml.set(dataKey+"." + name + ".longTermData", longTermData);
|
||||
for (String name : dataHashMap.keySet()){
|
||||
PlayerData playerData = dataHashMap.get(name);
|
||||
for (TimeType timeType : playerData.getValueMap().keySet()){
|
||||
int value = playerData.getValueData(timeType);
|
||||
String timeKey = playerData.getTimeToString(timeType);
|
||||
if(value >= 1) {
|
||||
yml.set(dataKey + "." + name + "." + timeKey, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
|
@ -65,4 +60,12 @@ public class ConsumeManage {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData(String name) {
|
||||
if(dataHashMap.get(name) == null){
|
||||
dataHashMap.put(name,new PlayerData(name,null));
|
||||
return dataHashMap.get(name);
|
||||
}
|
||||
return dataHashMap.get(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.yaohun.aurechargedata.manage;
|
||||
|
||||
import com.yaohun.aurechargedata.data.DayData;
|
||||
import com.yaohun.aurechargedata.data.MonthData;
|
||||
import com.yaohun.aurechargedata.data.TermData;
|
||||
import com.yaohun.aurechargedata.data.PlayerData;
|
||||
import com.yaohun.aurechargedata.util.TimeType;
|
||||
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 java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -16,51 +18,42 @@ public class RechargeManage {
|
|||
private File file;
|
||||
private FileConfiguration yml;
|
||||
private String dataKey = "RechargeData";
|
||||
private HashMap<String,Double> rechargeData = new HashMap<>();
|
||||
private HashMap<String, Double> dayDataMap = new HashMap<>();
|
||||
private HashMap<String, Double> monthDataMap = new HashMap<>();
|
||||
private HashMap<String, PlayerData> dataHashMap = new HashMap<>();
|
||||
|
||||
public RechargeManage(){
|
||||
file = new File("plugins/AuRechargeData", "recharge.yml");
|
||||
// 如果文件不存在,则创建新文件
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.getParentFile().mkdirs(); // 确保父文件夹存在
|
||||
file.createNewFile(); // 创建新文件
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
yml = YamlConfiguration.loadConfiguration(file);
|
||||
// 检查配置文件中是否包含 "RechargeData" 节点
|
||||
if (yml.getConfigurationSection(dataKey) != null) {
|
||||
// 遍历 "RechargeData" 节点下的所有键(用户名)
|
||||
for (String name : yml.getConfigurationSection(dataKey).getKeys(false)) {
|
||||
// 构建键路径前缀
|
||||
String str = dataKey+"." + name + ".";
|
||||
// 获取每日充值数据并存储到 dayDataMap
|
||||
double day = yml.getDouble(str + "daydata");
|
||||
dayDataMap.put(name, day);
|
||||
// 获取每月充值数据并存储到 monthDataMap
|
||||
double month = yml.getDouble(str + "monthdata");
|
||||
monthDataMap.put(name, month);
|
||||
// 获取长期充值数据并存储到 rechargeData
|
||||
double term = yml.getDouble(str + "longTermData");
|
||||
rechargeData.put(name, term);
|
||||
ConfigurationSection section = yml.getConfigurationSection(dataKey+"."+name);
|
||||
dataHashMap.put(name,new PlayerData(name,section));
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§6[充值数据] §f已有充值记录的玩家: §a" + dataHashMap.size() + "名");
|
||||
}
|
||||
|
||||
public void SaveData(){
|
||||
yml.set(dataKey,null);
|
||||
// 保存 dayDataMap 到配置文件
|
||||
for (Map.Entry<String, Double> entry : dayDataMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
double dayData = entry.getValue();
|
||||
yml.set(dataKey+"." + name + ".daydata", dayData);
|
||||
}
|
||||
// 保存 monthDataMap 到配置文件
|
||||
for (Map.Entry<String, Double> entry : monthDataMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
double monthData = entry.getValue();
|
||||
yml.set(dataKey+"." + name + ".monthdata", monthData);
|
||||
}
|
||||
// 保存 rechargeData 到配置文件
|
||||
for (Map.Entry<String, Double> entry : rechargeData.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
double longTermData = entry.getValue();
|
||||
yml.set(dataKey+"." + name + ".longTermData", longTermData);
|
||||
for (String name : dataHashMap.keySet()){
|
||||
PlayerData playerData = dataHashMap.get(name);
|
||||
for (TimeType timeType : playerData.getValueMap().keySet()){
|
||||
int value = playerData.getValueData(timeType);
|
||||
String timeKey = playerData.getTimeToString(timeType);
|
||||
if(value >= 1) {
|
||||
yml.set(dataKey + "." + name + "." + timeKey, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 保存配置文件
|
||||
try {
|
||||
|
@ -69,4 +62,12 @@ public class RechargeManage {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData(String name) {
|
||||
if(dataHashMap.get(name) == null){
|
||||
dataHashMap.put(name,new PlayerData(name,null));
|
||||
return dataHashMap.get(name);
|
||||
}
|
||||
return dataHashMap.get(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package com.yaohun.aurechargedata.util;
|
||||
|
||||
public enum TimeType {
|
||||
Annual,Monthly,Daily
|
||||
}
|
|
@ -2,4 +2,4 @@ RechargeData:
|
|||
玩家名:
|
||||
daydata: 100 # 今日数据
|
||||
monthdata: 100 # 本月数据
|
||||
longTermData: 100 # 长期数据
|
||||
annualData: 100 # 长期数据
|
|
@ -2,4 +2,4 @@ RechargeData:
|
|||
玩家名:
|
||||
daydata: 100 # 今日数据
|
||||
monthdata: 100 # 本月数据
|
||||
longTermData: 100 # 长期数据
|
||||
annualData: 100 # 长期数据
|
Loading…
Reference in New Issue
Block a user