125续15m: 成书limit 100→85(根治100仍劈法/章节粘连页偏密)+液体放水拦截(PlayerBucketEmptyEvent原空方法体,对齐denyLiquidUse,修玩家随意倒桶放水)
This commit is contained in:
@@ -14285,7 +14285,32 @@ public class AreaProtection implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPaintingPlace(
|
public void onPaintingPlace(
|
||||||
org.bukkit.event.player.PlayerBucketEmptyEvent e) {
|
org.bukkit.event.player.PlayerBucketEmptyEvent e) {
|
||||||
// 暂不处理
|
// ★ 125续15m:放水(倒桶)拦截——对齐 onLiquidUse(舀水)的 denyLiquidUse 权限。
|
||||||
|
// 旧版此方法体为空("暂不处理"),导致「液体使用 已禁用」只拦舀水、放水畅通,
|
||||||
|
// 玩家在领地里随意倒水桶放水(视频 1分43秒实证)。
|
||||||
|
// e.getBlock() 为水桶倒出后液体落入的方块位置(或空桶倒出时的目标方块),
|
||||||
|
// 按该方块定位领地;倒桶放液体(水/岩浆)才拦,倒桶放装饰画/盔甲架不受影响。
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
Block tgt = e.getBlock();
|
||||||
|
if (tgt == null) return;
|
||||||
|
// 仅拦"倒液体桶"(水/岩浆);装饰桶(装饰画)/盔甲桶不拦——按玩家主手桶内容判断
|
||||||
|
ItemStack held = p.getItemInHand();
|
||||||
|
if (held == null) return;
|
||||||
|
Material handMat = held.getType();
|
||||||
|
boolean emptyingLiquid = handMat == Material.BUCKET || handMat == Material.LAVA_BUCKET;
|
||||||
|
// 倒出后手会变成空桶/水→空气,但 e.getBlock() 的落点若是液体来源则必是放水
|
||||||
|
if (!emptyingLiquid) {
|
||||||
|
// 兜底:落点方块是水/岩浆且玩家主手持的是桶(任何桶),也视为放水
|
||||||
|
Material dropMat = tgt.getType();
|
||||||
|
if (!(dropMat == Material.WATER || dropMat == Material.LAVA)) return;
|
||||||
|
}
|
||||||
|
AreaConfig ac = getArea(tgt.getWorld().getName(), tgt.getX(), tgt.getY(), tgt.getZ());
|
||||||
|
if (ac == null) return;
|
||||||
|
if (getEffectiveDeny(p, ac, "denyLiquidUse")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
p.sendMessage("§c§l[区域防护] §f此领地禁止倒水/岩浆(液体使用已禁用)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
// ★ 15l-7k 的「投票规则详见第六章第3节;」分号容差需求,靠 findSemanticCut 的
|
// ★ 15l-7k 的「投票规则详见第六章第3节;」分号容差需求,靠 findSemanticCut 的
|
||||||
// 容差 limit+10=110 仍能满足(分号若落在 100~110 之间仍纳入切点)。
|
// 容差 limit+10=110 仍能满足(分号若落在 100~110 之间仍纳入切点)。
|
||||||
if (!body.isEmpty()) {
|
if (!body.isEmpty()) {
|
||||||
int cut = findSemanticCut(body, 100);
|
int cut = findSemanticCut(body, 85);
|
||||||
pages.add(body.substring(0, cut));
|
pages.add(body.substring(0, cut));
|
||||||
body = body.substring(cut);
|
body = body.substring(cut);
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
|
|
||||||
// 当前页为空:直接开始新段落
|
// 当前页为空:直接开始新段落
|
||||||
if (page.length() == 0) {
|
if (page.length() == 0) {
|
||||||
if (p.length() > 100) {
|
if (p.length() > 85) {
|
||||||
java.util.List<String> sentences = splitSentences(p);
|
java.util.List<String> sentences = splitSentences(p);
|
||||||
for (String s : sentences) {
|
for (String s : sentences) {
|
||||||
if (page.length() + s.length() + 1 > 100 && page.length() > 0) {
|
if (page.length() + s.length() + 1 > 100 && page.length() > 0) {
|
||||||
@@ -423,14 +423,14 @@ public class CustomScreenManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 当前页已有内容:判断段落是否能整段放入
|
// 当前页已有内容:判断段落是否能整段放入
|
||||||
if (page.length() + p.length() + 1 <= 100) {
|
if (page.length() + p.length() + 1 <= 85) {
|
||||||
page.append("\n").append(p);
|
page.append("\n").append(p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整段放不进:在「当前页 + 段落」里找语义边界截断
|
// 整段放不进:在「当前页 + 段落」里找语义边界截断
|
||||||
String candidate = page.toString() + "\n" + p;
|
String candidate = page.toString() + "\n" + p;
|
||||||
int cut = findSemanticCut(candidate, 100);
|
int cut = findSemanticCut(candidate, 85);
|
||||||
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
|
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
|
||||||
String firstHalf = candidate.substring(0, cut);
|
String firstHalf = candidate.substring(0, cut);
|
||||||
String secondHalf = candidate.substring(cut);
|
String secondHalf = candidate.substring(cut);
|
||||||
@@ -441,8 +441,8 @@ public class CustomScreenManager implements Listener {
|
|||||||
page = new StringBuilder(secondHalf);
|
page = new StringBuilder(secondHalf);
|
||||||
|
|
||||||
// 若剩余段仍超页,继续按语义截断或按句拆
|
// 若剩余段仍超页,继续按语义截断或按句拆
|
||||||
while (page.length() > 100) {
|
while (page.length() > 85) {
|
||||||
int nextCut = findSemanticCut(page.toString(), 100);
|
int nextCut = findSemanticCut(page.toString(), 85);
|
||||||
String chunk = page.substring(0, nextCut);
|
String chunk = page.substring(0, nextCut);
|
||||||
String remain = page.substring(nextCut);
|
String remain = page.substring(nextCut);
|
||||||
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
|
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
|
||||||
@@ -463,7 +463,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
if (pages.size() > 2) {
|
if (pages.size() > 2) {
|
||||||
String last = pages.get(pages.size() - 1);
|
String last = pages.get(pages.size() - 1);
|
||||||
String prev = pages.get(pages.size() - 2);
|
String prev = pages.get(pages.size() - 2);
|
||||||
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 100) {
|
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 85) {
|
||||||
pages.set(pages.size() - 2, prev + "\n" + last);
|
pages.set(pages.size() - 2, prev + "\n" + last);
|
||||||
pages.remove(pages.size() - 1);
|
pages.remove(pages.size() - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user