Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when running /gw from the console #31

Closed
caelunshun opened this issue May 22, 2019 · 2 comments · Fixed by #41
Closed

NullPointerException when running /gw from the console #31

caelunshun opened this issue May 22, 2019 · 2 comments · Fixed by #41
Labels
Accepted Good issue, working on a solution bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@caelunshun
Copy link

When running one of the plugin commands from the console, a NullPointerException occurs.

To Reproduce

  1. Run /gw in the console
  2. Command fails with an NPE

Expected behavior
Instead of throwing an exception, a message would be sent saying that a player needs to execute the command.

Exception:

[12:35:35 ERROR]: [GlobalWarming] [ACF] Exception in command: gw 
[12:35:35 ERROR]: [GlobalWarming] [ACF] java.lang.NullPointerException
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.GlobalWarming.lambda$registerCommands$1(GlobalWarming.java:122)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.RegisteredCommand.resolveContexts(RegisteredCommand.java:296)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.RegisteredCommand.resolveContexts(RegisteredCommand.java:215)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.RegisteredCommand.invoke(RegisteredCommand.java:149)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.BaseCommand.executeCommand(BaseCommand.java:576)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.BaseCommand.execute(BaseCommand.java:512)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.RootCommand.execute(RootCommand.java:99)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.porillo.shade.aikar.commands.BukkitRootCommand.execute(BukkitRootCommand.java:79)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:151)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:734)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchServerCommand(CraftServer.java:696)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.minecraft.server.v1_13_R2.DedicatedServer.handleCommandQueue(DedicatedServer.java:483)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:440)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:940)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:837)
[12:35:35 ERROR]: [GlobalWarming] [ACF] 	at java.lang.Thread.run(Thread.java:748)
@nsporillo
Copy link
Owner

@caelunshun thanks for the report. Im aware of this issue, it was mostly a design decision aimed at making things easier on the development side. Since a command sender isnt a player, you get that exception.

I plan on updating the command system eventually to support commands from the console.

@nsporillo nsporillo added the Accepted Good issue, working on a solution label May 22, 2019
@nsporillo nsporillo added bug Something isn't working help wanted Extra attention is needed labels Oct 2, 2019
@nsporillo
Copy link
Owner

In case anyone is interested in working on this and submitting a PR, the issue here is with how we use ACF (Annotation Command Framework). All of our methods that have the ACF annotations on them take GPlayer as a parameter. On line 136 in GlobalWarming.java, we register an issuer context using the CommandSender as a Player which is what is necessary to convert a command sender to a GPlayer.

However, we wish to add some support for just CommandSenders to issue commands. So we might want to replace GPlayer with CommandSender in all of our method signatures and instead include logic as needed to convert the command sender to a GPlayer when necessary and display error messages as needed.

@nsporillo nsporillo added the good first issue Good for newcomers label Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Good issue, working on a solution bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants