From 87110f5c5ab72775756b37936a9fa1d9c53872df Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Apr 2021 15:46:21 +0200 Subject: [PATCH] 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"); + } +}