SteamWar/BauSystem2.0
Archiviert
12
0

Fix SimulatorSaver
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2024-01-30 16:06:53 +01:00
Ursprung 85e6aab9e6
Commit 78c0bc51b9
2 geänderte Dateien mit 35 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -54,7 +54,7 @@ public final class RedstonePhase extends SimulatorPhase {
block.setType(Material.REDSTONE_BLOCK);
}
});
tickEnd.accept(tickOffset + lifetime, new SimulatorAction(0, 1) {
tickStart.accept(tickOffset + lifetime, new SimulatorAction(ORDER_LIMIT + 1, 1) {
@Override
public void accept(World world) {
BlockState state = blockState.get();

Datei anzeigen

@ -26,33 +26,31 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.bausystem.utils.TickEndEvent;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import de.steamwar.bausystem.utils.bossbar.BossBarService;
import de.steamwar.command.AbstractSWCommand;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import de.steamwar.core.Core;
import de.steamwar.core.TPSWarpUtils;
import de.steamwar.core.TPSWatcher;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Plain;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.boss.BarColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
@Linked
public class TPSSystem implements Plain {
public class TPSSystem implements Listener {
@Getter
private double currentTPSLimit = 20;
@ -87,12 +85,9 @@ public class TPSSystem implements Plain {
instance = this;
}
private BukkitTask stepper = null;
private void setTPS(double tps) {
if (stepper != null) {
stepper.cancel();
stepper = null;
if (currentlyStepping) {
currentlyStepping = false;
Bukkit.getOnlinePlayers().forEach(player -> {
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
});
@ -120,27 +115,34 @@ public class TPSSystem implements Plain {
});
}
private void setSkip(int steps, double tpsLimitToUse) {
double currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit;
setTPS(tpsLimitToUse);
stepper = new BukkitRunnable() {
AtomicInteger stepsLeft = new AtomicInteger(steps);
private boolean currentlyStepping = false;
private double currentLimit;
private int stepsTotal;
private int stepsLeft;
@Override
public void run() {
if (steps > 1) {
Bukkit.getOnlinePlayers().forEach(player -> {
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
bossbar.setColor(BarColor.YELLOW);
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (steps - stepsLeft.get()), steps));
bossbar.setProgress((steps - stepsLeft.get()) / (double) steps);
});
}
if (stepsLeft.decrementAndGet() < 0) {
setTPS(currentLimit);
}
}
}.runTaskTimer(BauSystem.getInstance(), 1, 1);
private void setSkip(int steps, double tpsLimitToUse) {
currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit;
setTPS(tpsLimitToUse);
stepsLeft = steps;
stepsTotal = steps;
currentlyStepping = true;
}
@EventHandler
public void onTickEnd(TickEndEvent event) {
if (!currentlyStepping) return;
if (stepsTotal > 1) {
Bukkit.getOnlinePlayers().forEach(player -> {
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
bossbar.setColor(BarColor.YELLOW);
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (stepsTotal - stepsLeft), stepsTotal));
bossbar.setProgress((stepsTotal - stepsLeft) / (double) stepsTotal);
});
}
stepsLeft--;
if (stepsLeft <= 0) {
setTPS(currentLimit);
}
}
public TypeValidator<Player> player() {
@ -341,7 +343,7 @@ public class TPSSystem implements Plain {
@Override
public String get(Region region, Player p) {
if (TPSSystem.getInstance().stepper != null) {
if (TPSSystem.getInstance().currentlyStepping) {
long time = System.currentTimeMillis() % 1000;
if (time < 250) {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";