SteamWar/BauSystem2.0
Archiviert
12
0

Merge branch 'master' into SimulatorPreview
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-09-02 12:13:58 +02:00
Commit 0b8a34bbe5
4 geänderte Dateien mit 18 neuen und 122 gelöschten Zeilen

Datei anzeigen

@ -22,41 +22,21 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.shared.Position;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector;
import java.util.function.Supplier;
@Getter
public class TNTPosition extends Position {
@RequiredArgsConstructor
public static class CachingSupplier<T> implements Supplier<T> {
private final Supplier<T> supplier;
private boolean initialized;
private T value;
@Override
public T get() {
if (!initialized) {
value = supplier.get();
initialized = true;
}
return value;
}
}
private final Record.TNTRecord record;
private final int fuseTicks;
private final Vector previousLocation;
private final Vector velocity;
private final CachingSupplier<Vector> updateVelocity;
private final Vector updateVelocity;
private final boolean source;
private final boolean exploded;
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier<Vector> updateVelocity, boolean source, boolean exploded) {
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, Vector updateVelocity, boolean source, boolean exploded) {
super(entity.getLocation().toVector());
this.record = record;
this.fuseTicks = entity.getFuseTicks();
@ -67,10 +47,6 @@ public class TNTPosition extends Position {
this.exploded = exploded;
}
public Vector getUpdateVelocity() {
return updateVelocity.get();
}
@Override
public String toString() {
return "Position{" +

Datei anzeigen

@ -118,21 +118,11 @@ public class Record {
private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) {
TNTPosition position;
if (positions.isEmpty()) {
position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), source, exploded);
position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), null, source, exploded);
} else {
int currentSize = positions.size() + 1;
TNTPosition.CachingSupplier<Vector> velocitySupplier = new TNTPosition.CachingSupplier<>(() -> {
Vector current = null;
for (int i = currentSize - 1; i >= 0; i--) {
TNTPosition currentTNT = positions.get(i);
if ((currentTNT.getVelocity().getX() == 0 || currentTNT.getVelocity().getZ() == 0) && current != null) {
break;
}
current = currentTNT.getVelocity();
}
return current;
});
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, source, exploded);
TNTPosition tntPosition = positions.get(positions.size() - 1);
Vector lastVelocity = tntPrimed.getLocation().toVector().clone().subtract(tntPosition.getLocation());
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), lastVelocity, source, exploded);
}
positions.add(position);
TraceShowManager.show(region, position);

Datei anzeigen

@ -25,6 +25,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
@Linked
@ -41,17 +42,18 @@ public class AFKStopperListener implements Listener {
if (RamUsage.getLoad() < 50.0 && RamUsage.getUsage() < 0.6) {
minutesAfk = 0;
return;
} else if (Bukkit.getOnlinePlayers().isEmpty()) {
Bukkit.shutdown();
return;
}
switch (minutesAfk) {
case 30:
Bukkit.shutdown();
break;
case 5:
if (Bukkit.getOnlinePlayers().isEmpty()) {
Bukkit.shutdown();
return;
}
for (Player p : Bukkit.getOnlinePlayers()) {
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
}
break;
case 4:
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
default:
@ -70,4 +72,9 @@ public class AFKStopperListener implements Listener {
minutesAfk = 0;
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.getPlayer().setOp(true);
}
}

Datei anzeigen

@ -1,77 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils;
import de.steamwar.linkage.Linked;
import de.steamwar.scoreboard.SWScoreboard;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitTask;
@Linked
public class AutoShutdownListener implements Listener {
private BukkitTask autoShutdown;
@EventHandler
public void onJoin(PlayerLoginEvent e) {
if (autoShutdown != null) {
autoShutdown.cancel();
autoShutdown = null;
}
Player p = e.getPlayer();
p.setOp(true);
}
@EventHandler
public void onLeave(PlayerQuitEvent e) {
Player p = e.getPlayer();
SWScoreboard.removeScoreboard(p);
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(p))) {
if (autoShutdown != null) {
autoShutdown.cancel();
}
TPSLimitUtils.setTPS(20.0);
if (false) {
Bukkit.shutdown();
return;
}
autoShutdown = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), new Runnable() {
int count = 0;
@Override
public void run() {
if (count >= 300) {
Bukkit.shutdown();
return;
}
count++;
}
}, 20, 20);
}
}
}