From 1e04cca2f8f5ba1c936ca84ce6ee05baef46b302 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 1 Jan 2022 16:42:00 +0100 Subject: [PATCH 1/6] Add Punishments Signed-off-by: Chaoscaot --- .../schematicsystem/commands/SchematicCommand.java | 9 +++++++++ .../schematicsystem/commands/SchematicCommandUtils.java | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index be665e4..31bc672 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -181,12 +181,21 @@ public class SchematicCommand extends SWCommand { @Register("addmember") public void addMember(Player player, SchematicNode node, SteamwarUser... targets) { SteamwarUser user = getUser(player); + if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l" + punishment.getReason()))) { + return; + } if (node.getOwner() != user.getId()) { player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur auf deine eigenen Sachen jemanden hinzufügen."); return; } List added = new ArrayList<>(); for (SteamwarUser target: targets) { + if(Punishment.isPunished(target, + Punishment.PunishmentType.NoSchemReceiving, + punishment -> player.sendMessage(SchematicSystem.PREFIX + "§c" + target.getUserName() + " darf nicht auf Schematics hinzugefügt werden."))) { + continue; + } + if (user.getId() == target.getId()) { player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!"); continue; diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java index 8b4e551..9cc41f7 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java @@ -322,6 +322,11 @@ public class SchematicCommandUtils { public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) { SteamwarUser user = getUser(player); + if(Punishment.isPunished(user, + Punishment.PunishmentType.NoSchemSubmitting, + punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics einsenden: §f§l: " + punishment.getReason()))) { + return; + } if (node.getOwner() != user.getId()) { player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur deine eigenen Schematics einsenden."); return; -- 2.39.2 From e58ad971f6090636034d6ff9dcb3b1cc55a35d03 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 4 Jan 2022 14:15:28 +0100 Subject: [PATCH 2/6] Add Schem Download to Punishments Signed-off-by: Chaoscaot --- .../schematicsystem/commands/SchematicCommandUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java index 9cc41f7..ad71001 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java @@ -311,6 +311,11 @@ public class SchematicCommandUtils { public static void download(Player player, SchematicNode node) { SteamwarUser user = getUser(player); + if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> { + player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics Downloaden: §f§l" + punishment.getReason()); + })) { + return; + } if (node.getOwner() != user.getId()) { player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!"); return; -- 2.39.2 From 897fdba6bbe5bfe19551ddf099e9b7de45fc3c67 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 27 Jan 2022 21:17:50 +0100 Subject: [PATCH 3/6] Add a butt ton of Code for BauSystem --- .../commands/SchematicCommand.java | 9 ++- .../commands/SchematicCommandUtils.java | 21 +++++-- .../providers/BauSystemProvider.java | 56 +++++++++++++++++++ .../providers/impl/BauSystem1Provider.java | 28 ++++++++++ .../providers/impl/BauSystem2Provider.java | 31 ++++++++++ SchematicSystem_Core/src/plugin.yml | 1 + 6 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java create mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java create mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 0f8d83b..c9605f5 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -24,6 +24,7 @@ import de.steamwar.command.TypeMapper; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SchematicSelector; import de.steamwar.schematicsystem.SchematicSystem; +import de.steamwar.schematicsystem.providers.BauSystemProvider; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; @@ -134,11 +135,17 @@ public class SchematicCommand extends SWCommand { @Register("save") @Register("s") public void saveSchem(Player player, @Mapper("dirStringMapper") String name) { + SteamwarUser user = getUser(player); + if((Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics laden")) || + Punishment.isPunished(SteamwarUser.get(BauSystemProvider.use(BauSystemProvider::getOwner, 0)), Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau kannst du keine Schematics speichern"))) && + Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false))) { + player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics speichern"); + return; + } if (name.endsWith("/")) { player.sendMessage(SchematicSystem.PREFIX + "§cDu must auch einen Namen für die Schematic nach dem Ordner angeben"); return; } - SteamwarUser user = getUser(player); if (name.startsWith("/")) name = name.substring(1); String[] layers = name.split("/"); if (invalidSchemName(player, layers)) return; diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java index ad71001..43e56e4 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java @@ -25,6 +25,7 @@ import de.steamwar.inventory.SWItem; import de.steamwar.schematicsystem.AutoCheckResult; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; +import de.steamwar.schematicsystem.providers.BauSystemProvider; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; @@ -45,7 +46,8 @@ public class SchematicCommandUtils { private static final List PUBLIC_TOGGLED = new ArrayList<>(); private static final List FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public")); - private SchematicCommandUtils() {} + private SchematicCommandUtils() { + } public static boolean invalidSchemName(Player player, String[] layers) { for (String layer : layers) { @@ -65,7 +67,7 @@ public class SchematicCommandUtils { player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen"); return true; } - if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) { + if (FORBIDDEN_NAMES.contains(layer.toLowerCase())) { player.sendMessage(SchematicSystem.PREFIX + "§cDer Pfad darf nicht \"§l" + layer + "§c\" enthalten"); return true; } @@ -236,7 +238,7 @@ public class SchematicCommandUtils { base.addExtra(rename); } - TextComponent delete = new TextComponent("[" + (node.getOwner()==user.getId()?"Löschen":"Entfernen") + "] "); + TextComponent delete = new TextComponent("[" + (node.getOwner() == user.getId() ? "Löschen" : "Entfernen") + "] "); delete.setColor(ChatColor.DARK_RED); delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen"))); delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user))); @@ -292,6 +294,13 @@ public class SchematicCommandUtils { } public static void loadSchem(Player player, SchematicNode node) { + SteamwarUser user = getUser(player); + if ((Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics laden")) && + Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false))) || + (Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false)) && + Punishment.isPunished(BauSystemProvider.use(bauSystemProvider -> SteamwarUser.get(bauSystemProvider.getOwner()), user), Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst auf diesem Bau keine Schematics laden")))) { + return; + } if (node.isDir()) { player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst keine Ordner Laden"); return; @@ -311,7 +320,7 @@ public class SchematicCommandUtils { public static void download(Player player, SchematicNode node) { SteamwarUser user = getUser(player); - if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> { + if (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> { player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics Downloaden: §f§l" + punishment.getReason()); })) { return; @@ -327,7 +336,7 @@ public class SchematicCommandUtils { public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) { SteamwarUser user = getUser(player); - if(Punishment.isPunished(user, + if (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSubmitting, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics einsenden: §f§l: " + punishment.getReason()))) { return; @@ -342,7 +351,7 @@ public class SchematicCommandUtils { return; } - if(!type.isAssignable()) { + if (!type.isAssignable()) { player.sendMessage(SchematicSystem.PREFIX + "§cZu diesem Typen können keine Schematics geändert werden."); } diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java new file mode 100644 index 0000000..fa3120c --- /dev/null +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java @@ -0,0 +1,56 @@ +package de.steamwar.schematicsystem.providers; + +import de.steamwar.schematicsystem.providers.impl.*; +import org.bukkit.Bukkit; + +import java.util.function.Consumer; +import java.util.function.Function; + +public interface BauSystemProvider { + + static T use(Function function, T def) { + return BauSystemProviderImplementor.use(function, def); + } + + static void use(Consumer consumer) { + BauSystemProviderImplementor.use(consumer); + } + + int getOwner(); + + class BauSystemProviderImplementor { + private BauSystemProviderImplementor() {} + + static boolean hasBausystem; + static BauSystemProvider bauSystemProvider; + + static { + try { + Class.forName("de.steamwar.bausystem.BauSystem"); + hasBausystem = true; + switch (Bukkit.getPluginManager().getPlugin("BauSystem").getDescription().getVersion()) { + case "2.0": + bauSystemProvider = new BauSystem2Provider(); + break; + case "1.0": + bauSystemProvider = new BauSystem1Provider(); + break; + default: + hasBausystem = false; + } + } catch (Exception e) { + hasBausystem = false; + } + } + + static T use(Function function, T def) { + if(!hasBausystem) return def; + return function.apply(bauSystemProvider); + } + + static void use(Consumer consumer) { + if(!hasBausystem) return; + consumer.accept(bauSystemProvider); + } + } +} diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java new file mode 100644 index 0000000..50c966c --- /dev/null +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java @@ -0,0 +1,28 @@ +package de.steamwar.schematicsystem.providers.impl; + +import de.steamwar.schematicsystem.providers.BauSystemProvider; + +import java.lang.reflect.Method; + +public class BauSystem1Provider implements BauSystemProvider { + + private static final Method BAUSYSTEM_GET_OWNER_ID; + + static { + try { + Class bausystem = Class.forName("de.steamwar.bausystem.BauSystem"); + BAUSYSTEM_GET_OWNER_ID = bausystem.getDeclaredMethod("getOwnerID"); + } catch (Exception e) { + throw new SecurityException(e); + } + } + + @Override + public int getOwner() { + try { + return (int) BAUSYSTEM_GET_OWNER_ID.invoke(null); + } catch (Exception e) { + throw new SecurityException(e); + } + } +} diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java new file mode 100644 index 0000000..7e807cb --- /dev/null +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java @@ -0,0 +1,31 @@ +package de.steamwar.schematicsystem.providers.impl; + +import de.steamwar.schematicsystem.providers.BauSystemProvider; + +import java.lang.reflect.Method; + +public class BauSystem2Provider implements BauSystemProvider { + + private static final Method BAU_SERVER_GET_OWNER_ID; + private static final Object BAU_SERVER_INSTANCE; + + static { + try { + Class bauServer = Class.forName("de.steamwar.bausystem.config.BauServer"); + Method bauServerGet = bauServer.getDeclaredMethod("getInstance"); + BAU_SERVER_GET_OWNER_ID = bauServer.getMethod("getOwnerID"); + BAU_SERVER_INSTANCE = bauServerGet.invoke(null); + } catch (Exception e) { + throw new SecurityException(e); + } + } + + @Override + public int getOwner() { + try { + return (int) BAU_SERVER_GET_OWNER_ID.invoke(BAU_SERVER_INSTANCE); + } catch (Exception e) { + throw new SecurityException(e); + } + } +} diff --git a/SchematicSystem_Core/src/plugin.yml b/SchematicSystem_Core/src/plugin.yml index 457fdd9..c5d64da 100644 --- a/SchematicSystem_Core/src/plugin.yml +++ b/SchematicSystem_Core/src/plugin.yml @@ -2,6 +2,7 @@ name: SchematicSystem version: "2.0" authors: [Yaruma3341, Lixfel, Chaoscaot] depend: [SpigotCore, WorldEdit] +softdepend: [BauSystem] main: de.steamwar.schematicsystem.SchematicSystem website: steamwar.de api-version: "1.13" -- 2.39.2 From d800b90ac2dffcc24b62264debd6eb49edd79c6e Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 27 Jan 2022 21:41:10 +0100 Subject: [PATCH 4/6] Move Provider to SPigotCore --- .../commands/SchematicCommand.java | 2 +- .../commands/SchematicCommandUtils.java | 2 +- .../providers/BauSystemProvider.java | 56 ------------------- .../providers/impl/BauSystem1Provider.java | 28 ---------- .../providers/impl/BauSystem2Provider.java | 31 ---------- 5 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java delete mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java delete mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index c9605f5..30c63cf 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -23,8 +23,8 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SchematicSelector; +import de.steamwar.providers.BauSystemProvider; import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.providers.BauSystemProvider; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java index 43e56e4..1e4b6e0 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java @@ -22,10 +22,10 @@ package de.steamwar.schematicsystem.commands; import de.steamwar.comms.packets.PrepareSchemPacket; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.providers.BauSystemProvider; import de.steamwar.schematicsystem.AutoCheckResult; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.providers.BauSystemProvider; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java deleted file mode 100644 index fa3120c..0000000 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/BauSystemProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.steamwar.schematicsystem.providers; - -import de.steamwar.schematicsystem.providers.impl.*; -import org.bukkit.Bukkit; - -import java.util.function.Consumer; -import java.util.function.Function; - -public interface BauSystemProvider { - - static T use(Function function, T def) { - return BauSystemProviderImplementor.use(function, def); - } - - static void use(Consumer consumer) { - BauSystemProviderImplementor.use(consumer); - } - - int getOwner(); - - class BauSystemProviderImplementor { - private BauSystemProviderImplementor() {} - - static boolean hasBausystem; - static BauSystemProvider bauSystemProvider; - - static { - try { - Class.forName("de.steamwar.bausystem.BauSystem"); - hasBausystem = true; - switch (Bukkit.getPluginManager().getPlugin("BauSystem").getDescription().getVersion()) { - case "2.0": - bauSystemProvider = new BauSystem2Provider(); - break; - case "1.0": - bauSystemProvider = new BauSystem1Provider(); - break; - default: - hasBausystem = false; - } - } catch (Exception e) { - hasBausystem = false; - } - } - - static T use(Function function, T def) { - if(!hasBausystem) return def; - return function.apply(bauSystemProvider); - } - - static void use(Consumer consumer) { - if(!hasBausystem) return; - consumer.accept(bauSystemProvider); - } - } -} diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java deleted file mode 100644 index 50c966c..0000000 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem1Provider.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.steamwar.schematicsystem.providers.impl; - -import de.steamwar.schematicsystem.providers.BauSystemProvider; - -import java.lang.reflect.Method; - -public class BauSystem1Provider implements BauSystemProvider { - - private static final Method BAUSYSTEM_GET_OWNER_ID; - - static { - try { - Class bausystem = Class.forName("de.steamwar.bausystem.BauSystem"); - BAUSYSTEM_GET_OWNER_ID = bausystem.getDeclaredMethod("getOwnerID"); - } catch (Exception e) { - throw new SecurityException(e); - } - } - - @Override - public int getOwner() { - try { - return (int) BAUSYSTEM_GET_OWNER_ID.invoke(null); - } catch (Exception e) { - throw new SecurityException(e); - } - } -} diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java deleted file mode 100644 index 7e807cb..0000000 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/providers/impl/BauSystem2Provider.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.steamwar.schematicsystem.providers.impl; - -import de.steamwar.schematicsystem.providers.BauSystemProvider; - -import java.lang.reflect.Method; - -public class BauSystem2Provider implements BauSystemProvider { - - private static final Method BAU_SERVER_GET_OWNER_ID; - private static final Object BAU_SERVER_INSTANCE; - - static { - try { - Class bauServer = Class.forName("de.steamwar.bausystem.config.BauServer"); - Method bauServerGet = bauServer.getDeclaredMethod("getInstance"); - BAU_SERVER_GET_OWNER_ID = bauServer.getMethod("getOwnerID"); - BAU_SERVER_INSTANCE = bauServerGet.invoke(null); - } catch (Exception e) { - throw new SecurityException(e); - } - } - - @Override - public int getOwner() { - try { - return (int) BAU_SERVER_GET_OWNER_ID.invoke(BAU_SERVER_INSTANCE); - } catch (Exception e) { - throw new SecurityException(e); - } - } -} -- 2.39.2 From 1247f596d2a4e9f2e622ec39a4be46058dbfe2be Mon Sep 17 00:00:00 2001 From: Chaos Date: Fri, 28 Jan 2022 16:15:54 +0100 Subject: [PATCH 5/6] If --- .../schematicsystem/commands/SchematicCommand.java | 11 ++++++----- .../commands/SchematicCommandUtils.java | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 30c63cf..2b0e4af 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -23,7 +23,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SchematicSelector; -import de.steamwar.providers.BauSystemProvider; +import de.steamwar.providers.BauServerInfo; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatColor; @@ -136,10 +136,11 @@ public class SchematicCommand extends SWCommand { @Register("s") public void saveSchem(Player player, @Mapper("dirStringMapper") String name) { SteamwarUser user = getUser(player); - if((Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics laden")) || - Punishment.isPunished(SteamwarUser.get(BauSystemProvider.use(BauSystemProvider::getOwner, 0)), Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau kannst du keine Schematics speichern"))) && - Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false))) { - player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics speichern"); + if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() && + (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment -> + player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht auf anderen Baus Schematics machen")) || + Punishment.isPunished(SteamwarUser.get(BauServerInfo.getOwnerId()), Punishment.PunishmentType.NoSchemSharing, punishment -> + player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau können keine Schematics gemacht werden")))) { return; } if (name.endsWith("/")) { diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java index 1e4b6e0..0ad1e4e 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandUtils.java @@ -22,7 +22,7 @@ package de.steamwar.schematicsystem.commands; import de.steamwar.comms.packets.PrepareSchemPacket; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; -import de.steamwar.providers.BauSystemProvider; +import de.steamwar.providers.BauServerInfo; import de.steamwar.schematicsystem.AutoCheckResult; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; @@ -295,10 +295,11 @@ public class SchematicCommandUtils { public static void loadSchem(Player player, SchematicNode node) { SteamwarUser user = getUser(player); - if ((Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics laden")) && - Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false))) || - (Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false)) && - Punishment.isPunished(BauSystemProvider.use(bauSystemProvider -> SteamwarUser.get(bauSystemProvider.getOwner()), user), Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst auf diesem Bau keine Schematics laden")))) { + if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() && + (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> + player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst hier keine Schematics laden")) || + Punishment.isPunished(SteamwarUser.get(BauServerInfo.getOwnerId()), Punishment.PunishmentType.NoSchemReceiving, punishment -> + player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau können keine Schematics geladen werden")))) { return; } if (node.isDir()) { -- 2.39.2 From 1b8e572025f327860a335a062e7ff469455ff738 Mon Sep 17 00:00:00 2001 From: Chaos Date: Sat, 29 Jan 2022 14:26:49 +0100 Subject: [PATCH 6/6] Remove SoftDependend --- SchematicSystem_Core/src/plugin.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/SchematicSystem_Core/src/plugin.yml b/SchematicSystem_Core/src/plugin.yml index c5d64da..457fdd9 100644 --- a/SchematicSystem_Core/src/plugin.yml +++ b/SchematicSystem_Core/src/plugin.yml @@ -2,7 +2,6 @@ name: SchematicSystem version: "2.0" authors: [Yaruma3341, Lixfel, Chaoscaot] depend: [SpigotCore, WorldEdit] -softdepend: [BauSystem] main: de.steamwar.schematicsystem.SchematicSystem website: steamwar.de api-version: "1.13" -- 2.39.2