#Weird error
1 messages · Page 1 of 1 (latest)
so
send in PlayerManager:93 again, please
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
let me check other functions that run
since you use IntelliJ, you can easily just search through the entire file tree
search after playerList.add or playerList.replace or playerList.set
alr
yes and the logged it and the values were not null but a normal player instance but opon tp its null
nope
what kind of list are you using?
an ArrayList @burnt garnet ?
HashMap
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
so the java gods just dont like me or smth?
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
try to log the player location
which is?
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!");
}
}
}
The map is null
witch line is 26
^
what is line 55 for / what are you checking
what does the logging say
are you shure he is even in a team?
apprently he isnt
but then playerList isnt saving the data right
debug if it runs the if body or the else body
send the code
log the teamlist and then the playerList
like the way you did earlier with the player
oh okay
mb
OH SHIT
wait
i think it removed the player first
im just stupid
bro
im so sorry for wasting your time
all good im watching a series while thinking a bit
np
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.
?learnjava