Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KingdomsX support. #542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@
<id>chestshop-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<!-- BlockLocker -->
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<!-- BlockLocker -->
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<!-- MythicLib (MMOItems) -->
<id>MMOPlugins</id>
Expand Down Expand Up @@ -218,6 +218,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>kingdoms</artifactId>
<version>1.14.15.3-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- https://dev.bukkit.org/projects/worldguard/files -->
<groupId>com.sk89q.worldguard</groupId>
Expand Down
1 change: 1 addition & 0 deletions resources/config/v12/de/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v12/en/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v12/fr/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v12/it/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v13/de/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v13/en/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v13/es/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v13/fr/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v13/it/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ eggnog:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
1 change: 1 addition & 0 deletions resources/config/v13/zh/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ recipes:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useKingdomsX: true
useTowny: true
useBlockLocker: true
useGMInventories: true
Expand Down
2 changes: 1 addition & 1 deletion resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/com/dre/brewery/filedata/BConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
30 changes: 25 additions & 5 deletions src/com/dre/brewery/integration/IntegrationListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
16 changes: 16 additions & 0 deletions src/com/dre/brewery/integration/barrel/KingdomsXBarrel.java
Original file line number Diff line number Diff line change
@@ -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());
}

}