From 87110f5c5ab72775756b37936a9fa1d9c53872df Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Apr 2021 15:46:21 +0200 Subject: [PATCH 1/3] Add LockSchemCommand --- .../features/team/LockSchemCommand.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java new file mode 100644 index 00000000..4640257d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java @@ -0,0 +1,85 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.features.team; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.command.SWCommand; +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserGroup; +import org.bukkit.entity.Player; + +@Linked(LinkageType.COMMAND) +public class LockSchemCommand extends SWCommand { + + public LockSchemCommand() { + super("lockschem", "schemlock"); + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId()); + UserGroup userGroup = steamwarUser.getUserGroup(); + + if (userGroup != UserGroup.Admin && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Moderator && + userGroup != UserGroup.Supporter) { + return; + } + + sendHelp(p); + } + + @Register + public void genericCommand(Player p, String owner, String schematicName) { + SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId()); + UserGroup userGroup = steamwarUser.getUserGroup(); + + if (userGroup != UserGroup.Admin && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Moderator && + userGroup != UserGroup.Supporter) { + return; + } + + SteamwarUser schemOwner = SteamwarUser.get(owner); + if (schemOwner == null) { + p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); + return; + } + Schematic schematic = Schematic.getSchemFromDB(schematicName, schemOwner.getUUID()); + if (schematic == null) { + p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); + return; + } + p.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " von " + schematic.getSchemType().toString() + + " auf NORMAL zurückgesetzt!"); + schematic.setSchemType(SchematicType.Normal); + } + + private void sendHelp(Player player) { + player.sendMessage("§8/§eschemlock §8[§7Owner§8] §8[§7Schematic§8] §8- §7 Sperre eine Schematic"); + } +} From 4c8159043f88f9be00851a0b477ea8531200d296 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Apr 2021 15:48:21 +0200 Subject: [PATCH 2/3] Fix GamemodeCommand code convention --- .../de/steamwar/bausystem/features/other/GamemodeCommand.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java index 8dd49934..18ef3580 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java @@ -25,7 +25,6 @@ import net.md_5.bungee.api.ChatColor; import org.bukkit.GameMode; import org.bukkit.entity.Player; - @Linked(LinkageType.COMMAND) public class GamemodeCommand extends SWCommand { @@ -33,14 +32,12 @@ public class GamemodeCommand extends SWCommand { super("gamemode", "gm", "g"); } - @Register(help = true) public void help(final Player p, final String... args) { p.sendMessage(ChatColor.RED + "Unbekannter Spielmodus."); p.sendMessage(ChatColor.RED + "Mögliche Spielmodi: survival, adventure, creative, specator."); } - @Register public void genericCommand(final Player p) { if (p.getGameMode() == GameMode.CREATIVE) { @@ -50,7 +47,6 @@ public class GamemodeCommand extends SWCommand { } } - @Register public void gamemodeCommand(final Player p, final GameMode gameMode) { p.setGameMode(gameMode); From 3c545103e3d8bccdec4fb08d5743e5a8e8c13081 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Apr 2021 15:48:30 +0200 Subject: [PATCH 3/3] Fix GamemodeCommand code convention --- .../de/steamwar/bausystem/features/other/GamemodeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java index 18ef3580..720a3157 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java @@ -51,4 +51,4 @@ public class GamemodeCommand extends SWCommand { public void gamemodeCommand(final Player p, final GameMode gameMode) { p.setGameMode(gameMode); } -} \ No newline at end of file +}