Make EventFactionsFactionShowAsync
This commit is contained in:
		@@ -2,12 +2,17 @@ package com.massivecraft.factions.cmd;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.TreeSet;
 | 
					import java.util.TreeSet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
					import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsFactionShow;
 | 
					import com.massivecraft.factions.event.EventFactionsFactionShowAsync;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.Factions;
 | 
				
			||||||
import com.massivecraft.factions.Perm;
 | 
					import com.massivecraft.factions.Perm;
 | 
				
			||||||
import com.massivecraft.massivecore.PriorityLines;
 | 
					import com.massivecraft.massivecore.PriorityLines;
 | 
				
			||||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
					import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.mixin.Mixin;
 | 
				
			||||||
import com.massivecraft.massivecore.util.Txt;
 | 
					import com.massivecraft.massivecore.util.Txt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class CmdFactionsFaction extends FactionsCommand
 | 
					public class CmdFactionsFaction extends FactionsCommand
 | 
				
			||||||
@@ -36,23 +41,33 @@ public class CmdFactionsFaction extends FactionsCommand
 | 
				
			|||||||
	public void perform()
 | 
						public void perform()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Args
 | 
							// Args
 | 
				
			||||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
							final Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
				
			||||||
		if (faction == null) return;
 | 
							if (faction == null) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Event
 | 
							final CommandSender sender = this.sender;
 | 
				
			||||||
		EventFactionsFactionShow event = new EventFactionsFactionShow(sender, faction);
 | 
					 | 
				
			||||||
		event.run();
 | 
					 | 
				
			||||||
		if (event.isCancelled()) return;
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Title
 | 
							Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
 | 
				
			||||||
		msg(Txt.titleize("Faction " + faction.getName(msender)));
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Lines
 | 
					 | 
				
			||||||
		TreeSet<PriorityLines> priorityLiness = new TreeSet<PriorityLines>(event.getIdPriorityLiness().values());
 | 
					 | 
				
			||||||
		for (PriorityLines priorityLines : priorityLiness)
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			sendMessage(priorityLines.getLines());
 | 
								@Override
 | 
				
			||||||
		}
 | 
								public void run()
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									// Event
 | 
				
			||||||
 | 
									EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
 | 
				
			||||||
 | 
									event.run();
 | 
				
			||||||
 | 
									if (event.isCancelled()) return;
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									// Title
 | 
				
			||||||
 | 
									Mixin.messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									// Lines
 | 
				
			||||||
 | 
									TreeSet<PriorityLines> priorityLiness = new TreeSet<PriorityLines>(event.getIdPriorityLiness().values());
 | 
				
			||||||
 | 
									for (PriorityLines priorityLines : priorityLiness)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										Mixin.messageOne(sender, priorityLines.getLines());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ import com.massivecraft.factions.entity.MConf;
 | 
				
			|||||||
import com.massivecraft.factions.entity.MPlayerColl;
 | 
					import com.massivecraft.factions.entity.MPlayerColl;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
 | 
					import com.massivecraft.factions.event.EventFactionsChunkChangeType;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsChunksChange;
 | 
					import com.massivecraft.factions.event.EventFactionsChunksChange;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsFactionShow;
 | 
					import com.massivecraft.factions.event.EventFactionsFactionShowAsync;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsPvpDisallowed;
 | 
					import com.massivecraft.factions.event.EventFactionsPvpDisallowed;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsPowerChange;
 | 
					import com.massivecraft.factions.event.EventFactionsPowerChange;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason;
 | 
					import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason;
 | 
				
			||||||
@@ -122,7 +122,7 @@ public class EngineMain extends EngineAbstract
 | 
				
			|||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
 | 
						@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
 | 
				
			||||||
	public void onFactionShow(EventFactionsFactionShow event)
 | 
						public void onFactionShow(EventFactionsFactionShowAsync event)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		final int tableCols = 4;
 | 
							final int tableCols = 4;
 | 
				
			||||||
		final CommandSender sender = event.getSender();
 | 
							final CommandSender sender = event.getSender();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,4 +23,10 @@ public abstract class EventFactionsAbstractSender extends EventMassiveCore
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		this.sender = sender;
 | 
							this.sender = sender;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public EventFactionsAbstractSender(boolean async, CommandSender sender)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(async);
 | 
				
			||||||
 | 
							this.sender = sender;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ import org.bukkit.event.HandlerList;
 | 
				
			|||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.massivecore.PriorityLines;
 | 
					import com.massivecraft.massivecore.PriorityLines;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class EventFactionsFactionShow extends EventFactionsAbstractSender
 | 
					public class EventFactionsFactionShowAsync extends EventFactionsAbstractSender
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// REQUIRED EVENT CODE
 | 
						// REQUIRED EVENT CODE
 | 
				
			||||||
@@ -33,9 +33,9 @@ public class EventFactionsFactionShow extends EventFactionsAbstractSender
 | 
				
			|||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public EventFactionsFactionShow(CommandSender sender, Faction faction)
 | 
						public EventFactionsFactionShowAsync(CommandSender sender, Faction faction)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(sender);
 | 
							super(true, sender);
 | 
				
			||||||
		this.faction = faction;
 | 
							this.faction = faction;
 | 
				
			||||||
		this.idPriorityLiness = new HashMap<String, PriorityLines>();
 | 
							this.idPriorityLiness = new HashMap<String, PriorityLines>();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user