From 238906422ae19809c7a750d3c5283de998343bb9 Mon Sep 17 00:00:00 2001
From: UserSv4 <70157095+UserSv4@users.noreply.github.com>
Date: Sun, 5 Feb 2023 21:35:59 +0400
Subject: [PATCH] Added KingdomsX support.
---
pom.xml | 22 ++++++++++----
resources/config/v12/de/config.yml | 1 +
resources/config/v12/en/config.yml | 1 +
resources/config/v12/fr/config.yml | 1 +
resources/config/v12/it/config.yml | 1 +
resources/config/v13/de/config.yml | 1 +
resources/config/v13/en/config.yml | 1 +
resources/config/v13/es/config.yml | 1 +
resources/config/v13/fr/config.yml | 1 +
resources/config/v13/it/config.yml | 1 +
resources/config/v13/zh/config.yml | 1 +
resources/plugin.yml | 2 +-
src/com/dre/brewery/filedata/BConfig.java | 2 ++
.../integration/IntegrationListener.java | 30 +++++++++++++++----
.../integration/barrel/KingdomsXBarrel.java | 16 ++++++++++
15 files changed, 71 insertions(+), 11 deletions(-)
create mode 100644 src/com/dre/brewery/integration/barrel/KingdomsXBarrel.java
diff --git a/pom.xml b/pom.xml
index 3fdc8c1e..8f820d82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -127,11 +127,11 @@
chestshop-repo
https://repo.minebench.de/
-
-
- CodeMC
- https://repo.codemc.org/repository/maven-public
-
+
+
+ CodeMC
+ https://repo.codemc.org/repository/maven-public
+
MMOPlugins
@@ -218,6 +218,18 @@
+
+ com.github.cryptomorin
+ kingdoms
+ 1.14.15.3-SNAPSHOT
+ provided
+
+
+ *
+ *
+
+
+
com.sk89q.worldguard
diff --git a/resources/config/v12/de/config.yml b/resources/config/v12/de/config.yml
index a633b30f..7b903178 100644
--- a/resources/config/v12/de/config.yml
+++ b/resources/config/v12/de/config.yml
@@ -460,6 +460,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v12/en/config.yml b/resources/config/v12/en/config.yml
index 02bdffc4..6be437d2 100644
--- a/resources/config/v12/en/config.yml
+++ b/resources/config/v12/en/config.yml
@@ -462,6 +462,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v12/fr/config.yml b/resources/config/v12/fr/config.yml
index 4df161dd..c9f643fa 100644
--- a/resources/config/v12/fr/config.yml
+++ b/resources/config/v12/fr/config.yml
@@ -457,6 +457,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v12/it/config.yml b/resources/config/v12/it/config.yml
index b12bd6c9..0ff89428 100644
--- a/resources/config/v12/it/config.yml
+++ b/resources/config/v12/it/config.yml
@@ -449,6 +449,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v13/de/config.yml b/resources/config/v13/de/config.yml
index a2a62426..a50469d2 100644
--- a/resources/config/v13/de/config.yml
+++ b/resources/config/v13/de/config.yml
@@ -858,6 +858,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v13/en/config.yml b/resources/config/v13/en/config.yml
index 1da2ef9d..7e347073 100644
--- a/resources/config/v13/en/config.yml
+++ b/resources/config/v13/en/config.yml
@@ -852,6 +852,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v13/es/config.yml b/resources/config/v13/es/config.yml
index 99bc6e25..a45e4300 100644
--- a/resources/config/v13/es/config.yml
+++ b/resources/config/v13/es/config.yml
@@ -852,6 +852,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v13/fr/config.yml b/resources/config/v13/fr/config.yml
index 627450cd..1189b702 100644
--- a/resources/config/v13/fr/config.yml
+++ b/resources/config/v13/fr/config.yml
@@ -858,6 +858,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v13/it/config.yml b/resources/config/v13/it/config.yml
index c2779d4c..0b96f0b5 100644
--- a/resources/config/v13/it/config.yml
+++ b/resources/config/v13/it/config.yml
@@ -852,6 +852,7 @@ eggnog:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/config/v13/zh/config.yml b/resources/config/v13/zh/config.yml
index 52dcca47..9de8c7e1 100644
--- a/resources/config/v13/zh/config.yml
+++ b/resources/config/v13/zh/config.yml
@@ -856,6 +856,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
+useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
diff --git a/resources/plugin.yml b/resources/plugin.yml
index 96cf9b36..efdb17ca 100644
--- a/resources/plugin.yml
+++ b/resources/plugin.yml
@@ -1,7 +1,7 @@
name: Brewery
version: 3.1.1
main: com.dre.brewery.P
-softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun]
+softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun, Kingdoms]
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
api-version: 1.13
commands:
diff --git a/src/com/dre/brewery/filedata/BConfig.java b/src/com/dre/brewery/filedata/BConfig.java
index e45ac187..d209bc0d 100644
--- a/src/com/dre/brewery/filedata/BConfig.java
+++ b/src/com/dre/brewery/filedata/BConfig.java
@@ -50,6 +50,7 @@ public class BConfig {
public static boolean useLWC; //LWC
public static boolean useLB; //LogBlock
public static boolean useGP; //GriefPrevention
+ public static boolean useKingdomsX; //KingdomsX
public static boolean useTowny; //Towny
public static boolean useBlocklocker; //LockBlocker
public static boolean hasVault; // Vault
@@ -206,6 +207,7 @@ public static void readConfig(FileConfiguration config) {
useLWC = config.getBoolean("useLWC", true) && plMan.isPluginEnabled("LWC");
useTowny = config.getBoolean("useTowny", true) && plMan.isPluginEnabled("Towny");
useGP = config.getBoolean("useGriefPrevention", true) && plMan.isPluginEnabled("GriefPrevention");
+ useKingdomsX = config.getBoolean("useKingdomsX", true) && plMan.isPluginEnabled("Kingdoms");
useLB = config.getBoolean("useLogBlock", false) && plMan.isPluginEnabled("LogBlock");
useGMInventories = config.getBoolean("useGMInventories", false);
useCitadel = config.getBoolean("useCitadel", false) && plMan.isPluginEnabled("Citadel");
diff --git a/src/com/dre/brewery/integration/IntegrationListener.java b/src/com/dre/brewery/integration/IntegrationListener.java
index 4408b453..fa90cd56 100644
--- a/src/com/dre/brewery/integration/IntegrationListener.java
+++ b/src/com/dre/brewery/integration/IntegrationListener.java
@@ -6,11 +6,7 @@
import com.dre.brewery.api.events.barrel.BarrelDestroyEvent;
import com.dre.brewery.api.events.barrel.BarrelRemoveEvent;
import com.dre.brewery.filedata.BConfig;
-import com.dre.brewery.integration.barrel.BlocklockerBarrel;
-import com.dre.brewery.integration.barrel.GriefPreventionBarrel;
-import com.dre.brewery.integration.barrel.LWCBarrel;
-import com.dre.brewery.integration.barrel.LogBlockBarrel;
-import com.dre.brewery.integration.barrel.TownyBarrel;
+import com.dre.brewery.integration.barrel.*;
import com.dre.brewery.integration.item.MMOItemsPluginItem;
import com.dre.brewery.recipe.BCauldronRecipe;
import com.dre.brewery.recipe.RecipeItem;
@@ -114,6 +110,30 @@ public void onBarrelAccess(BarrelAccessEvent event) {
}
}
}
+ if (BConfig.useKingdomsX) {
+ if (P.p.getServer().getPluginManager().isPluginEnabled("Kingdoms")) {
+ try {
+ if (!KingdomsXBarrel.checkAccess(event)) {
+ P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
+ event.setCancelled(true);
+ return;
+ }
+ } catch (Throwable e) {
+ event.setCancelled(true);
+ P.p.errorLog("Failed to Check KingdomsX for Barrel Open Permissions!");
+ P.p.errorLog("Disable the KingdomsX support in the config and do /brew reload");
+ e.printStackTrace();
+ Player player = event.getPlayer();
+ if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
+ P.p.msg(player, "&cKingdomsX check Error");
+ P.p.msg(player, "&cSet &7useKingdomsX: false &cin the config and /brew reload");
+ } else {
+ P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
+ }
+ return;
+ }
+ }
+ }
if (BConfig.useLWC) {
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("LWC");
diff --git a/src/com/dre/brewery/integration/barrel/KingdomsXBarrel.java b/src/com/dre/brewery/integration/barrel/KingdomsXBarrel.java
new file mode 100644
index 00000000..ee62d737
--- /dev/null
+++ b/src/com/dre/brewery/integration/barrel/KingdomsXBarrel.java
@@ -0,0 +1,16 @@
+package com.dre.brewery.integration.barrel;
+
+import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
+import org.kingdoms.constants.land.Land;
+import org.kingdoms.constants.land.location.SimpleChunkLocation;
+import org.kingdoms.constants.player.KingdomPlayer;
+
+public class KingdomsXBarrel {
+
+ public static boolean checkAccess(BarrelAccessEvent event) {
+ Land land = SimpleChunkLocation.of(event.getSpigot().getLocation()).getLand();
+ return land == null || land.getKingdomId() == null || !land.isClaimed()
+ || land.getKingdomId().equals(KingdomPlayer.getKingdomPlayer(event.getPlayer()).getKingdomId());
+ }
+
+}