From e4ba3249d7893d0bb740c1d39da99e9f710925ed Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 13 Sep 2022 21:03:02 +0200 Subject: [PATCH] Add KickallCommand Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 5 +- BauSystem_Main/src/BauSystem_de.properties | 5 +- .../features/world/KickallCommand.java | 54 +++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index cb4a561d..f6d05410 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -1289,6 +1289,9 @@ STOP_NO_PERMS = §cYou do not have the permission to stop the server STOP_MESSAGE = §eServer is stopping WORLD_EDIT_NO_PERMS = §cYou do not have the permission to use WorldEdit +KICKALL_HELP = §8/§ekickall §8- §7Kick all players from the server except the owner +KICKALL_NO_PERM = §cThis is not your world! + # Techhider TECHHIDER_HELP = §8/§etechhider §8- §7Toggle Techhider TECHHIDER_GLOBAL = §cNo techhider in global region @@ -1304,7 +1307,5 @@ XRAY_OFF = §cXray deactivated # WorldEdit COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another -COLORREPLACE_NO_PERMS = §cYou do not have the permission to use this command TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another -TYPEREPLACE_NO_PERMS = §cYou do not have the permission to use this command diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 5f36dfd1..77efe0ee 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -1267,6 +1267,9 @@ STOP_NO_PERMS = §cDu hast keine Rechte den Server zu stoppen STOP_MESSAGE = §eDer Server wird gestoppt WORLD_EDIT_NO_PERMS = §cDu darfst hier kein WorldEdit benutzen +KICKALL_HELP = §8/§ekickall §8- §7Kickt alle Spieler vom Server außer den Owner +KICKALL_NO_PERM = §cDies ist nicht deine Welt! + # Techhider TECHHIDER_HELP = §8/§etechhider §8- §7Techhider umschalten TECHHIDER_GLOBAL = §cKein Techhider in der globalen region @@ -1282,7 +1285,5 @@ XRAY_OFF = §cXray deaktiviert # WorldEdit COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen -COLORREPLACE_NO_PERMS = §cDu hast keine Rechte um Farben zu ersetzen TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen -TYPEREPLACE_NO_PERMS = §cDu hast keine Rechte um Blockgruppen zu ersetzen diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java new file mode 100644 index 00000000..ae85381c --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java @@ -0,0 +1,54 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 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 . + */ + +package de.steamwar.bausystem.features.world; + +import de.steamwar.bausystem.config.BauServer; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeValidator; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +@Linked(LinkageType.COMMAND) +public class KickallCommand extends SWCommand { + + @LinkedInstance + public BauServer bauServer; + + public KickallCommand() { + super("/kickall"); + } + + @Register(description = "KICKALL_HELP") + public void genericCommand(@Validator Player player) { + Bukkit.getOnlinePlayers().forEach(p -> { + if (!bauServer.getOwner().equals(p.getUniqueId())) p.kickPlayer(""); + }); + } + + @ClassValidator(value = Player.class, local = true) + public TypeValidator validator() { + return (commandSender, player, messageSender) -> { + return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "KICKALL_NO_PERM"); + }; + } +}