<commit_before>package core.entities;

import java.awt.Color;
import java.text.DecimalFormat;
import java.util.HashMap;

import core.util.Functions;
import core.util.TimerTrigger;
import net.dv8tion.jda.core.OnlineStatus;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;

public class Server {
	private String id;
	private Guild guild;
	private Settings settings;
	private QueueManager qm;
	public Commands cmds;
	private HashMap<User, Long> activityList = new HashMap<User, Long>();

	public Server(Guild guild) {
		this.guild = guild;
		this.id = guild.getId();
		Functions.createDir(String.format("%s/%s", "app_data", id));
		qm = new QueueManager(id);
		cmds = new Commands();
		settings = new Settings(id);
		qm.getQueue().forEach((q) -> q.getPlayersInQueue().forEach((u) -> updateActivityList(u)));
		startAFKTimer();
	}

	public String getid() {
		return id;
	}

	public QueueManager getQueueManager() {
		return qm;
	}

	public Settings getSettings() {
		return settings;
	}

	public TextChannel getPugChannel() {
		for (TextChannel c : guild.getTextChannels()) {
			if (c.getName().equalsIgnoreCase(settings.pugChannel())) {
				return c;
			}
		}
		return guild.getDefaultChannel();
	}

	private void startAFKTimer() {
		TimerTrigger tt = () -> afkTimerEnd();
		Timer afkTimer = new Timer(60, tt);
		afkTimer.start();
	}

	private void afkTimerEnd() {
		activityList.forEach((u, l) -> {
			if (qm.isPlayerInQueue(u) && (System.currentTimeMillis() - l) / 60000 >= settings.afkTime()) {
				qm.deletePlayer(u);
				String s = String.format("%s has been removed from the queue due to inactivity", u.getName());
				getPugChannel().sendMessage(Functions.createMessage("", s, Color.red)).queue();
				u.openPrivateChannel().complete().sendMessage("You have been removed from the queue due to inactivity")
						.queue();
				qm.updateTopic();
				System.out.println(s);
			}
		});

		startAFKTimer();
	}

	private void startDcTimer(Member m) {
		TimerTrigger trigger = () -> dcTimerEnd(m);
		Timer timer = new Timer(settings.dcTime(), trigger);
		timer.start();
		System.out.println(String.format("User %s has gone offline, starting dc timer", m.getEffectiveName()));
	}

	private void dcTimerEnd(Member m) {
		if (m.getOnlineStatus().equals(OnlineStatus.OFFLINE)) {
			qm.deletePlayer(m.getUser());
			qm.updateTopic();
			String s = String.format("%s has been removed from queue after being offline for %s minutes", m.getEffectiveName(), new DecimalFormat("#.##").format((double)settings.dcTime()/60));
			getPugChannel().sendMessage(Functions.createMessage("", s,Color.red)).queue();
			System.out.println(s);
		}else{
			System.out.println(String.format("%s has returned", m.getEffectiveName()));
		}
	}
	<commit_msg>Revised Server<commit_after>package core.entities;

import java.awt.Color;
import java.text.DecimalFormat;
import java.util.HashMap;

import core.util.Functions;
import core.util.TimerTrigger;
import net.dv8tion.jda.core.OnlineStatus;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;

public class Server {
	private String id;
	private Guild guild;
	private Settings settings;
	private QueueManager qm;
	private HashMap<User, Long> activityList = new HashMap<User, Long>();
	
	public Commands cmds;

	public Server(Guild guild) {
		this.guild = guild;
		this.id = guild.getId();
		Functions.createDir(String.format("%s/%s", "app_data", id));
		qm = new QueueManager(id);
		cmds = new Commands();
		settings = new Settings(id);
		qm.getQueue().forEach((q) -> q.getPlayersInQueue().forEach((u) -> updateActivityList(u)));
		startAFKTimer();
	}

	public String getid() {
		return id;
	}

	public QueueManager getQueueManager() {
		return qm;
	}

	public Settings getSettings() {
		return settings;
	}

	public TextChannel getPugChannel() {
		for (TextChannel c : guild.getTextChannels()) {
			if (c.getName().equalsIgnoreCase(settings.pugChannel())) {
				return c;
			}
		}
		return guild.getDefaultChannel();
	}

	private void startAFKTimer() {
		TimerTrigger tt = () -> afkTimerEnd();
		Timer afkTimer = new Timer(60, tt);
		afkTimer.start();
	}

	private void afkTimerEnd() {
		activityList.forEach((u, l) -> {
			if (qm.isPlayerInQueue(u) && (System.currentTimeMillis() - l) / 60000 >= settings.afkTime()) {
				qm.deletePlayer(u);
				String s = String.format("%s has been removed from the queue due to inactivity", u.getName());
				getPugChannel().sendMessage(Functions.createMessage("", s, Color.red)).queue();
				u.openPrivateChannel().complete().sendMessage("You have been removed from the queue due to inactivity")
						.queue();
				qm.updateTopic();
				System.out.println(s);
			}
		});

		startAFKTimer();
	}

	private void startDcTimer(Member m) {
		TimerTrigger trigger = () -> dcTimerEnd(m);
		Timer timer = new Timer(settings.dcTime(), trigger);
		timer.start();
		System.out.println(String.format("User %s has gone offline, starting dc timer", m.getEffectiveName()));
	}

	private void dcTimerEnd(Member m) {
		if (m.getOnlineStatus().equals(OnlineStatus.OFFLINE) && qm.isPlayerInQueue(m.getUser())) {
			qm.deletePlayer(m.getUser());
			qm.updateTopic();
			String s = String.format("%s has been removed from queue after being offline for %s minutes", m.getEffectiveName(), new DecimalFormat("#.##").format((double)settings.dcTime()/60));
			getPugChannel().sendMessage(Functions.createMessage("", s,Color.red)).queue();
			System.out.println(s);
		}
	}
	
{'fraction_non_alphanumeric': 0.1501411432604093, 'fraction_numerical': 0.004940014114326041, 'mean_word_length': 4.482591876208898, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '1658984', 'n_tokens_mistral': 2060, 'n_tokens_neox': 1859, 'n_words': 411}