mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-29 12:45:14 +01:00
New general Barrel open perms checker + Towny
This commit is contained in:
parent
d77d511dae
commit
4228bbc02c
8
pom.xml
8
pom.xml
@ -89,7 +89,7 @@
|
|||||||
<url>http://maven.sk89q.com/repo/</url>
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<!-- GriefPrevention, SlimeFun -->
|
<!-- GriefPrevention, SlimeFun, Towny -->
|
||||||
<id>jitpack.io</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
@ -233,6 +233,12 @@
|
|||||||
<version>3.11</version>
|
<version>3.11</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TownyAdvanced</groupId>
|
||||||
|
<artifactId>Towny</artifactId>
|
||||||
|
<version>0.96.3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
@ -426,9 +426,14 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
useCitadel: true
|
useCitadel: true
|
||||||
|
|
||||||
|
# Beim öffnen eine virtuelle Kiste nutzen um Rechte bei alle anderen Plugins abzufragen
|
||||||
|
# Könnte Anti-Cheat plugins verwirren aber sonst ok zu aktivieren
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Änderungen an Fassinventaren mit LogBlock aufzeichen [true]
|
# Änderungen an Fassinventaren mit LogBlock aufzeichen [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -428,9 +428,14 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
useCitadel: true
|
useCitadel: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Enable the Logging of Barrel Inventories to LogBlock [true]
|
# Enable the Logging of Barrel Inventories to LogBlock [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -423,9 +423,14 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
useCitadel: true
|
useCitadel: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Activer l'historique du contenu des tonneaux avec LogBlock [true]
|
# Activer l'historique du contenu des tonneaux avec LogBlock [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -415,9 +415,14 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
useCitadel: true
|
useCitadel: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Abilita il logging degli inventari dei barili [true]
|
# Abilita il logging degli inventari dei barili [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -786,8 +786,14 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
|
|
||||||
|
# Beim Fass öffnen eine virtuelle Kiste nutzen um Rechte bei alle anderen Plugins abzufragen
|
||||||
|
# Könnte Anti-Cheat plugins verwirren aber sonst ok zu aktivieren
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
|
|
||||||
# Änderungen an Fassinventaren mit LogBlock aufzeichen [true]
|
# Änderungen an Fassinventaren mit LogBlock aufzeichen [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -780,8 +780,13 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Enable the Logging of Barrel Inventories to LogBlock [true]
|
# Enable the Logging of Barrel Inventories to LogBlock [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -780,8 +780,13 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Enable the Logging of Barrel Inventories to LogBlock [true]
|
# Enable the Logging of Barrel Inventories to LogBlock [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -786,8 +786,13 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Activer l'historique du contenu des tonneaux avec LogBlock [true]
|
# Activer l'historique du contenu des tonneaux avec LogBlock [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -780,8 +780,13 @@ eggnog:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# Abilita il logging degli inventari dei barili [true]
|
# Abilita il logging degli inventari dei barili [true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -784,8 +784,13 @@ recipes:
|
|||||||
useWorldGuard: true
|
useWorldGuard: true
|
||||||
useLWC: true
|
useLWC: true
|
||||||
useGriefPrevention: true
|
useGriefPrevention: true
|
||||||
|
useTowny: true
|
||||||
useGMInventories: true
|
useGMInventories: true
|
||||||
|
|
||||||
|
# Use a virtual chest when opening a Barrel to check with all other protection plugins
|
||||||
|
# This could confuse Anti-Cheat plugins, but is otherwise good to use
|
||||||
|
useVirtualChestPerms: false
|
||||||
|
|
||||||
# 对LogBlock启用方块数据录入[true]
|
# 对LogBlock启用方块数据录入[true]
|
||||||
useLogBlock: true
|
useLogBlock: true
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Brewery
|
name: Brewery
|
||||||
version: 2.1.2
|
version: 2.1.2
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Towny]
|
||||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
|
@ -176,7 +176,9 @@ public class BDistiller {
|
|||||||
if (now instanceof BrewingStand) {
|
if (now instanceof BrewingStand) {
|
||||||
BrewingStand stand = (BrewingStand) now;
|
BrewingStand stand = (BrewingStand) now;
|
||||||
if (brewTime == -1) { // only check at the beginning (and end) for distillables
|
if (brewTime == -1) { // only check at the beginning (and end) for distillables
|
||||||
prepareForDistillables(stand);
|
if (!prepareForDistillables(stand)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
brewTime--; // count down.
|
brewTime--; // count down.
|
||||||
@ -204,7 +206,7 @@ public class BDistiller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareForDistillables(BrewingStand stand) {
|
private boolean prepareForDistillables(BrewingStand stand) {
|
||||||
BrewerInventory inventory = stand.getInventory();
|
BrewerInventory inventory = stand.getInventory();
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
contents = getDistillContents(inventory);
|
contents = getDistillContents(inventory);
|
||||||
@ -234,13 +236,14 @@ public class BDistiller {
|
|||||||
trackedDistillers.remove(standBlock);
|
trackedDistillers.remove(standBlock);
|
||||||
showAlc(inventory, contents);
|
showAlc(inventory, contents);
|
||||||
P.p.debugLog("nothing to distill");
|
P.p.debugLog("nothing to distill");
|
||||||
return;
|
return false;
|
||||||
default:
|
default:
|
||||||
runTime = getLongestDistillTime(contents);
|
runTime = getLongestDistillTime(contents);
|
||||||
brewTime = runTime;
|
brewTime = runTime;
|
||||||
P.p.debugLog("using brewtime: " + runTime);
|
P.p.debugLog("using brewtime: " + runTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Call event
|
// Call event
|
||||||
BarrelAccessEvent accessEvent = new BarrelAccessEvent(this, player, event.getClickedBlock());
|
BarrelAccessEvent accessEvent = new BarrelAccessEvent(this, player, event.getClickedBlock(), event.getBlockFace());
|
||||||
// Listened to by WGBarrel7, WGBarrelNew, WGBarrelOld, GriefPreventionBarrel (IntegrationListener)
|
// Listened to by WGBarrel7, WGBarrelNew, WGBarrelOld, GriefPreventionBarrel (IntegrationListener)
|
||||||
P.p.getServer().getPluginManager().callEvent(accessEvent);
|
P.p.getServer().getPluginManager().callEvent(accessEvent);
|
||||||
if (accessEvent.isCancelled()) {
|
if (accessEvent.isCancelled()) {
|
||||||
|
@ -2,6 +2,7 @@ package com.dre.brewery.api.events.barrel;
|
|||||||
|
|
||||||
import com.dre.brewery.Barrel;
|
import com.dre.brewery.Barrel;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@ -16,12 +17,18 @@ public class BarrelAccessEvent extends BarrelEvent implements Cancellable {
|
|||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Block clickedBlock;
|
private final Block clickedBlock;
|
||||||
|
private final BlockFace clickedBlockFace;
|
||||||
private boolean isCancelled;
|
private boolean isCancelled;
|
||||||
|
|
||||||
public BarrelAccessEvent(Barrel barrel, Player player, Block clickedBlock) {
|
public BarrelAccessEvent(Barrel barrel, Player player, Block clickedBlock) {
|
||||||
|
this(barrel, player, clickedBlock, BlockFace.UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BarrelAccessEvent(Barrel barrel, Player player, Block clickedBlock, BlockFace clickedBlockFace) {
|
||||||
super(barrel);
|
super(barrel);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.clickedBlock = clickedBlock;
|
this.clickedBlock = clickedBlock;
|
||||||
|
this.clickedBlockFace = clickedBlockFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +39,13 @@ public class BarrelAccessEvent extends BarrelEvent implements Cancellable {
|
|||||||
return clickedBlock;
|
return clickedBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the clicked Block Face when clicking on the Barrel Block
|
||||||
|
*/
|
||||||
|
public BlockFace getClickedBlockFace() {
|
||||||
|
return clickedBlockFace;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return isCancelled;
|
||||||
|
@ -49,6 +49,7 @@ public class BConfig {
|
|||||||
public static boolean useLWC; //LWC
|
public static boolean useLWC; //LWC
|
||||||
public static boolean useLB; //LogBlock
|
public static boolean useLB; //LogBlock
|
||||||
public static boolean useGP; //GriefPrevention
|
public static boolean useGP; //GriefPrevention
|
||||||
|
public static boolean useTowny; //Towny
|
||||||
public static boolean hasVault; // Vault
|
public static boolean hasVault; // Vault
|
||||||
public static boolean useCitadel; // CivCraft/DevotedMC Citadel
|
public static boolean useCitadel; // CivCraft/DevotedMC Citadel
|
||||||
public static boolean useGMInventories; // GamemodeInventories
|
public static boolean useGMInventories; // GamemodeInventories
|
||||||
@ -59,6 +60,7 @@ public class BConfig {
|
|||||||
// Barrel
|
// Barrel
|
||||||
public static boolean openEverywhere;
|
public static boolean openEverywhere;
|
||||||
public static boolean loadDataAsync;
|
public static boolean loadDataAsync;
|
||||||
|
public static boolean virtualChestPerms;
|
||||||
|
|
||||||
// Cauldron
|
// Cauldron
|
||||||
public static boolean useOffhandForCauldron;
|
public static boolean useOffhandForCauldron;
|
||||||
@ -212,10 +214,12 @@ public class BConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
useLWC = config.getBoolean("useLWC", true) && plMan.isPluginEnabled("LWC");
|
useLWC = config.getBoolean("useLWC", true) && plMan.isPluginEnabled("LWC");
|
||||||
|
useTowny = config.getBoolean("useTowny", true) && plMan.isPluginEnabled("Towny");
|
||||||
useGP = config.getBoolean("useGriefPrevention", true) && plMan.isPluginEnabled("GriefPrevention");
|
useGP = config.getBoolean("useGriefPrevention", true) && plMan.isPluginEnabled("GriefPrevention");
|
||||||
useLB = config.getBoolean("useLogBlock", false) && plMan.isPluginEnabled("LogBlock");
|
useLB = config.getBoolean("useLogBlock", false) && plMan.isPluginEnabled("LogBlock");
|
||||||
useGMInventories = config.getBoolean("useGMInventories", false);
|
useGMInventories = config.getBoolean("useGMInventories", false);
|
||||||
useCitadel = config.getBoolean("useCitadel", false) && plMan.isPluginEnabled("Citadel");
|
useCitadel = config.getBoolean("useCitadel", false) && plMan.isPluginEnabled("Citadel");
|
||||||
|
virtualChestPerms = config.getBoolean("useVirtualChestPerms", false);
|
||||||
// The item util has been removed in Vault 1.7+
|
// The item util has been removed in Vault 1.7+
|
||||||
hasVault = plMan.isPluginEnabled("Vault")
|
hasVault = plMan.isPluginEnabled("Vault")
|
||||||
&& Integer.parseInt(plMan.getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
|
&& Integer.parseInt(plMan.getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
|
||||||
|
@ -9,6 +9,7 @@ import com.dre.brewery.filedata.BConfig;
|
|||||||
import com.dre.brewery.integration.barrel.GriefPreventionBarrel;
|
import com.dre.brewery.integration.barrel.GriefPreventionBarrel;
|
||||||
import com.dre.brewery.integration.barrel.LWCBarrel;
|
import com.dre.brewery.integration.barrel.LWCBarrel;
|
||||||
import com.dre.brewery.integration.barrel.LogBlockBarrel;
|
import com.dre.brewery.integration.barrel.LogBlockBarrel;
|
||||||
|
import com.dre.brewery.integration.barrel.TownyBarrel;
|
||||||
import com.dre.brewery.integration.item.MMOItemsPluginItem;
|
import com.dre.brewery.integration.item.MMOItemsPluginItem;
|
||||||
import com.dre.brewery.recipe.BCauldronRecipe;
|
import com.dre.brewery.recipe.BCauldronRecipe;
|
||||||
import com.dre.brewery.recipe.RecipeItem;
|
import com.dre.brewery.recipe.RecipeItem;
|
||||||
@ -17,7 +18,9 @@ import net.mmogroup.mmolib.api.item.NBTItem;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -106,6 +109,7 @@ public class IntegrationListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,6 +128,7 @@ public class IntegrationListener implements Listener {
|
|||||||
if (!LWCBarrel.checkAccess(player, sign, plugin)) {
|
if (!LWCBarrel.checkAccess(player, sign, plugin)) {
|
||||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -137,11 +142,75 @@ public class IntegrationListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BConfig.useTowny) {
|
||||||
|
if (P.p.getServer().getPluginManager().isPluginEnabled("Towny")) {
|
||||||
|
try {
|
||||||
|
if (!TownyBarrel.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 Towny for Barrel Open Permissions!");
|
||||||
|
P.p.errorLog("Brewery was tested with Towny v0.96.3.0");
|
||||||
|
P.p.errorLog("Disable the Towny 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, "&cTowny check Error, Brewery was tested with up to v0.96.3.0 of Towny");
|
||||||
|
P.p.msg(player, "&cSet &7useTowny: false &cin the config and /brew reload");
|
||||||
|
} else {
|
||||||
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BConfig.virtualChestPerms) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
BlockState originalBlockState = event.getClickedBlock().getState();
|
||||||
|
|
||||||
|
event.getClickedBlock().setType(Material.CHEST, false);
|
||||||
|
PlayerInteractEvent simulatedEvent = new PlayerInteractEvent(
|
||||||
|
player,
|
||||||
|
Action.RIGHT_CLICK_BLOCK,
|
||||||
|
player.getInventory().getItemInMainHand(),
|
||||||
|
event.getClickedBlock(),
|
||||||
|
event.getClickedBlockFace(),
|
||||||
|
EquipmentSlot.HAND);
|
||||||
|
|
||||||
|
try {
|
||||||
|
P.p.getServer().getPluginManager().callEvent(simulatedEvent);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
P.p.errorLog("Failed to simulate a Chest for Barrel Open Permissions!");
|
||||||
|
P.p.errorLog("Disable useVirtualChestPerms in the config and do /brew reload");
|
||||||
|
e.printStackTrace();
|
||||||
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
|
P.p.msg(player, "&cVirtual Chest Error");
|
||||||
|
P.p.msg(player, "&cSet &7useVirtualChestPerms: false &cin the config and /brew reload");
|
||||||
|
} else {
|
||||||
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
event.getClickedBlock().setType(Material.AIR, false);
|
||||||
|
originalBlockState.update(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simulatedEvent.useInteractedBlock() == Event.Result.DENY) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||||
|
//return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
|
23
src/com/dre/brewery/integration/barrel/TownyBarrel.java
Normal file
23
src/com/dre/brewery/integration/barrel/TownyBarrel.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package com.dre.brewery.integration.barrel;
|
||||||
|
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.TownySettings;
|
||||||
|
import com.palmergames.bukkit.towny.object.TownyPermission;
|
||||||
|
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public class TownyBarrel {
|
||||||
|
public static boolean checkAccess(BarrelAccessEvent event) {
|
||||||
|
if (!TownySettings.isSwitchMaterial("BREWERY") && !TownySettings.isSwitchMaterial("BARREL")) {
|
||||||
|
if (P.use1_14) {
|
||||||
|
return true;
|
||||||
|
} else if (!TownySettings.isSwitchMaterial("CHEST")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Material mat = P.use1_14 ? Material.BARREL : Material.CHEST;
|
||||||
|
return PlayerCacheUtil.getCachePermission(event.getPlayer(), event.getSpigot().getLocation(), mat, TownyPermission.ActionType.SWITCH);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user