<commit_before>package de.zockerstream.NoPlayers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class NoPlayers extends JavaPlugin implements Listener {
	
	private HashMap<String, Boolean> alreadyHidden = new HashMap<String, Boolean>();
	
	@Override
	public void onEnable() {
		getServer().getPluginManager().registerEvents(this, this);
	}

	@Override
	public void onDisable() {
	}

	/* Method checks if players are already hidden or not
	*  and if necessary, all players are hidden or made ​​visible again
	*/ 
	@EventHandler
	public void onInteract(PlayerInteractEvent e) {
		if (e.getPlayer().getItemInHand().getType() == Material.PAPER && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
			if(alreadyHidden.get(e.getPlayer().getName()) == false) {
				hidePlayer(e.getPlayer());
				alreadyHidden.put(e.getPlayer().getName(), true);
			} else {
				showPlayer(e.getPlayer());
				alreadyHidden.put(e.getPlayer().getName(), false);
			}
		}
	}
	
	// Method sets the player an item to his Inventory
	@EventHandler 
	public void onPlayerJoin(PlayerJoinEvent e) {
		Player p = e.getPlayer();
		ItemStack itemstack = new ItemStack(Material.PAPER, 1);
		List<String> ls = new ArrayList<String>();
		ls.add("§cHide all players.");
		if(!p.getInventory().contains(setName(itemstack, "§6§l§oHide", ls))) 
		{
			p.getInventory().addItem(setName(itemstack, "§6§l§oHide", ls));
		}
		alreadyHidden.put(p.getName(), false);
	}
	
	// Method hides all players
	public void hidePlayer(Player s) {
		Player[] target = s.getServer().getOnlinePlayers();
		for (int i = 0; i < target.length; i++) {
			s.hidePlayer(target[i]);
		}
		s.sendMessage("§eWooosh! Hello? Hellooo?");
	}
	
	// Method shows all players
	public void showPlayer(Player s) {
		Player[] target = s.getServer().getOnlinePlayers();
		for (int i = 0; i < target.length; i++) {
			s.showPlayer(target[i]);
		}
		s.sendMessage("§eWooosh! You can see me!");
	}
	
	// Sets the name of the Itemstack
	private ItemStack setName(ItemStack is, String name, List<String> lore) {
		ItemMeta im = is.getItemMeta();
		if (name != null) {
			im.setDisplayName(name);
		}
		if (lore != null) {
			im.setLore(lore);
			is.setItemMeta(im);
		}
		return is;
	}
}

<commit_msg>More comments and small changes<commit_after>package de.zockerstream.NoPlayers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class NoPlayers extends JavaPlugin implements Listener {
	private HashMap<String, Boolean> alreadyHidden = new HashMap<String, Boolean>();
	
	/**
	 * Register the EventHandler
	 */
	@Override
	public void onEnable() {
		getServer().getPluginManager().registerEvents(this, this);
	}

	/**
	 * Handles the use of items / blocks by the player
	 * Checks if the player interacts with a paper and hides / shows the other players
	 */
	@EventHandler
	public void onInteract(PlayerInteractEvent e) {
		// Is the item a paper? Right-Click?
		if (e.getPlayer().getItemInHand().getType() == Material.PAPER && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
			// Players already hidden? Then make them visible again
			if (alreadyHidden.get(e.getPlayer().getName()) == false) {
				hidePlayer(e.getPlayer());
				alreadyHidden.put(e.getPlayer().getName(), true);
			} else {
				showPlayer(e.getPlayer());
				alreadyHidden.put(e.getPlayer().getName(), false);
			}
		}
	}
	
	/**
	 * Handles joining of players
	 * Gives the player his paper
	 */
	@EventHandler 
	public void onPlayerJoin(PlayerJoinEvent e) {
		Player p = e.getPlayer();
		
		// Create the paper
		ItemStack itemstack = new ItemStack(Material.PAPER, 1);
		List<String> ls = new ArrayList<String>();
		ls.add("§cHide all players.");
		
		// Player already has this paper? Then don't add an other one
		if (!p.getInventory().contains(setName(itemstack, "§6§l§oHide", ls))) {
			p.getInventory().addItem(setName(itemstack, "§6§l§oHide", ls));
		}
		alreadyHidden.put(p.getName(), false);
	}
	
	/**
	 * Hides every player for the specified player
	 * @param p Player which wants to hide the others
	 */
	public void hidePlayer(Player p) {
		for (Player players : Bukkit.getOnlinePlayers()) {
			p.hidePlayer(players);
		}
		p.sendMessage("§eWooosh! Hello? Hellooo?");
	}
	
	/**
	 * Shows every player for the specified player
	 * @param p Player which wants to see the others
	 */
	public void showPlayer(Player p) {
		for (Player players : Bukkit.getOnlinePlayers()) {
			p.showPlayer(players);
		}
		p.sendMessage("§eWooosh! You can see me!");
	}
	
	/**
	 * Helper, which gives an ItemStack a (coloured) name and additional text
	 * @param is	ItemStack to modify
	 * @param name	ItemStack's name
	 * @param lore	ItemStack's info
	 */
	private ItemStack setName(ItemStack is, String name, List<String> lore) {
		ItemMeta im = is.getItemMeta();
		if (name != null) {
			im.setDisplayName(name);
		}
		if (lore != null) {
			im.setLore(lore);
			is.setItemMeta(im);
		}
		return is;
	}
}

{'fraction_non_alphanumeric': 0.13747000342817964, 'fraction_numerical': 0.0013712718546451835, 'mean_word_length': 4.163716814159292, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '5441425', 'n_tokens_mistral': 2112, 'n_tokens_neox': 1900, 'n_words': 474}