彻底移除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,
|
||||
String msg,
|
||||
String target) {
|
||||
net.milkbowl.vault.economy.Economy econ
|
||||
= null;
|
||||
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格式错误");
|
||||
}
|
||||
// Economy已移除,所有经济操作改用债券系统
|
||||
admin.sendMessage("§c[经济操作] 功能已移除,请使用债券系统");
|
||||
}
|
||||
|
||||
private void handleBondInput(Player admin,
|
||||
|
||||
@@ -149,18 +149,8 @@ public class CommissionManager {
|
||||
originalAmount * rate;
|
||||
if (commission <= 0) return;
|
||||
|
||||
// 通过 Vault 发放
|
||||
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);
|
||||
// Economy已移除,佣金提成功能不可用
|
||||
// 邀请人可通过债券系统获取奖励
|
||||
|
||||
// 通知邀请人
|
||||
Player inviterP =
|
||||
|
||||
@@ -193,18 +193,7 @@ public class GUIManager implements Listener {
|
||||
}
|
||||
// 在 openMain 方法中,Row3 区域加:
|
||||
|
||||
// ★ 余额查询 - 所有人都能看 ★
|
||||
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) {}
|
||||
// 余额查询已移除Vault支持,仅显示债券余额
|
||||
int myBonds = plugin.getBonds().getBonds(p.getName());
|
||||
g.setItem(32, mkItem(Material.EMERALD,
|
||||
"§b§l我的钱包",
|
||||
@@ -341,28 +330,19 @@ public class GUIManager implements Listener {
|
||||
public void openBalanceOps(Player p) {
|
||||
Inventory g = Bukkit.createInventory(null, 54, "§d§l余额操作");
|
||||
fillBg(g);
|
||||
|
||||
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) {}
|
||||
// Vault经济支持已移除,仅显示债券余额
|
||||
|
||||
int slot = 0;
|
||||
for (Player op : Bukkit.getOnlinePlayers()) {
|
||||
if (slot >= 45) break;
|
||||
double bal = 0;
|
||||
if (eco != null) bal = eco.getBalance(op);
|
||||
boolean isSelf = op.getName().equals(p.getName());
|
||||
int bondBal = plugin.getBonds().getBonds(op.getName());
|
||||
g.setItem(slot, mkItem(
|
||||
isSelf ? Material.EMERALD_BLOCK : Material.PLAYER_HEAD,
|
||||
"§e" + op.getName(),
|
||||
"§7金币: §a$" + String.format("%.2f", bal),
|
||||
"§7债券: §e" + bondBal + " §6枚",
|
||||
"",
|
||||
"§a左键经济(±) §6右键债券(±)"));
|
||||
"§a仅显示债券余额(Vault经济支持已移除)"));
|
||||
slot++;
|
||||
}
|
||||
|
||||
@@ -940,7 +920,7 @@ public class GUIManager implements Listener {
|
||||
// ===== 余额操作 =====
|
||||
if ("§d§l余额操作".equals(title)) {
|
||||
event.setCancelled(true);
|
||||
if (raw == 49) { openAdmin(p); return; }
|
||||
if (raw == 49) { plugin.openMyWallet(p); return; }
|
||||
if (raw < 0 || raw >= 45) return;
|
||||
ItemStack item = event.getView()
|
||||
.getTopInventory().getItem(raw);
|
||||
|
||||
@@ -425,7 +425,7 @@ public class GarbageManager {
|
||||
"§7已是最后一页"));
|
||||
}
|
||||
|
||||
// 52 格:返回
|
||||
// 52 格:返回主菜单
|
||||
g.setItem(52, mk(Material.ARROW,
|
||||
"§7返回",
|
||||
"§7返回主菜单"));
|
||||
|
||||
@@ -194,28 +194,21 @@ public class GiftManager {
|
||||
giveItem(p, Material.WOODEN_AXE);
|
||||
giveItem(p, Material.WOODEN_SHOVEL);
|
||||
} else if (stage == 2) {
|
||||
if (plugin.getEconomy() != null) {
|
||||
double before = plugin.getEconomy()
|
||||
.getBalance(p);
|
||||
plugin.getEconomy()
|
||||
.depositPlayer(p, 500);
|
||||
double after = plugin.getEconomy()
|
||||
.getBalance(p);
|
||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
||||
+ (long) before
|
||||
+ "§f → §a" + (long) after);
|
||||
// 游戏币改为债券
|
||||
BondManager bm = plugin.getBonds();
|
||||
if (bm != null) {
|
||||
int before = bm.getBonds(p.getName());
|
||||
bm.addBonds(p.getName(), 500, "gift_stage2", "", "新手礼包", "阶段2奖励");
|
||||
int after = bm.getBonds(p.getName());
|
||||
p.sendMessage("§a§l[礼包] §f债券: §e" + before + "§f → §a" + after);
|
||||
}
|
||||
} else if (stage == 3) {
|
||||
if (plugin.getEconomy() != null) {
|
||||
double before = plugin.getEconomy()
|
||||
.getBalance(p);
|
||||
plugin.getEconomy()
|
||||
.depositPlayer(p, 1500);
|
||||
double after = plugin.getEconomy()
|
||||
.getBalance(p);
|
||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
||||
+ (long) before
|
||||
+ "§f → §a" + (long) after);
|
||||
BondManager bm = plugin.getBonds();
|
||||
if (bm != null) {
|
||||
int before = bm.getBonds(p.getName());
|
||||
bm.addBonds(p.getName(), 1500, "gift_stage3", "", "新手礼包", "阶段3奖励");
|
||||
int after = bm.getBonds(p.getName());
|
||||
p.sendMessage("§a§l[礼包] §f债券: §e" + before + "§f → §a" + after);
|
||||
}
|
||||
giveItem(p, Material.IRON_PICKAXE);
|
||||
giveItem(p, Material.IRON_AXE);
|
||||
@@ -225,16 +218,12 @@ public class GiftManager {
|
||||
giveItem(p, Material.IRON_LEGGINGS);
|
||||
giveItem(p, Material.IRON_BOOTS);
|
||||
} else if (stage == 4) {
|
||||
if (plugin.getEconomy() != null) {
|
||||
double before = plugin.getEconomy()
|
||||
.getBalance(p);
|
||||
plugin.getEconomy()
|
||||
.depositPlayer(p, 2000);
|
||||
double after = plugin.getEconomy()
|
||||
.getBalance(p);
|
||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
||||
+ (long) before
|
||||
+ "§f → §a" + (long) after);
|
||||
BondManager bm = plugin.getBonds();
|
||||
if (bm != null) {
|
||||
int before = bm.getBonds(p.getName());
|
||||
bm.addBonds(p.getName(), 2000, "gift_stage4", "", "新手礼包", "阶段4奖励");
|
||||
int after = bm.getBonds(p.getName());
|
||||
p.sendMessage("§a§l[礼包] §f债券: §e" + before + "§f → §a" + after);
|
||||
}
|
||||
giveItem(p, Material.DIAMOND_HELMET);
|
||||
giveItem(p, Material.DIAMOND_CHESTPLATE);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Sdf1_login;
|
||||
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -53,7 +53,6 @@ public class Main extends JavaPlugin
|
||||
private PointsManager points;
|
||||
public GUIManager gui;
|
||||
private ChatInputManager chatInput;
|
||||
private Economy economy;
|
||||
private VerificationManager verification;
|
||||
private IPGroupManager ipGroup;
|
||||
private AccountRequestManager accountRequest;
|
||||
@@ -216,9 +215,7 @@ public class Main extends JavaPlugin
|
||||
return email;
|
||||
}
|
||||
|
||||
public Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
// getEconomy() 已移除 — Sdf1_login 放弃对 Vault Economy 的支持,使用 BondManager 替代
|
||||
|
||||
public LoginManager getLoginMgr() {
|
||||
return loginMgr;
|
||||
@@ -388,7 +385,8 @@ public class Main extends JavaPlugin
|
||||
.registerEvents(new IronBlockElevator(), this);
|
||||
|
||||
// ===== 8. 经济 =====
|
||||
setupEconomy();
|
||||
// 经济系统已移除,Sdf1_login 不再依赖 Vault
|
||||
// 所有经济相关功能使用 BondManager(债券系统)替代
|
||||
|
||||
// ===== 9. 注册命令 =====
|
||||
if (getCommand("sdf1_login") != null) {
|
||||
@@ -712,16 +710,7 @@ public class Main extends JavaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void setupEconomy() {
|
||||
if (getServer().getPluginManager()
|
||||
.getPlugin("Vault") == null) return;
|
||||
RegisteredServiceProvider<Economy> rsp =
|
||||
getServer().getServicesManager()
|
||||
.getRegistration(
|
||||
Economy.class);
|
||||
if (rsp != null)
|
||||
economy = rsp.getProvider();
|
||||
}
|
||||
// setupEconomy() 已移除 — Sdf1_login 放弃对 Vault Economy 的支持
|
||||
|
||||
// ===== Timers =====
|
||||
private void startTimeoutCheck() {
|
||||
@@ -3898,113 +3887,8 @@ public class Main extends JavaPlugin
|
||||
multiplier = 1.1;
|
||||
}
|
||||
|
||||
// ===== 3. 经济奖励(不再重复加积分) =====
|
||||
if (economy == null) {
|
||||
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;
|
||||
}
|
||||
// ===== 3. 经济奖励已移除 =====
|
||||
// 签到不再通过Vault经济发放奖励,所有经济奖励已通过债券系统或积分系统替代
|
||||
|
||||
// 无经济奖励
|
||||
playSuccessSound(p);
|
||||
|
||||
@@ -259,20 +259,21 @@ public class PointsManager {
|
||||
switch (slot) {
|
||||
case 10:
|
||||
if (points >= 100) {
|
||||
plugin.getDb().deductPoints(
|
||||
p.getName(), 100);
|
||||
if (plugin.getEconomy() != null) {
|
||||
plugin.getEconomy()
|
||||
.depositPlayer(p, 1000);
|
||||
}
|
||||
p.sendMessage(plugin.getConfig2()
|
||||
.msg("points_purchase_success")
|
||||
BondManager bm = plugin.getBonds();
|
||||
if (bm != null) {
|
||||
int before = bm.getBonds(p.getName());
|
||||
bm.addBonds(p.getName(), 1000, "points_exchange", "", "积分商店", "积分兑换债券");
|
||||
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(plugin.getConfig2()
|
||||
.msg("points_insufficient")
|
||||
.replace("{points}",
|
||||
String.valueOf(points)));
|
||||
p.sendMessage("§c债券系统不可用");
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(plugin.getConfig2().msg("points_insufficient")
|
||||
.replace("{points}", String.valueOf(points)));
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
|
||||
@@ -1213,15 +1213,6 @@ public class QuestTracker {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -1247,53 +1238,17 @@ public class QuestTracker {
|
||||
// 尝试识别经济金额
|
||||
double amt = extractEconomyAmount(part);
|
||||
if (amt > 0) {
|
||||
// ★ 根据配置分发
|
||||
if (useEconomy && econ != null) {
|
||||
// —— Vault 经济 ——
|
||||
double before =
|
||||
econ.getBalance(player);
|
||||
econ.depositPlayer(player, amt);
|
||||
double after =
|
||||
econ.getBalance(player);
|
||||
player.sendMessage(
|
||||
"§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 {
|
||||
// —— 债券(默认) ——
|
||||
int bondAmt =
|
||||
(int) Math.round(amt);
|
||||
// Economy已移除,全部转为债券发放
|
||||
// —— 债券 ——
|
||||
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)");
|
||||
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债券系统不可用");
|
||||
}
|
||||
player.sendMessage("§c债券系统不可用");
|
||||
}
|
||||
sentCount++;
|
||||
continue;
|
||||
|
||||
@@ -1707,6 +1707,33 @@ public class WebManager {
|
||||
// ★ 全员下线暂停:不调度下一轮
|
||||
if (timersBCPaused) {
|
||||
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; // 不调度下一轮,定时器自然停止
|
||||
}
|
||||
|
||||
@@ -4366,10 +4393,10 @@ public class WebManager {
|
||||
boolean isRegistered = plugin.getDb().userExists(playerName);
|
||||
|
||||
// ★ 使用push_player_login_status端点,推送玩家在线状态+token到PHP
|
||||
// ★ 必须异步执行,不能在server thread上同步HTTP(会导致10秒阻塞!)
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
boolean syncSuccess = false;
|
||||
try {
|
||||
// 用GET请求,所有参数通过URL传递
|
||||
// ★ 获取玩家真实IP地址
|
||||
String playerIp = "";
|
||||
java.net.InetSocketAddress addr = player.getAddress();
|
||||
if (addr != null && addr.getAddress() != null) {
|
||||
@@ -4383,7 +4410,7 @@ public class WebManager {
|
||||
+ "&online=1"
|
||||
+ "®istered=" + (isRegistered ? "1" : "0")
|
||||
+ "&ip=" + java.net.URLEncoder.encode(playerIp, "UTF-8")
|
||||
+ "&login_verified=1"; // ★ 玩家刚登录游戏已认证,直接告诉PHP放行
|
||||
+ "&login_verified=1";
|
||||
|
||||
String response = doGet(urlStr);
|
||||
if (response != null) {
|
||||
@@ -4396,13 +4423,11 @@ public class WebManager {
|
||||
plugin.getLogger().warning("[Web通信] 推送玩家登录状态失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
// 延迟5秒发送消息,与登录消息一起打印,避免刷屏
|
||||
final boolean[] syncSuccessHolder = {syncSuccess};
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 回到主线程发送消息
|
||||
final boolean finalSuccess = syncSuccess;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (player.isOnline()) {
|
||||
if (syncSuccessHolder[0]) {
|
||||
if (finalSuccess) {
|
||||
player.sendMessage("§7[Web] §e请点击链接登录Web端:");
|
||||
player.sendMessage("§b" + webBaseUrl + "/login.php?token=" + token);
|
||||
} else {
|
||||
@@ -4410,11 +4435,11 @@ public class WebManager {
|
||||
}
|
||||
player.sendMessage("§7[Web] 使用 §e/sdf1_login weblogin §7可重新获取");
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, 100L);
|
||||
});
|
||||
|
||||
// ★ 事件驱动:玩家加入时触发一次登录轮询
|
||||
// 事件驱动:玩家加入时触发一次登录轮询
|
||||
triggerLoginPoll();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user