Code
I've tried creating the "Buttons" in the main class, NO luck, moved it to the "onplayerCommand" it worked, but I get
"GuiImage cannot be cast to net.risingworld.api.gui.GuiLabel" when I go to click on it.. ANY HELP??????????????
I've tried creating the "Buttons" in the main class, NO luck, moved it to the "onplayerCommand" it worked, but I get
"GuiImage cannot be cast to net.risingworld.api.gui.GuiLabel" when I go to click on it.. ANY HELP??????????????
About the "needs a throw clause": This is required by the "ImageInformation" constructor, since it can throw an IOException (file not found, invalid file etc). The easiest way is to surround it with a try-catch-statement:
About the cast exception, it indicates that you're trying to assign a GuiImage to a GuiLabel object. As @Blacky1004 mentioned, please post the full error message and the according code
PLUGIN EXCEPTION (EffNet, , Bleckman) ---->
java.lang.ClassCastException: net.risingworld.api.gui.GuiImage cannot be cast to net.risingworld.api.gui.GuiLabel
at EffNet.EffNet.PlayerGuiElementClick(EffNet.java:262)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at pluginapi.PluginEventHandler.triggerEvent(SourceFile:169)
at aE.b.a(SourceFile:1789)
at aE.b.messageReceived(SourceFile:125)
at j.e.a(SourceFile:109)
at j.c.run(SourceFile:65)
at EffNet.EffNet.PlayerGuiElementClick(EffNet.java:262)
Hello Captain_Cornball,
please show me the Line 262 off your PlayerGuiElementClick EventMethode
this.okbutton = ((GuiLabel)event.getGuiElement());
Apparently, the GuiElement associated with the event is not a GuiLabel but a GuiImage; then, it is not possible to cast it to a GuiLabel. It is important to keep a clear vision of what is what, in order to minimise the errors.
Don’t have an account yet? Create a new account now and be part of our community!