Add RestartCommand Fix KillAllCommand Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
dce3bab522
Commit
06e4c5cf3f
@ -24,12 +24,15 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class SWUtils {
|
public class SWUtils {
|
||||||
|
|
||||||
@ -60,6 +63,18 @@ public class SWUtils {
|
|||||||
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void actionBar(Function<Player, String> message) {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message.apply(player)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void message(Function<Player, String> message) {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
player.sendMessage(message.apply(player));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static NamespacedKey getNamespaceKey(String name) {
|
public static NamespacedKey getNamespaceKey(String name) {
|
||||||
return new NamespacedKey(getBausystem(), name);
|
return new NamespacedKey(getBausystem(), name);
|
||||||
}
|
}
|
||||||
|
@ -744,7 +744,7 @@ OTHER_GAMEMODE_POSSIBLE=§cMögliche Spielmodi: survival, adventure, creative, s
|
|||||||
OTHER_KILLALL_HELP_SELF=§8/§ekillall §8- §7Entferne alle Entities aus deiner Region
|
OTHER_KILLALL_HELP_SELF=§8/§ekillall §8- §7Entferne alle Entities aus deiner Region
|
||||||
OTHER_KILLALL_HELP_ALL=§8/§ekillall §8[§7Global§8/Local§7] §8- §7Entferne alle Entities aus deiner Region oder global
|
OTHER_KILLALL_HELP_ALL=§8/§ekillall §8[§7Global§8/Local§7] §8- §7Entferne alle Entities aus deiner Region oder global
|
||||||
OTHER_KILLALL_REGION=§a{0} Entities aus der Region entfernt
|
OTHER_KILLALL_REGION=§a{0} Entities aus der Region entfernt
|
||||||
OTHER_KILLALL_GLOBAL=§a{0} Entities aus der Global entfernt
|
OTHER_KILLALL_GLOBAL=§a{0} Entities aus der Welt entfernt
|
||||||
OTHER_TELEPORT_HELP = §8/§etp §8[§7Player§8] §8-§7 Teleportiere dich zu einem Spieler
|
OTHER_TELEPORT_HELP = §8/§etp §8[§7Player§8] §8-§7 Teleportiere dich zu einem Spieler
|
||||||
OTHER_TELEPORT_SELF_0=§cSei eins mit dir selbst!
|
OTHER_TELEPORT_SELF_0=§cSei eins mit dir selbst!
|
||||||
OTHER_TELEPORT_SELF_1=§cDu brauchst Leute zum spielen? Wir haben auch einen TeamSpeak!
|
OTHER_TELEPORT_SELF_1=§cDu brauchst Leute zum spielen? Wir haben auch einen TeamSpeak!
|
||||||
@ -961,3 +961,8 @@ WARP_HELP_5=§8/§ewarp gui - §7Öffne die Warp-GUI
|
|||||||
WARP_HELP_6=§8/§ewarp list - §7Liste alle Warp-Punkt auf
|
WARP_HELP_6=§8/§ewarp list - §7Liste alle Warp-Punkt auf
|
||||||
WARP_MOON_ITEM_NAME=§3Atemkugel
|
WARP_MOON_ITEM_NAME=§3Atemkugel
|
||||||
WARP_MOON_COUNTDOOWN=§7Noch §e§l{0} §7Sekunden!
|
WARP_MOON_COUNTDOOWN=§7Noch §e§l{0} §7Sekunden!
|
||||||
|
|
||||||
|
# WORLD
|
||||||
|
STOP_HELP = §8/§estop §8- §7Stoppt den Server
|
||||||
|
STOP_NO_PERMS = §cDu hast keine Rechte den Server zu stoppen
|
||||||
|
STOP_MESSAGE = §eDer Server wird gestoppt
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.other;
|
package de.steamwar.bausystem.features.other;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
import de.steamwar.bausystem.region.GlobalRegion;
|
||||||
@ -60,7 +62,7 @@ public class KillAllCommand extends SWCommand {
|
|||||||
entity.remove();
|
entity.remove();
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
});
|
});
|
||||||
RegionUtils.actionBar(GlobalRegion.getInstance(), "OTHER_KILLALL_GLOBAL", count.get());
|
SWUtils.actionBar(current -> BauSystem.MESSAGE.parse("OTHER_KILLALL_GLOBAL", current, count.get()));
|
||||||
} else {
|
} else {
|
||||||
WORLD.getEntities()
|
WORLD.getEntities()
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
|
public class RestartCommand extends SWCommand {
|
||||||
|
|
||||||
|
public RestartCommand() {
|
||||||
|
super("restart");
|
||||||
|
unregister();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.Permission;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import de.steamwar.command.GuardCheckType;
|
||||||
|
import de.steamwar.command.GuardChecker;
|
||||||
|
import de.steamwar.command.GuardResult;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.UserGroup;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
|
public class StopCommand extends SWCommand {
|
||||||
|
|
||||||
|
public StopCommand() {
|
||||||
|
super("stop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(description = "STOP_HELP")
|
||||||
|
public void genericCommand(Player p) {
|
||||||
|
SWUtils.message(current -> BauSystem.MESSAGE.parsePrefixed("STOP_MESSAGE", current));
|
||||||
|
Bukkit.getServer().shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassGuard(value = Player.class, local = true)
|
||||||
|
public GuardChecker stopGuard() {
|
||||||
|
return (commandSender, guardCheckType, strings, s) -> {
|
||||||
|
Player player = (Player) commandSender;
|
||||||
|
if (Permission.hasPermission(player, Permission.WORLD)) {
|
||||||
|
return GuardResult.ALLOWED;
|
||||||
|
}
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
||||||
|
if (steamwarUser.getUserGroup().isAdminGroup()) {
|
||||||
|
return GuardResult.ALLOWED;
|
||||||
|
}
|
||||||
|
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||||
|
BauSystem.MESSAGE.send("STOP_NO_PERMS", player);
|
||||||
|
}
|
||||||
|
return GuardResult.DENIED;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren