Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
85b383c596
Commit
a8aa431210
@ -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()) {
|
||||||
switch (minutesAfk) {
|
|
||||||
case 5:
|
|
||||||
if (Bukkit.getOnlinePlayers().isEmpty()) {
|
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
switch (minutesAfk) {
|
||||||
|
case 30:
|
||||||
|
Bukkit.shutdown();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
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