Merge branch 'master' into SimulatorPreview
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
0b8a34bbe5
@ -22,41 +22,21 @@ package de.steamwar.bausystem.features.tracer;
|
|||||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||||
import de.steamwar.bausystem.shared.Position;
|
import de.steamwar.bausystem.shared.Position;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class TNTPosition extends Position {
|
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 Record.TNTRecord record;
|
||||||
private final int fuseTicks;
|
private final int fuseTicks;
|
||||||
private final Vector previousLocation;
|
private final Vector previousLocation;
|
||||||
private final Vector velocity;
|
private final Vector velocity;
|
||||||
private final CachingSupplier<Vector> updateVelocity;
|
private final Vector updateVelocity;
|
||||||
private final boolean source;
|
private final boolean source;
|
||||||
private final boolean exploded;
|
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());
|
super(entity.getLocation().toVector());
|
||||||
this.record = record;
|
this.record = record;
|
||||||
this.fuseTicks = entity.getFuseTicks();
|
this.fuseTicks = entity.getFuseTicks();
|
||||||
@ -67,10 +47,6 @@ public class TNTPosition extends Position {
|
|||||||
this.exploded = exploded;
|
this.exploded = exploded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getUpdateVelocity() {
|
|
||||||
return updateVelocity.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Position{" +
|
return "Position{" +
|
||||||
|
@ -118,21 +118,11 @@ public class Record {
|
|||||||
private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) {
|
private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) {
|
||||||
TNTPosition position;
|
TNTPosition position;
|
||||||
if (positions.isEmpty()) {
|
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 {
|
} else {
|
||||||
int currentSize = positions.size() + 1;
|
TNTPosition tntPosition = positions.get(positions.size() - 1);
|
||||||
TNTPosition.CachingSupplier<Vector> velocitySupplier = new TNTPosition.CachingSupplier<>(() -> {
|
Vector lastVelocity = tntPrimed.getLocation().toVector().clone().subtract(tntPosition.getLocation());
|
||||||
Vector current = null;
|
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), lastVelocity, source, exploded);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
positions.add(position);
|
positions.add(position);
|
||||||
TraceShowManager.show(region, position);
|
TraceShowManager.show(region, position);
|
||||||
|
@ -25,6 +25,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -41,17 +42,18 @@ public class AFKStopperListener implements Listener {
|
|||||||
if (RamUsage.getLoad() < 50.0 && RamUsage.getUsage() < 0.6) {
|
if (RamUsage.getLoad() < 50.0 && RamUsage.getUsage() < 0.6) {
|
||||||
minutesAfk = 0;
|
minutesAfk = 0;
|
||||||
return;
|
return;
|
||||||
|
} else if (Bukkit.getOnlinePlayers().isEmpty()) {
|
||||||
|
Bukkit.shutdown();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
switch (minutesAfk) {
|
switch (minutesAfk) {
|
||||||
|
case 30:
|
||||||
|
Bukkit.shutdown();
|
||||||
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (Bukkit.getOnlinePlayers().isEmpty()) {
|
|
||||||
Bukkit.shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
|
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 4:
|
case 4:
|
||||||
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
|
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
|
||||||
default:
|
default:
|
||||||
@ -70,4 +72,9 @@ public class AFKStopperListener implements Listener {
|
|||||||
minutesAfk = 0;
|
minutesAfk = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
event.getPlayer().setOp(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren