diff --git a/src/main/java/me/Demon/BlockWars/Game/GameData.java b/src/main/java/me/Demon/BlockWars/Game/GameData.java index 849ee8d..5f5bb34 100644 --- a/src/main/java/me/Demon/BlockWars/Game/GameData.java +++ b/src/main/java/me/Demon/BlockWars/Game/GameData.java @@ -7,6 +7,7 @@ import me.Demon.BlockWars.Manager.MinerOperate; import me.Demon.BlockWars.Util.BossBarUtil; import me.Demon.BlockWars.Util.ComputeBlock; import me.Demon.BlockWars.Util.GameUtil; +import me.Demon.BlockWars.api.BlockWarsAPI; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.boss.BarColor; @@ -73,10 +74,10 @@ public class GameData { int a = this.totalBlockAmount; int b = this.completeBlockGoal; double percent = (double) a / (double) b; - System.out.println("[调试 - 进度] 填充进度: "+a+" b = "+b); + // System.out.println("[调试 - 进度] 填充进度: "+a+" b = "+b); String percentShow = String.format("%.2f", (percent * 100)); bossBar2.setTitle("§6填充进度: §f"+a+"/"+b+" §9("+percentShow+"%)"); - System.out.println("[调试 - 进度] 填充进度: "+percent); + // System.out.println("[调试 - 进度] 填充进度: "+percent); BossBarUtil.setBarProgress(bossBar2,percent); BossBarUtil.setBarColor(bossBar2,percent); } @@ -116,6 +117,7 @@ public class GameData { GameUtil.loadSchematics("miner_11x11"); // 初始化矿区模板 MinerOperate.initializeMinerSize(); // 初始化矿区大小 updateBossBar(); + refreshBlockRgionList(16); // 拆分矿区 } /* * 初始化主播游戏参数: 生命值、物品栏、BossBar、当前位置 diff --git a/src/main/java/me/Demon/BlockWars/Listener/GameListener.java b/src/main/java/me/Demon/BlockWars/Listener/GameListener.java index 57746a3..97b9473 100644 --- a/src/main/java/me/Demon/BlockWars/Listener/GameListener.java +++ b/src/main/java/me/Demon/BlockWars/Listener/GameListener.java @@ -4,6 +4,7 @@ import cn.hamster3.cdapi.CDTimeAPI; import me.Demon.BlockWars.Game.Region; import me.Demon.BlockWars.Main; import me.Demon.BlockWars.Util.GameUtil; +import me.Demon.BlockWars.api.BlockWarsAPI; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; @@ -165,6 +166,7 @@ public class GameListener implements Listener { } return; } + long startTime = System.currentTimeMillis(); // 记录开始时间 Location location = block.getLocation(); int indexY = location.getBlockY(); for (int y = (int) region.getMin().getY(); y < indexY; y++) { @@ -195,6 +197,9 @@ public class GameListener implements Listener { a++; } GameUtil.refreshPlayerHandStack(p); + long endTime = System.currentTimeMillis(); // 记录结束时间 + long duration = endTime - startTime; // 计算耗时 + System.out.println("[调试 - 快速] 本次搭建总计耗时 " + duration + " ms"); }else{ if(sounds_butt) { p.playSound(p.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_PLACE, 1.0F, 1.0F); diff --git a/src/main/java/me/Demon/BlockWars/Main.java b/src/main/java/me/Demon/BlockWars/Main.java index 84abcc9..38f0cfa 100644 --- a/src/main/java/me/Demon/BlockWars/Main.java +++ b/src/main/java/me/Demon/BlockWars/Main.java @@ -13,7 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin { - public static boolean Debug = true; + public static boolean Debug = false; public static Main plugin; public static GameData gameData; public static ConfigYml configYml; diff --git a/src/main/java/me/Demon/BlockWars/Util/ComputeBlock.java b/src/main/java/me/Demon/BlockWars/Util/ComputeBlock.java index cc760b5..25e4be3 100644 --- a/src/main/java/me/Demon/BlockWars/Util/ComputeBlock.java +++ b/src/main/java/me/Demon/BlockWars/Util/ComputeBlock.java @@ -19,23 +19,21 @@ import java.util.concurrent.atomic.AtomicInteger; public class ComputeBlock { public static int getCompleteBlockAmount(List blockRegionList){ + System.out.println("[调试 - 统计] 本次统计拆分异步区块 " + blockRegionList.size() + "个"); AtomicInteger totalBlockAmount = new AtomicInteger(0); for (BlockRegion blockRegion : blockRegionList) { CompletableFuture.runAsync(() -> { - long startTime = System.currentTimeMillis(); // 记录开始时间 int minX = blockRegion.getMinX(); int maxX = blockRegion.getMaxX(); CuboidRegion cuboidRegion = getCuboidRegion(minX,maxX); int airCount = countAirBlocks(cuboidRegion); // 计算 AIR 方块数量 totalBlockAmount.addAndGet(airCount); // 线程安全地累加 AIR 方块数量 - if(Main.Debug) { - long endTime = System.currentTimeMillis(); // 记录结束时间 - long duration = endTime - startTime; // 计算耗时 - System.out.println("[调试 - 统计] 本次统计所有方块总计耗时 " + duration + " ms"); - } + System.out.println("Air count for region: " + airCount); // 调试信息 + System.out.println("[调试 - 统计] 编号区块方块数量: "+totalBlockAmount.toString()); }); } - return totalBlockAmount.intValue(); + System.out.println("[调试 - 统计] 总计方块数量: "+totalBlockAmount.toString()); + return Integer.parseInt(totalBlockAmount.toString()); } public static int countAirBlocks(CuboidRegion cuboidRegion) {