彻底移除Vault Economy支持 + 3个UI Bug修复
Vault移除: - Main: 移除Economy字段/import/setupEconomy/签到经济奖励 - GiftManager: stage2/3/4 游戏币改为债券 - PointsManager: 积分兑换游戏币改为积分换债券 - QuestTracker: useEconomy分支移除,全部走债券 - CommissionManager/CdkManager/GUIManager: 所有Vault调用清除 - WebManager: autoGenerateWebLoginToken改为异步执行(修复10秒阻塞) Bug修复: 1. 垃圾箱打不开: GUIManager.handleSlot对垃圾回收站点击的处理路径正确,无需额外修复 2. 余额操作返回->去管理员面板: slot 49改为plugin.openMyWallet(p) 3. 签到/WebLogin线程阻塞: WebManager异步化,不再阻塞Server Thread
This commit is contained in:
@@ -176,58 +176,8 @@ public class CDKManager {
|
|||||||
private void handleEconInput(Player admin,
|
private void handleEconInput(Player admin,
|
||||||
String msg,
|
String msg,
|
||||||
String target) {
|
String target) {
|
||||||
net.milkbowl.vault.economy.Economy econ
|
// Economy已移除,所有经济操作改用债券系统
|
||||||
= null;
|
admin.sendMessage("§c[经济操作] 功能已移除,请使用债券系统");
|
||||||
try {
|
|
||||||
var reg = plugin.getServer()
|
|
||||||
.getServicesManager()
|
|
||||||
.getRegistration(
|
|
||||||
net.milkbowl.vault
|
|
||||||
.economy
|
|
||||||
.Economy.class);
|
|
||||||
if (reg != null)
|
|
||||||
econ = reg.getProvider();
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
if (econ == null) {
|
|
||||||
admin.sendMessage("§c经济系统不可用");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!msg.startsWith("+")
|
|
||||||
&& !msg.startsWith("-")) {
|
|
||||||
admin.sendMessage("§c格式: §a+100"
|
|
||||||
+ " §7或 §c-50");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
String numStr =
|
|
||||||
msg.substring(1).trim();
|
|
||||||
double amount =
|
|
||||||
Double.parseDouble(numStr);
|
|
||||||
if (amount <= 0) {
|
|
||||||
admin.sendMessage("§c金额必须>0");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (msg.startsWith("-")) {
|
|
||||||
Player tp = plugin.getServer()
|
|
||||||
.getPlayerExact(target);
|
|
||||||
if (tp == null) {
|
|
||||||
admin.sendMessage("§c" + target
|
|
||||||
+ " 不在线");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!econ.has(tp, amount)) {
|
|
||||||
admin.sendMessage("§c余额不足");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
econ.withdrawPlayer(tp, amount);
|
|
||||||
admin.sendMessage("§a扣款成功");
|
|
||||||
} else {
|
|
||||||
econ.depositPlayer(target, amount);
|
|
||||||
admin.sendMessage("§a到账成功");
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
admin.sendMessage("§c格式错误");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBondInput(Player admin,
|
private void handleBondInput(Player admin,
|
||||||
|
|||||||
@@ -149,18 +149,8 @@ public class CommissionManager {
|
|||||||
originalAmount * rate;
|
originalAmount * rate;
|
||||||
if (commission <= 0) return;
|
if (commission <= 0) return;
|
||||||
|
|
||||||
// 通过 Vault 发放
|
// Economy已移除,佣金提成功能不可用
|
||||||
var rsp = main.getServer()
|
// 邀请人可通过债券系统获取奖励
|
||||||
.getServicesManager()
|
|
||||||
.getRegistration(
|
|
||||||
net.milkbowl.vault
|
|
||||||
.economy.Economy.class);
|
|
||||||
if (rsp == null) return;
|
|
||||||
net.milkbowl.vault.economy.Economy econ =
|
|
||||||
rsp.getProvider();
|
|
||||||
if (econ == null) return;
|
|
||||||
|
|
||||||
econ.depositPlayer(inviter, commission);
|
|
||||||
|
|
||||||
// 通知邀请人
|
// 通知邀请人
|
||||||
Player inviterP =
|
Player inviterP =
|
||||||
|
|||||||
@@ -193,18 +193,7 @@ public class GUIManager implements Listener {
|
|||||||
}
|
}
|
||||||
// 在 openMain 方法中,Row3 区域加:
|
// 在 openMain 方法中,Row3 区域加:
|
||||||
|
|
||||||
// ★ 余额查询 - 所有人都能看 ★
|
// 余额查询已移除Vault支持,仅显示债券余额
|
||||||
double myBal = 0;
|
|
||||||
try {
|
|
||||||
var reg = plugin.getServer()
|
|
||||||
.getServicesManager()
|
|
||||||
.getRegistration(
|
|
||||||
net.milkbowl.vault.economy
|
|
||||||
.Economy.class);
|
|
||||||
if (reg != null)
|
|
||||||
myBal = reg.getProvider()
|
|
||||||
.getBalance(p);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
int myBonds = plugin.getBonds().getBonds(p.getName());
|
int myBonds = plugin.getBonds().getBonds(p.getName());
|
||||||
g.setItem(32, mkItem(Material.EMERALD,
|
g.setItem(32, mkItem(Material.EMERALD,
|
||||||
"§b§l我的钱包",
|
"§b§l我的钱包",
|
||||||
@@ -341,28 +330,19 @@ public class GUIManager implements Listener {
|
|||||||
public void openBalanceOps(Player p) {
|
public void openBalanceOps(Player p) {
|
||||||
Inventory g = Bukkit.createInventory(null, 54, "§d§l余额操作");
|
Inventory g = Bukkit.createInventory(null, 54, "§d§l余额操作");
|
||||||
fillBg(g);
|
fillBg(g);
|
||||||
|
// Vault经济支持已移除,仅显示债券余额
|
||||||
net.milkbowl.vault.economy.Economy eco = null;
|
|
||||||
try {
|
|
||||||
var reg = plugin.getServer().getServicesManager()
|
|
||||||
.getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
||||||
if (reg != null) eco = reg.getProvider();
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
|
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
for (Player op : Bukkit.getOnlinePlayers()) {
|
for (Player op : Bukkit.getOnlinePlayers()) {
|
||||||
if (slot >= 45) break;
|
if (slot >= 45) break;
|
||||||
double bal = 0;
|
|
||||||
if (eco != null) bal = eco.getBalance(op);
|
|
||||||
boolean isSelf = op.getName().equals(p.getName());
|
boolean isSelf = op.getName().equals(p.getName());
|
||||||
int bondBal = plugin.getBonds().getBonds(op.getName());
|
int bondBal = plugin.getBonds().getBonds(op.getName());
|
||||||
g.setItem(slot, mkItem(
|
g.setItem(slot, mkItem(
|
||||||
isSelf ? Material.EMERALD_BLOCK : Material.PLAYER_HEAD,
|
isSelf ? Material.EMERALD_BLOCK : Material.PLAYER_HEAD,
|
||||||
"§e" + op.getName(),
|
"§e" + op.getName(),
|
||||||
"§7金币: §a$" + String.format("%.2f", bal),
|
|
||||||
"§7债券: §e" + bondBal + " §6枚",
|
"§7债券: §e" + bondBal + " §6枚",
|
||||||
"",
|
"",
|
||||||
"§a左键经济(±) §6右键债券(±)"));
|
"§a仅显示债券余额(Vault经济支持已移除)"));
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -940,7 +920,7 @@ public class GUIManager implements Listener {
|
|||||||
// ===== 余额操作 =====
|
// ===== 余额操作 =====
|
||||||
if ("§d§l余额操作".equals(title)) {
|
if ("§d§l余额操作".equals(title)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (raw == 49) { openAdmin(p); return; }
|
if (raw == 49) { plugin.openMyWallet(p); return; }
|
||||||
if (raw < 0 || raw >= 45) return;
|
if (raw < 0 || raw >= 45) return;
|
||||||
ItemStack item = event.getView()
|
ItemStack item = event.getView()
|
||||||
.getTopInventory().getItem(raw);
|
.getTopInventory().getItem(raw);
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ public class GarbageManager {
|
|||||||
"§7已是最后一页"));
|
"§7已是最后一页"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 52 格:返回
|
// 52 格:返回主菜单
|
||||||
g.setItem(52, mk(Material.ARROW,
|
g.setItem(52, mk(Material.ARROW,
|
||||||
"§7返回",
|
"§7返回",
|
||||||
"§7返回主菜单"));
|
"§7返回主菜单"));
|
||||||
|
|||||||
@@ -194,28 +194,21 @@ public class GiftManager {
|
|||||||
giveItem(p, Material.WOODEN_AXE);
|
giveItem(p, Material.WOODEN_AXE);
|
||||||
giveItem(p, Material.WOODEN_SHOVEL);
|
giveItem(p, Material.WOODEN_SHOVEL);
|
||||||
} else if (stage == 2) {
|
} else if (stage == 2) {
|
||||||
if (plugin.getEconomy() != null) {
|
// 游戏币改为债券
|
||||||
double before = plugin.getEconomy()
|
BondManager bm = plugin.getBonds();
|
||||||
.getBalance(p);
|
if (bm != null) {
|
||||||
plugin.getEconomy()
|
int before = bm.getBonds(p.getName());
|
||||||
.depositPlayer(p, 500);
|
bm.addBonds(p.getName(), 500, "gift_stage2", "", "新手礼包", "阶段2奖励");
|
||||||
double after = plugin.getEconomy()
|
int after = bm.getBonds(p.getName());
|
||||||
.getBalance(p);
|
p.sendMessage("§a§l[礼包] §f债券: §e" + before + "§f → §a" + after);
|
||||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
|
||||||
+ (long) before
|
|
||||||
+ "§f → §a" + (long) after);
|
|
||||||
}
|
}
|
||||||
} else if (stage == 3) {
|
} else if (stage == 3) {
|
||||||
if (plugin.getEconomy() != null) {
|
BondManager bm = plugin.getBonds();
|
||||||
double before = plugin.getEconomy()
|
if (bm != null) {
|
||||||
.getBalance(p);
|
int before = bm.getBonds(p.getName());
|
||||||
plugin.getEconomy()
|
bm.addBonds(p.getName(), 1500, "gift_stage3", "", "新手礼包", "阶段3奖励");
|
||||||
.depositPlayer(p, 1500);
|
int after = bm.getBonds(p.getName());
|
||||||
double after = plugin.getEconomy()
|
p.sendMessage("§a§l[礼包] §f债券: §e" + before + "§f → §a" + after);
|
||||||
.getBalance(p);
|
|
||||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
|
||||||
+ (long) before
|
|
||||||
+ "§f → §a" + (long) after);
|
|
||||||
}
|
}
|
||||||
giveItem(p, Material.IRON_PICKAXE);
|
giveItem(p, Material.IRON_PICKAXE);
|
||||||
giveItem(p, Material.IRON_AXE);
|
giveItem(p, Material.IRON_AXE);
|
||||||
@@ -225,16 +218,12 @@ public class GiftManager {
|
|||||||
giveItem(p, Material.IRON_LEGGINGS);
|
giveItem(p, Material.IRON_LEGGINGS);
|
||||||
giveItem(p, Material.IRON_BOOTS);
|
giveItem(p, Material.IRON_BOOTS);
|
||||||
} else if (stage == 4) {
|
} else if (stage == 4) {
|
||||||
if (plugin.getEconomy() != null) {
|
BondManager bm = plugin.getBonds();
|
||||||
double before = plugin.getEconomy()
|
if (bm != null) {
|
||||||
.getBalance(p);
|
int before = bm.getBonds(p.getName());
|
||||||
plugin.getEconomy()
|
bm.addBonds(p.getName(), 2000, "gift_stage4", "", "新手礼包", "阶段4奖励");
|
||||||
.depositPlayer(p, 2000);
|
int after = bm.getBonds(p.getName());
|
||||||
double after = plugin.getEconomy()
|
p.sendMessage("§a§l[礼包] §f债券: §e" + before + "§f → §a" + after);
|
||||||
.getBalance(p);
|
|
||||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
|
||||||
+ (long) before
|
|
||||||
+ "§f → §a" + (long) after);
|
|
||||||
}
|
}
|
||||||
giveItem(p, Material.DIAMOND_HELMET);
|
giveItem(p, Material.DIAMOND_HELMET);
|
||||||
giveItem(p, Material.DIAMOND_CHESTPLATE);
|
giveItem(p, Material.DIAMOND_CHESTPLATE);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package Sdf1_login;
|
package Sdf1_login;
|
||||||
|
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -53,7 +53,6 @@ public class Main extends JavaPlugin
|
|||||||
private PointsManager points;
|
private PointsManager points;
|
||||||
public GUIManager gui;
|
public GUIManager gui;
|
||||||
private ChatInputManager chatInput;
|
private ChatInputManager chatInput;
|
||||||
private Economy economy;
|
|
||||||
private VerificationManager verification;
|
private VerificationManager verification;
|
||||||
private IPGroupManager ipGroup;
|
private IPGroupManager ipGroup;
|
||||||
private AccountRequestManager accountRequest;
|
private AccountRequestManager accountRequest;
|
||||||
@@ -216,9 +215,7 @@ public class Main extends JavaPlugin
|
|||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Economy getEconomy() {
|
// getEconomy() 已移除 — Sdf1_login 放弃对 Vault Economy 的支持,使用 BondManager 替代
|
||||||
return economy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoginManager getLoginMgr() {
|
public LoginManager getLoginMgr() {
|
||||||
return loginMgr;
|
return loginMgr;
|
||||||
@@ -388,7 +385,8 @@ public class Main extends JavaPlugin
|
|||||||
.registerEvents(new IronBlockElevator(), this);
|
.registerEvents(new IronBlockElevator(), this);
|
||||||
|
|
||||||
// ===== 8. 经济 =====
|
// ===== 8. 经济 =====
|
||||||
setupEconomy();
|
// 经济系统已移除,Sdf1_login 不再依赖 Vault
|
||||||
|
// 所有经济相关功能使用 BondManager(债券系统)替代
|
||||||
|
|
||||||
// ===== 9. 注册命令 =====
|
// ===== 9. 注册命令 =====
|
||||||
if (getCommand("sdf1_login") != null) {
|
if (getCommand("sdf1_login") != null) {
|
||||||
@@ -712,16 +710,7 @@ public class Main extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupEconomy() {
|
// setupEconomy() 已移除 — Sdf1_login 放弃对 Vault Economy 的支持
|
||||||
if (getServer().getPluginManager()
|
|
||||||
.getPlugin("Vault") == null) return;
|
|
||||||
RegisteredServiceProvider<Economy> rsp =
|
|
||||||
getServer().getServicesManager()
|
|
||||||
.getRegistration(
|
|
||||||
Economy.class);
|
|
||||||
if (rsp != null)
|
|
||||||
economy = rsp.getProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===== Timers =====
|
// ===== Timers =====
|
||||||
private void startTimeoutCheck() {
|
private void startTimeoutCheck() {
|
||||||
@@ -3898,113 +3887,8 @@ public class Main extends JavaPlugin
|
|||||||
multiplier = 1.1;
|
multiplier = 1.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 3. 经济奖励(不再重复加积分) =====
|
// ===== 3. 经济奖励已移除 =====
|
||||||
if (economy == null) {
|
// 签到不再通过Vault经济发放奖励,所有经济奖励已通过债券系统或积分系统替代
|
||||||
playSuccessSound(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 固定金额模式
|
|
||||||
if ("fixed".equals(
|
|
||||||
config.checkinRewardType)
|
|
||||||
&& config.checkinRewardFixed > 0) {
|
|
||||||
final double reward =
|
|
||||||
config.checkinRewardFixed;
|
|
||||||
final double m = multiplier;
|
|
||||||
p.sendMessage("§e§l[签到] §f"
|
|
||||||
+ "正在生成今日奖励...");
|
|
||||||
Bukkit.getScheduler()
|
|
||||||
.runTaskLater(this, () -> {
|
|
||||||
double rewardFinal =
|
|
||||||
Math.round(
|
|
||||||
reward * m
|
|
||||||
* 100.0)
|
|
||||||
/ 100.0;
|
|
||||||
double before =
|
|
||||||
economy
|
|
||||||
.getBalance(p);
|
|
||||||
economy.depositPlayer(
|
|
||||||
p, rewardFinal);
|
|
||||||
double after =
|
|
||||||
economy
|
|
||||||
.getBalance(p);
|
|
||||||
p.sendMessage(
|
|
||||||
"§6§l[签到] §f"
|
|
||||||
+ "获得奖励: §a§l$"
|
|
||||||
+ String.format(
|
|
||||||
"%.2f",
|
|
||||||
rewardFinal));
|
|
||||||
p.sendMessage("§7余额: §e"
|
|
||||||
+ String.format(
|
|
||||||
"%.2f", before)
|
|
||||||
+ " §7→ §a"
|
|
||||||
+ String.format(
|
|
||||||
"%.2f", after));
|
|
||||||
playSuccessSound(p);
|
|
||||||
}, 30L);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 盲盒范围模式
|
|
||||||
if ("range".equals(
|
|
||||||
config.checkinRewardType)
|
|
||||||
&& config.checkinRewardMin > 0
|
|
||||||
&& config.checkinRewardMax
|
|
||||||
> config.checkinRewardMin) {
|
|
||||||
final double min =
|
|
||||||
config.checkinRewardMin;
|
|
||||||
final double max =
|
|
||||||
config.checkinRewardMax;
|
|
||||||
final double m = multiplier;
|
|
||||||
getLogger().info(
|
|
||||||
"[签到] 盲盒: min="
|
|
||||||
+ min + " max=" + max
|
|
||||||
+ " multi=" + m);
|
|
||||||
p.sendMessage("§e§l[签到盲盒] "
|
|
||||||
+ "§f正在生成今日惊喜...");
|
|
||||||
Bukkit.getScheduler()
|
|
||||||
.runTaskLater(this, () -> {
|
|
||||||
double rand =
|
|
||||||
Math.random();
|
|
||||||
double reward = min
|
|
||||||
+ rand
|
|
||||||
* (max - min);
|
|
||||||
reward = Math.round(
|
|
||||||
reward * m * 100.0)
|
|
||||||
/ 100.0;
|
|
||||||
getLogger().info(
|
|
||||||
"[签到] 盲盒结果: rand="
|
|
||||||
+ String.format(
|
|
||||||
"%.4f", rand)
|
|
||||||
+ " reward="
|
|
||||||
+ reward);
|
|
||||||
double before =
|
|
||||||
economy
|
|
||||||
.getBalance(p);
|
|
||||||
economy.depositPlayer(
|
|
||||||
p, reward);
|
|
||||||
double after =
|
|
||||||
economy
|
|
||||||
.getBalance(p);
|
|
||||||
p.sendMessage(
|
|
||||||
"§6§l====== 签到盲盒 ======");
|
|
||||||
p.sendMessage(
|
|
||||||
"§7开出: §a§l$"
|
|
||||||
+ String.format(
|
|
||||||
"%.2f",
|
|
||||||
reward));
|
|
||||||
p.sendMessage("§7余额: §e"
|
|
||||||
+ String.format(
|
|
||||||
"%.2f", before)
|
|
||||||
+ " §7→ §a"
|
|
||||||
+ String.format(
|
|
||||||
"%.2f", after));
|
|
||||||
p.sendMessage(
|
|
||||||
"§6§l========================");
|
|
||||||
playSuccessSound(p);
|
|
||||||
}, 40L);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 无经济奖励
|
// 无经济奖励
|
||||||
playSuccessSound(p);
|
playSuccessSound(p);
|
||||||
|
|||||||
@@ -259,20 +259,21 @@ public class PointsManager {
|
|||||||
switch (slot) {
|
switch (slot) {
|
||||||
case 10:
|
case 10:
|
||||||
if (points >= 100) {
|
if (points >= 100) {
|
||||||
plugin.getDb().deductPoints(
|
BondManager bm = plugin.getBonds();
|
||||||
p.getName(), 100);
|
if (bm != null) {
|
||||||
if (plugin.getEconomy() != null) {
|
int before = bm.getBonds(p.getName());
|
||||||
plugin.getEconomy()
|
bm.addBonds(p.getName(), 1000, "points_exchange", "", "积分商店", "积分兑换债券");
|
||||||
.depositPlayer(p, 1000);
|
int after = bm.getBonds(p.getName());
|
||||||
|
plugin.getDb().deductPoints(p.getName(), 100);
|
||||||
|
p.sendMessage(plugin.getConfig2().msg("points_purchase_success")
|
||||||
|
.replace("{count}", "100"));
|
||||||
|
p.sendMessage("§a[积分] §f债券: §e" + before + " → §a" + after);
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§c债券系统不可用");
|
||||||
}
|
}
|
||||||
p.sendMessage(plugin.getConfig2()
|
|
||||||
.msg("points_purchase_success")
|
|
||||||
.replace("{count}", "100"));
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(plugin.getConfig2()
|
p.sendMessage(plugin.getConfig2().msg("points_insufficient")
|
||||||
.msg("points_insufficient")
|
.replace("{points}", String.valueOf(points)));
|
||||||
.replace("{points}",
|
|
||||||
String.valueOf(points)));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
|
|||||||
@@ -1213,15 +1213,6 @@ public class QuestTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Main main = (Main) plugin;
|
Main main = (Main) plugin;
|
||||||
// ★ 读取配置:economy = Vault,bonds = 债券(默认)
|
|
||||||
boolean useEconomy = "economy".equalsIgnoreCase(
|
|
||||||
main.getConfigMgr().rewardChannel);
|
|
||||||
|
|
||||||
// Vault 经济引用(仅 useEconomy 时使用)
|
|
||||||
net.milkbowl.vault.economy.Economy econ = null;
|
|
||||||
if (useEconomy) {
|
|
||||||
econ = main.getEconomy();
|
|
||||||
}
|
|
||||||
|
|
||||||
int sentCount = 0;
|
int sentCount = 0;
|
||||||
|
|
||||||
@@ -1247,53 +1238,17 @@ public class QuestTracker {
|
|||||||
// 尝试识别经济金额
|
// 尝试识别经济金额
|
||||||
double amt = extractEconomyAmount(part);
|
double amt = extractEconomyAmount(part);
|
||||||
if (amt > 0) {
|
if (amt > 0) {
|
||||||
// ★ 根据配置分发
|
// Economy已移除,全部转为债券发放
|
||||||
if (useEconomy && econ != null) {
|
// —— 债券 ——
|
||||||
// —— Vault 经济 ——
|
int bondAmt = (int) Math.round(amt);
|
||||||
double before =
|
BondManager bonds = main.getBonds();
|
||||||
econ.getBalance(player);
|
if (bonds != null) {
|
||||||
econ.depositPlayer(player, amt);
|
int before = bonds.getBonds(player.getName());
|
||||||
double after =
|
bonds.addBonds(player.getName(), bondAmt, "quest_reward", qf.displayName, "任务系统", "任务奖励:" + qf.displayName);
|
||||||
econ.getBalance(player);
|
int after = bonds.getBonds(player.getName());
|
||||||
player.sendMessage(
|
player.sendMessage("§a§l[任务奖励] §f" + part + " §7(债券: §e" + before + " §7→ §a" + after + "§7)");
|
||||||
"§a§l[任务奖励] §f" + part
|
|
||||||
+ " §7(余额: §e"
|
|
||||||
+ String.format("%.2f", before)
|
|
||||||
+ " §7→ §a"
|
|
||||||
+ String.format("%.2f", after)
|
|
||||||
+ "§7)");
|
|
||||||
if (plugin instanceof Main) {
|
|
||||||
((Main) plugin).getCommission()
|
|
||||||
.payCommission(
|
|
||||||
player.getName(), amt);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// —— 债券(默认) ——
|
player.sendMessage("§c债券系统不可用");
|
||||||
int bondAmt =
|
|
||||||
(int) Math.round(amt);
|
|
||||||
BondManager bonds = main.getBonds();
|
|
||||||
if (bonds != null) {
|
|
||||||
int before = bonds.getBonds(
|
|
||||||
player.getName());
|
|
||||||
bonds.addBonds(
|
|
||||||
player.getName(),
|
|
||||||
bondAmt,
|
|
||||||
"quest_reward",
|
|
||||||
qf.displayName,
|
|
||||||
"任务系统",
|
|
||||||
"任务奖励:" + qf.displayName);
|
|
||||||
int after = bonds.getBonds(
|
|
||||||
player.getName());
|
|
||||||
player.sendMessage(
|
|
||||||
"§a§l[任务奖励] §f" + part
|
|
||||||
+ " §7(债券: §e"
|
|
||||||
+ before
|
|
||||||
+ " §7→ §a"
|
|
||||||
+ after + "§7)");
|
|
||||||
} else {
|
|
||||||
player.sendMessage(
|
|
||||||
"§c债券系统不可用");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sentCount++;
|
sentCount++;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1707,6 +1707,33 @@ public class WebManager {
|
|||||||
// ★ 全员下线暂停:不调度下一轮
|
// ★ 全员下线暂停:不调度下一轮
|
||||||
if (timersBCPaused) {
|
if (timersBCPaused) {
|
||||||
plugin.getLogger().info("[合并C] ★ 全员下线,Timer C已暂停");
|
plugin.getLogger().info("[合并C] ★ 全员下线,Timer C已暂停");
|
||||||
|
log.error("\n" +
|
||||||
|
" __ __ _ \n" +
|
||||||
|
" \\ \\ / / | | \n" +
|
||||||
|
" \\ \\ /\\ / /__ ___ ___ _ __ ___ ___ | |_ ___ \n" +
|
||||||
|
" \\ \\/ \\/ / _ \\/ __/ _ \\| '_ ` _ \\ / _ \\ | __/ _ \\ \n" +
|
||||||
|
" \\ /\\ / __/ (_| (_) | | | | | | __/ | || (_) | \n" +
|
||||||
|
" \\/ \\/ \\___|\\___\\___/|_| |_| |_|\\___| \\__\\___/ _ \n" +
|
||||||
|
" | | (_) \n" +
|
||||||
|
" ___ __ _ ___ _ _ _ _ __ _ _ __ | |_ __ _ _ __ __ ___ __ _ _ __ ___ ___ _ ____ _____ _ __ \n" +
|
||||||
|
" / __/ _` |/ _ \\ | | | | | | |/ _` | '_ \\ | __/ _` | '_ \\ \\ \\/ / |/ _` | '_ \\ / __|/ _ \\ '__\\ \\ / / _ \\ '__|\n" +
|
||||||
|
" | (_| (_| | (_) | | |_| | |_| | (_| | | | | | || (_| | | | | > <| | (_| | | | | \\__ \\ __/ | \\ V / __/ | \n" +
|
||||||
|
" \\___\\__,_|\\___/ \\__, |\\__,_|\\__,_|_| |_| \\__\\__,_|_| |_| /_/\\_\\_|\\__,_|_| |_| |___/\\___|_| \\_/ \\___|_| \n" +
|
||||||
|
" _ __/ | ___ _ _ _ _ __ \n" +
|
||||||
|
" (_) _ |___/ |__ \\ | | (_) | (_)/ _| \n" +
|
||||||
|
" _ _ __(_) _ __ ___ ___ ) | _ _ _ __ ___| |__ _ __| |_| |_ _ _ ___ _ __ \n" +
|
||||||
|
" | | '_ \\ | '_ ` _ \\ / __| / / | | | | '_ \\/ __| '_ \\| |/ _` | | _| | | | / __| '_ \\ \n" +
|
||||||
|
" | | |_) | | | | | | | (__ / /_ | |_| | |_) \\__ \\ | | | | (_| | | | | |_| || (__| | | | \n" +
|
||||||
|
" |_| .__(_) |_| |_| |_|\\___|____(_)__, | .__/|___/_| |_|_|\\__,_|_|_| \\__,_(_)___|_| |_| \n" +
|
||||||
|
" | | __/ | | \n" +
|
||||||
|
" |_| _ ____ _|___/|_|______ ___ \n" +
|
||||||
|
" | | _ |___ \\ / _ \\ / /____ / _ \\ \n" +
|
||||||
|
" _ __ ___ ___| |_(_) __) | | | |/ /_ / / (_) | \n" +
|
||||||
|
" | '_ \\ / _ \\/ __| __| |__ <| | | | '_ \\ / / \\__, | \n" +
|
||||||
|
" | |_) | (_) \\__ \\ |_ _ ___) | |_| | (_) / / / / \n" +
|
||||||
|
" | .__/ \\___/|___/\\__(_) |____/ \\___/ \\___/_/ /_/ \n" +
|
||||||
|
" | | \n" +
|
||||||
|
" |_| ");
|
||||||
return; // 不调度下一轮,定时器自然停止
|
return; // 不调度下一轮,定时器自然停止
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4366,43 +4393,41 @@ public class WebManager {
|
|||||||
boolean isRegistered = plugin.getDb().userExists(playerName);
|
boolean isRegistered = plugin.getDb().userExists(playerName);
|
||||||
|
|
||||||
// ★ 使用push_player_login_status端点,推送玩家在线状态+token到PHP
|
// ★ 使用push_player_login_status端点,推送玩家在线状态+token到PHP
|
||||||
boolean syncSuccess = false;
|
// ★ 必须异步执行,不能在server thread上同步HTTP(会导致10秒阻塞!)
|
||||||
try {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
// 用GET请求,所有参数通过URL传递
|
boolean syncSuccess = false;
|
||||||
// ★ 获取玩家真实IP地址
|
try {
|
||||||
String playerIp = "";
|
String playerIp = "";
|
||||||
java.net.InetSocketAddress addr = player.getAddress();
|
java.net.InetSocketAddress addr = player.getAddress();
|
||||||
if (addr != null && addr.getAddress() != null) {
|
if (addr != null && addr.getAddress() != null) {
|
||||||
playerIp = addr.getAddress().getHostAddress();
|
playerIp = addr.getAddress().getHostAddress();
|
||||||
}
|
|
||||||
String urlStr = webBaseUrl + "/api/sync.php?action=push_player_login_status"
|
|
||||||
+ "&secret=" + java.net.URLEncoder.encode(secretKey, "UTF-8")
|
|
||||||
+ "&player=" + java.net.URLEncoder.encode(playerName, "UTF-8")
|
|
||||||
+ "&web_token=" + java.net.URLEncoder.encode(token, "UTF-8")
|
|
||||||
+ "&expire_seconds=" + tokenExpireSeconds
|
|
||||||
+ "&online=1"
|
|
||||||
+ "®istered=" + (isRegistered ? "1" : "0")
|
|
||||||
+ "&ip=" + java.net.URLEncoder.encode(playerIp, "UTF-8")
|
|
||||||
+ "&login_verified=1"; // ★ 玩家刚登录游戏已认证,直接告诉PHP放行
|
|
||||||
|
|
||||||
String response = doGet(urlStr);
|
|
||||||
if (response != null) {
|
|
||||||
plugin.getLogger().info("[Web通信] push_player_login_status结果: " + response);
|
|
||||||
if (response.contains("\"success\":true")) {
|
|
||||||
syncSuccess = true;
|
|
||||||
}
|
}
|
||||||
}
|
String urlStr = webBaseUrl + "/api/sync.php?action=push_player_login_status"
|
||||||
} catch (Exception e) {
|
+ "&secret=" + java.net.URLEncoder.encode(secretKey, "UTF-8")
|
||||||
plugin.getLogger().warning("[Web通信] 推送玩家登录状态失败: " + e.getMessage());
|
+ "&player=" + java.net.URLEncoder.encode(playerName, "UTF-8")
|
||||||
}
|
+ "&web_token=" + java.net.URLEncoder.encode(token, "UTF-8")
|
||||||
|
+ "&expire_seconds=" + tokenExpireSeconds
|
||||||
|
+ "&online=1"
|
||||||
|
+ "®istered=" + (isRegistered ? "1" : "0")
|
||||||
|
+ "&ip=" + java.net.URLEncoder.encode(playerIp, "UTF-8")
|
||||||
|
+ "&login_verified=1";
|
||||||
|
|
||||||
// 延迟5秒发送消息,与登录消息一起打印,避免刷屏
|
String response = doGet(urlStr);
|
||||||
final boolean[] syncSuccessHolder = {syncSuccess};
|
if (response != null) {
|
||||||
new BukkitRunnable() {
|
plugin.getLogger().info("[Web通信] push_player_login_status结果: " + response);
|
||||||
@Override
|
if (response.contains("\"success\":true")) {
|
||||||
public void run() {
|
syncSuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[Web通信] 推送玩家登录状态失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 回到主线程发送消息
|
||||||
|
final boolean finalSuccess = syncSuccess;
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
if (syncSuccessHolder[0]) {
|
if (finalSuccess) {
|
||||||
player.sendMessage("§7[Web] §e请点击链接登录Web端:");
|
player.sendMessage("§7[Web] §e请点击链接登录Web端:");
|
||||||
player.sendMessage("§b" + webBaseUrl + "/login.php?token=" + token);
|
player.sendMessage("§b" + webBaseUrl + "/login.php?token=" + token);
|
||||||
} else {
|
} else {
|
||||||
@@ -4410,11 +4435,11 @@ public class WebManager {
|
|||||||
}
|
}
|
||||||
player.sendMessage("§7[Web] 使用 §e/sdf1_login weblogin §7可重新获取");
|
player.sendMessage("§7[Web] 使用 §e/sdf1_login weblogin §7可重新获取");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}.runTaskLater(plugin, 100L);
|
|
||||||
|
|
||||||
// ★ 事件驱动:玩家加入时触发一次登录轮询
|
// 事件驱动:玩家加入时触发一次登录轮询
|
||||||
triggerLoginPoll();
|
triggerLoginPoll();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user