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> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version> <version>1.15.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version> <version>1.15.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<!-- testing --> <!-- testing -->
<dependency> <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.parser.DisguisePerm;
import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods; import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -53,7 +54,7 @@ public class ParamInfoManager {
} }
if (method.getDeclaringClass() == FallingBlockWatcher.class && if (method.getDeclaringClass() == FallingBlockWatcher.class &&
method.getParameterTypes()[0] == ItemStack.class) { (method.getParameterTypes()[0] == Material.class || method.getParameterTypes()[0] == ItemStack.class)) {
return getParamInfoItemBlock(); return getParamInfoItemBlock();
} }

View File

@ -50,7 +50,7 @@ public class ParamInfoItemBlock extends ParamInfoItemStack {
Material material = ReflectionManager.getMaterial(split[0].toLowerCase()); Material material = ReflectionManager.getMaterial(split[0].toLowerCase());
if (material == null) { if (material == null || material == Material.AIR) {
material = Material.getMaterial(split[0].toUpperCase()); material = Material.getMaterial(split[0].toUpperCase());
} }

View File

@ -1446,11 +1446,19 @@ public class ReflectionManager {
public static int getCombinedIdByItemStack(ItemStack itemStack) { public static int getCombinedIdByItemStack(ItemStack itemStack) {
try { try {
Object nmsItem = getNmsItem(itemStack); Object nmsBlock;
Object item = getNmsMethod("ItemStack", "getItem").invoke(nmsItem);
Class blockClass = getNmsClass("Block"); 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); Object iBlockData = getNmsMethod(blockClass, "getBlockData").invoke(nmsBlock);