From 7720f020bd136cf5316b28cda221a0140c9eb6f0 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 23 Nov 2019 21:36:49 +0100 Subject: [PATCH 1/3] added lockschem --- .../src/de/steamwar/bausystem/BauSystem.java | 1 + .../bausystem/commands/CommandLockschem.java | 52 +++++++++++++++++++ BauSystem_Main/src/plugin.yml | 3 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index c28fbf1..e06f6e1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -74,6 +74,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("protect").setExecutor(new CommandProtect()); getCommand("skull").setExecutor(new CommandSkull()); getCommand("loader").setExecutor(new CommandLoader()); + getCommand("lockschem").setExecutor(new CommandLockschem()); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java new file mode 100644 index 0000000..ddb5943 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java @@ -0,0 +1,52 @@ +package de.steamwar.bausystem.commands; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserGroup; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandLockschem implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) { + return false; + } + Player player = (Player) sender; + + SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); + UserGroup userGroup = steamwarUser.getUserGroup(); + + if(userGroup != UserGroup.Admin && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Moderator && + userGroup != UserGroup.Supporter) + return false; + + if(args.length == 2) { + SteamwarUser schemOwner = SteamwarUser.get(args[0]); + if(schemOwner == null) { + player.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); + return false; + } + Schematic schematic = Schematic.getSchemFromDB(args[1], schemOwner.getUUID()); + if(schematic == null) { + player.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); + return false; + } + player.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + + steamwarUser.getUserName() + " von " + schematic.getSchemType().toString() + + " auf NORMAL zurückgesetzt!"); + return false; + } + sendHelp(player); + return false; + } + + private void sendHelp(Player player) { + player.sendMessage(BauSystem.PREFIX + "/schemlock [OWNER] [SCHEM NAME]"); + } +} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 06b680b..88ebac8 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -18,4 +18,5 @@ commands: freeze: loader: nightvision: - aliases: nv \ No newline at end of file + aliases: nv + lockschem: \ No newline at end of file From ff49a0451a16ef69089aa3a2f017be703e2bbb9e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 23 Nov 2019 21:39:48 +0100 Subject: [PATCH 2/3] code cleanup --- .../bausystem/commands/CommandLockschem.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java index ddb5943..e0e8167 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java @@ -12,9 +12,8 @@ import org.bukkit.entity.Player; public class CommandLockschem implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) { + if(!(sender instanceof Player)) return false; - } Player player = (Player) sender; SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); @@ -26,23 +25,24 @@ public class CommandLockschem implements CommandExecutor { userGroup != UserGroup.Supporter) return false; - if(args.length == 2) { - SteamwarUser schemOwner = SteamwarUser.get(args[0]); - if(schemOwner == null) { - player.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); - return false; - } - Schematic schematic = Schematic.getSchemFromDB(args[1], schemOwner.getUUID()); - if(schematic == null) { - player.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); - return false; - } - player.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + - steamwarUser.getUserName() + " von " + schematic.getSchemType().toString() + - " auf NORMAL zurückgesetzt!"); + if(args.length != 2) { + sendHelp(player); return false; } - sendHelp(player); + + SteamwarUser schemOwner = SteamwarUser.get(args[0]); + if(schemOwner == null) { + player.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); + return false; + } + Schematic schematic = Schematic.getSchemFromDB(args[1], schemOwner.getUUID()); + if(schematic == null) { + player.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); + return false; + } + player.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + + steamwarUser.getUserName() + " von " + schematic.getSchemType().toString() + + " auf NORMAL zurückgesetzt!"); return false; } From aa96f91abc8eda70c26bed36e6360c805d6233dc Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 23 Nov 2019 21:45:09 +0100 Subject: [PATCH 3/3] code cleanup --- .../src/de/steamwar/bausystem/commands/CommandLockschem.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java index e0e8167..de8f523 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java @@ -2,6 +2,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicType; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import org.bukkit.command.Command; @@ -41,8 +42,9 @@ public class CommandLockschem implements CommandExecutor { return false; } player.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + - steamwarUser.getUserName() + " von " + schematic.getSchemType().toString() + + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " von " + schematic.getSchemType().toString() + " auf NORMAL zurückgesetzt!"); + schematic.setSchemType(SchematicType.Normal); return false; }