<commit_before><commit_msg>New LiquidFlowSubListener<commit_after>package markehme.factionsplus.sublisteners;

import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.event.block.BlockFromToEvent;

import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.ps.PS;

public class LiquidFlowSubListener {
	
	public BlockFromToEvent blockFromToEvent(BlockFromToEvent event) {
		Chunk fromchunk = event.getBlock().getChunk();
		Chunk tochunk = event.getToBlock().getChunk();
		
		if(fromchunk == tochunk) return event;
		
		if(!event.getBlock().getType().equals(Material.WATER) || !event.getBlock().getType().equals(Material.LAVA)) {
			return event;
		}
		
		PS fromLoc	= PS.valueOf(event.getBlock().getLocation());
		PS toLoc	= PS.valueOf(event.getToBlock().getLocation());
		
		// If it's not a Faction, let it go
		if(BoardColls.get().getFactionAt(toLoc).getId().equals(UConf.get(toLoc).factionIdNone)) {
			return event;
		}
		
		// Check if the Factions match 
		if(BoardColls.get().getFactionAt(fromLoc) != BoardColls.get().getFactionAt(toLoc)) {
			
			event.setCancelled(true);
			
			event.getBlock().setType(Material.COBBLESTONE);
		}
		
		return event;
	}
}
{'fraction_non_alphanumeric': 0.1362549800796813, 'fraction_numerical': 0.0, 'mean_word_length': 4.841860465116279, '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': '1463187', 'n_tokens_mistral': 474, 'n_tokens_neox': 419, 'n_words': 64}