mirror of
https://github.com/MiniDay/HamsterCurrency-Parent.git
synced 2025-08-25 13:45:30 +08:00
feat: 更新gradle版本并优化指令部分的重复代码
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'cn.hamster3'
|
||||
version '2.2.8'
|
||||
version '2.2.9'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
@@ -20,7 +20,7 @@ dependencies {
|
||||
compileOnly "cn.hamster3:HamsterService-Bukkit:2.8.3-SNAPSHOT"
|
||||
compileOnly "cn.hamster3:HamsterAPI:2.4.8-SNAPSHOT"
|
||||
compileOnly 'net.milkbowl.vault:VaultAPI:1.7'
|
||||
compileOnly "me.clip:placeholderapi:2.10.9"
|
||||
compileOnly "me.clip:placeholderapi:2.11.6"
|
||||
|
||||
compileOnly rootProject.fileTree(dir: './libs', includes: ['*.jar'])
|
||||
}
|
||||
@@ -39,7 +39,7 @@ java {
|
||||
|
||||
jar {
|
||||
archivesBaseName = "HamsterCurrency"
|
||||
destinationDir(rootProject.buildDir)
|
||||
destinationDirectory = rootProject.layout.buildDirectory
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
@@ -62,8 +62,8 @@ publishing {
|
||||
url = 'https://maven.airgame.net/public/'
|
||||
|
||||
credentials {
|
||||
username maven_username
|
||||
password maven_password
|
||||
username = findProperty("MAVEN_AIRGAME_USERNAME")?.toString() ?: ""
|
||||
password = findProperty("MAVEN_AIRGAME_PASSWORD")?.toString() ?: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -81,7 +81,6 @@ public abstract class CurrencyAdminSetCommand extends CommandExecutor {
|
||||
.replace("%type%", type.getId())
|
||||
.replace("%amount%", String.format("%.2f", data.getPlayerCurrency(type.getId())))
|
||||
);
|
||||
dataManager.savePlayerData(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hamster3.currency.command.currency;
|
||||
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
|
||||
@@ -17,9 +17,6 @@ public class CurrencyGiveCommand extends CurrencyAdminSetCommand {
|
||||
|
||||
@Override
|
||||
protected void doSet(PlayerData data, CurrencyType type, double amount) {
|
||||
double balance = data.getPlayerCurrency(type.getId()) + amount;
|
||||
data.setPlayerCurrency(type.getId(), balance);
|
||||
dataManager.insertLog(new CurrencyLog(data.getUuid(), data.getPlayerName(), type.getId(), "add", amount, balance));
|
||||
CurrencyAPI.addPlayerCurrency(data.getUuid(), type.getId(), amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,10 +2,10 @@ package cn.hamster3.currency.command.currency;
|
||||
|
||||
import cn.hamster3.api.HamsterAPI;
|
||||
import cn.hamster3.api.command.CommandExecutor;
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.FileManager;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.core.Message;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
import cn.hamster3.service.bukkit.api.ServiceMessageAPI;
|
||||
@@ -77,22 +77,15 @@ public class CurrencyPayCommand extends CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerData fromData = dataManager.getPlayerData(player.getUniqueId());
|
||||
if (fromData.getPlayerCurrency(type.getId()) < amount) {
|
||||
if (!CurrencyAPI.hasPlayerCurrency(player.getUniqueId(), type.getId(), amount)) {
|
||||
sender.sendMessage(
|
||||
Message.currencyNotEnough.toString()
|
||||
.replace("%type%", type.getId())
|
||||
);
|
||||
return true;
|
||||
}
|
||||
double fromBalance = fromData.getPlayerCurrency(type.getId()) - amount;
|
||||
fromData.setPlayerCurrency(type.getId(), fromBalance);
|
||||
double toBalance = toData.getPlayerCurrency(type.getId()) + amount;
|
||||
toData.setPlayerCurrency(type.getId(), toBalance);
|
||||
dataManager.savePlayerData(fromData);
|
||||
dataManager.savePlayerData(toData);
|
||||
dataManager.insertLog(new CurrencyLog(fromData.getUuid(), fromData.getPlayerName(), type.getId(), "payOut", amount, fromBalance));
|
||||
dataManager.insertLog(new CurrencyLog(toData.getUuid(), toData.getPlayerName(), type.getId(), "payIn", amount, toBalance));
|
||||
CurrencyAPI.takePlayerCurrency(player.getUniqueId(), type.getId(), amount);
|
||||
CurrencyAPI.addPlayerCurrency(toData.getUuid(), type.getId(), amount);
|
||||
sender.sendMessage(
|
||||
Message.paySuccess.toString()
|
||||
.replace("%player%", toData.getPlayerName())
|
||||
|
@@ -19,5 +19,4 @@ public class CurrencySetCommand extends CurrencyAdminSetCommand {
|
||||
protected void doSet(PlayerData data, CurrencyType type, double amount) {
|
||||
CurrencyAPI.setPlayerCurrency(data.getUuid(), type.getId(), amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hamster3.currency.command.currency;
|
||||
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
|
||||
@@ -17,8 +17,6 @@ public class CurrencyTakeCommand extends CurrencyAdminSetCommand {
|
||||
|
||||
@Override
|
||||
protected void doSet(PlayerData data, CurrencyType type, double amount) {
|
||||
double balance = data.getPlayerCurrency(type.getId()) - amount;
|
||||
data.setPlayerCurrency(type.getId(), balance);
|
||||
dataManager.insertLog(new CurrencyLog(data.getUuid(), data.getPlayerName(), type.getId(), "take", amount, balance));
|
||||
CurrencyAPI.takePlayerCurrency(data.getUuid(), type.getId(), amount);
|
||||
}
|
||||
}
|
||||
|
@@ -67,12 +67,6 @@ public abstract class VaultAdminSetCommand extends CommandExecutor {
|
||||
}
|
||||
doSet(data, type, amount);
|
||||
dataManager.savePlayerData(data);
|
||||
sender.sendMessage(
|
||||
Message.seeCurrency.toString()
|
||||
.replace("%player%", data.getPlayerName())
|
||||
.replace("%type%", type.getId())
|
||||
.replace("%amount%", String.format("%.2f", data.getPlayerCurrency(type.getId())))
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hamster3.currency.command.vault;
|
||||
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
|
||||
@@ -17,8 +17,6 @@ public class VaultGiveCommand extends VaultAdminSetCommand {
|
||||
|
||||
@Override
|
||||
public void doSet(PlayerData data, CurrencyType type, double amount) {
|
||||
double balance = data.getPlayerCurrency(type.getId()) + amount;
|
||||
data.setPlayerCurrency(type.getId(), balance);
|
||||
dataManager.insertLog(new CurrencyLog(data.getUuid(), data.getPlayerName(), type.getId(), "add", amount, balance));
|
||||
CurrencyAPI.addPlayerCurrency(data.getUuid(), type.getId(), amount);
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,10 @@ package cn.hamster3.currency.command.vault;
|
||||
|
||||
import cn.hamster3.api.HamsterAPI;
|
||||
import cn.hamster3.api.command.CommandManager;
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.FileManager;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.core.Message;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
import cn.hamster3.service.bukkit.api.ServiceMessageAPI;
|
||||
@@ -79,24 +79,16 @@ public class VaultPayCommand extends CommandManager {
|
||||
sender.sendMessage(Message.amountNumberError.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerData fromData = dataManager.getPlayerData(player.getUniqueId());
|
||||
if (fromData.getPlayerCurrency(type.getId()) < amount) {
|
||||
if (!CurrencyAPI.hasPlayerCurrency(player.getUniqueId(), type.getId(), amount)) {
|
||||
sender.sendMessage(
|
||||
Message.currencyNotEnough.toString()
|
||||
.replace("%type%", type.getId())
|
||||
);
|
||||
return true;
|
||||
}
|
||||
double fromBalance = fromData.getPlayerCurrency(type.getId()) - amount;
|
||||
fromData.setPlayerCurrency(type.getId(), fromBalance);
|
||||
double toBalance = toData.getPlayerCurrency(type.getId()) + amount;
|
||||
toData.setPlayerCurrency(type.getId(), toBalance);
|
||||
dataManager.savePlayerData(fromData);
|
||||
dataManager.savePlayerData(toData);
|
||||
dataManager.insertLog(new CurrencyLog(fromData.getUuid(), fromData.getPlayerName(), type.getId(), "payOut", amount, fromBalance));
|
||||
dataManager.insertLog(new CurrencyLog(toData.getUuid(), toData.getPlayerName(), type.getId(), "payIn", amount, toBalance));
|
||||
CurrencyAPI.takePlayerCurrency(player.getUniqueId(), type.getId(), amount);
|
||||
CurrencyAPI.addPlayerCurrency(toData.getUuid(), type.getId(), amount);
|
||||
sender.sendMessage(
|
||||
Message.paySuccess.toString()
|
||||
.replace("%player%", toData.getPlayerName())
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hamster3.currency.command.vault;
|
||||
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
|
||||
@@ -17,7 +17,6 @@ public class VaultSetCommand extends VaultAdminSetCommand {
|
||||
|
||||
@Override
|
||||
public void doSet(PlayerData data, CurrencyType type, double amount) {
|
||||
data.setPlayerCurrency(type.getId(), amount);
|
||||
dataManager.insertLog(new CurrencyLog(data.getUuid(), data.getPlayerName(), type.getId(), "set", amount, amount));
|
||||
CurrencyAPI.setPlayerCurrency(data.getUuid(), type.getId(), amount);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hamster3.currency.command.vault;
|
||||
|
||||
import cn.hamster3.currency.api.CurrencyAPI;
|
||||
import cn.hamster3.currency.core.IDataManager;
|
||||
import cn.hamster3.currency.data.CurrencyLog;
|
||||
import cn.hamster3.currency.data.CurrencyType;
|
||||
import cn.hamster3.currency.data.PlayerData;
|
||||
|
||||
@@ -17,8 +17,6 @@ public class VaultTakeCommand extends VaultAdminSetCommand {
|
||||
|
||||
@Override
|
||||
public void doSet(PlayerData data, CurrencyType type, double amount) {
|
||||
double balance = data.getPlayerCurrency(type.getId()) - amount;
|
||||
data.setPlayerCurrency(type.getId(), balance);
|
||||
dataManager.insertLog(new CurrencyLog(data.getUuid(), data.getPlayerName(), type.getId(), "take", amount, balance));
|
||||
CurrencyAPI.takePlayerCurrency(data.getUuid(), type.getId(), amount);
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,8 @@ import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
private final UUID uuid;
|
||||
private String playerName;
|
||||
private final HashMap<String, Double> playerCurrencies;
|
||||
private String playerName;
|
||||
|
||||
public PlayerData(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
|
@@ -6,7 +6,7 @@ useBC: true
|
||||
# 若开启跨服模式,则需要配置datasource
|
||||
datasource:
|
||||
driver: "com.mysql.jdbc.Driver"
|
||||
url: "jdbc:mysql://localhost:3306/mc1.12.2-germ?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||
url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||
user: root
|
||||
password: Root123...
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@@ -40,5 +40,5 @@ jar {
|
||||
rootProject.file("LICENSE")
|
||||
])
|
||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||
destinationDir(rootProject.buildDir)
|
||||
destinationDirectory = rootProject.layout.buildDirectory
|
||||
}
|
||||
|
@@ -43,5 +43,5 @@ jar {
|
||||
rootProject.file("LICENSE")
|
||||
])
|
||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||
destinationDir(rootProject.buildDir)
|
||||
destinationDirectory = rootProject.layout.buildDirectory
|
||||
}
|
||||
|
Reference in New Issue
Block a user