Fix #482, unable to disguise as variants with no item equiv
This commit is contained in:
parent
281d94fbb9
commit
0777947173
4
pom.xml
4
pom.xml
@ -88,12 +88,12 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15-R0.1-SNAPSHOT</version>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15-R0.1-SNAPSHOT</version>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- testing -->
|
||||
<dependency>
|
||||
|
@ -12,6 +12,7 @@ import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoSoundGro
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -53,7 +54,7 @@ public class ParamInfoManager {
|
||||
}
|
||||
|
||||
if (method.getDeclaringClass() == FallingBlockWatcher.class &&
|
||||
method.getParameterTypes()[0] == ItemStack.class) {
|
||||
(method.getParameterTypes()[0] == Material.class || method.getParameterTypes()[0] == ItemStack.class)) {
|
||||
return getParamInfoItemBlock();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class ParamInfoItemBlock extends ParamInfoItemStack {
|
||||
|
||||
Material material = ReflectionManager.getMaterial(split[0].toLowerCase());
|
||||
|
||||
if (material == null) {
|
||||
if (material == null || material == Material.AIR) {
|
||||
material = Material.getMaterial(split[0].toUpperCase());
|
||||
}
|
||||
|
||||
|
@ -1446,11 +1446,19 @@ public class ReflectionManager {
|
||||
|
||||
public static int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||
try {
|
||||
Object nmsItem = getNmsItem(itemStack);
|
||||
Object item = getNmsMethod("ItemStack", "getItem").invoke(nmsItem);
|
||||
Object nmsBlock;
|
||||
Class blockClass = getNmsClass("Block");
|
||||
|
||||
Object nmsBlock = getNmsMethod(blockClass, "asBlock", getNmsClass("Item")).invoke(null, item);
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
nmsBlock = getCraftMethod("util.CraftMagicNumbers", "getBlock", Material.class)
|
||||
.invoke(null, itemStack.getType());
|
||||
} else {
|
||||
Object nmsItem = getNmsItem(itemStack);
|
||||
|
||||
Object item = getNmsMethod("ItemStack", "getItem").invoke(nmsItem);
|
||||
|
||||
nmsBlock = getNmsMethod(blockClass, "asBlock", getNmsClass("Item")).invoke(null, item);
|
||||
}
|
||||
|
||||
Object iBlockData = getNmsMethod(blockClass, "getBlockData").invoke(nmsBlock);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user