ShieldCommunity / SternalBoard

Lightweight & animated scoreboard, packet-based designed for easy usage
https://www.spigotmc.org/resources/sternalboard-lightweight-animated-scoreboard.89245/
MIT License
64 stars 20 forks source link

Fix an IndexOutOfBounds exception being thrown when buffer is empty. #59

Closed Bloedarend closed 10 months ago

Bloedarend commented 10 months ago

Happened to stumble on an exception when pressing the ESC key twice in a screen on an Ubuntu server. I am not sure why this triggered the AsyncTabAutoCompleteEvent, but it did and it came with an empty buffer.

I added an extra check that ensures that if the sender is a ConsoleCommandSender and the buffer is empty, it does not throw an IndexOutOfBoundsException at buffer#charAt(0).

I have not been able to test if this works, since some methods were missing (most likely not pushed to the main branch) and relocation of dependencies did not work when assembling the plugin with gradle. I am fairly sure though, that this would not pose any problems, as when a command is sent through console, it does not start with a '/' anyway.

xism4 commented 10 months ago

Happened to stumble on an exception when pressing the ESC key twice in a screen on an Ubuntu server. I am not sure why this triggered the AsyncTabAutoCompleteEvent, but it did and it came with an empty buffer.

I added an extra check that ensures that if the sender is a ConsoleCommandSender and the buffer is empty, it does not throw an IndexOutOfBoundsException at buffer#charAt(0).

I have not been able to test if this works, since some methods were missing (most likely not pushed to the main branch) and relocation of dependencies did not work when assembling the plugin with gradle. I am fairly sure though, that this would not pose any problems, as when a command is sent through console, it does not start with a '/' anyway.

This happends by

Happened to stumble on an exception when pressing the ESC key twice in a screen on an Ubuntu server. I am not sure why this triggered the AsyncTabAutoCompleteEvent, but it did and it came with an empty buffer.

Probably it even checks console "commands" from prompt, thanks for the fix!