<commit_before>package com.kylantraynor.civilizations.listeners;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

import com.kylantraynor.civilizations.Civilizations;
import com.kylantraynor.civilizations.groups.settlements.forts.Fort;
import com.kylantraynor.civilizations.hook.titlemanager.TitleManagerHook;
import com.kylantraynor.civilizations.territories.InfluenceMap;
import com.kylantraynor.civilizations.territories.PlayerMoveData;

public class TerritoryListener implements Listener {
	
	@EventHandler
	public void onPlayerMove(PlayerMoveEvent event){
		if(event.isCancelled()) return;
		if(event.getTo().getBlock().equals(event.getFrom().getBlock())) return;
		
		InfluenceMap map = Civilizations.getInfluenceMap(event.getTo().getWorld());
		PlayerMoveData data = map.processPlayerMove(event.getPlayer(), event.getFrom(), event.getTo());
		if(Civilizations.currentInstance.isDEBUG()){
			String from = data.getFrom() == null ? "NullRegion" : data.getFrom().getName();
			String to = data.getTo() == null ? "NullRegion" : data.getTo().getName();
			Civilizations.DEBUG("Moving from " + from + " to " + to + ".");
		}
		if(data.changedRegion() && data.getTo() != null){
			TitleManagerHook.sendTitle("", data.getTo().getName(), 0, 1, 5, event.getPlayer());
		}
		/*Fort f = InfluenceMap.getInfluentFortAt(event.getTo());
		/Fort oldFort = null;
		if(playerLocations.containsKey(event.getPlayer())){
			oldFort = playerLocations.get(event.getPlayer());
		}
		boolean territoryHasChanged = false;
		if(f != null){
			if(oldFort == null){
				territoryHasChanged = true;
			} else if(!oldFort.equals(f)) {
				territoryHasChanged = true;
			}
		} else {
			if(oldFort != null){
				territoryHasChanged = true;
			}
		}
		if(territoryHasChanged){
			PlayerTerritoryChangeEvent e = new PlayerTerritoryChangeEvent(event.getPlayer(), oldFort, f);
			Civilizations.callEvent(e);
			if(!e.isCancelled()){
				if(e.hasNewFort()){
					playerLocations.put(event.getPlayer(), f);
					TitleManagerHook.sendActionBar("House " + f.getHouse().getName() + "'s territory.", event.getPlayer(), false);
				} else {
					if(playerLocations.containsKey(event.getPlayer())){
						playerLocations.remove(event.getPlayer());
					}
				}
			} else {
				event.setCancelled(true);
			}
		}
		*/
	}

}<commit_msg>Fixed region checker<commit_after>package com.kylantraynor.civilizations.listeners;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

import com.kylantraynor.civilizations.Civilizations;
import com.kylantraynor.civilizations.groups.settlements.forts.Fort;
import com.kylantraynor.civilizations.hook.titlemanager.TitleManagerHook;
import com.kylantraynor.civilizations.territories.InfluenceMap;
import com.kylantraynor.civilizations.territories.PlayerMoveData;

public class TerritoryListener implements Listener {
	
	@EventHandler
	public void onPlayerMove(PlayerMoveEvent event){
		if(event.isCancelled()) return;
		if(event.getTo().getBlock().equals(event.getFrom().getBlock())) return;
		
		InfluenceMap map = Civilizations.getInfluenceMap(event.getTo().getWorld());
		PlayerMoveData data = map.processPlayerMove(event.getPlayer(), event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation());
		if(Civilizations.currentInstance.isDEBUG()){
			String from = data.getFrom() == null ? "NullRegion" : data.getFrom().getName();
			String to = data.getTo() == null ? "NullRegion" : data.getTo().getName();
			Civilizations.DEBUG("Moving from " + from + " to " + to + ".");
		}
		if(data.changedRegion() && data.getTo() != null){
			TitleManagerHook.sendTitle("", data.getTo().getName(), 0, 1, 5, event.getPlayer());
		}
		/*Fort f = InfluenceMap.getInfluentFortAt(event.getTo());
		/Fort oldFort = null;
		if(playerLocations.containsKey(event.getPlayer())){
			oldFort = playerLocations.get(event.getPlayer());
		}
		boolean territoryHasChanged = false;
		if(f != null){
			if(oldFort == null){
				territoryHasChanged = true;
			} else if(!oldFort.equals(f)) {
				territoryHasChanged = true;
			}
		} else {
			if(oldFort != null){
				territoryHasChanged = true;
			}
		}
		if(territoryHasChanged){
			PlayerTerritoryChangeEvent e = new PlayerTerritoryChangeEvent(event.getPlayer(), oldFort, f);
			Civilizations.callEvent(e);
			if(!e.isCancelled()){
				if(e.hasNewFort()){
					playerLocations.put(event.getPlayer(), f);
					TitleManagerHook.sendActionBar("House " + f.getHouse().getName() + "'s territory.", event.getPlayer(), false);
				} else {
					if(playerLocations.containsKey(event.getPlayer())){
						playerLocations.remove(event.getPlayer());
					}
				}
			} else {
				event.setCancelled(true);
			}
		}
		*/
	}

}
{'fraction_non_alphanumeric': 0.1487603305785124, 'fraction_numerical': 0.0012094335819391251, 'mean_word_length': 4.789964994165694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2281849', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1590, 'n_words': 248}