<commit_before>package co.neweden.playtimer;

import java.util.ArrayList;
import java.util.UUID;

import net.milkbowl.vault.permission.Permission;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;

public class PlayTimer extends JavaPlugin implements Listener {

	public static ArrayList<Player> verifiedUsers = new ArrayList<Player>();

	public static Permission permission = null;

	private boolean setupPermissions() {
		RegisteredServiceProvider<Permission> permissionProvider = getServer()
				.getServicesManager().getRegistration(
						net.milkbowl.vault.permission.Permission.class);
		if (permissionProvider != null) {
			permission = permissionProvider.getProvider();
		}
		return (permission != null);
	}

	// Plugin enable sends login message and starts a repeating process to
	// update the config/database
	public void onEnable() {
		// Greetings console!
		getLogger().info("PlayTimer started!");

		// Setup vault perms
		setupPermissions();

		// Schedule plugin to run every minute (1200 Ticks) and update users
		// currently connected in the config
		BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
		scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
			public void run() {
				updateAllPlayers();
			}

		}, 0L, 1200L);

		// Register Events
		getServer().getPluginManager().registerEvents(this, this);

		// Create default config.yml in the pugins folder
		this.saveDefaultConfig();

	}

	@EventHandler
	public void onLogin(PlayerJoinEvent eventLogin) {
		// Get user UUID and write it into the config file
		UUID pID = eventLogin.getPlayer().getUniqueId();

		if (this.getConfig().isInt("players." + pID.toString() + ".totaltime") == false) {
			updatePlayer(eventLogin.getPlayer());
		}
	}

	// Player time updater and rank increaser
	public void updatePlayer(Player player) {
		int totalTime = 0;
		String userName = player.getName().toString();
		try {
			totalTime = this.getConfig().getInt(
					"players." + player.getUniqueId() + ".totaltime");
		} catch (NullPointerException e) {
			totalTime = 0;
		}

		if (totalTime >= 719) {
			// Check if explorer, if yes promote to builder, message player and
			// broadcast to server

			if (permission.getPrimaryGroup(player).equals("Explorer")) {
				// Checks if an Explorer has been added to the verified users
				// list
				if (verifiedUsers.contains(player) == true)
					return;
				
				// Checks if the user exists on the forums and gives a
				// registration link if they don't
				if (HTTPRequest.forumUserExists(userName) == false) {
					player.sendMessage(Util
							.formatString("&f[&8PlayTimer&f]: "
									+ "&2You need to register on the forums (http://pngn.co/q) before we can promote you to Builder. Please note that you must use your ingame username."));
					return;
				}<commit_msg>Switched out text that informs users of the requirements for Builder mentioned in #4, colour changed to stand out more.<commit_after>package co.neweden.playtimer;

import java.util.ArrayList;
import java.util.UUID;

import net.milkbowl.vault.permission.Permission;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;

public class PlayTimer extends JavaPlugin implements Listener {

	public static ArrayList<Player> verifiedUsers = new ArrayList<Player>();

	public static Permission permission = null;

	private boolean setupPermissions() {
		RegisteredServiceProvider<Permission> permissionProvider = getServer()
				.getServicesManager().getRegistration(
						net.milkbowl.vault.permission.Permission.class);
		if (permissionProvider != null) {
			permission = permissionProvider.getProvider();
		}
		return (permission != null);
	}

	// Plugin enable sends login message and starts a repeating process to
	// update the config/database
	public void onEnable() {
		// Greetings console!
		getLogger().info("PlayTimer started!");

		// Setup vault perms
		setupPermissions();

		// Schedule plugin to run every minute (1200 Ticks) and update users
		// currently connected in the config
		BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
		scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
			public void run() {
				updateAllPlayers();
			}

		}, 0L, 1200L);

		// Register Events
		getServer().getPluginManager().registerEvents(this, this);

		// Create default config.yml in the pugins folder
		this.saveDefaultConfig();

	}

	@EventHandler
	public void onLogin(PlayerJoinEvent eventLogin) {
		// Get user UUID and write it into the config file
		UUID pID = eventLogin.getPlayer().getUniqueId();

		if (this.getConfig().isInt("players." + pID.toString() + ".totaltime") == false) {
			updatePlayer(eventLogin.getPlayer());
		}
	}

	// Player time updater and rank increaser
	public void updatePlayer(Player player) {
		int totalTime = 0;
		String userName = player.getName().toString();
		try {
			totalTime = this.getConfig().getInt(
					"players." + player.getUniqueId() + ".totaltime");
		} catch (NullPointerException e) {
			totalTime = 0;
		}

		if (totalTime >= 719) {
			// Check if explorer, if yes promote to builder, message player and
			// broadcast to server

			if (permission.getPrimaryGroup(player).equals("Explorer")) {
				// Checks if an Explorer has been added to the verified users
				// list
				if (verifiedUsers.contains(player) == true)
					return;
				
				// Checks if the user exists on the forums and gives a
				// registration link if they don't
				if (HTTPRequest.forumUserExists(userName) == false) {
					player.sendMessage(Util
							.formatString("&f[&8PlayTimer&f]: "
									+ "&6Congratulations! You have played for atleast 12 hours, this means you are eligible to be promoted to from Explorer to Builder, all you need to do now is to register on our forum, go to http://pngn.co/q to get started. Remember to register using your Minecraft username, otherwise you won't get promote"));
					return;
				}
{'fraction_non_alphanumeric': 0.10593852581319009, 'fraction_numerical': 0.005222321695016413, 'mean_word_length': 4.043641835966892, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6257368', 'n_tokens_mistral': 2222, 'n_tokens_neox': 1905, 'n_words': 572}