ME1312 / SubServers-2

SubServers – The Minecraft Server Management Platform
Apache License 2.0
92 stars 23 forks source link

SubAPI usage question #66

Closed wysohn closed 3 years ago

wysohn commented 3 years ago

Platform Information

21:43:04 [INFO] CONSOLE executed command: /sub version
21:43:04 [INFO] SubServers > These are the platforms and versions that are running SubServers.Bungee:
21:43:04 [INFO]   Linux 5.4.0-77-generic [x64],
21:43:04 [INFO]   Java 16.0.1 [x64],
21:43:04 [INFO]   BungeeCord git:BungeeCord-Bootstrap:1.17-R0.1-SNAPSHOT:c866619:1594,
21:43:04 [INFO]   SubServers.Bungee v2.17a (21w24k)
21:43:04 [INFO] 
21:43:04 [INFO] You are on the latest version.

What Happened

I get this exception but it doesn't show any useful info:

[21:33:46] [Server thread/INFO]: Gfelrk issued server command: /trg reload
[21:33:46] [Server thread/INFO]: [TriggerReactor] Reloading global variables...
[21:33:46] [Server thread/INFO]: [TriggerReactor] Global variables were loaded from GsonConfigSource{file=plugins/TriggerReactor/var.json}
[21:33:56] [Server thread/INFO]: Gfelrk issued server command: /trg call SubServer:restart serverName="short";templateName="MinecraftDay"
[21:33:56] [Server thread/INFO]: Removing short

[21:33:56] [Server thread/INFO]: Creating short with template MinecraftDay

[21:33:56] [Server thread/WARN]: java.lang.reflect.InvocationTargetException

[21:33:56] [Server thread/WARN]:    at net.ME1312.SubServers.Client.Common.Network.API.SimplifiedData.requestHost(SimplifiedData.java:58)

[21:33:56] [Server thread/WARN]:    at net.ME1312.SubServers.Client.Common.ClientAPI.getHost(ClientAPI.java:61)

[21:33:56] [Server thread/WARN]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[21:33:56] [Server thread/WARN]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)

[21:33:56] [Server thread/WARN]:    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[21:33:56] [Server thread/WARN]:    at java.base/java.lang.reflect.Method.invoke(Method.java:567)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.tools.ReflectionUtil.invokeMethod(ReflectionUtil.java:295)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.tools.ReflectionUtil.invokeMethod(ReflectionUtil.java:359)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.callFunction(Interpreter.java:1177)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:989)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:544)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.startWithContextAndInterrupter(Interpreter.java:202)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.manager.trigger.Trigger.start(Trigger.java:275)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.manager.trigger.Trigger$1.call(Trigger.java:230)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.manager.trigger.Trigger$1.call(Trigger.java:226)

[21:33:56] [Server thread/WARN]:    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

[21:33:56] [Server thread/WARN]:    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)

[21:33:56] [Server thread/WARN]:    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)

[21:33:56] [Server thread/WARN]:    at java.base/java.lang.Thread.run(Thread.java:831)

[21:33:56] [Server thread/WARN]: Caused by: java.lang.reflect.UndeclaredThrowableException

[21:33:56] [Server thread/WARN]:    at jdk.proxy9/jdk.proxy9.$Proxy78.run(Unknown Source)

[21:33:56] [Server thread/WARN]:    at net.ME1312.SubServers.Client.Common.Network.API.SimplifiedData.lambda$requestHost$1(SimplifiedData.java:66)

[21:33:56] [Server thread/WARN]:    at net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadHostInfo.receive(PacketDownloadHostInfo.java:53)

[21:33:56] [Server thread/WARN]:    at net.ME1312.SubData.Client.Protocol.PacketObjectIn.receive(PacketObjectIn.java:32)

[21:33:56] [Server thread/WARN]:    at net.ME1312.SubData.Client.SubDataClient.lambda$read$6(SubDataClient.java:175)

[21:33:56] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59)

[21:33:56] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:352)

[21:33:56] [Server thread/WARN]:    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:783)

[21:33:56] [Server thread/WARN]:    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378)

[21:33:56] [Server thread/WARN]:    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713)

[21:33:56] [Server thread/WARN]:    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616)

[21:33:56] [Server thread/WARN]:    ... 1 more

[21:33:56] [Server thread/WARN]: Caused by: io.github.wysohn.triggerreactor.core.script.interpreter.InterpreterException: Error at row[18], col[8]

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:1105)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:544)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:212)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.lambda.LambdaFunction.invoke(LambdaFunction.java:44)

[21:33:56] [Server thread/WARN]:    ... 12 more

[21:33:56] [Server thread/WARN]: Caused by: java.lang.NullPointerException: [SubCreator].create(short,net.ME1312.SubServers.Client.Common.Network.API.SubCreator$ServerTemplate@7bb02ac9,null,null)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.tools.ReflectionUtil.invokeMethod(ReflectionUtil.java:297)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.tools.ReflectionUtil.invokeMethod(ReflectionUtil.java:359)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.callFunction(Interpreter.java:1177)

[21:33:56] [Server thread/WARN]:    at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:989)

[21:33:56] [Server thread/WARN]:    ... 15 more

How It Happened

Here is the custom script code:

IMPORT net.ME1312.SubServers.Client.Bukkit.SubAPI

api = SubAPI.getInstance()

api.getHost("short", LAMBDA host => 
    #LOG "Removing "+serverName
    host.recycleSubServer(serverName)

    creator = host.getCreator()
    template = creator.getTemplate(templateName)
    #LOG "Creating "+serverName+" with template "+templateName

    creator.create(serverName, template, null, null)
    #LOG "Initiated restart"
ENDLAMBDA)

So basically, I was able to delete the server without a problem, then when I try to create a new server using the template, it throws InvocationTargetException without any useful info. Not sure what I am doing wrong here :/

But it works if I do the command manually: sub create short short MincraftDay

It could be a problem on my end, yet I want to know your opinion.

I looked into the code at SimplifiedData.java:58, but there isn't really a code that can produce such an exception, so it confuses me.

Additional Information

You have to use TriggerReactor plugin to run this code, yet I think you probably get the idea by just looking at the pseudo

wysohn commented 3 years ago

Could it be the host setting? Here is the config file too

Hosts:
  '~':
    Enabled: true
    Display: Default
    Driver: VIRTUAL
    Address: 127.0.0.1
    Port-Range: 25500-25559
    Directory: ./SubServers/Servers
    Git-Bash: '%ProgramFiles%\Git'
    Log-Creator: true
  short:
    Enabled: true
    Display: Short Term
    Driver: VIRTUAL
    Address: 127.0.0.1
    Port-Range: 20000-25499
    Directory: ./SubServers/Servers
    Git-Bash: '%ProgramFiles%\Git'
    Log-Creator: true
ME1312 commented 3 years ago

It looks like it's having trouble accessing the create method. As for why, well, I don't really know. The most relevant section of this string of errors is the one at the bottom.

wysohn commented 3 years ago

It looks like it's having trouble accessing the create method. As for why, well, I don't really know. The most relevant section of this string of errors is the one at the bottom.

Oh that's right

I for some reason thought it's the one at the top causing the error

Thank you!