<commit_before>/**
 * Player listener.
 * Built upon the SimpleJail project, created by imjake9.
 * https://github.com/imjake9/SimpleJail
 *
 * @author imjake9
 * @author Mitsugaru
 */
package com.mitsugaru.karmicjail;

import com.mitsugaru.karmicjail.KarmicJail.JailStatus;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;

public class KarmicJailListener implements Listener {
	//Class variables
    private final KarmicJail plugin;
    private static final long minutesToTicks = 1200;

    public KarmicJailListener(KarmicJail plugin) {
        this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.LOWEST)
    public void onPlayerChat(final PlayerChatEvent event)
    {
    	final Player player = event.getPlayer();
        if(plugin.playerIsJailed(player.getName()))
        {
        	if(plugin.playerIsMuted(player.getName()))
        	{
        		event.setCancelled(true);
        	}
        }
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerRespawn(final PlayerRespawnEvent event) {

        final Player player = event.getPlayer();

        if(!plugin.playerIsJailed(player.getName())) return;

        event.setRespawnLocation(plugin.getJailLocation());
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerJoin(final PlayerJoinEvent event) {

    	//Attempt to add player to database
    	plugin.addPlayerToDatabase(event.getPlayer().getName());

        final Player player = event.getPlayer();
        final String status = plugin.getPlayerStatus(player.getName());

        // Check status
        if (status.equals(""+JailStatus.PENDINGJAIL) || status.equals(""+JailStatus.JAILED)) {
            if (plugin.playerIsTempJailed(player.getName())) {
            	final long time = plugin.getPlayerTime(player.getName());
            	if(time > 0)
            	{
            		final int minutes = (int) ((time / minutesToTicks));
            		player.sendMessage(ChatColor.AQUA + "You are jailed for " + plugin.prettifyMinutes(minutes) + ".");
            		plugin.addThread(player.getName(), time);
            	}
            	else
            	{
            		plugin.unjailPlayer(plugin.console, player.getName());
            	}
            } else {
                player.sendMessage(ChatColor.AQUA + "You are jailed.");
            }
            player.teleport(plugin.getJailLocation());
            if(status.equals(""+JailStatus.PENDINGJAIL))
            {
            	plugin.setPlayerStatus(JailStatus.JAILED, player.getName());
            }<commit_msg>Minor edit.<commit_after>/**
 * Player listener.
 * Built upon the SimpleJail project, created by imjake9.
 * https://github.com/imjake9/SimpleJail
 *
 * @author imjake9
 * @author Mitsugaru
 */
package com.mitsugaru.karmicjail;

import com.mitsugaru.karmicjail.KarmicJail.JailStatus;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;

public class KarmicJailListener implements Listener {
	//Class variables
    private final KarmicJail plugin;
    private static final long minutesToTicks = 1200;

    public KarmicJailListener(KarmicJail plugin) {
        this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.LOWEST)
    public void onPlayerChat(final PlayerChatEvent event)
    {
    	final Player player = event.getPlayer();
        if(plugin.playerIsJailed(player.getName()))
        {
        	if(plugin.playerIsMuted(player.getName()))
        	{
        		event.setCancelled(true);
        	}
        }
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerRespawn(final PlayerRespawnEvent event) {

        final Player player = event.getPlayer();

        if(!plugin.playerIsJailed(player.getName())) return;

        event.setRespawnLocation(plugin.getJailLocation());
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerJoin(final PlayerJoinEvent event) {

    	//Attempt to add player to database
    	plugin.addPlayerToDatabase(event.getPlayer().getName());

        final Player player = event.getPlayer();
        final String status = plugin.getPlayerStatus(player.getName());

        // Check status
        if (status.equals(""+JailStatus.PENDINGJAIL) || status.equals(""+JailStatus.JAILED)) {
            if (plugin.playerIsTempJailed(player.getName())) {
            	final long time = plugin.getPlayerTime(player.getName());
            	if(time > 0)
            	{
            		final int minutes = (int) ((time / minutesToTicks));
            		player.sendMessage(ChatColor.AQUA + "You are jailed for " + plugin.prettifyMinutes(minutes) + ".");
            		plugin.addThread(player.getName(), time);
            	}
            	else
            	{
            		plugin.unjailPlayer(plugin.console, player.getName(), true);
            	}
            } else {
                player.sendMessage(ChatColor.AQUA + "You are jailed.");
            }
            player.teleport(plugin.getJailLocation());
            if(status.equals(""+JailStatus.PENDINGJAIL))
            {
            	plugin.setPlayerStatus(JailStatus.JAILED, player.getName());
            }
{'fraction_non_alphanumeric': 0.10902777777777778, 'fraction_numerical': 0.002777777777777778, 'mean_word_length': 2.726390685640362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1791299', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1701, 'n_words': 300}