mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 08:59:01 +00:00
More merge fixes
and use "Levelled" for Cauldrons in 1.13
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
# IntelliJ
|
# IntelliJ
|
||||||
/.idea
|
/.idea
|
||||||
|
/*.iml
|
||||||
|
|
||||||
# various other potential build files
|
# various other potential build files
|
||||||
/build
|
/build
|
||||||
|
|||||||
@@ -35,8 +35,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.7.0</version>
|
<version>3.7.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: ${project.name}
|
name: Brewery
|
||||||
version: ${project.version}
|
version: 1.7
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
|
||||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.dre.brewery;
|
|||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.block.data.Levelled;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@@ -9,6 +10,7 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.material.Cauldron;
|
||||||
|
|
||||||
public class BCauldron {
|
public class BCauldron {
|
||||||
public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<>();
|
public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<>();
|
||||||
@@ -94,10 +96,25 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
ItemStack potion = bcauldron.ingredients.cook(bcauldron.state);
|
ItemStack potion = bcauldron.ingredients.cook(bcauldron.state);
|
||||||
if (potion != null) {
|
if (potion != null) {
|
||||||
|
|
||||||
|
if (P.use1_13) {
|
||||||
|
Levelled cauldron = ((Levelled) block.getBlockData());
|
||||||
|
if (cauldron.getLevel() <= 0) {
|
||||||
|
bcauldrons.remove(bcauldron);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cauldron.setLevel(cauldron.getLevel() - 1);
|
||||||
|
|
||||||
|
if (cauldron.getLevel() <= 0) {
|
||||||
|
bcauldrons.remove(bcauldron);
|
||||||
|
} else {
|
||||||
|
bcauldron.someRemoved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
byte data = block.getData();
|
byte data = block.getData();
|
||||||
if (data > 3) {
|
if (data > 3) {
|
||||||
data = 3;
|
data = 3;
|
||||||
LegacyUtil.setData(block, data);
|
|
||||||
} else if (data <= 0) {
|
} else if (data <= 0) {
|
||||||
bcauldrons.remove(bcauldron);
|
bcauldrons.remove(bcauldron);
|
||||||
return false;
|
return false;
|
||||||
@@ -110,6 +127,7 @@ public class BCauldron {
|
|||||||
} else {
|
} else {
|
||||||
bcauldron.someRemoved = true;
|
bcauldron.someRemoved = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Bukkit Bug, inventory not updating while in event so this
|
// Bukkit Bug, inventory not updating while in event so this
|
||||||
// will delay the give
|
// will delay the give
|
||||||
// but could also just use deprecated updateInventory()
|
// but could also just use deprecated updateInventory()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import org.bukkit.block.data.Levelled;
|
import org.bukkit.block.data.Levelled;
|
||||||
import org.bukkit.material.Cauldron;
|
import org.bukkit.material.Cauldron;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.Stairs;
|
||||||
import org.bukkit.material.Tree;
|
import org.bukkit.material.Tree;
|
||||||
import org.bukkit.material.Wood;
|
import org.bukkit.material.Wood;
|
||||||
|
|
||||||
@@ -22,13 +23,12 @@ public class LegacyUtil {
|
|||||||
private static Method SET_DATA;
|
private static Method SET_DATA;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// -1.12.2 methods
|
// <= 1.12.2 methods
|
||||||
try {
|
try {
|
||||||
GET_MATERIAL = Material.class.getDeclaredMethod("getMaterial", int.class);
|
GET_MATERIAL = Material.class.getDeclaredMethod("getMaterial", int.class);
|
||||||
GET_BLOCK_TYPE_ID_AT = World.class.getDeclaredMethod("getBlockTypeIdAt", Location.class);
|
GET_BLOCK_TYPE_ID_AT = World.class.getDeclaredMethod("getBlockTypeIdAt", Location.class);
|
||||||
} catch (NoSuchMethodException | SecurityException e) {
|
} catch (NoSuchMethodException | SecurityException e) {
|
||||||
}
|
}
|
||||||
// 1.13+ methods
|
|
||||||
try {
|
try {
|
||||||
SET_DATA = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".block.CraftBlock").getDeclaredMethod("setData", byte.class);
|
SET_DATA = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".block.CraftBlock").getDeclaredMethod("setData", byte.class);
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
|
||||||
@@ -60,7 +60,7 @@ public class LegacyUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWoodPlanks(Material type) {
|
public static boolean isWoodPlanks(Material type) {
|
||||||
return type.name().contains("PLANKS") || type.name().equals("WOOD");
|
return type.name().endsWith("PLANKS") || type.name().equals("WOOD");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWoodStairs(Material type) {
|
public static boolean isWoodStairs(Material type) {
|
||||||
@@ -73,12 +73,12 @@ public class LegacyUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSign(Material type) {
|
public static boolean isSign(Material type) {
|
||||||
return type.name().equals("SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN;
|
return type == Material.SIGN || type == Material.WALL_SIGN || (!P.use1_13 && type.name().equals("SIGN_POST"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAVA and STATIONARY_LAVA are merged as of 1.13
|
// LAVA and STATIONARY_LAVA are merged as of 1.13
|
||||||
public static boolean isLava(Material type) {
|
public static boolean isLava(Material type) {
|
||||||
return type.name().equals("STATIONARY_LAVA") || type == Material.LAVA;
|
return type == Material.LAVA || (!P.use1_13 && type.name().equals("STATIONARY_LAVA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areStairsInverted(Block block) {
|
public static boolean areStairsInverted(Block block) {
|
||||||
@@ -177,6 +177,7 @@ public class LegacyUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only used for very old versions of LogBlock
|
||||||
public static int getBlockTypeIdAt(Location location) {
|
public static int getBlockTypeIdAt(Location location) {
|
||||||
try {
|
try {
|
||||||
return GET_BLOCK_TYPE_ID_AT != null ? (int) GET_BLOCK_TYPE_ID_AT.invoke(location.getWorld(), location) : 0;
|
return GET_BLOCK_TYPE_ID_AT != null ? (int) GET_BLOCK_TYPE_ID_AT.invoke(location.getWorld(), location) : 0;
|
||||||
@@ -185,7 +186,7 @@ public class LegacyUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting byte data to blocks works in 1.13, but isn't part of the API anymore
|
// Setting byte data to blocks for older versions
|
||||||
public static void setData(Block block, byte data) {
|
public static void setData(Block block, byte data) {
|
||||||
try {
|
try {
|
||||||
SET_DATA.invoke(block, data);
|
SET_DATA.invoke(block, data);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class P extends JavaPlugin {
|
|||||||
String v = Bukkit.getBukkitVersion();
|
String v = Bukkit.getBukkitVersion();
|
||||||
useUUID = !v.matches("(^|.*[^\\.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.7\\.[0-5]([^\\d].*|$)");
|
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_9 = !v.matches("(^|.*[^\\.\\d])1\\.[0-8]([^\\d].*|$)");
|
||||||
use1_12 = !v.matches("(^|.*[^\\.\\d])1\\.[0-11]([^\\d].*|$)");
|
use1_12 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-1]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
use1_13 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)");
|
use1_13 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
|
|
||||||
// load the Config
|
// load the Config
|
||||||
@@ -95,7 +95,11 @@ public class P extends JavaPlugin {
|
|||||||
readData();
|
readData();
|
||||||
|
|
||||||
// Setup Metrics
|
// Setup Metrics
|
||||||
|
try {
|
||||||
new Metrics(this);
|
new Metrics(this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// Listeners
|
// Listeners
|
||||||
blockListener = new BlockListener();
|
blockListener = new BlockListener();
|
||||||
|
|||||||
Reference in New Issue
Block a user