From 951fb18dc9ec660792f45ac823718a2afd043796 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sun, 28 Jan 2018 20:48:27 +0100 Subject: [PATCH 01/20] Replace old materials with dynamic calls --- pom.xml | 4 +-- src/com/dre/brewery/BCauldron.java | 2 +- src/com/dre/brewery/BRecipe.java | 2 +- src/com/dre/brewery/Barrel.java | 33 ++++++++----------- src/com/dre/brewery/LegacyUtil.java | 19 +++++++++++ src/com/dre/brewery/P.java | 2 ++ .../dre/brewery/listeners/PlayerListener.java | 8 ++--- 7 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 src/com/dre/brewery/LegacyUtil.java diff --git a/pom.xml b/pom.xml index 38637bc..d93b253 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ md_5-releases - http://repo.md-5.net/content/repositories/releases/ + http://repo.mvdw-software.be/content/groups/public/http://repo.md-5.net/content/repositories/releases/<--> spigot-repo @@ -74,7 +74,7 @@ org.bukkit bukkit - 1.10.2-R0.1-SNAPSHOT + 18w03b-R0.1-SNAPSHOT1.12.2<--> provided diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java index 03421ce..5d985b0 100644 --- a/src/com/dre/brewery/BCauldron.java +++ b/src/com/dre/brewery/BCauldron.java @@ -36,7 +36,7 @@ public class BCauldron { public void onUpdate() { // Check if fire still alive - if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_LAVA + if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == LegacyUtil.LAVA || block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) { // add a minute to cooking time state++; diff --git a/src/com/dre/brewery/BRecipe.java b/src/com/dre/brewery/BRecipe.java index 22830f3..836acfd 100644 --- a/src/com/dre/brewery/BRecipe.java +++ b/src/com/dre/brewery/BRecipe.java @@ -64,7 +64,7 @@ public class BRecipe { if (durability == -1 && vaultItem.getSubTypeId() != 0) { durability = vaultItem.getSubTypeId(); } - if (mat == Material.LEAVES) { + if (mat.name().contains("LEAVES")) { if (durability > 3) { durability -= 4; // Vault has leaves with higher durability } diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java index ae73bb1..5407867 100644 --- a/src/com/dre/brewery/Barrel.java +++ b/src/com/dre/brewery/Barrel.java @@ -161,7 +161,7 @@ public class Barrel implements InventoryHolder { if (plugin != null) { // If the Clicked Block was the Sign, LWC already knows and we dont need to do anything here - if (!isSign(event.getClickedBlock())) { + if (!LegacyUtil.isSign(event.getClickedBlock().getType())) { Block sign = getSignOfSpigot(); // If the Barrel does not have a Sign, it cannot be locked if (!sign.equals(event.getClickedBlock())) { @@ -272,7 +272,7 @@ public class Barrel implements InventoryHolder { // Returns true if this Block is part of this Barrel public boolean hasBlock(Block block) { if (block != null) { - if (block.getType().equals(Material.WOOD)) { + if (LegacyUtil.isWoodPlanks(block.getType())) { if (hasWoodBlock(block)) { return true; } @@ -398,7 +398,7 @@ public class Barrel implements InventoryHolder { // Get the barrel by its corpus (Wood Planks, Stairs) public static Barrel getByWood(Block wood) { - if (wood.getType().equals(Material.WOOD)) { + if (LegacyUtil.isWoodPlanks(wood.getType())) { for (Barrel barrel : barrels) { if (barrel.hasWoodBlock(wood)) { return barrel; @@ -427,7 +427,7 @@ public class Barrel implements InventoryHolder { if (barrel == null) { barrel = new Barrel(spigot, signoffset); if (barrel.getBrokenBlock(true) == null) { - if (isSign(spigot)) { + if (LegacyUtil.isSign(spigot.getType())) { if (!player.hasPermission("brewery.createbarrel.small")) { P.p.msg(player, P.p.languageReader.get("Perms_NoSmallBarrelCreate")); return false; @@ -582,11 +582,11 @@ public class Barrel implements InventoryHolder { public static int getDirection(Block spigot) { int direction = 0;// 1=x+ 2=x- 3=z+ 4=z- Material type = spigot.getRelative(0, 0, 1).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { direction = 3; } type = spigot.getRelative(0, 0, -1).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { if (direction == 0) { direction = 4; } else { @@ -594,7 +594,7 @@ public class Barrel implements InventoryHolder { } } type = spigot.getRelative(1, 0, 0).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { if (direction == 0) { direction = 1; } else { @@ -602,7 +602,7 @@ public class Barrel implements InventoryHolder { } } type = spigot.getRelative(-1, 0, 0).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { if (direction == 0) { direction = 2; } else { @@ -614,12 +614,7 @@ public class Barrel implements InventoryHolder { // is this a Large barrel? public boolean isLarge() { - return !isSign(spigot); - } - - // true for small barrels - public static boolean isSign(Block spigot) { - return spigot.getType() == Material.WALL_SIGN || spigot.getType() == Material.SIGN_POST; + return !LegacyUtil.isSign(spigot.getType()); } // woodtype of the block the spigot is attached to @@ -695,11 +690,11 @@ public class Barrel implements InventoryHolder { // returns the Sign of a large barrel, the spigot if there is none public Block getSignOfSpigot() { if (signoffset != 0) { - if (isSign(spigot)) { + if (LegacyUtil.isSign(spigot.getType())) { return spigot; } - if (isSign(spigot.getRelative(0, signoffset, 0))) { + if (LegacyUtil.isSign(spigot.getRelative(0, signoffset, 0).getType())) { return spigot.getRelative(0, signoffset, 0); } else { signoffset = 0; @@ -759,7 +754,7 @@ public class Barrel implements InventoryHolder { public Block getBrokenBlock(boolean force) { if (force || spigot.getChunk().isLoaded()) { spigot = getSpigotOfSign(spigot); - if (isSign(spigot)) { + if (LegacyUtil.isSign(spigot.getType())) { return checkSBarrel(); } else { return checkLBarrel(); @@ -906,8 +901,8 @@ public class Barrel implements InventoryHolder { continue; } } - if (type == Material.WOOD || isStairs(type)) { - if (type == Material.WOOD) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type)) { woods.add(block.getX()); woods.add(block.getY()); woods.add(block.getZ()); diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java new file mode 100644 index 0000000..b82b5c4 --- /dev/null +++ b/src/com/dre/brewery/LegacyUtil.java @@ -0,0 +1,19 @@ +package com.dre.brewery; + +import org.bukkit.Material; + +public class LegacyUtil { + + public static final Material FLOWING_LAVA = Material.valueOf(P.use1_13 ? "FLOWING_LAVA" : "LAVA"); + public static final Material LAVA = Material.valueOf(P.use1_13 ? "LAVA" : "STATIONARY_LAVA"); + public static final Material CLOCK = Material.valueOf(P.use1_13 ? "CLOCK" : "WATCH"); + + public static boolean isWoodPlanks(Material type) { + return type.name().contains("PLANKS") || type.name().equals("WOOD"); + } + + public static boolean isSign(Material type) { + return type.name().equals("LEGACY_SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; + } + +} diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index 45df16c..d8cf2ab 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -39,6 +39,7 @@ public class P extends JavaPlugin { public static boolean debug; public static boolean useUUID; public static boolean use1_9; + public static boolean use1_13; public static boolean updateCheck; // Third Party Enabled @@ -70,6 +71,7 @@ public class P extends JavaPlugin { String v = Bukkit.getBukkitVersion(); 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_13 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)"); // load the Config try { diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java index abf6911..f62c1c2 100644 --- a/src/com/dre/brewery/listeners/PlayerListener.java +++ b/src/com/dre/brewery/listeners/PlayerListener.java @@ -42,7 +42,7 @@ public class PlayerListener implements Listener { if (materialInHand == null || materialInHand == Material.BUCKET) { return; - } else if (materialInHand == Material.WATCH) { + } else if (materialInHand == LegacyUtil.CLOCK) { BCauldron.printTime(player, clickedBlock); return; @@ -78,7 +78,7 @@ public class PlayerListener implements Listener { // Check if fire alive below cauldron when adding ingredients Block down = clickedBlock.getRelative(BlockFace.DOWN); - if (down.getType() == Material.FIRE || down.getType() == Material.STATIONARY_LAVA || down.getType() == Material.LAVA) { + if (down.getType() == Material.FIRE || down.getType() == LegacyUtil.LAVA || down.getType() == LegacyUtil.FLOWING_LAVA) { event.setCancelled(true); boolean handSwap = false; @@ -147,7 +147,7 @@ public class PlayerListener implements Listener { // Access a Barrel Barrel barrel = null; - if (type == Material.WOOD) { + if (LegacyUtil.isWoodPlanks(type)) { if (openEverywhere) { barrel = Barrel.get(clickedBlock); } @@ -160,7 +160,7 @@ public class PlayerListener implements Listener { break; } } - } else if (Barrel.isFence(type) || type == Material.SIGN_POST || type == Material.WALL_SIGN) { + } else if (Barrel.isFence(type) || LegacyUtil.isSign(type)) { barrel = Barrel.getBySpigot(clickedBlock); } From 00341a814d12bdb7c29df33332e5eb38494916c5 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 10 Mar 2018 17:04:23 +0100 Subject: [PATCH 02/20] Rewrite Material switch statements to allow dynamic calls --- pom.xml | 2 +- src/com/dre/brewery/Barrel.java | 155 +++++++++------------------- src/com/dre/brewery/LegacyUtil.java | 39 ++++++- src/com/dre/brewery/P.java | 31 ++---- 4 files changed, 93 insertions(+), 134 deletions(-) diff --git a/pom.xml b/pom.xml index d93b253..d83fc69 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.dre brewery - 1.5 + 1.6-SNAPSHOT Brewery diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java index 5407867..e32aa6e 100644 --- a/src/com/dre/brewery/Barrel.java +++ b/src/com/dre/brewery/Barrel.java @@ -276,7 +276,7 @@ public class Barrel implements InventoryHolder { if (hasWoodBlock(block)) { return true; } - } else if (isStairs(block.getType())) { + } else if (LegacyUtil.isWoodStairs(block.getType())) { if (hasStairsBlock(block)) { return true; } @@ -337,37 +337,14 @@ public class Barrel implements InventoryHolder { // Get the Barrel by Block, null if that block is not part of a barrel public static Barrel get(Block block) { - if (block != null) { - switch (block.getType()) { - case FENCE: - case NETHER_FENCE: - case SIGN_POST: - case WALL_SIGN: - case ACACIA_FENCE: - case BIRCH_FENCE: - case DARK_OAK_FENCE: - case IRON_FENCE: - case JUNGLE_FENCE: - case SPRUCE_FENCE: - Barrel barrel = getBySpigot(block); - if (barrel != null) { - return barrel; - } - return null; - case WOOD: - case WOOD_STAIRS: - case BIRCH_WOOD_STAIRS: - case JUNGLE_WOOD_STAIRS: - case SPRUCE_WOOD_STAIRS: - case ACACIA_STAIRS: - case DARK_OAK_STAIRS: - Barrel barrel2 = getByWood(block); - if (barrel2 != null) { - return barrel2; - } - default: - break; - } + if (block == null) { + return null; + } + Material type = block.getType(); + if (LegacyUtil.isFence(type) || LegacyUtil.isSign(type) ) { + return getBySpigot(block); + } else if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)) { + return getByWood(block); } return null; } @@ -404,7 +381,7 @@ public class Barrel implements InventoryHolder { return barrel; } } - } else if (isStairs(wood.getType())) { + } else if (LegacyUtil.isWoodStairs(wood.getType())) { for (Barrel barrel : Barrel.barrels) { if (barrel.hasStairsBlock(wood)) { return barrel; @@ -582,11 +559,11 @@ public class Barrel implements InventoryHolder { public static int getDirection(Block spigot) { int direction = 0;// 1=x+ 2=x- 3=z+ 4=z- Material type = spigot.getRelative(0, 0, 1).getType(); - if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)) { direction = 3; } type = spigot.getRelative(0, 0, -1).getType(); - if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)) { if (direction == 0) { direction = 4; } else { @@ -594,7 +571,7 @@ public class Barrel implements InventoryHolder { } } type = spigot.getRelative(1, 0, 0).getType(); - if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)) { if (direction == 0) { direction = 1; } else { @@ -602,7 +579,7 @@ public class Barrel implements InventoryHolder { } } type = spigot.getRelative(-1, 0, 0).getType(); - if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)) { if (direction == 0) { direction = 2; } else { @@ -635,54 +612,48 @@ public class Barrel implements InventoryHolder { default: wood = spigot.getRelative(0, 0, -1); } - try { - switch (wood.getType()) { - case WOOD: - MaterialData data = wood.getState().getData(); - TreeSpecies woodType; - if (data instanceof Tree) { - woodType = ((Tree) data).getSpecies(); - } else if (data instanceof Wood) { - woodType = ((Wood) data).getSpecies(); - } else { - return 0; - } - switch (woodType) { - case GENERIC: - return 2; - case REDWOOD: - return 4; - case BIRCH: - return 1; - case JUNGLE: - return 3; - case ACACIA: - return 5; - case DARK_OAK: - return 6; - default: - return 0; - } + Material type = wood.getType(); + if (LegacyUtil.isWoodPlanks(type)) { + MaterialData data = wood.getState().getData(); + TreeSpecies woodType; + if (data instanceof Tree) { + woodType = ((Tree) data).getSpecies(); + } else if (data instanceof Wood) { + woodType = ((Wood) data).getSpecies(); + } else { + return 0; + } - case WOOD_STAIRS: + switch (woodType) { + case GENERIC: return 2; - case SPRUCE_WOOD_STAIRS: + case REDWOOD: return 4; - case BIRCH_WOOD_STAIRS: + case BIRCH: return 1; - case JUNGLE_WOOD_STAIRS: + case JUNGLE: return 3; - case ACACIA_STAIRS: + case ACACIA: return 5; - case DARK_OAK_STAIRS: + case DARK_OAK: return 6; default: return 0; } - - } catch (NoSuchFieldError | NoClassDefFoundError e) { - // Using older minecraft versions some fields and classes do not exist + } else if (type == LegacyUtil.OAK_STAIRS) { + return 2; + } else if (type == LegacyUtil.SPRUCE_STAIRS) { + return 4; + } else if (type == LegacyUtil.BIRCH_STAIRS) { + return 1; + } else if (type == LegacyUtil.JUNGLE_STAIRS) { + return 3; + } else if (type == LegacyUtil.ACACIA_STAIRS) { + return 5; + } else if (type == LegacyUtil.DARK_OAK_STAIRS) { + return 6; + } else { return 0; } } @@ -710,7 +681,7 @@ public class Barrel implements InventoryHolder { while (y <= 1) { // Fence and Netherfence Block relative = block.getRelative(0, y, 0); - if (isFence(relative.getType())) { + if (LegacyUtil.isFence(relative.getType())) { return (relative); } y++; @@ -718,36 +689,6 @@ public class Barrel implements InventoryHolder { return block; } - public static boolean isStairs(Material material) { - switch (material) { - case WOOD_STAIRS: - case SPRUCE_WOOD_STAIRS: - case BIRCH_WOOD_STAIRS: - case JUNGLE_WOOD_STAIRS: - case ACACIA_STAIRS: - case DARK_OAK_STAIRS: - return true; - default: - return false; - } - } - - public static boolean isFence(Material material) { - switch (material) { - case FENCE: - case NETHER_FENCE: - case ACACIA_FENCE: - case BIRCH_FENCE: - case DARK_OAK_FENCE: - case IRON_FENCE: - case JUNGLE_FENCE: - case SPRUCE_FENCE: - return true; - default: - return false; - } - } - // returns null if Barrel is correctly placed; the block that is missing when not // the barrel needs to be formed correctly // flag force to also check if chunk is not loaded @@ -807,7 +748,7 @@ public class Barrel implements InventoryHolder { Block block = spigot.getRelative(x, y, z); type = block.getType(); - if (isStairs(type)) { + if (LegacyUtil.isWoodStairs(type)) { if (y == 0) { // stairs have to be upside down MaterialData data = block.getState().getData(); @@ -901,7 +842,7 @@ public class Barrel implements InventoryHolder { continue; } } - if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || LegacyUtil.isWoodStairs(type)) { if (LegacyUtil.isWoodPlanks(type)) { woods.add(block.getX()); woods.add(block.getY()); diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java index b82b5c4..f914b86 100644 --- a/src/com/dre/brewery/LegacyUtil.java +++ b/src/com/dre/brewery/LegacyUtil.java @@ -4,16 +4,47 @@ import org.bukkit.Material; public class LegacyUtil { - public static final Material FLOWING_LAVA = Material.valueOf(P.use1_13 ? "FLOWING_LAVA" : "LAVA"); - public static final Material LAVA = Material.valueOf(P.use1_13 ? "LAVA" : "STATIONARY_LAVA"); - public static final Material CLOCK = Material.valueOf(P.use1_13 ? "CLOCK" : "WATCH"); + public static final Material FLOWING_LAVA = get("FLOWING_LAVA", "LAVA"); + public static final Material LAVA = get("LAVA", "STATIONARY_LAVA"); + public static final Material CLOCK = get("CLOCK", "WATCH"); + public static final Material OAK_STAIRS = get("OAK_STAIRS", "WOOD_STAIRS"); + public static final Material SPRUCE_STAIRS = get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"); + public static final Material BIRCH_STAIRS = get("BIRCH_STAIRS", "BIRCH_WOOD_STAIRS"); + public static final Material JUNGLE_STAIRS = get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS"); + public static final Material ACACIA_STAIRS = get("ACACIA_STAIRS"); + public static final Material DARK_OAK_STAIRS = get("DARK_OAK_STAIRS"); + + private static Material get(String name) { + try { + return Material.valueOf(name); + } catch (IllegalArgumentException exception) { + return null; + } + } + + private static Material get(String oldName, String newName) { + try { + return Material.valueOf(P.use1_13 ? newName : oldName); + } catch (IllegalArgumentException exception) { + return null; + } + } public static boolean isWoodPlanks(Material type) { return type.name().contains("PLANKS") || type.name().equals("WOOD"); } + public static boolean isWoodStairs(Material type) { + return type == OAK_STAIRS || type == SPRUCE_STAIRS || type == BIRCH_STAIRS || type == JUNGLE_STAIRS + || (type == ACACIA_STAIRS && ACACIA_STAIRS != null) || (type == DARK_OAK_STAIRS && DARK_OAK_STAIRS != null); + } + + public static boolean isFence(Material material) { + return material.name().endsWith("FENCE"); + } + public static boolean isSign(Material type) { - return type.name().equals("LEGACY_SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; + return type.name().equals("SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; } } diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index d8cf2ab..ea3d8a0 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -697,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) { @@ -721,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) { @@ -738,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)) { @@ -753,9 +742,7 @@ public class P extends JavaPlugin { return false; } } - default: - break; - } + } return true; } From 70a386ec915e61f1fb6172541a96fd483cec6d70 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 10 Mar 2018 17:10:42 +0100 Subject: [PATCH 03/20] Update fence / wood stairs checks to use LegacyUtil --- src/com/dre/brewery/listeners/PlayerListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java index f62c1c2..457333c 100644 --- a/src/com/dre/brewery/listeners/PlayerListener.java +++ b/src/com/dre/brewery/listeners/PlayerListener.java @@ -151,7 +151,7 @@ public class PlayerListener implements Listener { if (openEverywhere) { barrel = Barrel.get(clickedBlock); } - } else if (Barrel.isStairs(type)) { + } else if (LegacyUtil.isWoodStairs(type)) { for (Barrel barrel2 : Barrel.barrels) { if (barrel2.hasStairsBlock(clickedBlock)) { if (openEverywhere || !barrel2.isLarge()) { @@ -160,7 +160,7 @@ public class PlayerListener implements Listener { break; } } - } else if (Barrel.isFence(type) || LegacyUtil.isSign(type)) { + } else if (LegacyUtil.isFence(type) || LegacyUtil.isSign(type)) { barrel = Barrel.getBySpigot(clickedBlock); } From ddf14bd3b9381a5325be451fe309abff2dbbd384 Mon Sep 17 00:00:00 2001 From: Sataniel98 Date: Sun, 25 Mar 2018 22:14:28 +0200 Subject: [PATCH 04/20] Update pom.xml --- pom.xml | 230 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 113 insertions(+), 117 deletions(-) diff --git a/pom.xml b/pom.xml index d83fc69..122bbd3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,117 +1,113 @@ - - 4.0.0 - - com.dre - brewery - 1.6-SNAPSHOT - Brewery - - - UTF-8 - UTF-8 - - - - src - - - - - true - ${project.basedir}/resources - - **/*.yml - - - target/** - .travis.yml - - - - - - - maven-compiler-plugin - 3.5.1 - - 1.7 - 1.7 - UTF-8 - - - - - - - - md_5-releases - http://repo.mvdw-software.be/content/groups/public/http://repo.md-5.net/content/repositories/releases/<--> - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - vault-repo - http://nexus.theyeticave.net/content/repositories/pub_releases - - - mcstats-repo - http://repo.mcstats.org/content/repositories/public/ - - - sk89q-repo - http://maven.sk89q.com/repo/ - - - dre2n-rpo - http://feuerstern.bplaced.net/repo/ - - - - - - org.bukkit - bukkit - 18w03b-R0.1-SNAPSHOT1.12.2<--> - provided - - - net.milkbowl.vault - VaultAPI - 1.5 - provided - - - com.sk89q - worldguard - 6.1 - provided - - - com.griefcraft.lwc - LWCPlugin - 4.5.0-SNAPSHOT - provided - - - me.ryanhamshire - GriefPrevention - 14.5.4 - provided - - - de.diddiz - logblock - 1.94 - provided - - - de.diddiz - questioner - 1.94 - provided - - - + + 4.0.0 + + com.dre + brewery + 1.6-SNAPSHOT + Brewery + + + UTF-8 + UTF-8 + + + + src + + + + + true + ${project.basedir}/resources + + **/*.yml + + + target/** + .travis.yml + + + + + + + maven-compiler-plugin + 3.5.1 + + 1.7 + 1.7 + UTF-8 + + + + + + + + md_5-public + http://repo.md-5.net/content/groups/public/ + + + spigot-repo + http://repo.mvdw-software.be/content/groups/public/ + + + vault-repo + http://nexus.hc.to/content/repositories/pub_releases + + + sk89q-repo + http://maven.sk89q.com/repo/ + + + dre2n-rpo + http://erethon.de/repo/ + + + + + + org.bukkit + bukkit + 18w03b-R0.1-SNAPSHOT + provided + + + net.milkbowl.vault + VaultAPI + 1.6 + provided + + + com.sk89q + worldguard + 6.1 + provided + + + com.griefcraft + entitylwc + 2.0 + provided + + + me.ryanhamshire + GriefPrevention + 16.8 + provided + + + de.diddiz + logblock + 1.12-SNAPSHOT + provided + + + de.diddiz + questioner + + + + + From 27ecf2e19638baad95d603d82310722d0b0c0f4f Mon Sep 17 00:00:00 2001 From: Sataniel98 Date: Sun, 25 Mar 2018 22:27:28 +0200 Subject: [PATCH 05/20] Access legacy method with reflection to allow compilation --- src/com/dre/brewery/LegacyUtil.java | 131 +++++++---- src/com/dre/brewery/filedata/DataUpdater.java | 213 +++++++++--------- .../brewery/integration/LogBlockBarrel.java | 173 +++++++------- 3 files changed, 280 insertions(+), 237 deletions(-) diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java index f914b86..54bd9f5 100644 --- a/src/com/dre/brewery/LegacyUtil.java +++ b/src/com/dre/brewery/LegacyUtil.java @@ -1,50 +1,81 @@ -package com.dre.brewery; - -import org.bukkit.Material; - -public class LegacyUtil { - - public static final Material FLOWING_LAVA = get("FLOWING_LAVA", "LAVA"); - public static final Material LAVA = get("LAVA", "STATIONARY_LAVA"); - public static final Material CLOCK = get("CLOCK", "WATCH"); - public static final Material OAK_STAIRS = get("OAK_STAIRS", "WOOD_STAIRS"); - public static final Material SPRUCE_STAIRS = get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"); - public static final Material BIRCH_STAIRS = get("BIRCH_STAIRS", "BIRCH_WOOD_STAIRS"); - public static final Material JUNGLE_STAIRS = get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS"); - public static final Material ACACIA_STAIRS = get("ACACIA_STAIRS"); - public static final Material DARK_OAK_STAIRS = get("DARK_OAK_STAIRS"); - - private static Material get(String name) { - try { - return Material.valueOf(name); - } catch (IllegalArgumentException exception) { - return null; - } - } - - private static Material get(String oldName, String newName) { - try { - return Material.valueOf(P.use1_13 ? newName : oldName); - } catch (IllegalArgumentException exception) { - return null; - } - } - - public static boolean isWoodPlanks(Material type) { - return type.name().contains("PLANKS") || type.name().equals("WOOD"); - } - - public static boolean isWoodStairs(Material type) { - return type == OAK_STAIRS || type == SPRUCE_STAIRS || type == BIRCH_STAIRS || type == JUNGLE_STAIRS - || (type == ACACIA_STAIRS && ACACIA_STAIRS != null) || (type == DARK_OAK_STAIRS && DARK_OAK_STAIRS != null); - } - - public static boolean isFence(Material material) { - return material.name().endsWith("FENCE"); - } - - public static boolean isSign(Material type) { - return type.name().equals("SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; - } - -} +package com.dre.brewery; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; + +public class LegacyUtil { + + private static Method GET_MATERIAL; + private static Method GET_BLOCK_TYPE_ID_AT; + + static { + try { + GET_MATERIAL = Material.class.getDeclaredMethod("getMaterial", int.class); + GET_BLOCK_TYPE_ID_AT = World.class.getDeclaredMethod("getBlockTypeIdAt", Location.class); + } catch (NoSuchMethodException | SecurityException ex) { + } + } + + public static final Material FLOWING_LAVA = get("FLOWING_LAVA", "LAVA"); + public static final Material LAVA = get("LAVA", "STATIONARY_LAVA"); + public static final Material CLOCK = get("CLOCK", "WATCH"); + public static final Material OAK_STAIRS = get("OAK_STAIRS", "WOOD_STAIRS"); + public static final Material SPRUCE_STAIRS = get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"); + public static final Material BIRCH_STAIRS = get("BIRCH_STAIRS", "BIRCH_WOOD_STAIRS"); + public static final Material JUNGLE_STAIRS = get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS"); + public static final Material ACACIA_STAIRS = get("ACACIA_STAIRS"); + public static final Material DARK_OAK_STAIRS = get("DARK_OAK_STAIRS"); + + private static Material get(String name) { + try { + return Material.valueOf(name); + } catch (IllegalArgumentException exception) { + return null; + } + } + + private static Material get(String oldName, String newName) { + try { + return Material.valueOf(P.use1_13 ? newName : oldName); + } catch (IllegalArgumentException exception) { + return null; + } + } + + public static boolean isWoodPlanks(Material type) { + return type.name().contains("PLANKS") || type.name().equals("WOOD"); + } + + public static boolean isWoodStairs(Material type) { + return type == OAK_STAIRS || type == SPRUCE_STAIRS || type == BIRCH_STAIRS || type == JUNGLE_STAIRS + || (type == ACACIA_STAIRS && ACACIA_STAIRS != null) || (type == DARK_OAK_STAIRS && DARK_OAK_STAIRS != null); + } + + public static boolean isFence(Material material) { + return material.name().endsWith("FENCE"); + } + + public static boolean isSign(Material type) { + return type.name().equals("SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; + } + + public static Material getMaterial(int id) { + try { + return GET_MATERIAL != null ? (Material) GET_MATERIAL.invoke(null, id) : null; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) { + return null; + } + } + + public static int getBlockTypeIdAt(Location location) { + try { + return GET_BLOCK_TYPE_ID_AT != null ? (int) GET_BLOCK_TYPE_ID_AT.invoke(location.getWorld(), location) : 0; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) { + return 0; + } + } + +} diff --git a/src/com/dre/brewery/filedata/DataUpdater.java b/src/com/dre/brewery/filedata/DataUpdater.java index b76de94..0bacfe1 100644 --- a/src/com/dre/brewery/filedata/DataUpdater.java +++ b/src/com/dre/brewery/filedata/DataUpdater.java @@ -1,106 +1,107 @@ -package com.dre.brewery.filedata; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; - -import com.dre.brewery.P; - -public class DataUpdater { - - private FileConfiguration data; - private File file; - - public DataUpdater(FileConfiguration data, File file) { - this.data = data; - this.file = file; - } - - - - public void update(String fromVersion) { - if (fromVersion.equalsIgnoreCase("1.0")) { - update10(); - //fromVersion = "1.1"; - } - - try { - data.save(file); - } catch (IOException e) { - e.printStackTrace(); - } - } - - - - - @SuppressWarnings("deprecation") - public void update10() { - - data.set("Version", DataSave.dataVersion); - - ConfigurationSection section = data.getConfigurationSection("Ingredients"); - try { - if (section != null) { - for (String id : section.getKeys(false)) { - ConfigurationSection matSection = section.getConfigurationSection(id + ".mats"); - if (matSection != null) { - // matSection has all the materials + amount as Integers - Map ingredients = new HashMap<>(); - for (String ingredient : matSection.getKeys(false)) { - // convert to Material - Material mat = Material.getMaterial(P.p.parseInt(ingredient)); - if (mat != null) { - ingredients.put(mat.name(), matSection.getInt(ingredient)); - } - } - section.set(id + ".mats", ingredients); - } else { - P.p.errorLog("Ingredient id: '" + id + "' incomplete in data.yml"); - } - } - } - } catch (Exception e) { - // Getting Material by id may not work in the future - P.p.errorLog("Error Converting Ingredient Section of the Data File, newer versions of Bukkit may not support the old Save File anymore:"); - e.printStackTrace(); - } - - section = data.getConfigurationSection("BCauldron"); - if (section != null) { - try { - for (String uuid : section.getKeys(false)) { - ConfigurationSection cauldrons = section.getConfigurationSection(uuid); - if (cauldrons != null) { - for (String id : cauldrons.getKeys(false)) { - ConfigurationSection ingredientSection = cauldrons.getConfigurationSection(id + ".ingredients"); - if (ingredientSection != null) { - // has all the materials + amount as Integers - Map ingredients = new HashMap<>(); - for (String ingredient : ingredientSection.getKeys(false)) { - // convert to Material - Material mat = Material.getMaterial(P.p.parseInt(ingredient)); - if (mat != null) { - ingredients.put(mat.name(), ingredientSection.getInt(ingredient)); - } - } - cauldrons.set(id + ".ingredients", ingredients); - } else { - P.p.errorLog("BCauldron " + id + " is missing Ingredient Section"); - } - } - } - } - } catch (Exception e) { - // Getting Material by id may not work in the future - P.p.errorLog("Error Converting Ingredient Section of Cauldrons, newer versions of Bukkit may not support the old Save File anymore:"); - e.printStackTrace(); - } - } - } -} +package com.dre.brewery.filedata; + +import com.dre.brewery.LegacyUtil; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; + +import com.dre.brewery.P; + +public class DataUpdater { + + private FileConfiguration data; + private File file; + + public DataUpdater(FileConfiguration data, File file) { + this.data = data; + this.file = file; + } + + + + public void update(String fromVersion) { + if (fromVersion.equalsIgnoreCase("1.0")) { + update10(); + //fromVersion = "1.1"; + } + + try { + data.save(file); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + + + @SuppressWarnings("deprecation") + public void update10() { + + data.set("Version", DataSave.dataVersion); + + ConfigurationSection section = data.getConfigurationSection("Ingredients"); + try { + if (section != null) { + for (String id : section.getKeys(false)) { + ConfigurationSection matSection = section.getConfigurationSection(id + ".mats"); + if (matSection != null) { + // matSection has all the materials + amount as Integers + Map ingredients = new HashMap<>(); + for (String ingredient : matSection.getKeys(false)) { + // convert to Material + Material mat = LegacyUtil.getMaterial(P.p.parseInt(ingredient)); + if (mat != null) { + ingredients.put(mat.name(), matSection.getInt(ingredient)); + } + } + section.set(id + ".mats", ingredients); + } else { + P.p.errorLog("Ingredient id: '" + id + "' incomplete in data.yml"); + } + } + } + } catch (Exception e) { + // Getting Material by id may not work in the future + P.p.errorLog("Error Converting Ingredient Section of the Data File, newer versions of Bukkit may not support the old Save File anymore:"); + e.printStackTrace(); + } + + section = data.getConfigurationSection("BCauldron"); + if (section != null) { + try { + for (String uuid : section.getKeys(false)) { + ConfigurationSection cauldrons = section.getConfigurationSection(uuid); + if (cauldrons != null) { + for (String id : cauldrons.getKeys(false)) { + ConfigurationSection ingredientSection = cauldrons.getConfigurationSection(id + ".ingredients"); + if (ingredientSection != null) { + // has all the materials + amount as Integers + Map ingredients = new HashMap<>(); + for (String ingredient : ingredientSection.getKeys(false)) { + // convert to Material + Material mat = LegacyUtil.getMaterial(P.p.parseInt(ingredient)); + if (mat != null) { + ingredients.put(mat.name(), ingredientSection.getInt(ingredient)); + } + } + cauldrons.set(id + ".ingredients", ingredients); + } else { + P.p.errorLog("BCauldron " + id + " is missing Ingredient Section"); + } + } + } + } + } catch (Exception e) { + // Getting Material by id may not work in the future + P.p.errorLog("Error Converting Ingredient Section of Cauldrons, newer versions of Bukkit may not support the old Save File anymore:"); + e.printStackTrace(); + } + } + } +} diff --git a/src/com/dre/brewery/integration/LogBlockBarrel.java b/src/com/dre/brewery/integration/LogBlockBarrel.java index be0406d..d9d915d 100644 --- a/src/com/dre/brewery/integration/LogBlockBarrel.java +++ b/src/com/dre/brewery/integration/LogBlockBarrel.java @@ -1,81 +1,92 @@ -package com.dre.brewery.integration; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.entity.HumanEntity; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import de.diddiz.LogBlock.Consumer; -import de.diddiz.LogBlock.LogBlock; -import de.diddiz.LogBlock.Logging; -import static de.diddiz.LogBlock.config.Config.isLogging; -import static de.diddiz.util.BukkitUtils.compareInventories; -import static de.diddiz.util.BukkitUtils.compressInventory; -import static de.diddiz.util.BukkitUtils.rawData; - -public class LogBlockBarrel { - private static final List opened = new ArrayList<>(); - public static Consumer consumer = LogBlock.getInstance().getConsumer(); - - private HumanEntity player; - private ItemStack[] items; - private Location loc; - - public LogBlockBarrel(HumanEntity player, ItemStack[] items, Location spigotLoc) { - this.player = player; - this.items = items; - this.loc = spigotLoc; - opened.add(this); - } - - private void compareInv(final ItemStack[] after) { - if (consumer == null) { - return; - } - final ItemStack[] diff = compareInventories(items, after); - for (final ItemStack item : diff) { - consumer.queueChestAccess(player.getName(), loc, loc.getWorld().getBlockTypeIdAt(loc), (short) item.getTypeId(), (short) item.getAmount(), rawData(item)); - } - } - - public static LogBlockBarrel get(HumanEntity player) { - for (LogBlockBarrel open : opened) { - if (open.player.equals(player)) { - return open; - } - } - return null; - } - - public static void openBarrel(HumanEntity player, Inventory inv, Location spigotLoc) { - if (!isLogging(player.getWorld(), Logging.CHESTACCESS)) return; - new LogBlockBarrel(player, compressInventory(inv.getContents()), spigotLoc); - } - - public static void closeBarrel(HumanEntity player, Inventory inv) { - if (!isLogging(player.getWorld(), Logging.CHESTACCESS)) return; - LogBlockBarrel open = get(player); - if (open != null) { - open.compareInv(compressInventory(inv.getContents())); - opened.remove(open); - } - } - - public static void breakBarrel(String playerName, ItemStack[] contents, Location spigotLoc) { - if (consumer == null) { - return; - } - if (!isLogging(spigotLoc.getWorld(), Logging.CHESTACCESS)) return; - final ItemStack[] items = compressInventory(contents); - for (final ItemStack item : items) { - consumer.queueChestAccess(playerName, spigotLoc, spigotLoc.getWorld().getBlockTypeIdAt(spigotLoc), (short) item.getTypeId(), (short) (item.getAmount() * -1), rawData(item)); - } - } - - public static void clear() { - opened.clear(); - } -} +package com.dre.brewery.integration; + +import com.dre.brewery.LegacyUtil; +import com.dre.brewery.P; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.HumanEntity; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import de.diddiz.LogBlock.Consumer; +import de.diddiz.LogBlock.LogBlock; +import de.diddiz.LogBlock.Logging; +import static de.diddiz.LogBlock.config.Config.isLogging; +import static de.diddiz.util.BukkitUtils.compareInventories; +import static de.diddiz.util.BukkitUtils.compressInventory; +import static de.diddiz.util.BukkitUtils.rawData; + +public class LogBlockBarrel { + private static final List opened = new ArrayList<>(); + public static Consumer consumer = LogBlock.getInstance().getConsumer(); + + private HumanEntity player; + private ItemStack[] items; + private Location loc; + + public LogBlockBarrel(HumanEntity player, ItemStack[] items, Location spigotLoc) { + this.player = player; + this.items = items; + this.loc = spigotLoc; + opened.add(this); + } + + private void compareInv(final ItemStack[] after) { + if (consumer == null) { + return; + } + final ItemStack[] diff = compareInventories(items, after); + for (final ItemStack item : diff) { + if (P.use1_13) { + consumer.queueChestAccess(player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), rawData(item)); + } else { + // TODO: New method for LogBlock for 1.13+ + } + } + } + + public static LogBlockBarrel get(HumanEntity player) { + for (LogBlockBarrel open : opened) { + if (open.player.equals(player)) { + return open; + } + } + return null; + } + + public static void openBarrel(HumanEntity player, Inventory inv, Location spigotLoc) { + if (!isLogging(player.getWorld(), Logging.CHESTACCESS)) return; + new LogBlockBarrel(player, compressInventory(inv.getContents()), spigotLoc); + } + + public static void closeBarrel(HumanEntity player, Inventory inv) { + if (!isLogging(player.getWorld(), Logging.CHESTACCESS)) return; + LogBlockBarrel open = get(player); + if (open != null) { + open.compareInv(compressInventory(inv.getContents())); + opened.remove(open); + } + } + + public static void breakBarrel(String playerName, ItemStack[] contents, Location spigotLoc) { + if (consumer == null) { + return; + } + if (!isLogging(spigotLoc.getWorld(), Logging.CHESTACCESS)) return; + final ItemStack[] items = compressInventory(contents); + for (final ItemStack item : items) { + if (P.use1_13) { + consumer.queueChestAccess(playerName, spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData(item)); + } else { + // TODO: New method for LogBlock for 1.13+ + } + } + } + + public static void clear() { + opened.clear(); + } +} From 576ad7f3c91f9788f3610ef8f282987edcaac8fb Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 14 Aug 2018 15:32:30 +0200 Subject: [PATCH 06/20] Avoid MaterialData in 1.13 --- pom.xml | 10 +- resources/plugin.yml | 3 +- src/com/dre/brewery/BCauldron.java | 27 +---- src/com/dre/brewery/Barrel.java | 57 +--------- src/com/dre/brewery/LegacyUtil.java | 105 +++++++++++++++++- .../dre/brewery/listeners/PlayerListener.java | 5 +- 6 files changed, 118 insertions(+), 89 deletions(-) diff --git a/pom.xml b/pom.xml index 122bbd3..119858c 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ spigot-repo - http://repo.mvdw-software.be/content/groups/public/ + https://hub.spigotmc.org/nexus/content/groups/public/ vault-repo @@ -60,6 +60,10 @@ sk89q-repo http://maven.sk89q.com/repo/ + + jitpack.io + https://jitpack.io + dre2n-rpo http://erethon.de/repo/ @@ -70,7 +74,7 @@ org.bukkit bukkit - 18w03b-R0.1-SNAPSHOT + 1.13-R0.1-SNAPSHOT provided @@ -92,7 +96,7 @@ provided - me.ryanhamshire + com.github.TechFortress GriefPrevention 16.8 provided diff --git a/resources/plugin.yml b/resources/plugin.yml index 3e3bd01..25d1d21 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,8 +1,9 @@ name: ${project.name} version: ${project.version} main: com.dre.brewery.P -authors: [Milan Albrecht, Frank Baumann, ProgrammerDan] +authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel] softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault] +#api-version: 1.13 commands: brewery: description: Command for Administration diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java index 5d985b0..359295f 100644 --- a/src/com/dre/brewery/BCauldron.java +++ b/src/com/dre/brewery/BCauldron.java @@ -9,8 +9,6 @@ import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; import org.bukkit.Effect; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.material.Cauldron; -import org.bukkit.material.MaterialData; public class BCauldron { public static CopyOnWriteArrayList bcauldrons = new CopyOnWriteArrayList<>(); @@ -36,8 +34,7 @@ public class BCauldron { public void onUpdate() { // Check if fire still alive - if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == LegacyUtil.LAVA - || block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) { + if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || LegacyUtil.isLava(block.getRelative(BlockFace.DOWN).getType())) { // add a minute to cooking time state++; if (someRemoved) { @@ -74,7 +71,7 @@ public class BCauldron { // get cauldron from block and add given ingredient public static boolean ingredientAdd(Block block, ItemStack ingredient) { // if not empty - if (getFillLevel(block) != 0) { + if (LegacyUtil.getFillLevel(block) != 0) { BCauldron bcauldron = get(block); if (bcauldron != null) { bcauldron.add(ingredient); @@ -125,24 +122,6 @@ public class BCauldron { return false; } - // 0 = empty, 1 = something in, 2 = full - public static byte getFillLevel(Block block) { - if (block.getType() == Material.CAULDRON) { - MaterialData data = block.getState().getData(); - if (data instanceof Cauldron) { - Cauldron cauldron = (Cauldron) data; - if (cauldron.isEmpty()) { - return 0; - } else if (cauldron.isFull()) { - return 2; - } else { - return 1; - } - } - } - return 0; - } - // prints the current cooking time to the player public static void printTime(Player player, Block block) { if (!player.hasPermission("brewery.cauldron.time")) { @@ -161,7 +140,7 @@ public class BCauldron { // reset to normal cauldron public static void remove(Block block) { - if (getFillLevel(block) != 0) { + if (LegacyUtil.getFillLevel(block) != 0) { BCauldron bcauldron = get(block); if (bcauldron != null) { bcauldrons.remove(bcauldron); diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java index e32aa6e..4ee0f47 100644 --- a/src/com/dre/brewery/Barrel.java +++ b/src/com/dre/brewery/Barrel.java @@ -5,7 +5,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.Map; import org.bukkit.Material; -import org.bukkit.TreeSpecies; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.block.Block; @@ -15,10 +14,6 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.material.MaterialData; -import org.bukkit.material.Stairs; -import org.bukkit.material.Tree; -import org.bukkit.material.Wood; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; @@ -612,50 +607,7 @@ public class Barrel implements InventoryHolder { default: wood = spigot.getRelative(0, 0, -1); } - - Material type = wood.getType(); - if (LegacyUtil.isWoodPlanks(type)) { - MaterialData data = wood.getState().getData(); - TreeSpecies woodType; - if (data instanceof Tree) { - woodType = ((Tree) data).getSpecies(); - } else if (data instanceof Wood) { - woodType = ((Wood) data).getSpecies(); - } else { - return 0; - } - - switch (woodType) { - case GENERIC: - return 2; - case REDWOOD: - return 4; - case BIRCH: - return 1; - case JUNGLE: - return 3; - case ACACIA: - return 5; - case DARK_OAK: - return 6; - default: - return 0; - } - } else if (type == LegacyUtil.OAK_STAIRS) { - return 2; - } else if (type == LegacyUtil.SPRUCE_STAIRS) { - return 4; - } else if (type == LegacyUtil.BIRCH_STAIRS) { - return 1; - } else if (type == LegacyUtil.JUNGLE_STAIRS) { - return 3; - } else if (type == LegacyUtil.ACACIA_STAIRS) { - return 5; - } else if (type == LegacyUtil.DARK_OAK_STAIRS) { - return 6; - } else { - return 0; - } + return LegacyUtil.getWoodType(wood); } // returns the Sign of a large barrel, the spigot if there is none @@ -751,11 +703,8 @@ public class Barrel implements InventoryHolder { if (LegacyUtil.isWoodStairs(type)) { if (y == 0) { // stairs have to be upside down - MaterialData data = block.getState().getData(); - if (data instanceof Stairs) { - if (!((Stairs) data).isInverted()) { - return block; - } + if (!LegacyUtil.areStairsInverted(block)) { + return block; } } stairs.add(block.getX()); diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java index 54bd9f5..3857e2e 100644 --- a/src/com/dre/brewery/LegacyUtil.java +++ b/src/com/dre/brewery/LegacyUtil.java @@ -4,7 +4,15 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.TreeSpecies; import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Levelled; +import org.bukkit.material.Cauldron; +import org.bukkit.material.MaterialData; +import org.bukkit.material.Tree; +import org.bukkit.material.Wood; public class LegacyUtil { @@ -19,8 +27,6 @@ public class LegacyUtil { } } - public static final Material FLOWING_LAVA = get("FLOWING_LAVA", "LAVA"); - public static final Material LAVA = get("LAVA", "STATIONARY_LAVA"); public static final Material CLOCK = get("CLOCK", "WATCH"); public static final Material OAK_STAIRS = get("OAK_STAIRS", "WOOD_STAIRS"); public static final Material SPRUCE_STAIRS = get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"); @@ -54,14 +60,105 @@ public class LegacyUtil { || (type == ACACIA_STAIRS && ACACIA_STAIRS != null) || (type == DARK_OAK_STAIRS && DARK_OAK_STAIRS != null); } - public static boolean isFence(Material material) { - return material.name().endsWith("FENCE"); + public static boolean isFence(Material type) { + return type.name().endsWith("FENCE"); } public static boolean isSign(Material type) { return type.name().equals("SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; } + // LAVA and STATIONARY_LAVA are merged as of 1.13 + public static boolean isLava(Material type) { + return type.name().equals("STATIONARY_LAVA") || type == Material.LAVA; + } + + public static boolean areStairsInverted(Block block) { + if (P.use1_13) { + MaterialData data = block.getState().getData(); + return data instanceof org.bukkit.material.Stairs && (((org.bukkit.material.Stairs) data).isInverted()); + } else { + BlockData data = block.getBlockData(); + return data instanceof org.bukkit.block.data.type.Stairs && ((org.bukkit.block.data.type.Stairs) data).getHalf() == org.bukkit.block.data.type.Stairs.Half.TOP; + } + } + + public static byte getWoodType(Block wood) { + TreeSpecies woodType = null; + + if (P.use1_13 || isWoodStairs(wood.getType())) { + String material = wood.getType().name(); + if (material.startsWith("OAK")) { + woodType = TreeSpecies.GENERIC; + } else if (material.startsWith("SPRUCE")) { + woodType = TreeSpecies.REDWOOD; + } else if (material.startsWith("BIRCH")) { + woodType = TreeSpecies.BIRCH; + } else if (material.startsWith("JUNGLE")) { + woodType = TreeSpecies.JUNGLE; + } else if (material.startsWith("ACACIA")) { + woodType = TreeSpecies.ACACIA; + } else if (material.startsWith("DARK_OAK")) { + woodType = TreeSpecies.DARK_OAK; + } + + } else { + MaterialData data = wood.getState().getData(); + if (data instanceof Tree) { + woodType = ((Tree) data).getSpecies(); + } else if (data instanceof Wood) { + woodType = ((Wood) data).getSpecies(); + } else { + return 0; + } + } + + switch (woodType) { + case GENERIC: + return 2; + case REDWOOD: + return 4; + case BIRCH: + return 1; + case JUNGLE: + return 3; + case ACACIA: + return 5; + case DARK_OAK: + return 6; + default: + return 0; + } + } + + // 0 = empty, 1 = something in, 2 = full + public static byte getFillLevel(Block block) { + if (block.getType() != Material.CAULDRON) { + return 0; + } + + if (P.use1_13) { + Levelled cauldron = ((Levelled) block); + if (cauldron.getLevel() == 0) { + return 0; + } else if (cauldron.getLevel() == cauldron.getMaximumLevel()) { + return 2; + } else { + return 1; + } + + } else { + Cauldron cauldron = (Cauldron) block.getState().getData(); + if (cauldron.isEmpty()) { + return 0; + } else if (cauldron.isFull()) { + return 2; + } else { + return 1; + } + } + } + public static Material getMaterial(int id) { try { return GET_MATERIAL != null ? (Material) GET_MATERIAL.invoke(null, id) : null; diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java index 457333c..6623fcd 100644 --- a/src/com/dre/brewery/listeners/PlayerListener.java +++ b/src/com/dre/brewery/listeners/PlayerListener.java @@ -67,18 +67,17 @@ public class PlayerListener implements Listener { // reset cauldron when refilling to prevent unlimited source of potions } else if (materialInHand == Material.WATER_BUCKET) { if (!P.use1_9) { - if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) { + if (LegacyUtil.getFillLevel(clickedBlock) == 1) { // will only remove when existing BCauldron.remove(clickedBlock); } } return; - } // Check if fire alive below cauldron when adding ingredients Block down = clickedBlock.getRelative(BlockFace.DOWN); - if (down.getType() == Material.FIRE || down.getType() == LegacyUtil.LAVA || down.getType() == LegacyUtil.FLOWING_LAVA) { + if (down.getType() == Material.FIRE || LegacyUtil.isLava(down.getType())) { event.setCancelled(true); boolean handSwap = false; From 3cb9588158ffa40f50e8c372f1f4389dd27d57d8 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 14 Aug 2018 15:35:16 +0200 Subject: [PATCH 07/20] Access block byte data method in 1.13 --- src/com/dre/brewery/BCauldron.java | 4 ++-- src/com/dre/brewery/LegacyUtil.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java index 359295f..c453e79 100644 --- a/src/com/dre/brewery/BCauldron.java +++ b/src/com/dre/brewery/BCauldron.java @@ -97,13 +97,13 @@ public class BCauldron { byte data = block.getData(); if (data > 3) { data = 3; - block.setData(data); + LegacyUtil.setData(block, data); } else if (data <= 0) { bcauldrons.remove(bcauldron); return false; } data -= 1; - block.setData(data); + LegacyUtil.setData(block, data); if (data == 0) { bcauldrons.remove(bcauldron); diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java index 3857e2e..fb95adf 100644 --- a/src/com/dre/brewery/LegacyUtil.java +++ b/src/com/dre/brewery/LegacyUtil.java @@ -2,6 +2,7 @@ package com.dre.brewery; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.TreeSpecies; @@ -18,12 +19,14 @@ public class LegacyUtil { private static Method GET_MATERIAL; private static Method GET_BLOCK_TYPE_ID_AT; + private static Method SET_DATA; static { try { GET_MATERIAL = Material.class.getDeclaredMethod("getMaterial", int.class); GET_BLOCK_TYPE_ID_AT = World.class.getDeclaredMethod("getBlockTypeIdAt", Location.class); - } catch (NoSuchMethodException | SecurityException ex) { + SET_DATA = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".block.CraftBlock").getDeclaredMethod("setData", byte.class); + } catch (NoSuchMethodException | SecurityException | ClassNotFoundException ex) { } } @@ -175,4 +178,12 @@ public class LegacyUtil { } } + // Setting byte data to blocks works in 1.13, but isn't part of the API anymore + public static void setData(Block block, byte data) { + try { + SET_DATA.invoke(block, data); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + } + } + } From 7083ec323f87df7ba92be4fdbfeda92229b526e9 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 14 Aug 2018 17:03:03 +0200 Subject: [PATCH 08/20] LegacyUtil fixes --- src/com/dre/brewery/LegacyUtil.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java index fb95adf..1f9cdba 100644 --- a/src/com/dre/brewery/LegacyUtil.java +++ b/src/com/dre/brewery/LegacyUtil.java @@ -22,11 +22,16 @@ public class LegacyUtil { private static Method SET_DATA; static { + // -1.12.2 methods try { GET_MATERIAL = Material.class.getDeclaredMethod("getMaterial", int.class); GET_BLOCK_TYPE_ID_AT = World.class.getDeclaredMethod("getBlockTypeIdAt", Location.class); + } catch (NoSuchMethodException | SecurityException e) { + } + // 1.13+ methods + try { SET_DATA = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".block.CraftBlock").getDeclaredMethod("setData", byte.class); - } catch (NoSuchMethodException | SecurityException | ClassNotFoundException ex) { + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) { } } @@ -41,7 +46,7 @@ public class LegacyUtil { private static Material get(String name) { try { return Material.valueOf(name); - } catch (IllegalArgumentException exception) { + } catch (IllegalArgumentException e) { return null; } } @@ -49,7 +54,7 @@ public class LegacyUtil { private static Material get(String oldName, String newName) { try { return Material.valueOf(P.use1_13 ? newName : oldName); - } catch (IllegalArgumentException exception) { + } catch (IllegalArgumentException e) { return null; } } @@ -103,6 +108,8 @@ public class LegacyUtil { woodType = TreeSpecies.ACACIA; } else if (material.startsWith("DARK_OAK")) { woodType = TreeSpecies.DARK_OAK; + } else { + return 0; } } else { @@ -141,7 +148,7 @@ public class LegacyUtil { } if (P.use1_13) { - Levelled cauldron = ((Levelled) block); + Levelled cauldron = ((Levelled) block.getBlockData()); if (cauldron.getLevel() == 0) { return 0; } else if (cauldron.getLevel() == cauldron.getMaximumLevel()) { @@ -165,7 +172,7 @@ public class LegacyUtil { public static Material getMaterial(int id) { try { return GET_MATERIAL != null ? (Material) GET_MATERIAL.invoke(null, id) : null; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { return null; } } @@ -173,7 +180,7 @@ public class LegacyUtil { public static int getBlockTypeIdAt(Location location) { try { return GET_BLOCK_TYPE_ID_AT != null ? (int) GET_BLOCK_TYPE_ID_AT.invoke(location.getWorld(), location) : 0; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { return 0; } } @@ -182,7 +189,7 @@ public class LegacyUtil { public static void setData(Block block, byte data) { try { SET_DATA.invoke(block, data); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } From 88746401b4f0188366cbb74c6c26681ac3fd3d93 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 14 Aug 2018 17:03:15 +0200 Subject: [PATCH 09/20] Set API version to 1.13 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 25d1d21..8f2c8f0 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -3,7 +3,7 @@ version: ${project.version} main: com.dre.brewery.P authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel] softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault] -#api-version: 1.13 +api-version: 1.13 commands: brewery: description: Command for Administration From 374cf2ab589c6cb8899d51b9ffa1bc623d5c0c05 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Thu, 30 Aug 2018 17:51:17 +0200 Subject: [PATCH 10/20] Update dependencies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 119858c..7b86650 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ maven-compiler-plugin - 3.5.1 + 3.7.0 1.7 1.7 @@ -74,7 +74,7 @@ org.bukkit bukkit - 1.13-R0.1-SNAPSHOT + 1.13.1-R0.1-SNAPSHOT provided From 3d98b4d8dbad39c15cf88785dffe26fa60c8fe74 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Thu, 30 Aug 2018 19:44:16 +0200 Subject: [PATCH 11/20] Fix LegacyUtil bugs --- src/com/dre/brewery/LegacyUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java index 1f9cdba..4dac741 100644 --- a/src/com/dre/brewery/LegacyUtil.java +++ b/src/com/dre/brewery/LegacyUtil.java @@ -51,7 +51,7 @@ public class LegacyUtil { } } - private static Material get(String oldName, String newName) { + private static Material get(String newName, String oldName) { try { return Material.valueOf(P.use1_13 ? newName : oldName); } catch (IllegalArgumentException e) { @@ -82,7 +82,7 @@ public class LegacyUtil { } public static boolean areStairsInverted(Block block) { - if (P.use1_13) { + if (!P.use1_13) { MaterialData data = block.getState().getData(); return data instanceof org.bukkit.material.Stairs && (((org.bukkit.material.Stairs) data).isInverted()); } else { From ed369d55c96859057bd1b3df4926eeac0706ae2f Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 7 Sep 2018 14:13:29 +0200 Subject: [PATCH 12/20] Update LogBlock integration --- pom.xml | 2 +- .../brewery/integration/LogBlockBarrel.java | 37 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 7b86650..6ddac51 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,7 @@ de.diddiz logblock - 1.12-SNAPSHOT + 1.13.1-SNAPSHOT provided diff --git a/src/com/dre/brewery/integration/LogBlockBarrel.java b/src/com/dre/brewery/integration/LogBlockBarrel.java index d9d915d..3701123 100644 --- a/src/com/dre/brewery/integration/LogBlockBarrel.java +++ b/src/com/dre/brewery/integration/LogBlockBarrel.java @@ -2,6 +2,7 @@ package com.dre.brewery.integration; import com.dre.brewery.LegacyUtil; import com.dre.brewery.P; +import de.diddiz.LogBlock.Actor; import java.util.ArrayList; import java.util.List; @@ -15,13 +16,31 @@ import de.diddiz.LogBlock.Consumer; import de.diddiz.LogBlock.LogBlock; import de.diddiz.LogBlock.Logging; import static de.diddiz.LogBlock.config.Config.isLogging; +import de.diddiz.util.BukkitUtils; import static de.diddiz.util.BukkitUtils.compareInventories; import static de.diddiz.util.BukkitUtils.compressInventory; -import static de.diddiz.util.BukkitUtils.rawData; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; public class LogBlockBarrel { private static final List opened = new ArrayList<>(); public static Consumer consumer = LogBlock.getInstance().getConsumer(); + private static Method rawData; + private static Method queueChestAccess; + + static { + if (P.use1_13) { + try { + rawData = BukkitUtils.class.getDeclaredMethod("rawData", ItemStack.class); + queueChestAccess = Consumer.class.getDeclaredMethod("queueChestAccess", String.class, Location.class, int.class, short.class, short.class); + } catch (NoSuchMethodException e) { + P.p.errorLog("Failed to hook into LogBlock to log barrels. Logging barrel contents is not going to work."); + P.p.errorLog("Brewery was tested with version 1.12 to 1.13.1 of LogBlock."); + P.p.errorLog("Disable LogBlock support in the configuration file and type /brew reload."); + e.printStackTrace(); + } + } + } private HumanEntity player; private ItemStack[] items; @@ -41,9 +60,13 @@ public class LogBlockBarrel { final ItemStack[] diff = compareInventories(items, after); for (final ItemStack item : diff) { if (P.use1_13) { - consumer.queueChestAccess(player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), rawData(item)); + try { + queueChestAccess.invoke(consumer, player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), (short) rawData.invoke(null, item)); + } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } } else { - // TODO: New method for LogBlock for 1.13+ + consumer.queueChestAccess(Actor.actorFromEntity(player), loc, loc.getBlock().getBlockData(), item, false); } } } @@ -79,9 +102,13 @@ public class LogBlockBarrel { final ItemStack[] items = compressInventory(contents); for (final ItemStack item : items) { if (P.use1_13) { - consumer.queueChestAccess(playerName, spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData(item)); + try { + queueChestAccess.invoke(consumer, playerName, spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData.invoke(null, item)); + } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } } else { - // TODO: New method for LogBlock for 1.13+ + consumer.queueChestAccess(Actor.actorFromString(playerName), spigotLoc, spigotLoc.getBlock().getBlockData(), item, false); } } } From 8d4a73256d9e98fd3181715fd09563c1a0347956 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 8 Sep 2018 02:28:52 +0200 Subject: [PATCH 13/20] Update WorldGuard support to WG7 --- pom.xml | 12 ++++++ src/com/dre/brewery/P.java | 22 +++++------ .../dre/brewery/integration/WGBarrel7.java | 38 +++++++++++++++++++ 3 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 src/com/dre/brewery/integration/WGBarrel7.java diff --git a/pom.xml b/pom.xml index 6ddac51..9e2e192 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,18 @@ 6.1 provided + + com.sk89q.worldedit + worldedit-bukkit + 7.0.0-SNAPSHOT + provided + + + com.sk89q.worldguard + worldguard-legacy + 7.0.0-SNAPSHOT + provided + com.griefcraft entitylwc diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index ea3d8a0..9c3de8d 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -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.*; @@ -31,6 +32,7 @@ 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 { @@ -263,19 +265,17 @@ 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"); diff --git a/src/com/dre/brewery/integration/WGBarrel7.java b/src/com/dre/brewery/integration/WGBarrel7.java new file mode 100644 index 0000000..d46d886 --- /dev/null +++ b/src/com/dre/brewery/integration/WGBarrel7.java @@ -0,0 +1,38 @@ +package com.dre.brewery.integration; + + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import com.dre.brewery.P; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.World; +import com.sk89q.worldguard.WorldGuard; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.bukkit.permission.RegionPermissionModel; +import com.sk89q.worldguard.internal.platform.WorldGuardPlatform; +import com.sk89q.worldguard.protection.flags.Flags; +import com.sk89q.worldguard.protection.regions.RegionQuery; + +public class WGBarrel7 implements WGBarrel { + + public boolean checkAccess(Player player, Block spigot, Plugin plugin) { + WorldGuardPlugin wg = (WorldGuardPlugin) plugin; + WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform(); + + World world = platform.getWorldByName(spigot.getWorld().getName()); + if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled + if (new RegionPermissionModel(wg, player).mayIgnoreRegionProtection(spigot.getWorld())) return true; // Whitelisted cause + + RegionQuery query = platform.getRegionContainer().createQuery(); + + if (!query.testBuild(new Location(world, spigot.getX(), spigot.getY(), spigot.getZ()), wg.wrapPlayer(player), Flags.USE, Flags.CHEST_ACCESS)) { + P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess")); + return false; + } + + return true; + } + +} From dc7e23ac41c2540e4b186044a45cf8d5b7c3ae53 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 8 Sep 2018 02:45:45 +0200 Subject: [PATCH 14/20] Update EntityLWC and GriefPrevention dependencies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9e2e192..974153b 100644 --- a/pom.xml +++ b/pom.xml @@ -104,13 +104,13 @@ com.griefcraft entitylwc - 2.0 + 2.1 provided com.github.TechFortress GriefPrevention - 16.8 + 16.9 provided From 221adfa7bbc9612043dfe3fd23339b1feb49cb07 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 21 Sep 2018 02:02:47 +0200 Subject: [PATCH 15/20] Fix WG7 integration --- src/com/dre/brewery/integration/WGBarrel7.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/dre/brewery/integration/WGBarrel7.java b/src/com/dre/brewery/integration/WGBarrel7.java index d46d886..20cc6d0 100644 --- a/src/com/dre/brewery/integration/WGBarrel7.java +++ b/src/com/dre/brewery/integration/WGBarrel7.java @@ -4,13 +4,16 @@ package com.dre.brewery.integration; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; import com.dre.brewery.P; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.bukkit.permission.RegionPermissionModel; +import com.sk89q.worldguard.internal.permission.RegionPermissionModel; import com.sk89q.worldguard.internal.platform.WorldGuardPlatform; import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.regions.RegionQuery; @@ -23,7 +26,8 @@ public class WGBarrel7 implements WGBarrel { World world = platform.getWorldByName(spigot.getWorld().getName()); if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled - if (new RegionPermissionModel(wg, player).mayIgnoreRegionProtection(spigot.getWorld())) return true; // Whitelisted cause + WorldEditPlugin we = JavaPlugin.getPlugin(WorldEditPlugin.class); + if (new RegionPermissionModel((Actor) we.wrapPlayer(player)).mayIgnoreRegionProtection(world)) return true; // Whitelisted cause RegionQuery query = platform.getRegionContainer().createQuery(); From cc8d142ad9c6df3bb1d24d4cebf2dd38c5909e3c Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 21 Sep 2018 15:05:50 +0200 Subject: [PATCH 16/20] Fix LogBlock integration --- src/com/dre/brewery/integration/LogBlockBarrel.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/dre/brewery/integration/LogBlockBarrel.java b/src/com/dre/brewery/integration/LogBlockBarrel.java index 3701123..ec8ae75 100644 --- a/src/com/dre/brewery/integration/LogBlockBarrel.java +++ b/src/com/dre/brewery/integration/LogBlockBarrel.java @@ -29,10 +29,10 @@ public class LogBlockBarrel { private static Method queueChestAccess; static { - if (P.use1_13) { + if (!P.use1_13) { try { rawData = BukkitUtils.class.getDeclaredMethod("rawData", ItemStack.class); - queueChestAccess = Consumer.class.getDeclaredMethod("queueChestAccess", String.class, Location.class, int.class, short.class, short.class); + queueChestAccess = Consumer.class.getDeclaredMethod("queueChestAccess", String.class, Location.class, int.class, short.class, short.class, short.class); } catch (NoSuchMethodException e) { P.p.errorLog("Failed to hook into LogBlock to log barrels. Logging barrel contents is not going to work."); P.p.errorLog("Brewery was tested with version 1.12 to 1.13.1 of LogBlock."); @@ -59,7 +59,7 @@ public class LogBlockBarrel { } final ItemStack[] diff = compareInventories(items, after); for (final ItemStack item : diff) { - if (P.use1_13) { + if (!P.use1_13) { try { queueChestAccess.invoke(consumer, player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), (short) rawData.invoke(null, item)); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { @@ -101,7 +101,7 @@ public class LogBlockBarrel { if (!isLogging(spigotLoc.getWorld(), Logging.CHESTACCESS)) return; final ItemStack[] items = compressInventory(contents); for (final ItemStack item : items) { - if (P.use1_13) { + if (!P.use1_13) { try { queueChestAccess.invoke(consumer, playerName, spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData.invoke(null, item)); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { From 54ebee1dc84e9e53ecaf825097955116233b1b5a Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 21 Sep 2018 21:43:48 +0200 Subject: [PATCH 17/20] Add default configs for both 1.12- and 1.13+ Co-Authored-By: Zg12 --- resources/config/{ => v12}/de/config.yml | 0 resources/config/{ => v12}/en/config.yml | 0 resources/config/{ => v12}/fr/config.yml | 0 resources/config/{ => v12}/it/config.yml | 0 resources/config/v13/de/config.yml | 537 +++++++++++++++++++++ resources/config/v13/en/config.yml | 567 ++++++++++++++++++++++ resources/config/v13/fr/config.yml | 572 +++++++++++++++++++++++ resources/config/v13/it/config.yml | 567 ++++++++++++++++++++++ 8 files changed, 2243 insertions(+) rename resources/config/{ => v12}/de/config.yml (100%) rename resources/config/{ => v12}/en/config.yml (100%) rename resources/config/{ => v12}/fr/config.yml (100%) rename resources/config/{ => v12}/it/config.yml (100%) mode change 100755 => 100644 create mode 100644 resources/config/v13/de/config.yml create mode 100644 resources/config/v13/en/config.yml create mode 100644 resources/config/v13/fr/config.yml create mode 100644 resources/config/v13/it/config.yml diff --git a/resources/config/de/config.yml b/resources/config/v12/de/config.yml similarity index 100% rename from resources/config/de/config.yml rename to resources/config/v12/de/config.yml diff --git a/resources/config/en/config.yml b/resources/config/v12/en/config.yml similarity index 100% rename from resources/config/en/config.yml rename to resources/config/v12/en/config.yml diff --git a/resources/config/fr/config.yml b/resources/config/v12/fr/config.yml similarity index 100% rename from resources/config/fr/config.yml rename to resources/config/v12/fr/config.yml diff --git a/resources/config/it/config.yml b/resources/config/v12/it/config.yml old mode 100755 new mode 100644 similarity index 100% rename from resources/config/it/config.yml rename to resources/config/v12/it/config.yml diff --git a/resources/config/v13/de/config.yml b/resources/config/v13/de/config.yml new file mode 100644 index 0000000..908dbf2 --- /dev/null +++ b/resources/config/v13/de/config.yml @@ -0,0 +1,537 @@ +# config für Brewery.jar + + +# -- Verschiedene Einstellungen -- +# Standardeinstellungen sind in [] angegeben +# Löschen einzelner Einstellungen deaktiviert sie + +# Sprachedatei die genutzt werden sollte (befindet sich in plugins/Brewery/languages) +language: de + +# Ob der Spieler beim nächsten Einloggen nach starker Trunkenheit am nächsten morgen Zuhause "aufwacht" (Ein home Plugin muss installiert sein!) [true] +enableHome: true + +# Art des Nachhause-teleports: ['cmd: home'] +# bed = Spieler wird zu seinem Spawn Bett teleportiert +# 'cmd: home' = /home wird vom Spieler ausgelöst. Es sollte kein Verzögerungs, etc. plugin installiert sein! +# 'cmd: spawn' = /spawn wird vom Spieler ausgelöst +# 'cmd: whatever' = /whatever wird vom Spieler ausgelöst +homeType: 'cmd: home' + +# Ob der Spieler nach etwas kürzerem Ausloggen an einem zufälligen Ort "aufwacht" (diese müssen durch '/brew Wakeup add' von einem Admin festgelegt werden) +# Der Spieler wacht an dem nähesten zweier zufälliger Orte aus seiner Welt auf. [true] +enableWake: true + +# Ob der Spieler bei großer Trunkenheit mehrmals probieren muss sich einzuloggen, da sein Charakter kurz nicht reagiert [true] +enableLoginDisallow: true + +# Ob der Spieler kurz in Ohnmacht fällt (vom Server gekickt wird) wenn er die maximale Trunkenheit erreicht [false] +enableKickOnOverdrink: false + +# Ob der Spieler sich bei großer Trunkenheit übergibt (unten definiertes Item aus dem Mund fallen lässt) [true] +# Das Item kann nicht aufgesammelt werden und bleibt bis zum Despawnen liegen. +enablePuke: true + +# Item das beim Erbrechen mehrfach unaufsammelbar fallen gelassen wird [SOUL_SAND] +pukeItem: SOUL_SAND + +# Zeit in Sekunden bis die pukeitems despawnen, (mc standard wäre 300 = 5 min) [60] +# Wurde die item Despawnzeit in der spigot.yml verändert, verändert sich auch die pukeDespawnzeit in Abhängigkeit. +pukeDespawntime: 60 + +# Konsumierbares Item/Stärke. Senkt den Alkoholpegel um wenn konsumiert. +drainItems: +- BREAD/4 +- MILK_BUCKET/2 + +# Zeit (in Tagen) die Trunkenheitsdaten nach offlinegehen eines Spielers im Speicher verbleiben, um z.B. Kater-Effekte anzuwenden. [7] +hangoverDays: 7 + +# Färben der Iteminformationen je nach Qualität während sie sich 1. im Fass und/oder 2. im Braustand befinden [true, true] +colorInBarrels: true +colorInBrewer: true + +# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true] +openLargeBarrelEverywhere: true + +# In den Serverlog loggen was der Spieler tatsächlich geschrieben hat, bevor seine Worte verändert wurden [false] +logRealChat: false + +# Aktiviert das Suchen nach Updates für Brewery mit der curseforge api [true] +# Wenn ein Update gefunden wurde, wird dies bei Serverstart im log angezeigt, sowie OPs benachrichtigt +updateCheck: true + +# Autosave Intervall in Minuten [3] +autosave: 3 + +# Config Version +version: '1.5' + + +# -- Rezepte für Getränke -- + +# name: Verschiedene Namen für schlecht/mittel/gut (Farbcodes möglich: z.b. &6) +# ingredients: Auflistung von 'Material oder ID,Data/Anzahl' +# (Item-ids anstatt Material werden von Bukkit nicht mehr unterstützt und funktionieren möglicherweise in Zukunft nicht mehr!) +# Eine Liste von allen Materialien kann hier gefunden werden: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html +# Es kann ein Data-Wert (durability) angegeben werden, weglassen ignoriert diesen beim hinzufügen einer Zutat +# Wenn Vault installiert ist können normale englische Item Namen verwendet werden, anstatt Material, ID und Data! +# Vault erkennt Namen wie "Jungle Leaves" anstatt "LEAVES,3". Dies macht es viel einfacher! +# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen +# distillruns: Wie oft destilliert werden muss für vollen Alkoholgehalt (0=ohne Destillieren) +# distilltime: Wie lange (in sekunden) ein Destillations-Durchlauf braucht (0=Standard Zeit von 40 sek) MC Standard wäre 20 sek +# wood: Holz des Fasses 0=alle Holzsorten 1=Birke 2=Eiche 3=Jungel 4=Fichte 5=Akazie 6=Schwarzeiche +# age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen +# color: Farbe des Getränks nach destillieren/reifen. +# Benutzbare Farben: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY +# difficulty: 1-10 Genauigkeit der Einhaltung der Vorgaben (1 = ungenau/einfach 10 = sehr genau/schwer) +# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot) +# effects: Auflistung Effekt/Level/Dauer Besonderere Trank-Effekte beim Trinken, Dauer in sek. +# Ein 'X' an den Namen anhängen, um ihn zu verbergen. Bsp: 'POISONX/2/10' (WEAKNESS, INCREASE_DAMAGE, SLOW und SPEED sind immer verborgen.) +# Effekte sind ab der 1.9 immer verborgen, wegen Änderungen an den Tränken. +# Mögliche Effekte: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html +# Minimale und Maximale Level/Dauer können durch "-" festgelegt werden, Bsp: 'SPEED/1-2/30-40' = Level 1 und 30 sek minimal, Level 2 und 40 sek maximal +# Diese Bereiche funktionieren auch umgekehrt, Bsp: 'POISON/3-1/20-5' für abschwächende Effekte bei guter Qualität +# Längste mögliche Effektdauer: 1638 sek. Es muss keine Dauer für Effekte mit sofortiger Wirkung angegeben werden. + +recipes: +# Ein vollständiges Beispiel zuerst: + 0: + name: Schlechtes Beispiel/Beispiel/Gutes Beispiel + ingredients: + - SUGAR_CANE/5 + - diamond/1 + - Cocoa_Beans/20 + - spruce_planks/8 + - BEDROCK/1 +# - Jungle Leaves/64 # Nur mit Vault +# - Green Dye/6 # Nur mit Vault + cookingtime: 3 + distillruns: 2 + distilltime: 60 + wood: 4 + age: 11 + color: DARK_RED + difficulty: 3 + alcohol: 23 + effects: + - FIRE_RESISTANCE/20 + - HEAL/1 + - WEAKNESS/2-3/50-60 + - POISONX/1-0/20-0 + 1: + name: Ranziges Weißbier/Weißbier/Feines Weißbier + ingredients: + - WHEAT/3 + cookingtime: 8 + distillruns: 0 + wood: 1 + age: 2 + color: BRIGHT_GREY + difficulty: 1 + alcohol: 5 + 2: + name: Ranziges Bier/Bier/Feines Bier + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 0 + age: 3 + color: ORANGE + difficulty: 1 + alcohol: 6 + 3: + name: Ranziges Dunkelbier/Dunkelbier/Feines Dunkelbier + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 4 + age: 8 + color: BLACK + difficulty: 2 + alcohol: 7 + 4: + name: Scheußlicher Met/Met/&6Goldener Met + ingredients: + - SUGAR_CANE/6 + cookingtime: 3 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 2 + alcohol: 9 + 5: + name: Apfelmet/Süßer Apfelmet/&6Goldensüßer Apfelmet + ingredients: + - SUGAR_CANE/6 + - APPLE/2 + cookingtime: 4 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 4 + alcohol: 12 + effects: + - WATER_BREATHINGX/1-2/150 + 6: + name: Bitterer Rum/Würziger Rum/&6Goldener Rum + ingredients: + - SUGAR_CANE/14 + cookingtime: 5 + distillruns: 2 + distilltime: 30 + wood: 2 + age: 14 + color: DARK_RED + difficulty: 6 + alcohol: 30 + effects: + - FIRE_RESISTANCE/1/20-100 + - POISONX/1-0/30-0 + 7: + name: Abgeranzter Vodka/Vodka/Russischer Vodka + ingredients: + - POTATO/10 + cookingtime: 15 + distillruns: 3 + age: 0 + color: BRIGHT_GREY + difficulty: 4 + alcohol: 20 + effects: + - WEAKNESS/15 + - POISON/10 + 8: + name: minderwertiger Absinth/Absinth/Starker Absinth + ingredients: + - GRASS/15 + cookingtime: 3 + distillruns: 6 + distilltime: 80 + color: GREEN + difficulty: 8 + alcohol: 45 + effects: + - POISON/20-30 + 9: + name: Kartoffelsuppe + ingredients: + - POTATO_ITEM/5 + - LONG_GRASS/3 + cookingtime: 3 + color: PINK + difficulty: 1 + effects: + - HEAL/0-1 + 10: + name: Fader Kaffee/Kaffee/Starker Kaffee + ingredients: + - INK_SACK,3/12 + - MILK_BUCKET/2 + cookingtime: 2 + color: BLACK + difficulty: 3 + effects: + - REGENERATION/1/2-5 + - SPEED/1/30-140 + +# Mehr Ideen für Rezepte: Cachaca, Gin, Whiskey, Tequila, Cidre, etc, sowie Rezeptvarianten wie Goldener Vodka etc. +# Ich werde keine weiteren Rezepte zu dieser Standardconfig hinzufügen, da diese öffentlich und für Spieler zum Abschauen einsehbar wären +# Der Serveradmin kann neue Rezepte hinzufügen und bestehende ändern, um das Abschauen aus der Standardconfig zu verhindern. + + +# cooked: ALLE möglichen Zutaten und die nach dem Gähren daraus entstehenden Tranknamen: +# [Beispiel] MATERIAL_oder_id: Name nach Gähren + +cooked: + WHEAT: Getreideferment + SUGAR_CANE: Zuckersud + APPLE: Apfelmost + POTATO: Kartoffelmaische + GRASS: Kräuterbrühe + RED_MUSHROOM: Pilzsud + Cocoa_Beans: Farbige Brühe + MILK_BUCKET: Milchiges Wasser + + + +# -- 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 [true] +useLogBlock: true + + +# -- Chat Veränderungs Einstellungen -- + +# Ob geschriebener Chat bei großer Trunkenheit abgefälscht werden soll, +# so dass es etwas betrunken aussieht was geschrieben wird. +# Wie stark der Chat verändert wird hängt davon ab wie betrunken der Spieler ist +# Unten kann noch eingestellt werden wie und was verändert wird +enableChatDistortion: true + +# Text nach den angegebenen Kommandos wird bei Trunkenheit ebenfalls Verändert (Liste) [- /gl] +distortCommands: +- /gl +- /global +- /fl +- /s +- /letter +- /g +- /l +- /lokal +- /local +- /mail send +- /m +- /msg +- /w +- /whisper +- /reply +- /r +- /t +- /tell + +# Geschriebenen Text auf Schildern bei Trunkenheit verändern [false] +distortSignText: false + +# Im Chat geschriebener Text, der zwischen diesen Buchstaben steht, wird nicht verändert ("," als Trennung verwenden) (Liste) [- '[,]'] +# Also zum Beispiel im Chat: Hallo ich bin betrunken *Ich teste Brewery* +distortBypass: +- '*,*' +- '[,]' + +# words: Wörter und Buchstaben die bei Chatten während Trunkenheit ersetzt werden sollen. +# Diese werden von oben nach unten gelesen und in dieser Reihenfolge wird ein geschriebener Satz dann verändert. + +# replace: Zu ersetzendes Wort oder Buchstabe. (Besondere: "-space": ersetzt Leerzeichen, "-random": Einfügen in zufällige Position, "-all": Alles, "-start": Ganz am Anfang, "-end": Ganz ans Ende.) +# to: In welches Wort es ersetzt werden soll. +# pre: Wörter und Buchstaben vor dem gesuchten Wort (durch "," getrennt) +# match: true = eines der "pre"-Wörter muss vor dem gesuchten Wort stehen, false = keines der "pre" Wörter darf vor dem gesuchten stehen +# alcohol: 1-100 Trunkenheit ab der die Wörter ersetzt werden +# percentage: Wahrscheinlichkeit des Ersetzen eines Wortes in Prozent + +words: +- replace: ch + to: sch + pre: u,s,o,a + match: false + alcohol: 10 + percentage: 70 + +- replace: h + to: hh + pre: sch,h,t + match: false + percentage: 60 + alcohol: 20 + +- replace: u + to: uuh + percentage: 20 + +- replace: u + to: uo + pre: u + match: false + percentage: 60 + +- replace: das + to: dass + percentage: 20 + alcohol: 40 + +- replace: p + to: b + percentage: 30 + +- replace: p + to: b + percentage: 70 + alcohol: 60 + +- replace: up + to: ubb + percentage: 80 + +- replace: o + to: oh + percentage: 20 + +- replace: ei + to: i + percentage: 15 + +- replace: b + to: bb + percentage: 80 + alcohol: 40 + +- replace: '!!!' + to: '!!!111!!!einself!1!' + pre: '!' + match: false + percentage: 20 + alcohol: 70 + +- replace: '!' + to: '!!' + pre: '!' + match: false + percentage: 90 + +- replace: betrunken + to: brhetriunkhn + pre: bist,seid + match: false + percentage: 70 + alcohol: 65 + +- replace: laufen + to: lnhfeeehn + pre: kannst,kannst noch,kannst nicht + match: false + percentage: 80 + alcohol: 30 + +- replace: gehen + to: hgheehn + pre: kannst,kannst noch,kannst nicht + match: false + percentage: 80 + alcohol: 40 + +- replace: wtf + to: wft + percentage: 20 + alcohol: 40 + +- replace: lol + to: loool + percentage: 80 + alcohol: 10 + +- replace: afk + to: aafka + percentage: 20 + alcohol: 30 + +- replace: schreiben + to: schribeen + pre: kannst,kannst noch,kannst nicht + match: false + percentage: 80 + alcohol: 50 + +- replace: trinken + to: saufen + percentage: 80 + alcohol: 70 + +- replace: '?' + to: '????' + pre: '?' + match: false + percentage: 80 + alcohol: 40 + +- replace: -space + to: '' + pre: h,g,w + match: true + alcohol: 10 + +- replace: -space + to: '' + percentage: 30 + alcohol: 35 + +- replace: -space + to: '' + percentage: 10 + +- replace: -start + to: dho + percentage: 15 + alcohol: 50 + +- replace: -start + to: hhn + percentage: 10 + alcohol: 50 + +- replace: -random + to: lug + percentage: 10 + +- replace: -random + to: lu + percentage: 20 + alcohol: 40 + +- replace: -random + to: blub + percentage: 20 + alcohol: 70 + +- replace: -random + to: lerg + percentage: 40 + alcohol: 75 + +- replace: -random + to: gul + percentage: 50 + alcohol: 80 + +- replace: -random + to: ' ' + percentage: 100 + alcohol: 70 + +- replace: -random + to: ' ' + percentage: 60 + alcohol: 40 + +- replace: -random + to: ' ' + percentage: 50 + alcohol: 30 + +- replace: -end + to: '!' + percentage: 40 + alcohol: 30 + +- replace: -random + to: ' *hicks* ' + percentage: 80 + alcohol: 70 + +- replace: -random + to: ' *hicks* ' + percentage: 15 + alcohol: 40 + +- replace: -space + to: ' *hicks* ' + percentage: 5 + alcohol: 20 + +- replace: -end + to: ' *hicks*' + percentage: 70 + alcohol: 50 + +- replace: -all + to: '*rülps*' + percentage: 3 + alcohol: 60 \ No newline at end of file diff --git a/resources/config/v13/en/config.yml b/resources/config/v13/en/config.yml new file mode 100644 index 0000000..a7acf83 --- /dev/null +++ b/resources/config/v13/en/config.yml @@ -0,0 +1,567 @@ +# config for Brewery.jar + + +# -- Settings -- +# Defaults are written in [] +# Deleting of single settings disables them + +# Languagefile to be used (found in plugins/Brewery/languages) +language: en + +# If the player wakes up at /home when logging in after excessive drinking (/home plugin must be installed!) [true] +enableHome: true + +# Type of the home-teleport: ['cmd: home'] +# bed = Player will be teleported to his spawn bed +# 'cmd: home' = /home will be executed by the player. He has to have permissions for it without any delay! +# 'cmd: spawn' = /spawn will be executed by the player. +# 'cmd: whatever' = /whatever will be executed by the player. +homeType: 'cmd: home' + +# If the player "wakes up" at a random place when offline for some time while drinking (the places have to be defined with '/brew Wakeup add' through an admin) +# The Player wakes at the nearest of two random places of his world [true] +enableWake: true + +# If the Player may have to try multiple times when logging in while extremely drunk [true] +enableLoginDisallow: true + +# If the Player faints shortly (gets kicked from the server) if he drinks the max amount of alcohol possible [false] +enableKickOnOverdrink: false + +# If the Player vomits on high drunkeness (drops item defined below) [true] +# The item can not be collected and stays on the ground until it despawns. +enablePuke: true + +# Item that is dropped multiple times uncollectable when puking [SOUL_SAND] +pukeItem: SOUL_SAND + +# Time in seconds until the pukeitems despawn, (mc default is 300 = 5 min) [60] +# If the item despawn time was changed in the spigot.yml, the pukeDespawntime changes as well. +pukeDespawntime: 60 + +# Consumable Item/strength. Decreases the alcohol level by when consumed. (list) +drainItems: +- BREAD/4 +- MILK_BUCKET/2 + +# Time (in days) that drunkeness-data stays in memory after a player goes offline, to apply hangover etc. [7] +hangoverDays: 7 + +# Color the Item information (lore) depending on quality while it is 1. in a barrel and/or 2. in a brewing stand [true, true] +colorInBarrels: true +colorInBrewer: true + +# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true] +openLargeBarrelEverywhere: true + +# Enable checking for Updates, Checks the curseforge api for updates to Brewery [true] +# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game +updateCheck: true + +# Autosave interval in minutes [3] +autosave: 3 + +# Config Version +version: '1.5' + + +# -- Recipes for Potions -- + +# name: Different names for bad/normal/good (Formatting codes possible: such as &6) +# ingredients: List of 'material or id,data/amount' +# (Item-ids instead of material are deprecated by bukkit and may not work in the future!) +# A list of materials can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html +# You can specify a data (durability) value, omitting it will ignore the data value of the added ingredient +# If Vault is installed normal names can be used instead of material or id, so using Vault is highly recommended. +# Vault will recognize things like "Jungle Leaves" instead of "LEAVES,3" +# cookingtime: Time in real minutes ingredients have to boil +# distillruns: How often it has to be distilled for full alcohol (0=without distilling) +# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec +# wood: Wood of the barrel 0=any 1=Birch 2=Oak 3=Jungle 4=Spruce 5=Acacia 6=Dark Oak +# age: Time in Minecraft-days, the potion has to age in a barrel 0=no aging +# color: Color of the potion after distilling/aging. +# Usable Colors: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY +# difficulty: 1-10 accuracy needed to get good quality (1 = unaccurate/easy, 10 = very precise/hard) +# alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting) +# effects: List of effect/level/duration Special potion-effect when drinking, duration in sek. +# Suffix name with 'X' to hide effect from label. Sample: 'POISONX/2/10' (WEAKNESS, INCREASE_DAMAGE, SLOW and SPEED are always hidden.) +# Effects are always hidden in 1.9 and newer, because of changes in the potion mechanics. +# Possible Effects: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html +# Level or Duration ranges may be specified with a "-", ex. 'SPEED/1-2/30-40' = lvl 1 and 30 sec at worst and lvl 2 and 40 sec at best +# Ranges also work high-low, ex. 'POISON/3-1/20-5' for weaker effects at good quality. +# Highest possible Duration: 1638 sec. Instant Effects dont need any duration specified. + +recipes: +# Example Recipe with every possible entry first: + 0: + name: Bad Example/Example/Good Example + ingredients: + - SUGAR_CANE/5 + - diamond/1 + - Cocoa_Beans/20 + - spruce_planks/8 + - BEDROCK/1 +# - Jungle Leaves/64 # Only with Vault +# - Green Dye/6 # Only with Vault + cookingtime: 3 + distillruns: 2 + distilltime: 60 + wood: 4 + age: 11 + color: DARK_RED + difficulty: 3 + alcohol: 23 + effects: + - FIRE_RESISTANCE/20 + - HEAL/1 + - WEAKNESS/2-3/50-60 + - POISONX/1-0/20-0 + 1: + name: Skunky Wheatbeer/Wheatbeer/Fine Wheatbeer + ingredients: + - WHEAT/3 + cookingtime: 8 + distillruns: 0 + wood: 1 + age: 2 + color: BRIGHT_GREY + difficulty: 1 + alcohol: 5 + 2: + name: Skunky Beer/Beer/Fine Beer + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 0 + age: 3 + color: ORANGE + difficulty: 1 + alcohol: 6 + 3: + name: Skunky Darkbeer/Darkbeer/Fine Darkbeer + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 4 + age: 8 + color: BLACK + difficulty: 2 + alcohol: 7 + 4: + name: Awkward Mead/Mead/&6Golden Mead + ingredients: + - SUGAR_CANE/6 + cookingtime: 3 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 2 + alcohol: 9 + 5: + name: Apple Mead/Sweet Apple Mead/&6Sweet Golden Apple Mead + ingredients: + - SUGAR_CANE/6 + - APPLE/2 + cookingtime: 4 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 4 + alcohol: 12 + effects: + - WATER_BREATHINGX/1-2/150 + 6: + name: Bitter Rum/Spicy Rum/&6Golden Rum + ingredients: + - SUGAR_CANE/14 + cookingtime: 5 + distillruns: 2 + distilltime: 30 + wood: 2 + age: 14 + color: DARK_RED + difficulty: 6 + alcohol: 30 + effects: + - FIRE_RESISTANCE/1/20-100 + - POISONX/1-0/30-0 + 7: + name: Lousy Vodka/Vodka/Russian Vodka + ingredients: + - POTATO/10 + cookingtime: 15 + distillruns: 3 + age: 0 + color: BRIGHT_GREY + difficulty: 4 + alcohol: 20 + effects: + - WEAKNESS/15 + - POISON/10 + 8: + name: Poor Absinthe/Absinthe/Strong Absinthe + ingredients: + - GRASS/15 + cookingtime: 3 + distillruns: 6 + distilltime: 80 + color: GREEN + difficulty: 8 + alcohol: 45 + effects: + - POISON/20-30 + 9: + name: Potato soup + ingredients: + - POTATO/5 + - GRASS/3 + cookingtime: 3 + color: PINK + difficulty: 1 + effects: + - HEAL/0-1 + 10: + name: Stale Coffee/Coffee/Strong Coffee + ingredients: + - Cocoa_Beans/12 + - MILK_BUCKET/2 + cookingtime: 2 + color: BLACK + difficulty: 3 + effects: + - REGENERATION/1/2-5 + - SPEED/1/30-140 + +# More Recipes ideas: Cachaca, Gin, Whiskey, Tequila, Cider, etc. as well as high quality abbreviations like golden vodka etc. +# I will not add more Recipes to the default config, as they would be public and viewable by users to cheat. +# It is up to the Serveradmin to change and add Recipes, so players cannot cheat from the default config. + + + +# cooked: EVERY possible ingredient and the names for the originating potions after fermenting: +# [Example] MATERIAL_or_id: Name after cooking + +cooked: + WHEAT: Fermented wheat + SUGAR_CANE: Sugar brew + APPLE: Apple cider + POTATO: Potatomash + GRASS: Boiled herbs + RED_MUSHROOM: Mushroom brew + Cocoa_Beans: Colored brew + MILK_BUCKET: Milky water + + + +# -- 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 [true] +useLogBlock: true + + +# -- Chat Distortion Settings -- + +# If written Chat is distorted when the Player is Drunk, +# so that it looks like drunk writing +# How much the chat is distorted depends on how drunk the Player is +# Below are settings for what and how changes in chat occur +enableChatDistortion: true + +# Log to the Serverlog what the player actually wrote, before his words were altered [false] +logRealChat: false + +# Text after specified commands will be distorted when drunk (list) [- /gl] +distortCommands: +- /gl +- /global +- /fl +- /s +- /letter +- /g +- /l +- /lokal +- /local +- /mail send +- /m +- /msg +- /w +- /whisper +- /reply +- /r +- /t +- /tell + +# Distort the Text written on a Sign while drunk [false] +distortSignText: false + +# Enclose a Chat text with these Letters to bypass Chat Distortion (Use "," as Separator) (list) [- '[,]'] +# Chat Example: Hello i am drunk *I am testing Brewery* +distortBypass: +- '*,*' +- '[,]' + +# words: Words and letters that will be altered when chatting while being drunk. +# Will be processed from first to last and a written sentece is altered in that order. + +# replace: Word or letter to be replaced. (Special: "-space": replaces space, "-random": insert into random position, "-all": everything, "-start": At Beginning, "-end": At the End.) +# to: What to replace it with. +# pre: Words and Letters before the wanted word (split with ",") +# match: true = one of the "pre"-Words has to be before the wanted Word, false = none of the "pre" Words is allowed before the wanted Word +# alcohol: 1-100 minimum drunkeness after which this word ist replaced +# percentage: Probability of replacing a Word in percent + +words: +- replace: s + to: sh + percentage: 90 + alcohol: 30 + +- replace: ch + to: sh + pre: u,s,o,a + match: false + alcohol: 10 + percentage: 70 + +- replace: h + to: hh + pre: sch,h,t + match: false + percentage: 60 + alcohol: 20 + +- replace: th + to: thl + percentage: 40 + alcohol: 30 + +- replace: sch + to: shk + percentage: 60 + alcohol: 40 + +- replace: u + to: uuh + percentage: 20 + +- replace: y + to: yy + percentage: 60 + alcohol: 15 + +- replace: e + to: ee + percentage: 40 + alcohol: 15 + +- replace: you + to: u + percentage: 40 + +- replace: u + to: uo + pre: u + match: false + percentage: 60 + +- replace: that + to: taht + percentage: 20 + alcohol: 40 + +- replace: p + to: b + percentage: 30 + +- replace: p + to: b + percentage: 70 + alcohol: 60 + +- replace: up + to: ubb + percentage: 80 + alcohol: 25 + +- replace: o + to: oh + percentage: 20 + +- replace: ei + to: i + percentage: 30 + alcohol: 15 + +- replace: b + to: bb + percentage: 80 + alcohol: 40 + +- replace: '!!!' + to: '!!!111!!!eleven!1!' + pre: '!' + match: false + percentage: 20 + alcohol: 70 + +- replace: '!' + to: '!!' + pre: '!' + match: false + percentage: 90 + +- replace: drunk + to: dhrkunn + pre: are + match: false + percentage: 70 + alcohol: 65 + +- replace: walk + to: whhealhk + pre: you can, you can still, you can not + match: false + percentage: 80 + alcohol: 30 + +- replace: wtf + to: wft + percentage: 20 + alcohol: 40 + +- replace: lol + to: loool + percentage: 80 + alcohol: 10 + +- replace: afk + to: aafkayyy + percentage: 30 + alcohol: 30 + +- replace: write + to: wreitt + pre: you can,you can still,you can not + match: false + percentage: 80 + alcohol: 50 + +- replace: drink + to: booze + percentage: 80 + alcohol: 70 + +- replace: '?' + to: '????' + pre: '?' + match: false + percentage: 80 + alcohol: 40 + +- replace: -space + to: '' + pre: h,g,w + match: true + alcohol: 10 + +- replace: -space + to: '' + percentage: 30 + alcohol: 35 + +- replace: -space + to: '' + percentage: 10 + +- replace: -start + to: dho + percentage: 15 + alcohol: 50 + +- replace: -start + to: hhn + percentage: 10 + alcohol: 50 + +- replace: -random + to: lu + percentage: 10 + +- replace: -random + to: lug + percentage: 10 + alcohol: 50 + +- replace: -random + to: blub + percentage: 20 + alcohol: 80 + +- replace: -random + to: lerg + percentage: 40 + alcohol: 85 + +- replace: -random + to: gul + percentage: 40 + alcohol: 80 + +- replace: -random + to: ' ' + percentage: 100 + alcohol: 70 + +- replace: -random + to: ' ' + percentage: 60 + alcohol: 40 + +- replace: -random + to: ' ' + percentage: 50 + alcohol: 30 + +- replace: -end + to: '!' + percentage: 40 + alcohol: 30 + +- replace: -random + to: ' *hic* ' + percentage: 80 + alcohol: 70 + +- replace: -random + to: ' *hic* ' + percentage: 15 + alcohol: 40 + +- replace: -space + to: ' *hic* ' + percentage: 5 + alcohol: 20 + +- replace: -end + to: ' *hic*' + percentage: 70 + alcohol: 50 + +- replace: -all + to: '*burp*' + percentage: 3 + alcohol: 60 + +- replace: -all + to: '*burp*' + percentage: 6 + alcohol: 80 diff --git a/resources/config/v13/fr/config.yml b/resources/config/v13/fr/config.yml new file mode 100644 index 0000000..b798885 --- /dev/null +++ b/resources/config/v13/fr/config.yml @@ -0,0 +1,572 @@ +# config for Brewery.jar + + +# -- Paramètres -- +# Les paramètres par défaut sont entre [] +# Supprimer un paramètre le désactive + +# Fichier de langage utilisé (trouvable dans plugins/Brewery/languages) +language: fr + +# Si le joueur se réveille à son /home lors de sa connexion après un excès alcool (Un plugin de /home est nécessaire!) [true] +enableHome: true + +# Type de la téléportation /home: ['cmd: home'] +# bed = Le joueur se téléportera à son lit de réapparition. +# 'cmd: home' = /home sera exécuté par le joueur. Il devra avoir la permission sans le délai pour y parvenir! +# 'cmd: spawn' = /spawn sera exécuté par le joueur. +# 'cmd: whatever' = /whatever sera exécuté par le joueur. (Peu importe) +homeType: 'cmd: home' + +# Si le joueur se "réveille" à un point aléatoire sur la carte à sa connexion, pendant un excès d'alccol (Les points de réveil doivent être ajoutés avec '/brew Wakeup add' via un administrateur.) +# Le joueur se réveillera aléatoirement parmis les deux points de "réveil" les plus proches de lui [true] +enableWake: true + +# Si le joueur reçoit des connexions refusées au serveur s'il est ivre. [true] +enableLoginDisallow: true + +# Si le joueur s'évanouit (il sera kické) lorsqu'il boit trop d'alcool [false] +enableKickOnOverdrink: false + +# Si le joueur vomit en cas d'alcoolémie élevée (Le type d'objet "droppé" est configurable en dessous) [true] +# L'objet ne peut pas être collecté et reste sur le sol jusqu'à ce qu'il disparaisse +enablePuke: true + +# L'objet utilisé pour représenter le vomit [SOUL_SAND] +pukeItem: SOUL_SAND + +# Time in seconds until the pukeitems despawn, (mc default is 300 = 5 min) [60] +# If the item despawn time was changed in the spigot.yml, the pukeDespawntime changes as well. +pukeDespawntime: 60 + +# Consommables Objet/Force. Réduit le montant d'alcool par lors de la consommation. (list) +drainItems: +- BREAD/4 +- MILK_BUCKET/2 + +# Temps (en jours) pour que les données d'ivresse restent sauvergardées lorsque le joueur est déconnecté, pour appliquer les effets. [7] +hangoverDays: 7 + +# Colorer les informations d'objets (lore) au dépend de la qualité dans un tonneau et/ou dans un stand de brassage (l'alambic) [true, true] +colorInBarrels: true +colorInBrewer: true + +# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true] +openLargeBarrelEverywhere: true + +# Enable checking for Updates, Checks the curseforge api for updates to Brewery [true] +# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game +updateCheck: true + +# Intervale de la sauvegarde automatique en minutes [3] +autosave: 3 + +# Version de configuration +version: '1.5' + + +# -- Recette pour les boissons -- + +# name: Différents noms pour la mauvaise/moyen/bonne qualité (Les codes de mise en forme sont pris en charge: comme par exemple &6 pour la couleur Or.) +# ingredients: Liste des 'matériaux ou id,data/montant' +# (Les id d'objets à la place des matériaux sont obsolètes pour bukkit et pourraient ne pas fonctionner dans le futur!) +# Ex: 'SUGAR_CANE' +# Une liste des matériaux peuvent-être trouvés ici: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html +# Vous pouvez spécifier une data (Ex: 5,3 -> Planche de bois de jungle), si vous ne le faites pas la data ne sera pas prise en compte (Ex : 5 -> Bois en général) +# If Vault is installed normal names can be used instead of material or id, so using Vault is highly recommended. +# Vault will recognize things like "Jungle Leaves" instead of "5,3" +# cookingtime: Temps en minutes réelles durant lesquelles les ingrédients devront bouillir +# distillruns: Combien de fois le breuvage devra être distillé pour un alcool de qualité (0=Ne pas distiller) +# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec +# wood: Type de bois du baril 0=aucun 1=Bouleau 2=Chêne 3=Jungle 4=Pin 5=Acacia 6=Chêne Noir +# age: Temps en jours de Minecraft, la potion devra être âgée dans un baril. 0=Pas besoin d'âge +# color: Couleur de la potion après distillation/avoir laissé vieillir. +# Couleurs disponibles: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY (Dans l'ordre : Rouge foncé, Rouge, Rouge clair, Orange, Rose, Bleu, Cyan, Eau, Vert, Noir, Gris, Gris clair) +# difficulty: 1-10 précision nécessaire pour obtenir une bonne qualité (1 = imprécis/facile, 10 = très précis/difficile) +# alcohol: Le montant d'alcool absolu dans une boisson parfaite (cela sera ajouté directement au joueur, où 100% entraînera l'évanouissement), un degré d'alcooléisme en fait +# effects: Liste des effets/durée en secondes lors de la consommation. +# Rajouter le suffixe 'X' pour le cacher du label. Exemple: POISONX/10 +# (WEAKNESS, INCREASE_DAMAGE, SLOW et SPEED sont toujours cachés.) +# Effects are always hidden in 1.9 and newer, because of changes in the potion mechanics. +# Effets posssible: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html +# POUR LES EFFETS EN FONCTIONS DE LA QUALITE : Les Niveaux (I ou II) ou les Intervalles de durées d'effets doivent être spécifiés avec un "-". +# Ex: 'SPEED/1-2/30-40' => Vitesse niveau 1 et durée de 30 sec pour la pire qualité, et niveau 2 et durée de 40 sec pour la meilleure. +# Il est aussi possible de faire l'inverse, c'est à dire que le schéma "Meilleure qualité, meilleur effets" soit "Meilleure qualité, effets moins puissants. +# Cela peut-être utile pour des potions avec l'effet poison pour empoisonner moins avec une bonne qualité. +# Ex: 'POISON/3-1/20-5' => Poison de niveau 3 durant 20 sec à la moins bonne qualité et de niveau 1 et de durée 5 sec à la meilleure. +# Durées possibles maximum: 1638 sec. Les effets instantanés n'ont pas besoin d'avoir une durée spécifiée (Ex : Les potions de Soin instantané). + +recipes: +# Exemple de recette avec tous les paramètres possibles : + 0: + name: Mauvais Exemple/Exemple/Bonne Exemple + ingredients: + - SUGAR_CANE/5 + - diamond/1 + - Cocoa_Beans/20 + - spruce_planks/8 + - BEDROCK/1 +# - Jungle Leaves/64 # Only with Vault +# - Green Dye/6 # Only with Vault + cookingtime: 3 + distillruns: 2 + distilltime: 60 + wood: 4 + age: 11 + color: DARK_RED + difficulty: 3 + alcohol: 23 + effects: + - FIRE_RESISTANCE/20 + - HEAL/1 + - WEAKNESS/2-3/50-60 + - POISONX/1-0/20-0 + 1: + name: Bière Blanche Fade/Bière Blanche/Bonne Bière Blanche + ingredients: + - WHEAT/3 + cookingtime: 8 + distillruns: 0 + wood: 1 + age: 2 + color: BRIGHT_GREY + difficulty: 1 + alcohol: 5 + 2: + name: Bière Fade/Bière/Bonne Bière + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 0 + age: 3 + color: ORANGE + difficulty: 1 + alcohol: 6 + 3: + name: Bière Brune Fade/Bière Brune/Bonne Bière Brune + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 4 + age: 8 + color: BLACK + difficulty: 2 + alcohol: 7 + 4: + name: Hydromel Bizarre/Hydromel/&6Hydromel Doré + ingredients: + - SUGAR_CANE/6 + cookingtime: 3 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 2 + alcohol: 9 + 5: + name: Hydromel de Pommes/Doux Hydromel de Pommes/&6Doux Hydromel de Pommes Dorées + ingredients: + - SUGAR_CANE/6 + - APPLE/2 + cookingtime: 4 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 4 + alcohol: 12 + effects: + - WATER_BREATHINGX/1-2/150 + 6: + name: Rhum Amer/Rhum Epicé/&6Rhum Doré + ingredients: + - SUGAR_CANE/14 + cookingtime: 5 + distillruns: 2 + distilltime: 30 + wood: 2 + age: 14 + color: DARK_RED + difficulty: 6 + alcohol: 30 + effects: + - FIRE_RESISTANCE/1/20-100 + - POISONX/1-0/30-0 + 7: + name: Vodka Sale/Vodka/Vodka Russe + ingredients: + - POTATO/10 + cookingtime: 15 + distillruns: 3 + age: 0 + color: BRIGHT_GREY + difficulty: 4 + alcohol: 20 + effects: + - WEAKNESS/15 + - POISON/10 + 8: + name: Absinthe pauvre/Absinthe/Absinthe forte + ingredients: + - GRASS/15 + cookingtime: 3 + distillruns: 6 + distilltime: 80 + color: GREEN + difficulty: 8 + alcohol: 45 + effects: + - POISON/20-30 + 9: + name: Potato soup + ingredients: + - POTATO/5 + - GRASS/3 + cookingtime: 3 + color: PINK + difficulty: 1 + effects: + - HEAL/0-1 + 10: + name: Café fétide/Café/Café fort + ingredients: + - Cocoa_Beans/12 + - MILK_BUCKET/2 + cookingtime: 2 + color: BLACK + difficulty: 3 + effects: + - REGENERATION/1/2-5 + - SPEED/1/30-140 + +# Plus d'idées de recettes: Cachaça, Gin, Whisky, Tequila, Cidre, etc. et abréviations de haute qualité comme la vodka dorée etc. +# Je n'ajouterai pas plus de recettes à la configuration par défaut, car elles seront publiques et visibles par tous les utilisateurs et parce que les joueurs pourraient tricher en les voyant. +# Ce sera aux Admins des serveurs de changer et d'ajouter les recettes, ainsi les joueurs ne pourront pas tricher avec les configuration de base. + + + +# cooked: CHAQUE ingrédient possible avec le nom donné après la fermentation (la cuisson): +# [Exemple] MATERIEL_ou_id: Nom après la cuisson + +cooked: + WHEAT: Blé fermenté + SUGAR_CANE: Sucre fermenté + APPLE: Cidre de pommes + POTATO: Purée de Pommes de Terre + GRASS: Herbes bouillies + RED_MUSHROOM: Champignons fermentés + Cocoa_Beans: Fermentation colorée + MILK_BUCKET: Eau laiteuse + + + +# -- Compatibilité entre Plugins -- + +# Activer la vérification des autres plugins (si installés) pour les permissions des tonneaux. [true] +useWorldGuard: true +useLWC: true +useGriefPrevention: true + +# Activer l'historique du contenu des tonneaux avec LogBlock [true] +useLogBlock: true + + +# -- Paramètres de la distorsion du Chat -- + +# If written Chat is distorted when the Player is Drunk, +# so that it looks like drunk writing +# How much the chat is distorted depends on how drunk the Player is +# Below are settings for what and how changes in chat occur +enableChatDistortion: true + +# Ecrire dans les "logs" du serveur ce que le joueur devrait dire, à la place de la distorsion. [false] +logRealChat: false + +# Distordre le texte dans le Chat après les commandes spécifiées (list) [- /gl] +distortCommands: +- /gl +- /global +- /fl +- /s +- /letter +- /g +- /l +- /lokal +- /local +- /mail send +- /m +- /msg +- /w +- /whisper +- /reply +- /r +- /t +- /tell + +# Distordre le texte sur les panneaux pendant l'ivresse [false] +distortSignText: false + +# Entourer les textes avec ces caractères pour ignorer la distorsion (Utilisez "," comme un séparateur) (list) [- '[,]'] +# Chat Example: Hello i am drunk *I am testing Brewery* +distortBypass: +- '*,*' +- '[,]' + +# words: Les mots et les lettres altérées dans le chat lors d'un état d'ivresse. +# Commence du haut jusqu'au bas. Les phrases sont altérées par l'ordre écrit. + +# replace: Mot ou lettre à remplacer (Spécial: "-space": remplace les espaces, "-random": s'insère dans une position aléatoire, "-all": Toute la ligne, "-start": Au début, "-end": A la fin.) +# to: Ce qui remplacera. +# pre: Les mots et les lettres avant le mot désiré (séparez avec ",") +# match: true = Si un des "Pre-Mots" est nécessaire avant le mot désiré, false = Aucun des "Pre-Mots" n'est autorisé avant le mot désiré. +# alcohol: 1-100 Le montant minimal d'alcool pour que la distorsion fonctionne. +# percentage: Probabilité en pourcentage que le mot soit remplacé. + +words: +- replace: s + to: sh + percentage: 90 + alcohol: 30 + +- replace: ch + to: sh + pre: u,s,o,a + match: false + alcohol: 10 + percentage: 70 + +- replace: h + to: hh + pre: sch,h,t + match: false + percentage: 60 + alcohol: 20 + +- replace: th + to: thl + percentage: 40 + alcohol: 30 + +- replace: sch + to: shk + percentage: 60 + alcohol: 40 + +- replace: u + to: uuh + percentage: 20 + +- replace: y + to: yy + percentage: 60 + alcohol: 15 + +- replace: e + to: ee + percentage: 40 + alcohol: 15 + +- replace: toi + to: twa + percentage: 40 + +- replace: u + to: uo + pre: u + match: false + percentage: 60 + +- replace: ça + to: sha + percentage: 20 + alcohol: 40 + +- replace: p + to: b + percentage: 30 + +- replace: p + to: b + percentage: 70 + alcohol: 60 + +- replace: up + to: ubb + percentage: 80 + alcohol: 25 + +- replace: o + to: oh + percentage: 20 + +- replace: ei + to: i + percentage: 30 + alcohol: 15 + +- replace: b + to: bb + percentage: 80 + alcohol: 40 + +- replace: '!!!' + to: '!!!?!???!?!?!!!' + pre: '!' + match: false + percentage: 20 + alcohol: 70 + +- replace: '!' + to: '!!' + pre: '!' + match: false + percentage: 90 + +- replace: ivre + to: shaoul + pre: es, êtes + match: false + percentage: 70 + alcohol: 65 + +- replace: marcher + to: mrashere + pre: tu peux, vous pouvez, tu ne peux pas, vous ne pouvez pas + match: false + percentage: 80 + alcohol: 30 + +- replace: wtf + to: wft + percentage: 20 + alcohol: 40 + +- replace: lol + to: loool + percentage: 80 + alcohol: 10 + +- replace: afk + to: aaAAaafffFFFfffKAAAAAA + percentage: 30 + alcohol: 30 + +- replace: écrire + to: ekrir + pre: tu peux, vous pouvez, tu ne peux pas, vous ne pouvez pas + match: false + percentage: 80 + alcohol: 50 + +- replace: drink + to: booze + percentage: 80 + alcohol: 70 + +- replace: '?' + to: '????' + pre: '?' + match: false + percentage: 80 + alcohol: 40 + +- replace: -space + to: '' + pre: h,g,w + match: true + alcohol: 10 + +- replace: -space + to: '' + percentage: 30 + alcohol: 35 + +- replace: -space + to: '' + percentage: 10 + +- replace: -start + to: dho + percentage: 15 + alcohol: 50 + +- replace: -start + to: hhn + percentage: 10 + alcohol: 50 + +- replace: -random + to: lu + percentage: 10 + +- replace: -random + to: lug + percentage: 10 + alcohol: 50 + +- replace: -random + to: blub + percentage: 20 + alcohol: 80 + +- replace: -random + to: lerg + percentage: 40 + alcohol: 85 + +- replace: -random + to: gul + percentage: 40 + alcohol: 80 + +- replace: -random + to: ' ' + percentage: 100 + alcohol: 70 + +- replace: -random + to: ' ' + percentage: 60 + alcohol: 40 + +- replace: -random + to: ' ' + percentage: 50 + alcohol: 30 + +- replace: -end + to: '!' + percentage: 40 + alcohol: 30 + +- replace: -random + to: ' *hic* ' + percentage: 80 + alcohol: 70 + +- replace: -random + to: ' *hic* ' + percentage: 15 + alcohol: 40 + +- replace: -space + to: ' *hic* ' + percentage: 5 + alcohol: 20 + +- replace: -end + to: ' *hic*' + percentage: 70 + alcohol: 50 + +- replace: -all + to: '*burp*' + percentage: 3 + alcohol: 60 + +- replace: -all + to: '*burp*' + percentage: 6 + alcohol: 80 diff --git a/resources/config/v13/it/config.yml b/resources/config/v13/it/config.yml new file mode 100644 index 0000000..b207098 --- /dev/null +++ b/resources/config/v13/it/config.yml @@ -0,0 +1,567 @@ +# config di Brewery.jar + + +# -- Opzioni -- +# I valori di default sono scritti fra [] +# Cancellare una voce la disabilita + +# Lingua da usare (fra quelle in plugins/Brewery/languages) +language: it + +# Se il giocatore si sveglia nella sua /home dopo aver bevuto troppo(il plugin di /home deve essere installato!) [true] +enableHome: true + +# Tipo di teletrasporto alla home ['cmd: home'] +# bed = Il giocatore sarà teletrasportato al suo letto +# 'cmd: home' = /home sarà eseguito dal giocatore. Deve avere il permesso di farlo senza ritardi! +# 'cmd: spawn' = /spawn sarà eseguito dal giocatore +# 'cmd: faitu' = /faitu sarà eseguito dal giocatore. +homeType: 'cmd: home' + +# Se il giocatore si risveglia in un posto a caso dopo essere andato offline mentre beveva (questi posti devono essere definiti con '/brew Wakeup add' da un admin) +# Il giocatore si risveglia al punto di risveglio più vicino [true] +enableWake: true + +# Se il giocatore debba provare più volte per loggare da molto ubriaco [true] +enableLoginDisallow: true + +# Se il giocatore viene espulso dal server se raggiunge la percentuale massima di alcol [false] +enableKickOnOverdrink: false + +# Se il giocatore vomita se molto sbronzo [true] +# L'oggetto non può essere raccolto e resta per terra finché non sparisce. +enablePuke: true + +# L'oggetto droppato in massa quando si vomita che dovrebbe rappresentare il vomito [SOUL_SAND] +pukeItem: SOUL_SAND + +# Tempo in secondi perché il vomito sparisca (il valore di minecraft di default è 300 = 5 min) [60] +# Se il tempo di scomparsa viene cambiato in spigot.yml anche pukeDespawntime cambia. +pukeDespawntime: 60 + +# Oggetto consumabile/forza. Questi oggetti se consumati calano il livello di alcool (della "forza" che avevi impsotato) (list) +drainItems: +- BREAD/4 +- MILK_BUCKET/2 + +# Tempo in giorni che la sbronza resta in memoria dopo che il giocatore va offline, cioè il tempo per cui i postumi della sbornia durano. [7] +hangoverDays: 7 + +# Colora la descrizione dell'item in base alla qualità mentre è in un barile o in un alambicco [true, true] +colorInBarrels: true +colorInBrewer: true + +# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true] +openLargeBarrelEverywhere: true + +# Abilita il controllo degli aggiornamenti, controlla l'API di CurseForge per eventuali aggiornamenti di Brewery [true] +# Se quando un aggiornamento viene trovato un messaggio è loggato e mostrato agli OPs quando entrano in gioco. +updateCheck: true + +# Intervallo di autosalvataggio in minuti [3] +autosave: 3 + +# Versione del config +version: '1.5' + + +# -- Ricette per pozioni -- + +# name: Tre nomi diversi per diverse qualità (cattivo/normale/buono). I codici come &6 possono essere usati. +# ingredients: Lista degli ingredienti nel formato materiale o id,dati/quantità +# (Gli id invece dei materiali sono "disapprovati" da Bukkit e potrebbero non funzionare in futuro!) +# Una lista di materiali può essere trovata qui: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html +# Puoi specificare dei dati dell'oggetto, ma se omesso sarà semplicemente ignorato. +# Se Vault è installato i nomi normali possono essere usati invece del materiale o dell'id quindi l'uso di Vault è fortemente consigliato. +# Vault riconoscerà cose come "Jungle Leaves" invece di "LEAVES,3". +# cookingtime: Tempo in minuti richiesto dagli ingredienti per bollire +# distillruns: Quanto spesso deve essere distillato per ottenere la versione perfetta con il volume alcolico impostato (0=non serve distillare). +# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec +# wood: Legno del barile 0=qualiasi 1=Betulla 2=Quercia 3=Mogano 4=Abete 5=Acacia 6=Quercia nera +# age: Tempo in giorni di Minecraft per cui la pozione deve essere invecchiata in un barile (0=nessun invecchiamento). +# color: Colore della pozione dopo essere stata distillata/invecchiata +# Colori utilizzabili: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY +# difficoltà: Precisione richiesta per avere la migliore qualità da 1 a 10(1 = spreciso/più facile, 10 = molto preciso/più difficile) +# alcohol: Volume alcolico da 0 a 100 nella versione perfetta (sarà aggiunta direttamente al giocatore, dove 100 è la quantità massima di alcohol assorbibile. +# effects: Eventuali effetti come quelli delle pozioni nel formato di effetto/livello/durata. +# Aggiungere il suffisso 'X' per nascondere l'effetto dalla descrizione. Esempio: 'POISONX/2/10' (gli effetti WEAKNESS, INCREASE_DAMAGE, SLOW and SPEED sono sempre nascosti). +# Gli effetti sono sempre nascosti dalla 1.9 in poi, per via dei cambiamenti nelle meccaniche delle pozioni. +# Lista di effetti possibili: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html +# Intervalli di livelli o durate possono essere specificati con un "-", per esempio 'SPEED/1-2/30-40'. Ciò significa nel peggior caso livello 1 e 30 secondi di durata e livello 2 e 40 secondi nel migliore. +# Gli intervalli funzionano anche in ordine decrescente, per effetti più deboli a qualità maggiori. Esempio: 'POISON/3-1/20-5'. +# La durata massima possibile è 1638 secondi. Gli effetti instantaner non hanno bisogno che la durata sia specificata. + +recipes: +# Ricetta di esempio con ogni opzione possibile: + 0: + name: Cattivo esempio/Esempio/Buon esempio + ingredients: + - SUGAR_CANE/5 + - diamond/1 + - Cocoa_Beans/20 + - spruce_planks/8 + - BEDROCK/1 +# - Jungle Leaves/64 # Solo con Vault +# - Green Dye/6 # Solo con Vault + cookingtime: 3 + distillruns: 2 + distilltime: 60 + wood: 4 + age: 11 + color: DARK_RED + difficulty: 3 + alcohol: 23 + effects: + - FIRE_RESISTANCE/20 + - HEAL/1 + - WEAKNESS/2-3/50-60 + - POISONX/1-0/20-0 + 1: + name: Birra di frumento puzzolente/Birra di frumento/Birra di frumento pregiata + ingredients: + - WHEAT/3 + cookingtime: 8 + distillruns: 0 + wood: 1 + age: 2 + color: BRIGHT_GREY + difficulty: 1 + alcohol: 5 + 2: + name: Birra puzzolente/Birra/Birra pregiata + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 0 + age: 3 + color: ORANGE + difficulty: 1 + alcohol: 6 + 3: + name: Birra scura puzzolente/Birra scura/Birra scura pregiata + ingredients: + - WHEAT/6 + cookingtime: 8 + distillruns: 0 + wood: 4 + age: 8 + color: BLACK + difficulty: 2 + alcohol: 7 + 4: + name: Idromele scarso/Idromele/&6Idromele dorato + ingredients: + - SUGAR_CANE/6 + cookingtime: 3 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 2 + alcohol: 9 + 5: + name: Idromele di mele/Idromele di mele dolci/&6Idromele di mele dolci dorato + ingredients: + - SUGAR_CANE/6 + - APPLE/2 + cookingtime: 4 + distillruns: 0 + wood: 2 + age: 4 + color: ORANGE + difficulty: 4 + alcohol: 12 + effects: + - WATER_BREATHINGX/1-2/150 + 6: + name: Rum amaro/Rum speziato/&6Rum dorato + ingredients: + - SUGAR_CANE/14 + cookingtime: 5 + distillruns: 2 + distilltime: 30 + wood: 2 + age: 14 + color: DARK_RED + difficulty: 6 + alcohol: 30 + effects: + - FIRE_RESISTANCE/1/20-100 + - POISONX/1-0/30-0 + 7: + name: Vodka schifosa/Vodka/Vodka russa + ingredients: + - POTATO/10 + cookingtime: 15 + distillruns: 3 + age: 0 + color: BRIGHT_GREY + difficulty: 4 + alcohol: 20 + effects: + - WEAKNESS/15 + - POISON/10 + 8: + name: Assenzio scarso/Assenzio/Assenzio forte + ingredients: + - GRASS/15 + cookingtime: 3 + distillruns: 6 + distilltime: 80 + color: GREEN + difficulty: 8 + alcohol: 45 + effects: + - POISON/20-30 + 9: + name: Zuppa di patate + ingredients: + - POTATO/5 + - GRASS/3 + cookingtime: 3 + color: PINK + difficulty: 1 + effects: + - HEAL/0-1 + 10: + name: Caffè stantio/Caffè/Caffè forte + ingredients: + - Cocoa_Beans,3/12 + - MILK_BUCKET/2 + cookingtime: 2 + color: BLACK + difficulty: 3 + effects: + - REGENERATION/1/2-5 + - SPEED/1/30-140 + +# Altre idee per ricette: Cachaca, Gin, Whiskey, Tequila, Sidro, ecc. Altri nomi per le altre qualità come Vodka Dorata ecc. +# Io non aggiungerò altre ricette al config di default, perché sarebbero pubbliche e visibiliad altri utenti per barare. +# Aggiungere e cambiare ricette è compito del Server Admin, così che i giocatori non possano barare guardando il config di default. + + + +# cooked: OGNI possibile ingrediente e i nomi per la pozione originatasi dopo la fermentazione. +# (Esempio) MATERIALE_o_id: Nome dopo la cottura + +cooked: + WHEAT: Frumento fermentato + SUGAR_CANE: Miscela zuccherata + APPLE: Sidro di mele + POTATO: Purè di patate + GRASS: Erbe bollite + RED_MUSHROOM: Miscela ai funghi + Cocoa_Beans: Miscela colorata + MILK_BUCKET: Acqua lattea + + + +# -- Compatibilità con altri plugin -- + +# Abilita il controllo della presenza di altri plugin per i permessi relativi ai barili[true] +useWorldGuard: true +useLWC: true +useGriefPrevention: true + +# Abilita il logging degli inventari dei barili [true] +useLogBlock: true + + +# -- Imostazioni di distorsione della chat -- + +# If written Chat is distorted when the Player is Drunk, +# so that it looks like drunk writing +# How much the chat is distorted depends on how drunk the Player is +# Below are settings for what and how changes in chat occur +enableChatDistortion: true + +# Salva nel log del server quello che il giocatore ha realmente scritto, prima che le sue parole venissero alterate [false] +logRealChat: false + +# Il testo seguente ad alcuni comandi definiti qui sotto sarà distorto da ubriachi [- /gl] +distortCommands: +- /gl +- /global +- /fl +- /s +- /letter +- /g +- /l +- /lokal +- /local +- /mail send +- /m +- /msg +- /w +- /whisper +- /reply +- /r +- /t +- /tell + +# Distorci il testo sui cartelli quando sei ubriaco [false] +distortSignText: false + +# Definisci dei caratteri fra cui inserire le parole per evitare la distorsione della chat (usa "," come separatore) (list) [- '[,]'] +# Chat Example: Hello i am drunk *I am testing Brewery* +distortBypass: +- '*,*' +- '[,]' + +# words: Lettere e parole che saranno alterate chattando durante la sbronza. +# Saranno elaborate dalla prima all'ultima e la frase scritta viene alterata in quell'ordine. + +# replace: Lettere o parole da sostituire. (Special: "-space": sostituisco spazio, "-random": lo mette in una posizione a caso, "-all": tutto, "-start": all'inizio, "-end": alla fine.) +# to: Con cosa sostituirle. +# pre: Lettere e parole prima della parola voluta (separa con ","). +# match: true = una delle parole specificate in "pre" deve precedere la parola bersaglio, false = nessuna delle parole in "pre" deve trovarsi prima della parola bersaglio. +# alcohol: Ubriachezza minima da 1 a 100 perché la parola sia alterata. +# percentage: Probabilità di sostituzione in perchentuale. + +words: +- replace: s + to: sh + percentage: 90 + alcohol: 30 + +- replace: ch + to: sh + pre: u,s,o,a + match: false + alcohol: 10 + percentage: 70 + +- replace: h + to: hh + pre: sch,h,t + match: false + percentage: 60 + alcohol: 20 + +- replace: th + to: thl + percentage: 40 + alcohol: 30 + +- replace: sch + to: shk + percentage: 60 + alcohol: 40 + +- replace: u + to: uuh + percentage: 20 + +- replace: y + to: yy + percentage: 60 + alcohol: 15 + +- replace: e + to: ee + percentage: 40 + alcohol: 15 + +- replace: tu + to: te + percentage: 40 + +- replace: u + to: uo + pre: u + match: false + percentage: 60 + +- replace: that + to: taht + percentage: 20 + alcohol: 40 + +- replace: p + to: b + percentage: 30 + +- replace: p + to: b + percentage: 70 + alcohol: 60 + +- replace: up + to: ubb + percentage: 80 + alcohol: 25 + +- replace: o + to: oh + percentage: 20 + +- replace: ei + to: i + percentage: 30 + alcohol: 15 + +- replace: b + to: bb + percentage: 80 + alcohol: 40 + +- replace: '!!!' + to: '!!!111!!!undici!1!' + pre: '!' + match: false + percentage: 20 + alcohol: 70 + +- replace: '!' + to: '!!' + pre: '!' + match: false + percentage: 90 + +- replace: sbronzo + to: shhbronnzo + pre: are + match: false + percentage: 70 + alcohol: 65 + +- replace: cammina + to: caahkhhmmminnna + pre: puoi, puoi ancora, non puoi + match: false + percentage: 80 + alcohol: 30 + +- replace: wtf + to: wft + percentage: 20 + alcohol: 40 + +- replace: lol + to: loool + percentage: 80 + alcohol: 10 + +- replace: afk + to: aafkayyy + percentage: 30 + alcohol: 30 + +- replace: scrivere + to: shhkrihvehrre + pre: puoi,puoi ancora,non puoi + match: false + percentage: 80 + alcohol: 50 + +- replace: drink + to: booze + percentage: 80 + alcohol: 70 + +- replace: '?' + to: '????' + pre: '?' + match: false + percentage: 80 + alcohol: 40 + +- replace: -space + to: '' + pre: h,g,w + match: true + alcohol: 10 + +- replace: -space + to: '' + percentage: 30 + alcohol: 35 + +- replace: -space + to: '' + percentage: 10 + +- replace: -start + to: dho + percentage: 15 + alcohol: 50 + +- replace: -start + to: hhn + percentage: 10 + alcohol: 50 + +- replace: -random + to: lu + percentage: 10 + +- replace: -random + to: lug + percentage: 10 + alcohol: 50 + +- replace: -random + to: blub + percentage: 20 + alcohol: 80 + +- replace: -random + to: lerg + percentage: 40 + alcohol: 85 + +- replace: -random + to: gul + percentage: 40 + alcohol: 80 + +- replace: -random + to: ' ' + percentage: 100 + alcohol: 70 + +- replace: -random + to: ' ' + percentage: 60 + alcohol: 40 + +- replace: -random + to: ' ' + percentage: 50 + alcohol: 30 + +- replace: -end + to: '!' + percentage: 40 + alcohol: 30 + +- replace: -random + to: ' *hic* ' + percentage: 80 + alcohol: 70 + +- replace: -random + to: ' *hic* ' + percentage: 15 + alcohol: 40 + +- replace: -space + to: ' *hic* ' + percentage: 5 + alcohol: 20 + +- replace: -end + to: ' *hic*' + percentage: 70 + alcohol: 50 + +- replace: -all + to: '*burp*' + percentage: 3 + alcohol: 60 + +- replace: -all + to: '*burp*' + percentage: 6 + alcohol: 80 From f736a6e331270b0cad8e1babccc05f9f466f2a22 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 21 Sep 2018 22:10:07 +0200 Subject: [PATCH 18/20] Load 1.13 configs in 1.13+ and 1.12 configs in 1.12- --- resources/config/v12/de/config.yml | 2 +- resources/config/v12/en/config.yml | 2 +- resources/config/v12/fr/config.yml | 2 +- resources/config/v12/it/config.yml | 2 +- resources/config/v13/de/config.yml | 2 +- resources/config/v13/en/config.yml | 2 +- resources/config/v13/fr/config.yml | 2 +- resources/config/v13/it/config.yml | 2 +- src/com/dre/brewery/P.java | 6 +++--- src/com/dre/brewery/filedata/ConfigUpdater.java | 6 +++++- 10 files changed, 16 insertions(+), 12 deletions(-) diff --git a/resources/config/v12/de/config.yml b/resources/config/v12/de/config.yml index 06b6768..54183f2 100644 --- a/resources/config/v12/de/config.yml +++ b/resources/config/v12/de/config.yml @@ -65,7 +65,7 @@ updateCheck: true autosave: 3 # Config Version -version: '1.5' +version: '1.6' # -- Rezepte für Getränke -- diff --git a/resources/config/v12/en/config.yml b/resources/config/v12/en/config.yml index 2460954..47dec75 100644 --- a/resources/config/v12/en/config.yml +++ b/resources/config/v12/en/config.yml @@ -62,7 +62,7 @@ updateCheck: true autosave: 3 # Config Version -version: '1.5' +version: '1.6' # -- Recipes for Potions -- diff --git a/resources/config/v12/fr/config.yml b/resources/config/v12/fr/config.yml index e9d83d7..9353ccb 100644 --- a/resources/config/v12/fr/config.yml +++ b/resources/config/v12/fr/config.yml @@ -62,7 +62,7 @@ updateCheck: true autosave: 3 # Version de configuration -version: '1.5' +version: '1.6' # -- Recette pour les boissons -- diff --git a/resources/config/v12/it/config.yml b/resources/config/v12/it/config.yml index 591a76b..d168625 100644 --- a/resources/config/v12/it/config.yml +++ b/resources/config/v12/it/config.yml @@ -62,7 +62,7 @@ updateCheck: true autosave: 3 # Versione del config -version: '1.5' +version: '1.6' # -- Ricette per pozioni -- diff --git a/resources/config/v13/de/config.yml b/resources/config/v13/de/config.yml index 908dbf2..edd0e11 100644 --- a/resources/config/v13/de/config.yml +++ b/resources/config/v13/de/config.yml @@ -65,7 +65,7 @@ updateCheck: true autosave: 3 # Config Version -version: '1.5' +version: '1.6' # -- Rezepte für Getränke -- diff --git a/resources/config/v13/en/config.yml b/resources/config/v13/en/config.yml index a7acf83..d931e10 100644 --- a/resources/config/v13/en/config.yml +++ b/resources/config/v13/en/config.yml @@ -62,7 +62,7 @@ updateCheck: true autosave: 3 # Config Version -version: '1.5' +version: '1.6' # -- Recipes for Potions -- diff --git a/resources/config/v13/fr/config.yml b/resources/config/v13/fr/config.yml index b798885..3ffb606 100644 --- a/resources/config/v13/fr/config.yml +++ b/resources/config/v13/fr/config.yml @@ -62,7 +62,7 @@ updateCheck: true autosave: 3 # Version de configuration -version: '1.5' +version: '1.6' # -- Recette pour les boissons -- diff --git a/resources/config/v13/it/config.yml b/resources/config/v13/it/config.yml index b207098..972b72e 100644 --- a/resources/config/v13/it/config.yml +++ b/resources/config/v13/it/config.yml @@ -62,7 +62,7 @@ updateCheck: true autosave: 3 # Versione del config -version: '1.5' +version: '1.6' # -- Ricette per pozioni -- diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index 9c3de8d..be60092 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -37,7 +37,7 @@ 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; @@ -606,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; @@ -633,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(); diff --git a/src/com/dre/brewery/filedata/ConfigUpdater.java b/src/com/dre/brewery/filedata/ConfigUpdater.java index c168846..6cb8ebb 100644 --- a/src/com/dre/brewery/filedata/ConfigUpdater.java +++ b/src/com/dre/brewery/filedata/ConfigUpdater.java @@ -144,7 +144,11 @@ public class ConfigUpdater { fromVersion = "1.5"; } - if (!fromVersion.equals("1.5")) { + if (fromVersion.equals("1.5")) { + fromVersion = "1.6"; + } + + if (!fromVersion.equals("1.6")) { P.p.log(P.p.languageReader.get("Error_ConfigUpdate", fromVersion)); return; } From fcc60c133a1bc7e7aad881e77876c5792e152081 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 21 Sep 2018 22:28:35 +0200 Subject: [PATCH 19/20] Switch from MCStats to bStats --- pom.xml | 36 + src/com/dre/brewery/P.java | 10 +- src/com/dre/brewery/integration/Metrics.java | 758 ------------------- 3 files changed, 38 insertions(+), 766 deletions(-) delete mode 100644 src/com/dre/brewery/integration/Metrics.java diff --git a/pom.xml b/pom.xml index 974153b..c1d19cb 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,32 @@ UTF-8 + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + + package + + shade + + + + + org.bstats:bstats-bukkit + + + + + org.bstats.bukkit + com.dre.brewery.integration + + + + + + @@ -68,6 +94,10 @@ dre2n-rpo http://erethon.de/repo/ + + bstats-repo + http://repo.bstats.org/content/repositories/releases/ + @@ -125,5 +155,11 @@ + + org.bstats + bstats-bukkit + 1.2 + compile + diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index be60092..bdf6ed5 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -19,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; @@ -91,7 +92,7 @@ public class P extends JavaPlugin { readData(); // Setup Metrics - setupMetrics(); + new Metrics(this); // Listeners blockListener = new BlockListener(); @@ -156,13 +157,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; diff --git a/src/com/dre/brewery/integration/Metrics.java b/src/com/dre/brewery/integration/Metrics.java deleted file mode 100644 index 50de079..0000000 --- a/src/com/dre/brewery/integration/Metrics.java +++ /dev/null @@ -1,758 +0,0 @@ -package com.dre.brewery.integration; - -/* - * Copyright 2011-2013 Tyler Blair. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and contributors and should not be interpreted as representing official policies, - * either expressed or implied, of anybody else. - */ - -import org.bukkit.Bukkit; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.scheduler.BukkitTask; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.Proxy; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Level; -import java.util.zip.GZIPOutputStream; - -public class Metrics { - - /** - * The current revision number - */ - private final static int REVISION = 7; - - /** - * The base url of the metrics domain - */ - private static final String BASE_URL = "http://report.mcstats.org"; - - /** - * The url used to report a server's status - */ - private static final String REPORT_URL = "/plugin/%s"; - - /** - * Interval of time to ping (in minutes) - */ - private static final int PING_INTERVAL = 15; - - /** - * The plugin this metrics submits for - */ - private final Plugin plugin; - - /** - * All of the custom graphs to submit to metrics - */ - private final Set graphs = Collections.synchronizedSet(new HashSet()); - - /** - * The plugin configuration file - */ - private final YamlConfiguration configuration; - - /** - * The plugin configuration file - */ - private final File configurationFile; - - /** - * Unique server id - */ - private final String guid; - - /** - * Debug mode - */ - private final boolean debug; - - /** - * Lock for synchronization - */ - private final Object optOutLock = new Object(); - - /** - * The scheduled task - */ - private volatile BukkitTask task = null; - - public Metrics(final Plugin plugin) throws IOException { - if (plugin == null) { - throw new IllegalArgumentException("Plugin cannot be null"); - } - - this.plugin = plugin; - - // load the config - configurationFile = getConfigFile(); - configuration = YamlConfiguration.loadConfiguration(configurationFile); - - // add some defaults - configuration.addDefault("opt-out", false); - configuration.addDefault("guid", UUID.randomUUID().toString()); - configuration.addDefault("debug", false); - - // Do we need to create the file? - if (configuration.get("guid", null) == null) { - configuration.options().header("http://mcstats.org").copyDefaults(true); - configuration.save(configurationFile); - } - - // Load the guid then - guid = configuration.getString("guid"); - debug = configuration.getBoolean("debug", false); - } - - /** - * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics - * website. Plotters can be added to the graph object returned. - * - * @param name The name of the graph - * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given - */ - public Graph createGraph(final String name) { - if (name == null) { - throw new IllegalArgumentException("Graph name cannot be null"); - } - - // Construct the graph object - final Graph graph = new Graph(name); - - // Now we can add our graph - graphs.add(graph); - - // and return back - return graph; - } - - /** - * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend - * - * @param graph The name of the graph - */ - public void addGraph(final Graph graph) { - if (graph == null) { - throw new IllegalArgumentException("Graph cannot be null"); - } - - graphs.add(graph); - } - - /** - * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the - * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 - * ticks. - * - * @return True if statistics measuring is running, otherwise false. - */ - public boolean start() { - synchronized (optOutLock) { - // Did we opt out? - if (isOptOut()) { - return false; - } - - // Is metrics already running? - if (task != null) { - return true; - } - - // Begin hitting the server with glorious data - task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { - - private boolean firstPost = true; - - public void run() { - try { - // This has to be synchronized or it can collide with the disable method. - synchronized (optOutLock) { - // Disable Task, if it is running and the server owner decided to opt-out - if (isOptOut() && task != null) { - task.cancel(); - task = null; - // Tell all plotters to stop gathering information. - for (Graph graph : graphs) { - graph.onOptOut(); - } - } - } - - // We use the inverse of firstPost because if it is the first time we are posting, - // it is not a interval ping, so it evaluates to FALSE - // Each time thereafter it will evaluate to TRUE, i.e PING! - postPlugin(!firstPost); - - // After the first post we set firstPost to false - // Each post thereafter will be a ping - firstPost = false; - } catch (IOException e) { - if (debug) { - Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); - } - } - } - }, 0, PING_INTERVAL * 1200); - - return true; - } - } - - /** - * Has the server owner denied plugin metrics? - * - * @return true if metrics should be opted out of it - */ - public boolean isOptOut() { - synchronized (optOutLock) { - try { - // Reload the metrics file - configuration.load(getConfigFile()); - } catch (IOException ex) { - if (debug) { - Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); - } - return true; - } catch (InvalidConfigurationException ex) { - if (debug) { - Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); - } - return true; - } - return configuration.getBoolean("opt-out", false); - } - } - - /** - * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. - * - * @throws java.io.IOException - */ - public void enable() throws IOException { - // This has to be synchronized or it can collide with the check in the task. - synchronized (optOutLock) { - // Check if the server owner has already set opt-out, if not, set it. - if (isOptOut()) { - configuration.set("opt-out", false); - configuration.save(configurationFile); - } - - // Enable Task, if it is not running - if (task == null) { - start(); - } - } - } - - /** - * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. - * - * @throws java.io.IOException - */ - public void disable() throws IOException { - // This has to be synchronized or it can collide with the check in the task. - synchronized (optOutLock) { - // Check if the server owner has already set opt-out, if not, set it. - if (!isOptOut()) { - configuration.set("opt-out", true); - configuration.save(configurationFile); - } - - // Disable Task, if it is running - if (task != null) { - task.cancel(); - task = null; - } - } - } - - /** - * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status - * - * @return the File object for the config file - */ - public File getConfigFile() { - // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use - // is to abuse the plugin object we already have - // plugin.getDataFolder() => base/plugins/PluginA/ - // pluginsFolder => base/plugins/ - // The base is not necessarily relative to the startup directory. - File pluginsFolder = plugin.getDataFolder().getParentFile(); - - // return => base/plugins/PluginMetrics/config.yml - return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml"); - } - - /** - * Generic method that posts a plugin to the metrics website - */ - private void postPlugin(final boolean isPing) throws IOException { - // Server software specific section - PluginDescriptionFile description = plugin.getDescription(); - String pluginName = description.getName(); - boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled - String pluginVersion = description.getVersion(); - String serverVersion = Bukkit.getVersion(); - int playersOnline = Bukkit.getServer().getOnlinePlayers().size(); - - // END server software specific section -- all code below does not use any code outside of this class / Java - - // Construct the post data - StringBuilder json = new StringBuilder(1024); - json.append('{'); - - // The plugin's description file containg all of the plugin data such as name, version, author, etc - appendJSONPair(json, "guid", guid); - appendJSONPair(json, "plugin_version", pluginVersion); - appendJSONPair(json, "server_version", serverVersion); - appendJSONPair(json, "players_online", Integer.toString(playersOnline)); - - // New data as of R6 - String osname = System.getProperty("os.name"); - String osarch = System.getProperty("os.arch"); - String osversion = System.getProperty("os.version"); - String java_version = System.getProperty("java.version"); - int coreCount = Runtime.getRuntime().availableProcessors(); - - // normalize os arch .. amd64 -> x86_64 - if (osarch.equals("amd64")) { - osarch = "x86_64"; - } - - appendJSONPair(json, "osname", osname); - appendJSONPair(json, "osarch", osarch); - appendJSONPair(json, "osversion", osversion); - appendJSONPair(json, "cores", Integer.toString(coreCount)); - appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0"); - appendJSONPair(json, "java_version", java_version); - - // If we're pinging, append it - if (isPing) { - appendJSONPair(json, "ping", "1"); - } - - if (graphs.size() > 0) { - synchronized (graphs) { - json.append(','); - json.append('"'); - json.append("graphs"); - json.append('"'); - json.append(':'); - json.append('{'); - - boolean firstGraph = true; - - final Iterator iter = graphs.iterator(); - - while (iter.hasNext()) { - Graph graph = iter.next(); - - StringBuilder graphJson = new StringBuilder(); - graphJson.append('{'); - - for (Plotter plotter : graph.getPlotters()) { - appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue())); - } - - graphJson.append('}'); - - if (!firstGraph) { - json.append(','); - } - - json.append(escapeJSON(graph.getName())); - json.append(':'); - json.append(graphJson); - - firstGraph = false; - } - - json.append('}'); - } - } - - // close json - json.append('}'); - - // Create the url - URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName))); - - // Connect to the website - URLConnection connection; - - // Mineshafter creates a socks proxy, so we can safely bypass it - // It does not reroute POST requests so we need to go around it - if (isMineshafterPresent()) { - connection = url.openConnection(Proxy.NO_PROXY); - } else { - connection = url.openConnection(); - } - - - byte[] uncompressed = json.toString().getBytes(); - byte[] compressed = gzip(json.toString()); - - // Headers - connection.addRequestProperty("User-Agent", "MCStats/" + REVISION); - connection.addRequestProperty("Content-Type", "application/json"); - connection.addRequestProperty("Content-Encoding", "gzip"); - connection.addRequestProperty("Content-Length", Integer.toString(compressed.length)); - connection.addRequestProperty("Accept", "application/json"); - connection.addRequestProperty("Connection", "close"); - - connection.setDoOutput(true); - - if (debug) { - System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); - } - - // Write the data - OutputStream os = connection.getOutputStream(); - os.write(compressed); - os.flush(); - - // Now read the response - final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String response = reader.readLine(); - - // close resources - os.close(); - reader.close(); - - if (response == null || response.startsWith("ERR") || response.startsWith("7")) { - if (response == null) { - response = "null"; - } else if (response.startsWith("7")) { - response = response.substring(response.startsWith("7,") ? 2 : 1); - } - - throw new IOException(response); - } else { - // Is this the first update this hour? - if (response.equals("1") || response.contains("This is your first update this hour")) { - synchronized (graphs) { - final Iterator iter = graphs.iterator(); - - while (iter.hasNext()) { - final Graph graph = iter.next(); - - for (Plotter plotter : graph.getPlotters()) { - plotter.reset(); - } - } - } - } - } - } - - /** - * GZip compress a string of bytes - * - * @param input - * @return - */ - public static byte[] gzip(String input) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - GZIPOutputStream gzos = null; - - try { - gzos = new GZIPOutputStream(baos); - gzos.write(input.getBytes("UTF-8")); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (gzos != null) try { - gzos.close(); - } catch (IOException ignore) { - } - } - - return baos.toByteArray(); - } - - /** - * Check if mineshafter is present. If it is, we need to bypass it to send POST requests - * - * @return true if mineshafter is installed on the server - */ - private boolean isMineshafterPresent() { - try { - Class.forName("mineshafter.MineServer"); - return true; - } catch (Exception e) { - return false; - } - } - - /** - * Appends a json encoded key/value pair to the given string builder. - * - * @param json - * @param key - * @param value - * @throws UnsupportedEncodingException - */ - private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { - boolean isValueNumeric; - - try { - Double.parseDouble(value); - isValueNumeric = true; - } catch (NumberFormatException e) { - isValueNumeric = false; - } - - if (json.charAt(json.length() - 1) != '{') { - json.append(','); - } - - json.append(escapeJSON(key)); - json.append(':'); - - if (isValueNumeric) { - json.append(value); - } else { - json.append(escapeJSON(value)); - } - } - - /** - * Escape a string to create a valid JSON string - * - * @param text - * @return - */ - private static String escapeJSON(String text) { - StringBuilder builder = new StringBuilder(); - - builder.append('"'); - for (int index = 0; index < text.length(); index++) { - char chr = text.charAt(index); - - switch (chr) { - case '"': - case '\\': - builder.append('\\'); - builder.append(chr); - break; - case '\b': - builder.append("\\b"); - break; - case '\t': - builder.append("\\t"); - break; - case '\n': - builder.append("\\n"); - break; - case '\r': - builder.append("\\r"); - break; - default: - if (chr < ' ') { - String t = "000" + Integer.toHexString(chr); - builder.append("\\u" + t.substring(t.length() - 4)); - } else { - builder.append(chr); - } - break; - } - } - builder.append('"'); - - return builder.toString(); - } - - /** - * Encode text as UTF-8 - * - * @param text the text to encode - * @return the encoded text, as UTF-8 - */ - private static String urlEncode(final String text) throws UnsupportedEncodingException { - return URLEncoder.encode(text, "UTF-8"); - } - - /** - * Represents a custom graph on the website - */ - public static class Graph { - - /** - * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is - * rejected - */ - private final String name; - - /** - * The set of plotters that are contained within this graph - */ - private final Set plotters = new LinkedHashSet(); - - private Graph(final String name) { - this.name = name; - } - - /** - * Gets the graph's name - * - * @return the Graph's name - */ - public String getName() { - return name; - } - - /** - * Add a plotter to the graph, which will be used to plot entries - * - * @param plotter the plotter to add to the graph - */ - public void addPlotter(final Plotter plotter) { - plotters.add(plotter); - } - - /** - * Remove a plotter from the graph - * - * @param plotter the plotter to remove from the graph - */ - public void removePlotter(final Plotter plotter) { - plotters.remove(plotter); - } - - /** - * Gets an unmodifiable set of the plotter objects in the graph - * - * @return an unmodifiable {@link java.util.Set} of the plotter objects - */ - public Set getPlotters() { - return Collections.unmodifiableSet(plotters); - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public boolean equals(final Object object) { - if (!(object instanceof Graph)) { - return false; - } - - final Graph graph = (Graph) object; - return graph.name.equals(name); - } - - /** - * Called when the server owner decides to opt-out of BukkitMetrics while the server is running. - */ - protected void onOptOut() { - } - } - - /** - * Interface used to collect custom data for a plugin - */ - public static abstract class Plotter { - - /** - * The plot's name - */ - private final String name; - - /** - * Construct a plotter with the default plot name - */ - public Plotter() { - this("Default"); - } - - /** - * Construct a plotter with a specific plot name - * - * @param name the name of the plotter to use, which will show up on the website - */ - public Plotter(final String name) { - this.name = name; - } - - /** - * Get the current value for the plotted point. Since this function defers to an external function it may or may - * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called - * from any thread so care should be taken when accessing resources that need to be synchronized. - * - * @return the current value for the point to be plotted. - */ - public abstract int getValue(); - - /** - * Get the column name for the plotted point - * - * @return the plotted point's column name - */ - public String getColumnName() { - return name; - } - - /** - * Called after the website graphs have been updated - */ - public void reset() { - } - - @Override - public int hashCode() { - return getColumnName().hashCode(); - } - - @Override - public boolean equals(final Object object) { - if (!(object instanceof Plotter)) { - return false; - } - - final Plotter plotter = (Plotter) object; - return plotter.name.equals(name) && plotter.getValue() == getValue(); - } - } -} \ No newline at end of file From 0b57f2b8555e0b40d0358c798dfe674f5c1d3481 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sun, 23 Sep 2018 21:04:54 +0200 Subject: [PATCH 20/20] Don't use Vault 1.7+ --- pom.xml | 2 +- src/com/dre/brewery/P.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c1d19cb..fec04fe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.dre brewery - 1.6-SNAPSHOT + 1.6 Brewery diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index bdf6ed5..5201560 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -275,7 +275,9 @@ public class P extends JavaPlugin { 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"); + // 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);