|
1 | 1 | package com.btk5h.skriptmirror.skript.reflect; |
2 | 2 |
|
3 | 3 | import ch.njol.skript.Skript; |
| 4 | +import ch.njol.skript.aliases.ItemType; |
4 | 5 | import ch.njol.skript.classes.Changer; |
5 | 6 | import ch.njol.skript.classes.ClassInfo; |
6 | 7 | import ch.njol.skript.lang.Expression; |
|
20 | 21 | import com.btk5h.skriptmirror.util.SkriptUtil; |
21 | 22 | import com.btk5h.skriptmirror.util.StringSimilarity; |
22 | 23 | import org.bukkit.event.Event; |
| 24 | +import org.bukkit.inventory.ItemStack; |
23 | 25 |
|
24 | 26 | import java.io.File; |
25 | 27 | import java.io.PrintWriter; |
@@ -591,6 +593,11 @@ private static boolean canCoerceType(Object o, Class<?> to) { |
591 | 593 | return true; |
592 | 594 | } |
593 | 595 |
|
| 596 | + // coerce a Skript ItemType to an ItemStack |
| 597 | + if (o instanceof ItemType && to == ItemStack.class) { |
| 598 | + return true; |
| 599 | + } |
| 600 | + |
594 | 601 | // coerce javaclasses and classinfos into classes |
595 | 602 | if (to == Class.class && (o instanceof JavaType || o instanceof ClassInfo)) { |
596 | 603 | return true; |
@@ -659,6 +666,11 @@ private static Object[] convertTypes(MethodHandle mh, Object[] args) { |
659 | 666 | args[i] = ((String) args[i]).charAt(0); |
660 | 667 | } |
661 | 668 |
|
| 669 | + // coerce a Skript ItemType to an ItemStack |
| 670 | + if (args[i] instanceof ItemType && param == ItemStack.class) { |
| 671 | + args[i] = ((ItemType) args[i]).getRandom(); |
| 672 | + } |
| 673 | + |
662 | 674 | // coerce javatypes and classinfos into classes |
663 | 675 | if (param == Class.class) { |
664 | 676 | if (args[i] instanceof JavaType) { |
|
0 commit comments