inconsistent notation for importing inner classes
305pence opened this issue ยท 6 comments
Basically, i'm having trouble with importing org.bukkit.entity.EnderDragon.Phase
i tried this code to summon an ender dragon and set it's phase so it doesn't just float there
IMPORT org.bukkit.entity.EntityType
IMPORT java.lang.Math
IMPORT org.bukkit.entity.EnderDragon.Phase
FOR player = getPlayers()
world = $world
ENDFOR
pu = {"location.shrine"}
locS = pu.clone()
pu = {"location.mobspawn"}
locM = pu.clone()
x = locM.getX() - locS.getX()
z = locM.getZ() - locS.getZ()
rAngle = Math.atan(x/z)
IF z < 0
angle = Math.toRadians(180) + rAngle
ELSE
angle = rAngle
ENDIF
loc = locS.add(64*Math.sin(angle), 15, 64*Math.cos(angle))
dragon = world.spawnEntity(loc, EntityType.ENDER_DRAGON)
dragon.setPhase(EnderDragon.Phase.CHARGE_PLAYER)
and i got the error below
[20:31:34] [Server thread/WARN]: java.lang.Exception: Could not finish interpretation for [bug]!
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger.start(AbstractTriggerManager.java:409)
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger$1.call(AbstractTriggerManager.java:359)
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger$1.call(AbstractTriggerManager.java:355)
[20:31:34] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftFuture.run(CraftFuture.java:88)
[20:31:34] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394)
[20:31:34] [Server thread/WARN]: at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1022)
[20:31:34] [Server thread/WARN]: at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:393)
[20:31:34] [Server thread/WARN]: at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:970)
[20:31:34] [Server thread/WARN]: at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:815)
[20:31:34] [Server thread/WARN]: at java.lang.Thread.run(Unknown Source)
[20:31:34] [Server thread/WARN]: Caused by: io.github.wysohn.triggerreactor.core.script.interpreter.InterpreterException: Error at row[3], col[43]
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:921)
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:483)
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.startWithContextAndInterrupter(Interpreter.java:199)
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger.start(AbstractTriggerManager.java:404)
[20:31:34] [Server thread/WARN]: ... 9 more
[20:31:34] [Server thread/WARN]: Caused by: java.lang.ClassNotFoundException: org.bukkit.entity.EnderDragon.Phase
[20:31:34] [Server thread/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[20:31:34] [Server thread/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:81)
[20:31:34] [Server thread/WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
[20:31:34] [Server thread/WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
[20:31:34] [Server thread/WARN]: at java.lang.Class.forName0(Native Method)
[20:31:34] [Server thread/WARN]: at java.lang.Class.forName(Unknown Source)
[20:31:34] [Server thread/WARN]: at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:915)
[20:31:34] [Server thread/WARN]: ... 12 more
[20:31:34] [Server thread/INFO]: Could not execute this trigger.
[20:31:34] [Server thread/INFO]: >> Caused by:
[20:31:34] [Server thread/INFO]: Could not finish interpretation for [bug]!
[20:31:34] [Server thread/INFO]: >> Caused by:
[20:31:34] [Server thread/INFO]: Error at row[3], col[43]
[20:31:34] [Server thread/INFO]: >> Caused by:
[20:31:34] [Server thread/INFO]: org.bukkit.entity.EnderDragon.Phase
[20:31:34] [Server thread/INFO]: If you are administrator, see console for details.
@305pence
Hello,
The problem seems to be related to the inner class.
Java denote the inner class with $ sign instead of .(dot), so all you have to do is
IMPORT org.bukkit.entity.EnderDragon$Phase
Let us know if it doesn't work.
@wysohn
In that case, would the class be called Phase or EnderDragon$Phase in your code?
@gerzytet
I believe it is just Phase
I'm reopening this as a low priority bug because requiring this internal notation for importing is inconsistent with java and the javadocs.