mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 06:38:56 +00:00
Merge branch '1.13' of https://github.com/Sataniel98/Brewery into Sataniel98-1.13
This commit is contained in:
+30
-46
@@ -3,6 +3,7 @@ package com.dre.brewery;
|
||||
import com.dre.brewery.filedata.*;
|
||||
import com.dre.brewery.integration.LogBlockBarrel;
|
||||
import com.dre.brewery.integration.WGBarrel;
|
||||
import com.dre.brewery.integration.WGBarrel7;
|
||||
import com.dre.brewery.integration.WGBarrelNew;
|
||||
import com.dre.brewery.integration.WGBarrelOld;
|
||||
import com.dre.brewery.listeners.*;
|
||||
@@ -18,6 +19,7 @@ import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -31,15 +33,17 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class P extends JavaPlugin {
|
||||
public static P p;
|
||||
public static final String configVersion = "1.5";
|
||||
public static final String configVersion = "1.6";
|
||||
public static boolean debug;
|
||||
public static boolean useUUID;
|
||||
public static boolean use1_9;
|
||||
public static boolean use1_12;
|
||||
public static boolean use1_13;
|
||||
public static boolean updateCheck;
|
||||
|
||||
// Third Party Enabled
|
||||
@@ -73,6 +77,7 @@ public class P extends JavaPlugin {
|
||||
useUUID = !v.matches("(^|.*[^\\.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.7\\.[0-5]([^\\d].*|$)");
|
||||
use1_9 = !v.matches("(^|.*[^\\.\\d])1\\.[0-8]([^\\d].*|$)");
|
||||
use1_12 = !v.matches("(^|.*[^\\.\\d])1\\.[0-11]([^\\d].*|$)");
|
||||
use1_13 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||
|
||||
// load the Config
|
||||
try {
|
||||
@@ -90,7 +95,7 @@ public class P extends JavaPlugin {
|
||||
readData();
|
||||
|
||||
// Setup Metrics
|
||||
setupMetrics();
|
||||
new Metrics(this);
|
||||
|
||||
// Listeners
|
||||
blockListener = new BlockListener();
|
||||
@@ -155,13 +160,6 @@ public class P extends JavaPlugin {
|
||||
this.log(this.getDescription().getName() + " disabled!");
|
||||
}
|
||||
|
||||
public void setupMetrics() {
|
||||
try {
|
||||
new com.dre.brewery.integration.Metrics(this).start();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public void reload(CommandSender sender) {
|
||||
if (sender != null && !sender.equals(getServer().getConsoleSender())) {
|
||||
reloader = sender;
|
||||
@@ -264,27 +262,26 @@ public class P extends JavaPlugin {
|
||||
// Third-Party
|
||||
useWG = config.getBoolean("useWorldGuard", true) && getServer().getPluginManager().isPluginEnabled("WorldGuard");
|
||||
if (useWG) {
|
||||
try {
|
||||
try {
|
||||
Class.forName("com.sk89q.worldguard.bukkit.RegionContainer");
|
||||
wg = new WGBarrelNew();
|
||||
} catch (ClassNotFoundException e) {
|
||||
wg = new WGBarrelOld();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
wg = null;
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
if (plugin != null) {
|
||||
String wgv = plugin.getDescription().getVersion();
|
||||
if (wgv.startsWith("7.")) wg = new WGBarrel7();
|
||||
else if (wgv.startsWith("6.")) wg = new WGBarrelNew();
|
||||
else if (wgv.startsWith("5.")) wg = new WGBarrelOld();
|
||||
}
|
||||
if (wg == null) {
|
||||
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
||||
P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
|
||||
P.p.errorLog("Brewery was tested with version 5.8, 6.1 and 7.0 of WorldGuard!");
|
||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
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");
|
||||
hasVault = getServer().getPluginManager().isPluginEnabled("Vault");
|
||||
|
||||
useCitadel = config.getBoolean("useCitadel", false) && getServer().getPluginManager().isPluginEnabled("Citadel");
|
||||
// The item util has been removed in Vault 1.7+
|
||||
hasVault = getServer().getPluginManager().isPluginEnabled("Vault")
|
||||
&& Integer.parseInt(getServer().getPluginManager().getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
|
||||
|
||||
// various Settings
|
||||
DataSave.autosave = config.getInt("autosave", 3);
|
||||
@@ -609,7 +606,7 @@ public class P extends JavaPlugin {
|
||||
if (!cfg.exists()) {
|
||||
errorLog("No config.yml found, creating default file! You may want to choose a config according to your language!");
|
||||
errorLog("You can find them in plugins/Brewery/configs/");
|
||||
InputStream defconf = getResource("config/en/config.yml");
|
||||
InputStream defconf = getResource("config/" + (use1_13 ? "v13/" : "v12/") + "en/config.yml");
|
||||
if (defconf == null) {
|
||||
errorLog("default config file not found, your jarfile may be corrupt. Disabling Brewery!");
|
||||
return false;
|
||||
@@ -636,7 +633,7 @@ public class P extends JavaPlugin {
|
||||
for (String l : new String[] {"de", "en", "fr", "it"}) {
|
||||
File lfold = new File(configs, l);
|
||||
try {
|
||||
saveFile(getResource("config/" + l + "/config.yml"), lfold, "config.yml", overwrite);
|
||||
saveFile(getResource("config/" + (use1_13 ? "v13/" : "v12/") + l + "/config.yml"), lfold, "config.yml", overwrite);
|
||||
saveFile(getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages for now
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -700,19 +697,13 @@ public class P extends JavaPlugin {
|
||||
|
||||
// Returns true if the Block can be destroyed by the Player or something else (null)
|
||||
public boolean blockDestroy(Block block, Player player) {
|
||||
switch (block.getType()) {
|
||||
case CAULDRON:
|
||||
Material type = block.getType();
|
||||
if (type == Material.CAULDRON) {
|
||||
// will only remove when existing
|
||||
BCauldron.remove(block);
|
||||
return true;
|
||||
case FENCE:
|
||||
case NETHER_FENCE:
|
||||
case ACACIA_FENCE:
|
||||
case BIRCH_FENCE:
|
||||
case DARK_OAK_FENCE:
|
||||
case IRON_FENCE:
|
||||
case JUNGLE_FENCE:
|
||||
case SPRUCE_FENCE:
|
||||
|
||||
} else if (LegacyUtil.isFence(type)) {
|
||||
// remove barrel and throw potions on the ground
|
||||
Barrel barrel = Barrel.getBySpigot(block);
|
||||
if (barrel != null) {
|
||||
@@ -724,8 +715,8 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
|
||||
} else if (LegacyUtil.isSign(type)) {
|
||||
// remove small Barrels
|
||||
Barrel barrel2 = Barrel.getBySpigot(block);
|
||||
if (barrel2 != null) {
|
||||
@@ -741,13 +732,8 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case WOOD:
|
||||
case WOOD_STAIRS:
|
||||
case BIRCH_WOOD_STAIRS:
|
||||
case JUNGLE_WOOD_STAIRS:
|
||||
case SPRUCE_WOOD_STAIRS:
|
||||
case ACACIA_STAIRS:
|
||||
case DARK_OAK_STAIRS:
|
||||
|
||||
} else if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)){
|
||||
Barrel barrel3 = Barrel.getByWood(block);
|
||||
if (barrel3 != null) {
|
||||
if (barrel3.hasPermsDestroy(player)) {
|
||||
@@ -756,9 +742,7 @@ public class P extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user