Dieser Commit ist enthalten in:
Ursprung
e77680d25a
Commit
d1afb344d9
@ -54,7 +54,7 @@ public final class RedstonePhase extends SimulatorPhase {
|
|||||||
block.setType(Material.REDSTONE_BLOCK);
|
block.setType(Material.REDSTONE_BLOCK);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tickEnd.accept(tickOffset + lifetime, new SimulatorAction(0, 1) {
|
tickStart.accept(tickOffset + lifetime, new SimulatorAction(ORDER_LIMIT + 1, 1) {
|
||||||
@Override
|
@Override
|
||||||
public void accept(World world) {
|
public void accept(World world) {
|
||||||
BlockState state = blockState.get();
|
BlockState state = blockState.get();
|
||||||
|
@ -26,33 +26,31 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
|||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
import de.steamwar.bausystem.region.GlobalRegion;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
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.BauSystemBossbar;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.command.AbstractSWCommand;
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.TPSWarpUtils;
|
import de.steamwar.core.TPSWarpUtils;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Plain;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TPSSystem implements Plain {
|
public class TPSSystem implements Listener {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private double currentTPSLimit = 20;
|
private double currentTPSLimit = 20;
|
||||||
@ -87,12 +85,9 @@ public class TPSSystem implements Plain {
|
|||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BukkitTask stepper = null;
|
|
||||||
|
|
||||||
private void setTPS(double tps) {
|
private void setTPS(double tps) {
|
||||||
if (stepper != null) {
|
if (currentlyStepping) {
|
||||||
stepper.cancel();
|
currentlyStepping = false;
|
||||||
stepper = null;
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||||
});
|
});
|
||||||
@ -120,28 +115,35 @@ public class TPSSystem implements Plain {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSkip(int steps, double tpsLimitToUse) {
|
private boolean currentlyStepping = false;
|
||||||
double currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit;
|
private double currentLimit;
|
||||||
setTPS(tpsLimitToUse);
|
private int stepsTotal;
|
||||||
stepper = new BukkitRunnable() {
|
private int stepsLeft;
|
||||||
AtomicInteger stepsLeft = new AtomicInteger(steps);
|
|
||||||
|
|
||||||
@Override
|
private void setSkip(int steps, double tpsLimitToUse) {
|
||||||
public void run() {
|
currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit;
|
||||||
if (steps > 1) {
|
setTPS(tpsLimitToUse);
|
||||||
|
stepsLeft = steps;
|
||||||
|
stepsTotal = steps;
|
||||||
|
currentlyStepping = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTickEnd(TickEndEvent event) {
|
||||||
|
if (!currentlyStepping) return;
|
||||||
|
if (stepsTotal > 1) {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
||||||
bossbar.setColor(BarColor.YELLOW);
|
bossbar.setColor(BarColor.YELLOW);
|
||||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (steps - stepsLeft.get()), steps));
|
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (stepsTotal - stepsLeft), stepsTotal));
|
||||||
bossbar.setProgress((steps - stepsLeft.get()) / (double) steps);
|
bossbar.setProgress((stepsTotal - stepsLeft) / (double) stepsTotal);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (stepsLeft.decrementAndGet() < 0) {
|
stepsLeft--;
|
||||||
|
if (stepsLeft <= 0) {
|
||||||
setTPS(currentLimit);
|
setTPS(currentLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(BauSystem.getInstance(), 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TPSBaseCommand extends SWCommand {
|
private class TPSBaseCommand extends SWCommand {
|
||||||
|
|
||||||
@ -321,7 +323,7 @@ public class TPSSystem implements Plain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (TPSSystem.getInstance().stepper != null) {
|
if (TPSSystem.getInstance().currentlyStepping) {
|
||||||
long time = System.currentTimeMillis() % 1000;
|
long time = System.currentTimeMillis() % 1000;
|
||||||
if (time < 250) {
|
if (time < 250) {
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren