Cannot Add Player To Team

Discussion in 'Plugin Development' started by PAWN_EDM, Feb 8, 2024.

  1. Offline


        public void OnDeath(PlayerDeathEvent event) {
            Player player = event.getEntity();
            World nether = Bukkit.getWorld("world_nether");
            Location loc = new Location(nether, -185, 67, 40);
            player.setRespawnLocation(loc, true);
            Bukkit.getLogger().info(player.getDisplayName() + " has become a Demon");
    After extensive testing, I have found that this is not adding the player that died to the 'Demons' team but is still respawning them in the nether. The team does exist as /team list shows [Demons]. I've looked around at many other threads but all of them say "Fixed it" without sharing the fix.
  2. Online

    timtower Administrator Administrator Moderator

    Tried adding the player when he is alive again?
  3. Offline


    Have now. No dice. Also I found out that it's not even hearing the PlayerDeathEvent or PlayerRespawnEvent because my log lines are not executing. Hmm

    Somehow I fixed it. Not sure exactly what I did but the Demons team was being created in OnEnable() but since the team already exists in the world, it was throwing an error because it didn't like that I was creating a team that already exists. The only thing I changed was instead of doing it every time the plugin starts, it only does it if getTeam("Demons") is null, which apparently fixed it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Feb 10, 2024

Share This Page