mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-10-01 04:27:34 +02:00
Option to disable Third-Party Support
Put Calls to other Plugins in try blocks
This commit is contained in:
parent
0739b67157
commit
cb773a3662
13
config.yml
13
config.yml
@ -194,6 +194,19 @@ cooked:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -- Plugin Compatibility --
|
||||||
|
|
||||||
|
# Enable checking of other Plugins (if installed) for Barrel Permissions [true]
|
||||||
|
useWorldGuard: true
|
||||||
|
useLWC: true
|
||||||
|
useGriefPrevention: true
|
||||||
|
|
||||||
|
# Enable the Logging of Barrel Inventories to LogBlock
|
||||||
|
useLogBlock: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -- Chat Distortion Settings --
|
# -- Chat Distortion Settings --
|
||||||
|
|
||||||
# Log to the Serverlog what the player actually wrote, before his words were altered [false]
|
# Log to the Serverlog what the player actually wrote, before his words were altered [false]
|
||||||
|
@ -2,7 +2,7 @@ name: Brewery
|
|||||||
version: 1.2
|
version: 1.2
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
authors: [Milan Albrecht, Frank Baumann]
|
authors: [Milan Albrecht, Frank Baumann]
|
||||||
softdepend: [LWC, LogBlock]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention]
|
||||||
commands:
|
commands:
|
||||||
brewery:
|
brewery:
|
||||||
description: Command for Administration
|
description: Command for Administration
|
||||||
|
@ -108,21 +108,41 @@ public class Barrel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
||||||
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("WorldGuard");
|
if (P.p.useWG) {
|
||||||
if (plugin != null) {
|
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
if (!WGBarrel.checkAccess(player, spigot, plugin)) {
|
if (plugin != null) {
|
||||||
return false;
|
try {
|
||||||
|
if (!WGBarrel.checkAccess(player, spigot, plugin)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Check WorldGuard for Barrel Open Permissions!");
|
||||||
|
P.p.errorLog("Brewery was tested with version 5.8 of WorldGuard!");
|
||||||
|
e.printStackTrace();
|
||||||
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (P.p.getServer().getPluginManager().isPluginEnabled("GriefPrevention")) {
|
if (P.p.useGP) {
|
||||||
if (!GriefPreventionBarrel.checkAccess(player, spigot)) {
|
if (P.p.getServer().getPluginManager().isPluginEnabled("GriefPrevention")) {
|
||||||
return false;
|
try {
|
||||||
|
if (!GriefPreventionBarrel.checkAccess(player, spigot)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
||||||
|
P.p.errorLog("Brewery only works with the latest release of GriefPrevention (7.8)");
|
||||||
|
e.printStackTrace();
|
||||||
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != null) {
|
if (event != null && P.p.useLWC) {
|
||||||
plugin = P.p.getServer().getPluginManager().getPlugin("LWC");
|
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("LWC");
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
|
||||||
// If the Clicked Block was the Sign, LWC already knows and we dont need to do anything here
|
// If the Clicked Block was the Sign, LWC already knows and we dont need to do anything here
|
||||||
@ -130,7 +150,15 @@ public class Barrel {
|
|||||||
Block sign = getSignOfSpigot();
|
Block sign = getSignOfSpigot();
|
||||||
// If the Barrel does not have a Sign, it cannot be locked
|
// If the Barrel does not have a Sign, it cannot be locked
|
||||||
if (!sign.equals(event.getClickedBlock())) {
|
if (!sign.equals(event.getClickedBlock())) {
|
||||||
return LWCBarrel.checkAccess(player, sign, event, plugin);
|
try {
|
||||||
|
return LWCBarrel.checkAccess(player, sign, event, plugin);
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
||||||
|
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!");
|
||||||
|
e.printStackTrace();
|
||||||
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,8 +173,15 @@ public class Barrel {
|
|||||||
willDestroy();
|
willDestroy();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (P.p.hasLWC) {
|
if (P.p.useLWC) {
|
||||||
return LWCBarrel.checkDestroy(player, this);
|
try {
|
||||||
|
return LWCBarrel.checkDestroy(player, this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
||||||
|
e.printStackTrace();
|
||||||
|
P.p.msg(player, "&cError breaking Barrel, please report to an Admin!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -154,8 +189,13 @@ public class Barrel {
|
|||||||
|
|
||||||
// If something other than the Player is destroying the barrel, inform protection plugins
|
// If something other than the Player is destroying the barrel, inform protection plugins
|
||||||
public void willDestroy() {
|
public void willDestroy() {
|
||||||
if (P.p.hasLWC) {
|
if (P.p.useLWC) {
|
||||||
LWCBarrel.remove(this);
|
try {
|
||||||
|
LWCBarrel.remove(this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Remove LWC Lock from Barrel!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +234,14 @@ public class Barrel {
|
|||||||
// reset barreltime, potions have new age
|
// reset barreltime, potions have new age
|
||||||
time = 0;
|
time = 0;
|
||||||
|
|
||||||
if (P.p.hasLB) {
|
if (P.p.useLB) {
|
||||||
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
try {
|
||||||
|
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
||||||
|
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
@ -369,8 +415,14 @@ public class Barrel {
|
|||||||
human.closeInventory();
|
human.closeInventory();
|
||||||
}
|
}
|
||||||
ItemStack[] items = inventory.getContents();
|
ItemStack[] items = inventory.getContents();
|
||||||
if (P.p.hasLB && breaker != null) {
|
if (P.p.useLB && breaker != null) {
|
||||||
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
|
try {
|
||||||
|
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
|
||||||
|
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
@ -279,6 +279,39 @@ public class ConfigUpdater {
|
|||||||
} else {
|
} else {
|
||||||
addLines(index, lines);
|
addLines(index, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Plugin Support Settings
|
||||||
|
lines = new String[] {
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"# -- Plugin Kompatiblität --",
|
||||||
|
"",
|
||||||
|
"# Andere Plugins (wenn installiert) nach Rechten zum öffnen von Fässern checken [true]",
|
||||||
|
"useWorldGuard: true",
|
||||||
|
"useLWC: true",
|
||||||
|
"useGriefPrevention: true",
|
||||||
|
"",
|
||||||
|
"# Änderungen an Fassinventaren mit LogBlock aufzeichen",
|
||||||
|
"useLogBlock: true",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
};
|
||||||
|
index = indexOfStart("# -- Chat Veränderungs Einstellungen");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("# words");
|
||||||
|
}
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("distortCommands");
|
||||||
|
if (index > 4) {
|
||||||
|
index -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index != -1) {
|
||||||
|
addLines(index, lines);
|
||||||
|
} else {
|
||||||
|
appendLines(lines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates en from 1.1 to 1.2
|
// Updates en from 1.1 to 1.2
|
||||||
@ -311,6 +344,39 @@ public class ConfigUpdater {
|
|||||||
} else {
|
} else {
|
||||||
addLines(index, lines);
|
addLines(index, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Plugin Support Settings
|
||||||
|
lines = new String[] {
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"# -- Plugin Compatibility --",
|
||||||
|
"",
|
||||||
|
"# Enable checking of other Plugins (if installed) for Barrel Permissions [true]",
|
||||||
|
"useWorldGuard: true",
|
||||||
|
"useLWC: true",
|
||||||
|
"useGriefPrevention: true",
|
||||||
|
"",
|
||||||
|
"# Enable the Logging of Barrel Inventories to LogBlock",
|
||||||
|
"useLogBlock: true",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
};
|
||||||
|
index = indexOfStart("# -- Chat Distortion Settings");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("# words");
|
||||||
|
}
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("distortCommands");
|
||||||
|
if (index > 4) {
|
||||||
|
index -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index != -1) {
|
||||||
|
addLines(index, lines);
|
||||||
|
} else {
|
||||||
|
appendLines(lines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.util.ListIterator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -36,8 +37,10 @@ public class P extends JavaPlugin {
|
|||||||
public static int autosave = 3;
|
public static int autosave = 3;
|
||||||
|
|
||||||
// Third Party Enabled
|
// Third Party Enabled
|
||||||
public boolean hasLWC;
|
public boolean useWG; //WorldGuard
|
||||||
public boolean hasLB;
|
public boolean useLWC; //LWC
|
||||||
|
public boolean useLB; //LogBlock
|
||||||
|
public boolean useGP; //GriefPrevention
|
||||||
|
|
||||||
// Listeners
|
// Listeners
|
||||||
public BlockListener blockListener;
|
public BlockListener blockListener;
|
||||||
@ -125,8 +128,12 @@ public class P extends JavaPlugin {
|
|||||||
BIngredients.cookedNames.clear();
|
BIngredients.cookedNames.clear();
|
||||||
Words.words.clear();
|
Words.words.clear();
|
||||||
BPlayer.drainItems.clear();
|
BPlayer.drainItems.clear();
|
||||||
if (hasLB) {
|
if (useLB) {
|
||||||
LogBlockBarrel.clear();
|
try {
|
||||||
|
LogBlockBarrel.clear();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the Config
|
// load the Config
|
||||||
@ -163,14 +170,10 @@ public class P extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void errorLog(String msg) {
|
public void errorLog(String msg) {
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "[Brewery] " + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
|
Bukkit.getLogger().log(Level.SEVERE, ChatColor.DARK_GREEN + "[Brewery] " + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readConfig() {
|
public void readConfig() {
|
||||||
// Check Third Party
|
|
||||||
hasLWC = getServer().getPluginManager().isPluginEnabled("LWC");
|
|
||||||
hasLB = getServer().getPluginManager().isPluginEnabled("LogBlock");
|
|
||||||
|
|
||||||
File file = new File(p.getDataFolder(), "config.yml");
|
File file = new File(p.getDataFolder(), "config.yml");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
@ -194,6 +197,12 @@ public class P extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Third-Party
|
||||||
|
useWG = config.getBoolean("useWorldGuard", true) && getServer().getPluginManager().isPluginEnabled("WorldGuard");
|
||||||
|
useLWC = config.getBoolean("useLWC", true) && getServer().getPluginManager().isPluginEnabled("LWC");
|
||||||
|
useGP = config.getBoolean("useGriefPrevention", true) && getServer().getPluginManager().isPluginEnabled("GriefPrevention");
|
||||||
|
useLB = config.getBoolean("useLogBlock", false) && getServer().getPluginManager().isPluginEnabled("LogBlock");
|
||||||
|
|
||||||
// various Settings
|
// various Settings
|
||||||
autosave = config.getInt("autosave", 3);
|
autosave = config.getInt("autosave", 3);
|
||||||
debug = config.getBoolean("debug", false);
|
debug = config.getBoolean("debug", false);
|
||||||
|
@ -58,10 +58,16 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (!removedBarrel) {
|
if (!removedBarrel) {
|
||||||
if (barrel != null) {
|
if (barrel != null) {
|
||||||
if (P.p.hasLWC) {
|
if (P.p.useLWC) {
|
||||||
if (LWCBarrel.blockExplosion(barrel, block)) {
|
try {
|
||||||
iter.remove();
|
if (LWCBarrel.blockExplosion(barrel, block)) {
|
||||||
} else {
|
iter.remove();
|
||||||
|
} else {
|
||||||
|
removedBarrel = true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Check LWC on Barrel Explosion!");
|
||||||
|
e.printStackTrace();
|
||||||
removedBarrel = true;
|
removedBarrel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,10 +95,16 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClose(InventoryCloseEvent event) {
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
if (P.p.hasLB) {
|
if (P.p.useLB) {
|
||||||
if (event.getInventory().getType() == InventoryType.CHEST) {
|
if (event.getInventory().getType() == InventoryType.CHEST) {
|
||||||
if (event.getInventory().getTitle().equals(P.p.languageReader.get("Etc_Barrel"))) {
|
if (event.getInventory().getTitle().equals(P.p.languageReader.get("Etc_Barrel"))) {
|
||||||
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
try {
|
||||||
|
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
||||||
|
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user