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