<commit_before>package com.graywolf336.trailingperspective.listeners;

import java.util.HashSet;
import java.util.Set;

import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;

import com.graywolf336.trailingperspective.TrailingPerspectiveMain;
import com.graywolf336.trailingperspective.classes.Trailer;
import com.graywolf336.trailingperspective.enums.Settings;
import com.graywolf336.trailingperspective.interfaces.ITrailer;

public class TrailingPerspectivePlayerListener implements Listener {
    private TrailingPerspectiveMain pl;

    public TrailingPerspectivePlayerListener(TrailingPerspectiveMain plugin) {
        this.pl = plugin;
    }

    @EventHandler
    public void playersAreChattyPeople(AsyncPlayerChatEvent event) {
        if (Settings.CLEAR_TRAILERS_CHAT.asBoolean()) {
            Set<Player> rec = new HashSet<Player>(event.getRecipients());

            for (ITrailer trailer : this.pl.getTrailerManager().getTrailers()) {
                rec.remove(trailer.getPlayer());
            }

            event.getRecipients().clear();
            event.getRecipients().addAll(rec);
        }
    }

    @EventHandler
    public void playerDoneDied(PlayerDeathEvent event) {
        toggleTrailerTrailingPlayer(event.getEntity());
    }

    @EventHandler
    public void playerTeleportedSomeWhere(PlayerTeleportEvent event) {
        toggleTrailerTrailingPlayer(event.getPlayer());
    }

    @EventHandler
    public void playerHoppedARide(VehicleEnterEvent event) {
        Entity passenger = event.getEntered().getPassenger();

        if (passenger instanceof Player) {
            Player player = (Player) passenger;

            toggleTrailerTrailingPlayer(player);
        }
    }

    @EventHandler
    public void playerTookANap(PlayerBedEnterEvent event) {
        toggleTrailerTrailingPlayer(event.getPlayer());
    }

    @EventHandler
    public void playerHasDecidedToJoinUs(PlayerJoinEvent event) {
        if (Settings.USERNAME.asString().equalsIgnoreCase(event.getPlayer().getName()) && Settings.AUTOMATICALLY_ENABLED.asBoolean()) {
            this.pl.debug(false, "The selected player has joined the server and automatically enabled is set to true!");
            this.pl.getTrailerManager().addTrailer(new Trailer(event.getPlayer()));
        }<commit_msg>Targetted specific teleport events<commit_after>package com.graywolf336.trailingperspective.listeners;

import java.util.HashSet;
import java.util.Set;

import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.vehicle.VehicleEnterEvent;

import com.graywolf336.trailingperspective.TrailingPerspectiveMain;
import com.graywolf336.trailingperspective.classes.Trailer;
import com.graywolf336.trailingperspective.enums.Settings;
import com.graywolf336.trailingperspective.interfaces.ITrailer;

public class TrailingPerspectivePlayerListener implements Listener {
    private TrailingPerspectiveMain pl;

    public TrailingPerspectivePlayerListener(TrailingPerspectiveMain plugin) {
        this.pl = plugin;
    }

    @EventHandler
    public void playersAreChattyPeople(AsyncPlayerChatEvent event) {
        if (Settings.CLEAR_TRAILERS_CHAT.asBoolean()) {
            Set<Player> rec = new HashSet<Player>(event.getRecipients());

            for (ITrailer trailer : this.pl.getTrailerManager().getTrailers()) {
                rec.remove(trailer.getPlayer());
            }

            event.getRecipients().clear();
            event.getRecipients().addAll(rec);
        }
    }

    @EventHandler
    public void playerDoneDied(PlayerDeathEvent event) {
        toggleTrailerTrailingPlayer(event.getEntity());
    }

    @EventHandler
    public void playerTeleportedSomeWhere(PlayerTeleportEvent event) {
        TeleportCause cause = event.getCause();
        
        if(cause.equals(TeleportCause.END_PORTAL) || cause.equals(TeleportCause.NETHER_PORTAL))
        {
            toggleTrailerTrailingPlayer(event.getPlayer());
        }
    }

    @EventHandler
    public void playerHoppedARide(VehicleEnterEvent event) {
        Entity passenger = event.getEntered().getPassenger();

        if (passenger instanceof Player) {
            Player player = (Player) passenger;

            toggleTrailerTrailingPlayer(player);
        }
    }

    @EventHandler
    public void playerTookANap(PlayerBedEnterEvent event) {
        toggleTrailerTrailingPlayer(event.getPlayer());
    }

    @EventHandler
    public void playerHasDecidedToJoinUs(PlayerJoinEvent event) {
        if (Settings.USERNAME.asString().equalsIgnoreCase(event.getPlayer().getName()) && Settings.AUTOMATICALLY_ENABLED.asBoolean()) {
            this.pl.debug(false, "The selected player has joined the server and automatically enabled is set to true!");
            this.pl.getTrailerManager().addTrailer(new Trailer(event.getPlayer()));
        }
{'fraction_non_alphanumeric': 0.09367562053723223, 'fraction_numerical': 0.0051003060183611015, 'mean_word_length': 3.9106844741235394, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '145684', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1650, 'n_words': 272}