@ SeniorDeveloper 修复领地系统10项问题:空白日志、CLI效果管理、GUI验证、在线玩家同步、领地数据同步、领地所有权验证、用户端UI优化、效果管理、和平模式修复
This commit is contained in:
@@ -636,7 +636,7 @@ public class AreaCLIManager {
|
|||||||
perms.add(new PermItem("wool_shear", "剪切羊毛/生物", !land.denyWoolShear));
|
perms.add(new PermItem("wool_shear", "剪切羊毛/生物", !land.denyWoolShear));
|
||||||
perms.add(new PermItem("animal_feed", "投喂动物", !land.denyAnimalFeeding));
|
perms.add(new PermItem("animal_feed", "投喂动物", !land.denyAnimalFeeding));
|
||||||
perms.add(new PermItem("glowing", "玩家发光", !land.denyGlowing));
|
perms.add(new PermItem("glowing", "玩家发光", !land.denyGlowing));
|
||||||
perms.add(new PermItem("peace_mode", "启用和平模式", land.peaceMode));
|
perms.add(new PermItem("peace_mode", "和平模式", land.peaceMode));
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,7 +670,7 @@ public class AreaCLIManager {
|
|||||||
case "wool_shear": return "剪切羊毛";
|
case "wool_shear": return "剪切羊毛";
|
||||||
case "animal_feed": return "投喂动物";
|
case "animal_feed": return "投喂动物";
|
||||||
case "glowing": return "玩家发光";
|
case "glowing": return "玩家发光";
|
||||||
case "peace_mode": return "启用和平模式";
|
case "peace_mode": return "和平模式";
|
||||||
default: return key;
|
default: return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -966,7 +966,7 @@ public class AreaCLIManager {
|
|||||||
{"wool_shear", "剪切羊毛/生物", "denyWoolShear"},
|
{"wool_shear", "剪切羊毛/生物", "denyWoolShear"},
|
||||||
{"animal_feed", "投喂动物", "denyAnimalFeeding"},
|
{"animal_feed", "投喂动物", "denyAnimalFeeding"},
|
||||||
{"glowing", "玩家发光", "denyGlowing"},
|
{"glowing", "玩家发光", "denyGlowing"},
|
||||||
{"peace_mode", "启用和平模式", "peaceMode"}
|
{"peace_mode", "和平模式", "peaceMode"}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (String[] def : permDefs) {
|
for (String[] def : permDefs) {
|
||||||
@@ -1099,12 +1099,13 @@ public class AreaCLIManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component addLine = Component.empty().append(Component.text("§e[添加效果] "));
|
// ★ 可点击添加按钮 → 跳转到效果选择列表
|
||||||
p.sendMessage(addLine);
|
p.sendMessage(Component.text("")
|
||||||
|
.append(Component.text("§e[添加效果]"))
|
||||||
|
.hoverEvent(HoverEvent.showText(Component.text("§e点击选择要清除的效果")))
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 4")));
|
||||||
p.sendMessage(Component.text("§a[◀ 返回管理菜单]")
|
p.sendMessage(Component.text("§a[◀ 返回管理菜单]")
|
||||||
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 1")));
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 1")));
|
||||||
p.sendMessage(Component.text("§7提示: 单清效果请使用快捷指令: /protect cli effectsclearadd <效果名>"));
|
|
||||||
p.sendMessage(Component.text("§7支持中文(如:缓慢、中毒、凋零、饥饿)"));
|
|
||||||
p.sendMessage(Component.text("§7§l───────────────────────────────"));
|
p.sendMessage(Component.text("§7§l───────────────────────────────"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1128,14 +1129,123 @@ public class AreaCLIManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.sendMessage(Component.text(""));
|
p.sendMessage(Component.text(""));
|
||||||
p.sendMessage(Component.empty()
|
// ★ 可点击添加按钮 → 跳转到增益效果选择列表
|
||||||
|
p.sendMessage(Component.text("")
|
||||||
.append(Component.text("§e[添加增益]"))
|
.append(Component.text("§e[添加增益]"))
|
||||||
.append(Component.text("§a[◀ 返回管理菜单]")
|
.hoverEvent(HoverEvent.showText(Component.text("§e点击选择要添加的增益效果")))
|
||||||
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 1"))));
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 5")));
|
||||||
p.sendMessage(Component.text("§7提示: 添加增益效果请使用快捷指令: /protect cli effectsaddadd <效果名> [等级] [秒数]"));
|
p.sendMessage(Component.text("§a[◀ 返回管理菜单]")
|
||||||
p.sendMessage(Component.empty()
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 1")));
|
||||||
.append(Component.text("§e示例: /protect cli effectsaddadd 力量 2 300 = 力量II 持续5分钟"))
|
p.sendMessage(Component.text("§7§l───────────────────────────────"));
|
||||||
.clickEvent(ClickEvent.suggestCommand("/protect cli effectsaddadd 力量 2 300")));
|
}
|
||||||
|
|
||||||
|
// ========== 子菜单4:选择清除效果(可点击列表) ==========
|
||||||
|
else if (subPage == 4) {
|
||||||
|
p.sendMessage(header("选择要清除的效果: " + landName));
|
||||||
|
|
||||||
|
// ★ 负面效果(可点击添加到单清列表)
|
||||||
|
p.sendMessage(Component.text("§c§l负面效果:"));
|
||||||
|
String[][] badEffects = {
|
||||||
|
{"缓慢", "slowness"}, {"挖掘疲劳", "mining_fatigue"}, {"瞬间伤害", "instant_damage"},
|
||||||
|
{"反胃", "nausea"}, {"失明", "blindness"}, {"饥饿", "hunger"},
|
||||||
|
{"虚弱", "weakness"}, {"中毒", "poison"}, {"凋零", "wither"},
|
||||||
|
{"飘浮", "levitation"}, {"霉运", "unluck"}, {"黑暗", "darkness"},
|
||||||
|
{"蓄风", "wind_charged"}, {"盘丝", "weaving"}, {"渗浆", "oozing"}, {"寄生", "infested"}
|
||||||
|
};
|
||||||
|
for (String[] eff : badEffects) {
|
||||||
|
boolean alreadyInList = land.clearEffects.contains(eff[0]);
|
||||||
|
String prefix = alreadyInList ? "§7" : "§c";
|
||||||
|
String suffix = alreadyInList ? " §7(已添加)" : "";
|
||||||
|
Component btn = Component.text(prefix + "§l[+] " + eff[0] + suffix);
|
||||||
|
if (!alreadyInList) {
|
||||||
|
btn = btn.hoverEvent(HoverEvent.showText(Component.text("§e点击添加清除效果: " + eff[0])))
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsclearadd " + landName + " " + eff[0]));
|
||||||
|
}
|
||||||
|
p.sendMessage(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ★ 中性效果
|
||||||
|
p.sendMessage(Component.text(""));
|
||||||
|
p.sendMessage(Component.text("§e§l中性效果:"));
|
||||||
|
String[][] neutralEffects = {
|
||||||
|
{"不祥之兆", "bad_omen"}, {"袭击之兆", "raid_omen"}, {"试炼之兆", "trial_omen"}
|
||||||
|
};
|
||||||
|
for (String[] eff : neutralEffects) {
|
||||||
|
boolean alreadyInList = land.clearEffects.contains(eff[0]);
|
||||||
|
String prefix = alreadyInList ? "§7" : "§e";
|
||||||
|
String suffix = alreadyInList ? " §7(已添加)" : "";
|
||||||
|
Component btn = Component.text(prefix + "§l[+] " + eff[0] + suffix);
|
||||||
|
if (!alreadyInList) {
|
||||||
|
btn = btn.hoverEvent(HoverEvent.showText(Component.text("§e点击添加清除效果: " + eff[0])))
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsclearadd " + landName + " " + eff[0]));
|
||||||
|
}
|
||||||
|
p.sendMessage(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ★ 正面效果(也可以添加到清除列表)
|
||||||
|
p.sendMessage(Component.text(""));
|
||||||
|
p.sendMessage(Component.text("§a§l正面效果:"));
|
||||||
|
String[][] goodEffects = {
|
||||||
|
{"迅捷", "speed"}, {"急迫", "haste"}, {"力量", "strength"},
|
||||||
|
{"瞬间治疗", "instant_health"}, {"跳跃提升", "jump_boost"}, {"生命恢复", "regeneration"},
|
||||||
|
{"抗性提升", "resistance"}, {"抗火", "fire_resistance"}, {"水下呼吸", "water_breathing"},
|
||||||
|
{"隐身", "invisibility"}, {"夜视", "night_vision"}, {"发光", "glowing"},
|
||||||
|
{"生命提升", "health_boost"}, {"伤害吸收", "absorption"}, {"饱和", "saturation"},
|
||||||
|
{"幸运", "luck"}, {"村庄英雄", "hero_of_the_village"}, {"缓降", "slow_falling"},
|
||||||
|
{"潮涌能量", "conduit_power"}, {"海豚的恩惠", "dolphins_grace"}
|
||||||
|
};
|
||||||
|
for (String[] eff : goodEffects) {
|
||||||
|
boolean alreadyInList = land.clearEffects.contains(eff[0]);
|
||||||
|
String prefix = alreadyInList ? "§7" : "§a";
|
||||||
|
String suffix = alreadyInList ? " §7(已添加)" : "";
|
||||||
|
Component btn = Component.text(prefix + "§l[+] " + eff[0] + suffix);
|
||||||
|
if (!alreadyInList) {
|
||||||
|
btn = btn.hoverEvent(HoverEvent.showText(Component.text("§e点击添加清除效果: " + eff[0])))
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsclearadd " + landName + " " + eff[0]));
|
||||||
|
}
|
||||||
|
p.sendMessage(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.sendMessage(Component.text(""));
|
||||||
|
p.sendMessage(Component.text("§a[◀ 返回单清效果列表]")
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 2")));
|
||||||
|
p.sendMessage(Component.text("§7§l───────────────────────────────"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 子菜单5:选择增益效果(可点击列表) ==========
|
||||||
|
else if (subPage == 5) {
|
||||||
|
p.sendMessage(header("选择要添加的增益效果: " + landName));
|
||||||
|
p.sendMessage(Component.text("§7点击效果名称直接添加(默认等级1,持续300秒)"));
|
||||||
|
p.sendMessage(Component.text("§7高级: /protect cli effectsaddadd <效果名> [等级] [秒数]"));
|
||||||
|
|
||||||
|
String[][] giveEffectsList = {
|
||||||
|
{"迅捷", "speed"}, {"急迫", "haste"}, {"力量", "strength"},
|
||||||
|
{"瞬间治疗", "instant_health"}, {"跳跃提升", "jump_boost"}, {"生命恢复", "regeneration"},
|
||||||
|
{"抗性提升", "resistance"}, {"抗火", "fire_resistance"}, {"水下呼吸", "water_breathing"},
|
||||||
|
{"隐身", "invisibility"}, {"夜视", "night_vision"}, {"发光", "glowing"},
|
||||||
|
{"生命提升", "health_boost"}, {"伤害吸收", "absorption"}, {"饱和", "saturation"},
|
||||||
|
{"幸运", "luck"}, {"村庄英雄", "hero_of_the_village"}, {"缓降", "slow_falling"},
|
||||||
|
{"潮涌能量", "conduit_power"}, {"海豚的恩惠", "dolphins_grace"}
|
||||||
|
};
|
||||||
|
for (String[] eff : giveEffectsList) {
|
||||||
|
// 检查是否已存在同名增益
|
||||||
|
boolean alreadyExists = false;
|
||||||
|
for (String[] ge : land.giveEffects) {
|
||||||
|
if (ge[0].equals(eff[0])) { alreadyExists = true; break; }
|
||||||
|
}
|
||||||
|
String prefix = alreadyExists ? "§7" : "§a";
|
||||||
|
String suffix = alreadyExists ? " §7(已添加)" : "";
|
||||||
|
Component btn = Component.text(prefix + "§l[+] " + eff[0] + suffix);
|
||||||
|
if (!alreadyExists) {
|
||||||
|
btn = btn.hoverEvent(HoverEvent.showText(Component.text("§e点击添加增益: " + eff[0] + " Lv1 300秒")))
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsaddadd " + landName + " " + eff[0] + " 1 300"));
|
||||||
|
}
|
||||||
|
p.sendMessage(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.sendMessage(Component.text(""));
|
||||||
|
p.sendMessage(Component.text("§a[◀ 返回增益效果列表]")
|
||||||
|
.clickEvent(ClickEvent.runCommand("/protect cli effectsmgmt " + landName + " 3")));
|
||||||
p.sendMessage(Component.text("§7§l───────────────────────────────"));
|
p.sendMessage(Component.text("§7§l───────────────────────────────"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ public class AreaGUIManager implements Listener {
|
|||||||
{"所有效果", "denyAllEffects"}, {"禁止展示框", "denyItemFrame"}, {"红石电路", "denyRedstoneInteraction"},
|
{"所有效果", "denyAllEffects"}, {"禁止展示框", "denyItemFrame"}, {"红石电路", "denyRedstoneInteraction"},
|
||||||
{"禁止门禁", "denyDoorInteraction"}, {"音频", "denyNoteblockJukebox"}, {"拴绳使用", "denyLead"},
|
{"禁止门禁", "denyDoorInteraction"}, {"音频", "denyNoteblockJukebox"}, {"拴绳使用", "denyLead"},
|
||||||
{"农作物收获", "denyCropHarvest"}, {"剪切羊毛", "denyWoolShear"}, {"投喂动物", "denyAnimalFeeding"},
|
{"农作物收获", "denyCropHarvest"}, {"剪切羊毛", "denyWoolShear"}, {"投喂动物", "denyAnimalFeeding"},
|
||||||
{"玩家发光", "denyGlowing"}, {"禁止和平模式", "peaceMode"}
|
{"玩家发光", "denyGlowing"}, {"和平模式", "peaceMode"}
|
||||||
};
|
};
|
||||||
|
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
@@ -574,7 +574,7 @@ public class AreaGUIManager implements Listener {
|
|||||||
perms.add(new PermEntry("剪切羊毛/生物", !land.denyWoolShear));
|
perms.add(new PermEntry("剪切羊毛/生物", !land.denyWoolShear));
|
||||||
perms.add(new PermEntry("投喂动物", !land.denyAnimalFeeding));
|
perms.add(new PermEntry("投喂动物", !land.denyAnimalFeeding));
|
||||||
perms.add(new PermEntry("玩家发光", !land.denyGlowing));
|
perms.add(new PermEntry("玩家发光", !land.denyGlowing));
|
||||||
perms.add(new PermEntry("禁止和平模式", !land.peaceMode));
|
perms.add(new PermEntry("和平模式", land.peaceMode));
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +624,7 @@ public class AreaGUIManager implements Listener {
|
|||||||
case "剪切羊毛/生物": land.denyWoolShear = !land.denyWoolShear; break;
|
case "剪切羊毛/生物": land.denyWoolShear = !land.denyWoolShear; break;
|
||||||
case "投喂动物": land.denyAnimalFeeding = !land.denyAnimalFeeding; break;
|
case "投喂动物": land.denyAnimalFeeding = !land.denyAnimalFeeding; break;
|
||||||
case "玩家发光": land.denyGlowing = !land.denyGlowing; break;
|
case "玩家发光": land.denyGlowing = !land.denyGlowing; break;
|
||||||
case "禁止和平模式": land.peaceMode = !land.peaceMode; break;
|
case "和平模式": land.peaceMode = !land.peaceMode; break;
|
||||||
}
|
}
|
||||||
areaProtect.saveAreaToDb(land);
|
areaProtect.saveAreaToDb(land);
|
||||||
}
|
}
|
||||||
@@ -887,7 +887,7 @@ public class AreaGUIManager implements Listener {
|
|||||||
{"所有效果", "denyAllEffects"}, {"禁止展示框", "denyItemFrame"}, {"红石电路", "denyRedstoneInteraction"},
|
{"所有效果", "denyAllEffects"}, {"禁止展示框", "denyItemFrame"}, {"红石电路", "denyRedstoneInteraction"},
|
||||||
{"禁止门禁", "denyDoorInteraction"}, {"音频", "denyNoteblockJukebox"}, {"拴绳使用", "denyLead"},
|
{"禁止门禁", "denyDoorInteraction"}, {"音频", "denyNoteblockJukebox"}, {"拴绳使用", "denyLead"},
|
||||||
{"农作物收获", "denyCropHarvest"}, {"剪切羊毛", "denyWoolShear"}, {"投喂动物", "denyAnimalFeeding"},
|
{"农作物收获", "denyCropHarvest"}, {"剪切羊毛", "denyWoolShear"}, {"投喂动物", "denyAnimalFeeding"},
|
||||||
{"玩家发光", "denyGlowing"}, {"禁止和平模式", "peaceMode"}
|
{"玩家发光", "denyGlowing"}, {"和平模式", "peaceMode"}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (raw < permDefs.length) {
|
if (raw < permDefs.length) {
|
||||||
@@ -1352,8 +1352,9 @@ public class AreaGUIManager implements Listener {
|
|||||||
else if (subPage == 2) {
|
else if (subPage == 2) {
|
||||||
if (raw < land.clearEffects.size()) {
|
if (raw < land.clearEffects.size()) {
|
||||||
// 移除单清效果
|
// 移除单清效果
|
||||||
land.clearEffects.remove(raw);
|
String removed = land.clearEffects.remove(raw);
|
||||||
areaProtect.saveAreaToDb(land);
|
areaProtect.saveAreaToDb(land);
|
||||||
|
p.sendMessage("§a§l[效果管理] §f已移除清除效果: §e" + removed);
|
||||||
openEffectsManagement(p, landName, 2);
|
openEffectsManagement(p, landName, 2);
|
||||||
} else if (raw == 48) {
|
} else if (raw == 48) {
|
||||||
openEffectsManagement(p, landName, 1);
|
openEffectsManagement(p, landName, 1);
|
||||||
@@ -1368,8 +1369,10 @@ public class AreaGUIManager implements Listener {
|
|||||||
else if (subPage == 3) {
|
else if (subPage == 3) {
|
||||||
if (raw < land.giveEffects.size()) {
|
if (raw < land.giveEffects.size()) {
|
||||||
// 移除增益效果
|
// 移除增益效果
|
||||||
land.giveEffects.remove(raw);
|
String[] removed = land.giveEffects.remove(raw);
|
||||||
|
String desc = removed[0] + (removed.length > 1 ? " Lv" + removed[1] : "") + (removed.length > 2 ? " " + removed[2] + "秒" : "");
|
||||||
areaProtect.saveAreaToDb(land);
|
areaProtect.saveAreaToDb(land);
|
||||||
|
p.sendMessage("§a§l[效果管理] §f已移除增益效果: §a" + desc);
|
||||||
openEffectsManagement(p, landName, 3);
|
openEffectsManagement(p, landName, 3);
|
||||||
} else if (raw == 48) {
|
} else if (raw == 48) {
|
||||||
openEffectsManagement(p, landName, 1);
|
openEffectsManagement(p, landName, 1);
|
||||||
|
|||||||
@@ -1937,21 +1937,13 @@ public class AreaProtection implements Listener {
|
|||||||
|
|
||||||
public void banHostilesWithWhitelist(Player p, AreaConfig ac) {
|
public void banHostilesWithWhitelist(Player p, AreaConfig ac) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
// 看看附近到底有什么实体
|
|
||||||
List<Entity> nearby = p.getNearbyEntities(48, 48, 48);
|
List<Entity> nearby = p.getNearbyEntities(48, 48, 48);
|
||||||
/* plugin.getLogger().info("[和平] " + p.getName()
|
|
||||||
+ " 附近实体总数=" + nearby.size());*/
|
|
||||||
for (Entity ent : nearby) {
|
|
||||||
String typeName = ent.getType().name();
|
|
||||||
/* plugin.getLogger().info("[和平] 实体: "
|
|
||||||
+ typeName + " isHostile=" + isHostile(typeName));*/
|
|
||||||
}
|
|
||||||
int scanned = 0;
|
int scanned = 0;
|
||||||
int waiting = 0;
|
int waiting = 0;
|
||||||
int saved = 0;
|
int saved = 0;
|
||||||
int banished = 0;
|
int banished = 0;
|
||||||
|
|
||||||
for (Entity ent : p.getNearbyEntities(48, 48, 48)) {
|
for (Entity ent : nearby) {
|
||||||
if (!isHostile(ent.getType().name())) continue;
|
if (!isHostile(ent.getType().name())) continue;
|
||||||
scanned++;
|
scanned++;
|
||||||
|
|
||||||
@@ -1959,101 +1951,100 @@ public class AreaProtection implements Listener {
|
|||||||
Long protectUntil = protectedEntities.get(entUid);
|
Long protectUntil = protectedEntities.get(entUid);
|
||||||
String customName = ent.getCustomName();
|
String customName = ent.getCustomName();
|
||||||
|
|
||||||
|
// 白名单命名生物:永久保留
|
||||||
|
if (customName != null && !customName.isEmpty() && ac.peaceWhitelist.contains(customName)) {
|
||||||
|
if (protectUntil != null) protectedEntities.remove(entUid);
|
||||||
|
saved++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 有保护期记录
|
// 有保护期记录
|
||||||
if (protectUntil != null) {
|
if (protectUntil != null) {
|
||||||
long remain = protectUntil - now;
|
long remain = protectUntil - now;
|
||||||
|
|
||||||
if (remain > 0) {
|
if (remain > 0) {
|
||||||
// 保护期内,精确剩余秒数
|
|
||||||
int secondsLeft = (int) Math.ceil(remain / 1000.0);
|
|
||||||
waiting++;
|
waiting++;
|
||||||
|
continue;
|
||||||
// 保护期内也检查名字(玩家可能刚贴上)
|
}
|
||||||
if (customName != null
|
// 保护期到期 → 移除记录并检查白名单
|
||||||
&& !customName.isEmpty()
|
|
||||||
&& ac.peaceWhitelist.contains(customName)) {
|
|
||||||
protectedEntities.remove(entUid);
|
protectedEntities.remove(entUid);
|
||||||
|
if (customName != null && !customName.isEmpty() && ac.peaceWhitelist.contains(customName)) {
|
||||||
saved++;
|
saved++;
|
||||||
/* plugin.getLogger().info("[和平] "
|
continue;
|
||||||
+ ent.getType().name()
|
}
|
||||||
+ " 命名[" + customName
|
banEntity(ent);
|
||||||
+ "] 白名单匹配,永久保留");*/
|
banished++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* plugin.getLogger().info("[和平] "
|
// 无保护期记录 → 未命名敌对生物,立即清理
|
||||||
+ ent.getType().name()
|
banEntity(ent);
|
||||||
+ " 保护期剩余约" + secondsLeft + "秒");*/
|
banished++;
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保护期到了,最终检查
|
/**
|
||||||
protectedEntities.remove(entUid);
|
* 全图扫描清理和平模式下的未命名敌对生物
|
||||||
/* plugin.getLogger().info("[和平] "
|
* 由 Main 中的定时任务调用
|
||||||
+ ent.getType().name() + " 5秒到期");*/
|
*/
|
||||||
|
public void scanAllLandsPeaceMode() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
int cleared = 0;
|
||||||
|
|
||||||
// 到期时再查一次白名单
|
// 遍历所有已加载的区域
|
||||||
if (customName != null
|
for (Map.Entry<String, AreaConfig> entry : areas.entrySet()) {
|
||||||
&& !customName.isEmpty()
|
AreaConfig ac = entry.getValue();
|
||||||
&& ac.peaceWhitelist.contains(customName)) {
|
if (!ac.peaceMode) continue;
|
||||||
saved++;
|
|
||||||
/* plugin.getLogger().info("[和平] "
|
// 对该区域边界内的实体扫描
|
||||||
+ ent.getType().name()
|
// 简化:扫描该区域周围一定范围的实体
|
||||||
+ " 命名[" + customName
|
double centerX = (ac.x1 + ac.x2) / 2.0;
|
||||||
+ "] 到期但白名单匹配,保留");*/
|
double centerZ = (ac.z1 + ac.z2) / 2.0;
|
||||||
continue;
|
World world = Bukkit.getWorld(ac.world);
|
||||||
|
if (world == null) continue;
|
||||||
|
|
||||||
|
// 扫描区域中心 ±50 格的实体
|
||||||
|
List<Entity> nearby = new java.util.ArrayList<>(world.getNearbyEntities(
|
||||||
|
new Location(world, centerX, world.getMaxHeight() / 2, centerZ), 50, 50, 50));
|
||||||
|
|
||||||
|
for (Entity ent : nearby) {
|
||||||
|
if (!isHostile(ent.getType().name())) continue;
|
||||||
|
|
||||||
|
// 检查是否在领地范围内
|
||||||
|
AreaConfig landAc = getArea(world.getName(),
|
||||||
|
ent.getLocation().getBlockX(),
|
||||||
|
ent.getLocation().getBlockY(),
|
||||||
|
ent.getLocation().getBlockZ());
|
||||||
|
if (landAc == null || !landAc.peaceMode) continue;
|
||||||
|
|
||||||
|
// 白名单命名生物:跳过
|
||||||
|
String cname = ent.getCustomName();
|
||||||
|
if (cname != null && !cname.isEmpty() && landAc.peaceWhitelist.contains(cname)) continue;
|
||||||
|
|
||||||
|
// 保护期内:跳过
|
||||||
|
UUID uid = ent.getUniqueId();
|
||||||
|
Long protectUntil = protectedEntities.get(uid);
|
||||||
|
if (protectUntil != null && (protectUntil - now) > 0) continue;
|
||||||
|
|
||||||
|
// 清理
|
||||||
|
banEntity(ent);
|
||||||
|
cleared++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没名字或不在白名单,传送虚空
|
if (cleared > 0) {
|
||||||
|
plugin.getLogger().info("[和平模式扫描] 清理未命名敌对生物: " + cleared + " 个");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void banEntity(Entity ent) {
|
||||||
Location voidLoc = ent.getLocation().clone();
|
Location voidLoc = ent.getLocation().clone();
|
||||||
voidLoc.setY(ent.getWorld().getMinHeight() - 50);
|
voidLoc.setY(ent.getWorld().getMinHeight() - 50);
|
||||||
// 末影人受伤害会自动传送回来,所以直接移除实体
|
|
||||||
if ("ENDERMAN".equals(ent.getType().name())) {
|
if ("ENDERMAN".equals(ent.getType().name())) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
} else {
|
} else {
|
||||||
ent.teleport(voidLoc);
|
ent.teleport(voidLoc);
|
||||||
}
|
}
|
||||||
banished++;
|
protectedEntities.remove(ent.getUniqueId());
|
||||||
/* plugin.getLogger().info("[和平] "
|
|
||||||
+ ent.getType().name()
|
|
||||||
+ " 命名=[" + customName + "] 传送虚空");*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 没有保护期记录(非刷怪蛋生成的或记录被清了)
|
|
||||||
// 也检查一下白名单
|
|
||||||
if (customName != null
|
|
||||||
&& !customName.isEmpty()
|
|
||||||
&& ac.peaceWhitelist.contains(customName)) {
|
|
||||||
saved++;
|
|
||||||
/* plugin.getLogger().info("[和平] "
|
|
||||||
+ ent.getType().name()
|
|
||||||
+ " 命名[" + customName
|
|
||||||
+ "] 无保护期但白名单匹配,保留");*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 没有保护期且不在白名单,传送虚空
|
|
||||||
Location voidLoc = ent.getLocation().clone();
|
|
||||||
voidLoc.setY(ent.getWorld().getMinHeight() - 50);
|
|
||||||
// 末影人受伤害会自动传送回来,直接移除
|
|
||||||
if ("ENDERMAN".equals(ent.getType().name())) {
|
|
||||||
ent.remove();
|
|
||||||
} else {
|
|
||||||
ent.teleport(voidLoc);
|
|
||||||
}
|
|
||||||
banished++;
|
|
||||||
/* plugin.getLogger().info("[和平] "
|
|
||||||
+ ent.getType().name()
|
|
||||||
+ " 无保护期,命名=[" + customName + "] 传送虚空");*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* plugin.getLogger().info("[和平] "
|
|
||||||
+ " 扫描=" + scanned
|
|
||||||
+ " 等待=" + waiting
|
|
||||||
+ " 保留=" + saved
|
|
||||||
+ " 传送=" + banished
|
|
||||||
+ " 白名单=" + ac.peaceWhitelist);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<String> HOSTILE_TYPES = new HashSet<>(Arrays.asList(
|
private static final Set<String> HOSTILE_TYPES = new HashSet<>(Arrays.asList(
|
||||||
@@ -6760,23 +6751,14 @@ public class AreaProtection implements Listener {
|
|||||||
if (dbConnection == null) return result;
|
if (dbConnection == null) return result;
|
||||||
try {
|
try {
|
||||||
Statement stmt = dbConnection.createStatement();
|
Statement stmt = dbConnection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT id, name, owner, world, x1, z1, x2, z2, y_min, y_max, created_at FROM area_lands");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM area_lands");
|
||||||
|
int cols = rs.getMetaData().getColumnCount();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("id", rs.getInt("id"));
|
for (int i = 1; i <= cols; i++) {
|
||||||
map.put("name", rs.getString("name"));
|
String colName = rs.getMetaData().getColumnName(i);
|
||||||
map.put("owner", rs.getString("owner"));
|
map.put(colName, rs.getObject(colName));
|
||||||
map.put("world", rs.getString("world"));
|
}
|
||||||
map.put("x1", rs.getInt("x1"));
|
|
||||||
map.put("z1", rs.getInt("z1"));
|
|
||||||
map.put("x2", rs.getInt("x2"));
|
|
||||||
map.put("z2", rs.getInt("z2"));
|
|
||||||
map.put("y_min", rs.getInt("y_min"));
|
|
||||||
map.put("y_max", rs.getInt("y_max"));
|
|
||||||
int x1 = rs.getInt("x1"), x2 = rs.getInt("x2");
|
|
||||||
int z1 = rs.getInt("z1"), z2 = rs.getInt("z2");
|
|
||||||
map.put("area_size", Math.abs((x2 - x1 + 1) * (z2 - z1 + 1)));
|
|
||||||
map.put("created_at", rs.getLong("created_at"));
|
|
||||||
result.add(map);
|
result.add(map);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
@@ -7138,12 +7120,21 @@ public class AreaProtection implements Listener {
|
|||||||
p.sendMessage("§c§l[添加清除效果] §f效果名不能为空");
|
p.sendMessage("§c§l[添加清除效果] §f效果名不能为空");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// ★ 验证效果名是否有效
|
||||||
|
PotionEffectType resolved = resolveEffectType(effName);
|
||||||
|
if (resolved == null) {
|
||||||
|
p.sendMessage("§c§l[添加清除效果] §f无效的效果名: §e" + effName);
|
||||||
|
p.sendMessage("§7支持的中文名: 缓慢、挖掘疲劳、瞬间伤害、反胃、失明、饥饿、虚弱、中毒、凋零、飘浮、霉运、黑暗、蓄风、盘丝、渗浆、寄生");
|
||||||
|
p.sendMessage("§7中性: 不祥之兆、袭击之兆、试炼之兆");
|
||||||
|
p.sendMessage("§7正面: 迅捷、急迫、力量、瞬间治疗、跳跃提升、生命恢复、抗性提升、抗火、水下呼吸、隐身、夜视、发光、生命提升、伤害吸收、饱和、幸运、村庄英雄、缓降、潮涌能量、海豚的恩惠");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!land.clearEffects.contains(effName)) {
|
if (!land.clearEffects.contains(effName)) {
|
||||||
land.clearEffects.add(effName);
|
land.clearEffects.add(effName);
|
||||||
saveAreaToDb(land);
|
saveAreaToDb(land);
|
||||||
p.sendMessage("§a§l[添加清除效果] §f已添加: " + effName);
|
p.sendMessage("§a§l[添加清除效果] §f已添加: §e" + effName);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage("§e§l[添加清除效果] §f效果 " + effName + " 已在列表中");
|
p.sendMessage("§e§l[添加清除效果] §f效果 §e" + effName + " §f已在列表中");
|
||||||
}
|
}
|
||||||
} else if ("give".equals(inputType)) {
|
} else if ("give".equals(inputType)) {
|
||||||
// 添加增益效果: 格式 效果名 [等级] [秒数]
|
// 添加增益效果: 格式 效果名 [等级] [秒数]
|
||||||
@@ -7159,13 +7150,36 @@ public class AreaProtection implements Listener {
|
|||||||
if (parts.length >= 2) effLv = Integer.parseInt(parts[1]);
|
if (parts.length >= 2) effLv = Integer.parseInt(parts[1]);
|
||||||
if (parts.length >= 3) effDur = Integer.parseInt(parts[2]);
|
if (parts.length >= 3) effDur = Integer.parseInt(parts[2]);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
p.sendMessage("§c等级和秒数必须是数字");
|
p.sendMessage("§c§l[添加增益效果] §f等级和秒数必须是数字");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// ★ 验证等级和秒数范围
|
||||||
|
if (effLv < 1 || effLv > 255) {
|
||||||
|
p.sendMessage("§c§l[添加增益效果] §f等级范围: 1~255");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (effDur < 1 || effDur > 3600) {
|
||||||
|
p.sendMessage("§c§l[添加增益效果] §f持续时间范围: 1~3600秒");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ★ 验证效果名是否有效
|
||||||
|
PotionEffectType resolved = resolveEffectType(effName);
|
||||||
|
if (resolved == null) {
|
||||||
|
p.sendMessage("§c§l[添加增益效果] §f无效的效果名: §e" + effName);
|
||||||
|
p.sendMessage("§7推荐增益: 迅捷、急迫、力量、瞬间治疗、跳跃提升、生命恢复、抗性提升、抗火、水下呼吸、隐身、夜视、发光、生命提升、伤害吸收、饱和、幸运、村庄英雄、缓降、潮涌能量、海豚的恩惠");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ★ 检查是否已存在同名增益
|
||||||
|
for (String[] existing : land.giveEffects) {
|
||||||
|
if (existing[0].equals(effName)) {
|
||||||
|
p.sendMessage("§e§l[添加增益效果] §f增益 §e" + effName + " §f已存在,先移除旧的再添加");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
String[] effRecord = {effName, String.valueOf(effLv), String.valueOf(effDur)};
|
String[] effRecord = {effName, String.valueOf(effLv), String.valueOf(effDur)};
|
||||||
land.giveEffects.add(effRecord);
|
land.giveEffects.add(effRecord);
|
||||||
saveAreaToDb(land);
|
saveAreaToDb(land);
|
||||||
p.sendMessage("§a§l[添加增益效果] §f已添加: " + effName + " Lv" + effLv + " " + effDur + "秒");
|
p.sendMessage("§a§l[添加增益效果] §f已添加: §a" + effName + " §fLv" + effLv + " " + effDur + "秒");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新GUI,回到原来的subPage
|
// 刷新GUI,回到原来的subPage
|
||||||
|
|||||||
@@ -530,23 +530,7 @@ public class Main extends JavaPlugin
|
|||||||
// 和平模式独立检测
|
// 和平模式独立检测
|
||||||
getServer().getScheduler().runTaskTimer(this, () -> {
|
getServer().getScheduler().runTaskTimer(this, () -> {
|
||||||
if (areaProtection == null) return;
|
if (areaProtection == null) return;
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
areaProtection.scanAllLandsPeaceMode();
|
||||||
AreaProtection.AreaConfig ac = areaProtection.getArea(
|
|
||||||
p.getWorld().getName(),
|
|
||||||
p.getLocation().getBlockX(),
|
|
||||||
p.getLocation().getBlockY(),
|
|
||||||
p.getLocation().getBlockZ());
|
|
||||||
if (ac != null) {
|
|
||||||
// 无条件打印,不管 peaceMode 是啥
|
|
||||||
/* getLogger().info("[和平定时器] " + p.getName()
|
|
||||||
+ " 在[" + ac.name
|
|
||||||
+ "] peaceMode=" + ac.peaceMode
|
|
||||||
+ " 白名单=" + ac.peaceWhitelist);*/
|
|
||||||
if (ac.peaceMode) {
|
|
||||||
areaProtection.banHostilesWithWhitelist(p, ac);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 40L, 40L);
|
}, 40L, 40L);
|
||||||
areaProtection.startEnforceTask();
|
areaProtection.startEnforceTask();
|
||||||
if (areaProtection != null) {
|
if (areaProtection != null) {
|
||||||
|
|||||||
@@ -227,6 +227,20 @@ public class WebManager {
|
|||||||
submitDbTask(NORMAL_PRIORITY, name, action);
|
submitDbTask(NORMAL_PRIORITY, name, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交普通优先级数据库写入任务(支持绕过SSL断路器)
|
||||||
|
*/
|
||||||
|
private void submitNormalDbTask(String name, Runnable action, boolean bypassSslCheck) {
|
||||||
|
submitDbTask(NORMAL_PRIORITY, name, action, bypassSslCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交登录优先级数据库写入任务(支持绕过SSL断路器)
|
||||||
|
*/
|
||||||
|
private void submitDbTask(String name, Runnable action, boolean bypassSslCheck) {
|
||||||
|
submitDbTask(LOGIN_PRIORITY, name, action, bypassSslCheck);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交商店相关数据库写入任务(第二优先级)
|
* 提交商店相关数据库写入任务(第二优先级)
|
||||||
*/
|
*/
|
||||||
@@ -239,8 +253,15 @@ public class WebManager {
|
|||||||
* ★ 限制同种类任务最多3个(防止队列积压)
|
* ★ 限制同种类任务最多3个(防止队列积压)
|
||||||
*/
|
*/
|
||||||
private void submitDbTask(int priority, String name, Runnable action) {
|
private void submitDbTask(int priority, String name, Runnable action) {
|
||||||
// ★ SSL断路器:断路期间跳过所有HTTP相关任务
|
submitDbTask(priority, name, action, false);
|
||||||
if (isCircuitOpen()) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交任务(支持bypassSslCheck:关键任务如syncOnlinePlayers不应被SSL断路器阻断)
|
||||||
|
*/
|
||||||
|
private void submitDbTask(int priority, String name, Runnable action, boolean bypassSslCheck) {
|
||||||
|
// ★ SSL断路器:断路期间跳过所有HTTP相关任务(除非指定绕过)
|
||||||
|
if (!bypassSslCheck && isCircuitOpen()) {
|
||||||
plugin.getLogger().warning("[DB队列] SSL断路器开启,跳过任务: " + name);
|
plugin.getLogger().warning("[DB队列] SSL断路器开启,跳过任务: " + name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -259,8 +280,8 @@ public class WebManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ★ 同类型任务最多3个,超过则丢弃低优先级的
|
// ★ 同类型任务最多3个,超过则丢弃低优先级的(关键任务不丢弃)
|
||||||
if (sameTypeCount >= 3) {
|
if (sameTypeCount >= 3 && !bypassSslCheck) {
|
||||||
plugin.getLogger().warning("[DB队列] 同类型任务已满(3): " + taskType + ",丢弃: " + name);
|
plugin.getLogger().warning("[DB队列] 同类型任务已满(3): " + taskType + ",丢弃: " + name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -853,7 +874,7 @@ public class WebManager {
|
|||||||
submitDbTask("首次-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
submitDbTask("首次-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
// 普通同步操作低优先级(每个任务间随机间隔2-4秒,避免PHP端DB锁)
|
// 普通同步操作低优先级(每个任务间随机间隔2-4秒,避免PHP端DB锁)
|
||||||
submitNormalDbTask("首次-syncOnlinePlayers", () -> syncOnlinePlayers());
|
submitNormalDbTask("首次-syncOnlinePlayers", () -> syncOnlinePlayers(), true);
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
submitNormalDbTask("首次-syncShopData", () -> syncShopData());
|
submitNormalDbTask("首次-syncShopData", () -> syncShopData());
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
@@ -1218,7 +1239,7 @@ public class WebManager {
|
|||||||
|
|
||||||
if (hasRequest) {
|
if (hasRequest) {
|
||||||
plugin.getLogger().info("[合并C] 收到即时同步请求: " + players);
|
plugin.getLogger().info("[合并C] 收到即时同步请求: " + players);
|
||||||
submitDbTask("即时-syncOnlinePlayers", () -> syncOnlinePlayers());
|
submitDbTask("即时-syncOnlinePlayers", () -> syncOnlinePlayers(), true);
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
submitDbTask("即时-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
submitDbTask("即时-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
@@ -1249,7 +1270,7 @@ public class WebManager {
|
|||||||
syncAfterAllOffline = false;
|
syncAfterAllOffline = false;
|
||||||
lastSyncDone = true;
|
lastSyncDone = true;
|
||||||
lastOnlineCheckTime = System.currentTimeMillis();
|
lastOnlineCheckTime = System.currentTimeMillis();
|
||||||
submitDbTask("末轮-syncOnlinePlayers", () -> syncOnlinePlayers());
|
submitDbTask("末轮-syncOnlinePlayers", () -> syncOnlinePlayers(), true);
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
submitDbTask("末轮-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
submitDbTask("末轮-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
@@ -1276,7 +1297,7 @@ public class WebManager {
|
|||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
submitDbTask("周期-syncUserRegistrations", () -> syncUserRegistrations());
|
submitDbTask("周期-syncUserRegistrations", () -> syncUserRegistrations());
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
submitDbTask("周期-syncOnlinePlayers", () -> syncOnlinePlayers());
|
submitDbTask("周期-syncOnlinePlayers", () -> syncOnlinePlayers(), true);
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
submitDbTask("周期-syncBondTransactions", () -> syncBondTransactions());
|
submitDbTask("周期-syncBondTransactions", () -> syncBondTransactions());
|
||||||
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
try { Thread.sleep(6000 + (long)(Math.random() * 8000)); } catch (InterruptedException ignored) {}
|
||||||
@@ -2608,31 +2629,18 @@ public class WebManager {
|
|||||||
if (currentHash.equals(lastLandDataHash)) return;
|
if (currentHash.equals(lastLandDataHash)) return;
|
||||||
lastLandDataHash = currentHash;
|
lastLandDataHash = currentHash;
|
||||||
|
|
||||||
// 1. 同步领地列表
|
// 1. 同步领地列表(全字段)
|
||||||
if (!lands.isEmpty()) {
|
if (!lands.isEmpty()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder("[");
|
||||||
for (int i = 0; i < lands.size(); i++) {
|
for (int i = 0; i < lands.size(); i++) {
|
||||||
if (i > 0) sb.append(",");
|
if (i > 0) sb.append(",");
|
||||||
Map<String, Object> l = lands.get(i);
|
sb.append(mapToJson(lands.get(i)));
|
||||||
sb.append("{");
|
|
||||||
sb.append("\"id\":").append(l.getOrDefault("id", 0)).append(",");
|
|
||||||
sb.append("\"name\":\"").append(escapeJson(String.valueOf(l.getOrDefault("name", "")))).append("\",");
|
|
||||||
sb.append("\"owner\":\"").append(escapeJson(String.valueOf(l.getOrDefault("owner", "")))).append("\",");
|
|
||||||
sb.append("\"world\":\"").append(escapeJson(String.valueOf(l.getOrDefault("world", "")))).append("\",");
|
|
||||||
sb.append("\"x1\":").append(l.getOrDefault("x1", 0)).append(",");
|
|
||||||
sb.append("\"z1\":").append(l.getOrDefault("z1", 0)).append(",");
|
|
||||||
sb.append("\"x2\":").append(l.getOrDefault("x2", 0)).append(",");
|
|
||||||
sb.append("\"z2\":").append(l.getOrDefault("z2", 0)).append(",");
|
|
||||||
sb.append("\"y_min\":").append(l.getOrDefault("y_min", 0)).append(",");
|
|
||||||
sb.append("\"y_max\":").append(l.getOrDefault("y_max", 255)).append(",");
|
|
||||||
sb.append("\"area_size\":").append(l.getOrDefault("area_size", 0)).append(",");
|
|
||||||
sb.append("\"created_at\":").append(l.getOrDefault("created_at", 0));
|
|
||||||
sb.append("}");
|
|
||||||
}
|
}
|
||||||
|
sb.append("]");
|
||||||
Map<String, String> params = new LinkedHashMap<>();
|
Map<String, String> params = new LinkedHashMap<>();
|
||||||
params.put("action", "sync_lands");
|
params.put("action", "sync_lands");
|
||||||
params.put("secret", secretKey);
|
params.put("secret", secretKey);
|
||||||
params.put("lands", "[" + sb.toString() + "]");
|
params.put("lands", sb.toString());
|
||||||
httpGet("api/sync.php", params);
|
httpGet("api/sync.php", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3939,7 +3947,6 @@ public class WebManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (players.isEmpty()) {
|
if (players.isEmpty()) {
|
||||||
plugin.getLogger().info("[Web登录确认轮询] ○ 无待处理的登录确认");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4060,7 +4067,6 @@ public class WebManager {
|
|||||||
|
|
||||||
// ★ 逐个提取 {...} 对象,用 parseJson 解析,避免手动截取密码出错
|
// ★ 逐个提取 {...} 对象,用 parseJson 解析,避免手动截取密码出错
|
||||||
if (arrStr.trim().equals("[]")) {
|
if (arrStr.trim().equals("[]")) {
|
||||||
plugin.getLogger().info("[Web密码验证轮询] ○ 无待处理的密码验证请求");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getLogger().info("[Web密码验证轮询] ★ 发现待处理请求,数组长度=" + arrStr.length());
|
plugin.getLogger().info("[Web密码验证轮询] ★ 发现待处理请求,数组长度=" + arrStr.length());
|
||||||
@@ -4912,7 +4918,7 @@ public class WebManager {
|
|||||||
// 有人在线才响应通知
|
// 有人在线才响应通知
|
||||||
if (!Bukkit.getOnlinePlayers().isEmpty()) {
|
if (!Bukkit.getOnlinePlayers().isEmpty()) {
|
||||||
// ★ 通过DB队列串行化执行同步
|
// ★ 通过DB队列串行化执行同步
|
||||||
submitDbTask("通知-syncOnlinePlayers", () -> syncOnlinePlayers());
|
submitDbTask("通知-syncOnlinePlayers", () -> syncOnlinePlayers(), true);
|
||||||
submitDbTask("通知-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
submitDbTask("通知-pushWebLoginCredentials", () -> pushWebLoginCredentials());
|
||||||
submitDbTask("通知-syncUserRegistrations", () -> syncUserRegistrations());
|
submitDbTask("通知-syncUserRegistrations", () -> syncUserRegistrations());
|
||||||
submitDbTask("通知-syncServiceProviders", () -> syncServiceProviders());
|
submitDbTask("通知-syncServiceProviders", () -> syncServiceProviders());
|
||||||
|
|||||||
Reference in New Issue
Block a user