Tab list sorting - Null pointer Exception on client?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Bit

Member
Jan 26, 2021
27
0
1
Script Version (do not put latest): 2.6.2
Script Author: SkriptLang
Minecraft Version: git-Paper-1620 (MC: 1.12.2)
Full Code:
Code:
on load:
    delete {ranks::*}
    delete {prefixes::*}
    set {ranks::staff} to "A-staff"
    set {ranks::donator} to "B-donator"
    set {ranks::player} to "C-player"

on join:
    updateTab(player)
 
function updateTab(p: player):
    loop {ranks::*}:
        {_p}.getScoreboard().registerNewTeam(loop-value)
        player.getScoreboard().getTeam(loop-value).setPrefix({prefixes::%loop-index%})
    if {_p} has permission "group.staff":
        set {rank::sorting::%{_p}%} to "A-staff"
     
    else if {_p} has permission "group.donator":
        set {rank::sorting::%{_p}%} to "B-donator"
     
    else:
        set {rank::sorting::%{_p}%} to "C-player"
     
    {_p}.getScoreboard().getTeam({rank::sorting::%{_p}%}).addPlayer(player)
    loop players:
        loop-player.getScoreboard().getTeam({rank::sorting::%{_p}%}).addPlayer({_p})
        {_p}.getScoreboard().getTeam({rank::sorting::%loop-player%}).addPlayer(loop-player)


Errors on Reload:
There are no errors printed on reload or in general in to the console, yet clients get the following error as soon as more than one player is online:
Code:
Error executing task
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Player is either on another team or not on any team. Cannot remove from team 'A-staff'.
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at g.a(Util.java:20)
	at ave.av(SourceFile:881)
	at ave.a(SourceFile:325)
	at net.minecraft.client.main.Main.main(SourceFile:124)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.IllegalStateException: Player is either on another team or not on any team. Cannot remove from team 'A-staff'.
	at auo.a(SourceFile:271)
	at bcy.a(SourceFile:1387)
	at hr.a(SourceFile:113)
	at hr.a(SourceFile:13)
	at fh$1.run(PacketThreadUtil.java:22)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at g.a(Util.java:19)
	... 9 more
After that the client's console is getting spammed with Null Pointer Exceptions.

Other Useful Info:
I tried to use the solution by Shane found at https://forums.skunity.com/threads/tab-sorting.8944/
Yet, I use script-reflect instead of script-mirror
Addons using (including versions):
- skDragon v0.17
- skript-reflect v2.3 (https://github.com/TPGamesNL/skript-reflect)
- skript-db v1.3.6
- SkQuery v4.1.4
- Skore v1.0.3
- MundoSK v1.8.6-BETA.57 (https://forums.skunity.com/resources/mundosk.69/)
- SkStuff v1.6.4.1-fork-1.12
[doublepost=1658488193,1657804529][/doublepost]Bump
 
Status
Not open for further replies.