Fix #482, unable to disguise as variants with no item equiv

This commit is contained in:
libraryaddict 2020-06-24 17:20:18 +12:00
parent 281d94fbb9
commit 0777947173
No known key found for this signature in database
GPG key ID: 052E4FBCD257AEA4
4 changed files with 16 additions and 7 deletions

View file

@ -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>

View file

@ -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();
}

View file

@ -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());
}

View file

@ -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);