Skip to content

Commit

Permalink
misc: Handle more towny events
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 21, 2024
1 parent 68415ea commit 50e0f1d
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.event.TownClaimEvent;
import com.palmergames.bukkit.towny.event.TownSpawnEvent;
import com.palmergames.bukkit.towny.event.*;
import com.palmergames.bukkit.towny.event.player.PlayerEntersIntoTownBorderEvent;
import com.palmergames.bukkit.towny.event.player.PlayerExitsFromTownBorderEvent;
import com.palmergames.bukkit.towny.event.town.TownUnclaimEvent;
Expand Down Expand Up @@ -33,6 +32,7 @@
import xyz.nifeather.morph.config.MorphConfigManager;
import xyz.nifeather.morph.events.api.gameplay.PlayerMorphEvent;
import xyz.nifeather.morph.events.api.gameplay.PlayerUnMorphEvent;
import xyz.nifeather.morph.misc.NmsRecord;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -183,6 +183,18 @@ public void onTownClaim(TownClaimEvent e)
.forEach(chunkTask -> chunkTask.thenAccept(chunk -> this.updatePlayersInChunk(chunk, currentTown)));
}

@EventHandler
public void onTownRemoveResident(TownRemoveResidentEvent e)
{
updatePlayer(e.getResident().getPlayer(), e.getTown());
}

@EventHandler
public void onTownAddResident(TownAddResidentEvent e)
{
updatePlayer(e.getResident().getPlayer(), e.getTown());
}

@EventHandler
public void onPlayerMorph(PlayerMorphEvent e)
{
Expand Down Expand Up @@ -219,11 +231,11 @@ public void onPlayerExit(PlayerQuitEvent e)
this.unblockPlayer(e.getPlayer());
}

@EventHandler
@EventHandler(ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent e)
{
if (e.getFrom().getWorld().equals(e.getTo().getWorld()))
this.updatePlayer(e.getPlayer(), null);
this.updatePlayer(e.getPlayer(), townyAPI.getTown(e.getTo()));
}

public void updatePlayer(Player player, @Nullable Town town)
Expand Down

0 comments on commit 50e0f1d

Please sign in to comment.