#Weird error

1 messages · Page 1 of 1 (latest)

burnt garnet
gloomy rain
#

so

burnt garnet
gloomy rain
#

send in PlayerManager:93 again, please

burnt garnet
#

oh yeha

gloomy rain
#

so this isn't possible for any of the player instances to be null, unless you explicitly set a player to null

#

Bukkit.getOnlinePlayers() only returns nonnull objects, afaik

burnt garnet
#

let me check other functions that run

gloomy rain
#

since you use IntelliJ, you can easily just search through the entire file tree

#

search after playerList.add or playerList.replace or playerList.set

burnt garnet
#

alr

thorn forum
burnt garnet
gloomy rain
#

ah

#

very weird, is there anything else

burnt garnet
#

nope

gloomy rain
#

an ArrayList @burnt garnet ?

thorn forum
burnt garnet
gloomy rain
#

oh so playerList is a map

#

🤦‍♂️

#

im an idiot I programmed too much in typescript recently I forgot that forEach doesn't supply an index

#

for iterables

#

but this doesn't explain null anyways

burnt garnet
#

so the java gods just dont like me or smth?

gloomy rain
#

nah there will be a logical explanation

#

where do you call setPlayerTeam

burnt garnet
#

only place

gloomy rain
#

search for playerList.put instead lol

#

since I thought it was a list, I assumed .add

burnt garnet
gloomy rain
#

okay and addPlayer you only call in that loop...

#

very interesting situation

burnt garnet
#

this was working last time i tested it

#

it randomly stopped working

gloomy rain
#

well, put a sysout everywhere, where you mutate that map

#

so everywhere, where there is a put a replace or anything that modifies the map except removals

#

you just have to debug in what method you pass in null

burnt garnet
#

allr

#

alr

#

this is it

#

wait what

#

the /stopevent command is working now?!

thorn forum
#

try to log the player location

burnt garnet
#

wtf

#

its working now

#

but i've had another issue

thorn forum
#

which is?

burnt garnet
#

wait

#
@EventHandler
    private void onDeath(PlayerDeathEvent e) {
        if (gameManager.playerList.containsKey(e.getPlayer())) {
            e.setCancelled(true);
            e.getDrops().add(new ItemStack(Material.TOTEM_OF_UNDYING, 1));
            e.getDrops().forEach(drop -> e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), drop));
            gameManager.getPlayerManager().removePlayer(e.getPlayer());
            gameManager.getPlayerManager().removePlayerFromTeam(e.getPlayer());
            e.getPlayer().setGameMode(GameMode.SPECTATOR);
            util.broadcast(e.getEntity().getName() + " has lost!");
            e.getPlayer().getLocation().getWorld().strikeLightningEffect(e.getPlayer().getLocation());
            if (gameManager.teamList.size() == 1) {
                util.broadcast("Game over! Team number " + gameManager.getPlayerManager().getPlayerTeam(e.getPlayer()) + " has won!");
                util.broadcast("The following players were in the winning team:" + gameManager.getPlayerManager().getPlayersInTeam(gameManager.getPlayerManager().getPlayerTeam(e.getPlayer())));
                util.broadcast("You can do /lobby");
            } else {
                util.broadcast("There are " + gameManager.teamList.size() + " teams left!");
            }
        }
    }
thorn forum
#

The map is null

burnt garnet
#

same issue as the other one

#

but why is the stopevent working but not this

thorn forum
#

witch line is 26

burnt garnet
thorn forum
#

what is line 55 for / what are you checking

burnt garnet
#

if its there

#

i was just trying a bunch of stuff

#

cause nothing worked

thorn forum
#

what does the logging say

burnt garnet
#

lemme check

thorn forum
#

are you shure he is even in a team?

burnt garnet
#

i've looped it

#

before

#

he's in a team

#

wait

thorn forum
#

apprently he isnt

burnt garnet
#

i have a check team command

#

lemme use it rq

thorn forum
#

but then playerList isnt saving the data right

burnt garnet
#

i have no idea whats going on

#

is the way im checking the info wrong?

thorn forum
#

check what type of code is used for line 55

#

like the main or the else

burnt garnet
#

?

thorn forum
#

debug if it runs the if body or the else body

burnt garnet
#

oh okay

#

it wont say

#

the error happens before

thorn forum
#

send the code

burnt garnet
#

this?

#

its not pasting

#

one second

thorn forum
#

log the teamlist and then the playerList

burnt garnet
#

alr

#

like each team and player?

thorn forum
#

like the way you did earlier with the player

burnt garnet
#

alr

#

like that/

thorn forum
#

no just playerList.toString()

#

and teamList.toString()

burnt garnet
#

oh okay

#

mb

#

OH SHIT

#

wait

#

i think it removed the player first

#

im just stupid

#

bro

#

im so sorry for wasting your time

thorn forum
#

all good im watching a series while thinking a bit

burnt garnet
#

thank you for trying to help

#

im just stupid

thorn forum
#

np

tired salmon
# burnt garnet

Unnecessary check for #containsKey. you dont need to check when using #put operation

#

A tip from someone who is trying to better themselves. Follow OOP structure.