Factions/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java

62 lines
1.8 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
2017-02-10 16:38:36 +01:00
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.cmd.type.TypeFaction;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
2015-01-10 13:00:29 +01:00
import com.massivecraft.factions.event.EventFactionsFactionShowAsync;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.PriorityLines;
2016-05-13 12:32:05 +02:00
import com.massivecraft.massivecore.mixin.MixinMessage;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.util.Txt;
2017-03-24 13:05:58 +01:00
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import java.util.TreeSet;
2014-09-18 13:41:20 +02:00
public class CmdFactionsFaction extends FactionsCommand
2011-10-09 18:35:39 +02:00
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsFaction()
2011-10-09 18:35:39 +02:00
{
2013-11-11 09:31:04 +01:00
// Aliases
this.addAliases("f", "show", "who").setDesc("the faction to show info about");
2013-11-11 09:31:04 +01:00
// Parameters
this.addParameter(TypeFaction.get(), "faction", "you");
2011-03-23 17:39:56 +01:00
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
2011-10-09 18:35:39 +02:00
@Override
2015-02-12 12:00:55 +01:00
public void perform() throws MassiveException
2011-10-09 18:35:39 +02:00
{
2013-04-25 16:54:55 +02:00
// Args
2015-05-06 17:04:35 +02:00
final Faction faction = this.readArg(msenderFaction);
2015-01-10 13:00:29 +01:00
final CommandSender sender = this.sender;
2013-04-26 17:54:06 +02:00
2019-05-03 09:25:18 +02:00
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Event
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
event.run();
if (event.isCancelled()) return;
// Title
MixinMessage.get().messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
// Lines
TreeSet<PriorityLines> priorityLiness = new TreeSet<>(event.getIdPriorityLiness().values());
for (PriorityLines priorityLines : priorityLiness)
2015-01-10 13:00:29 +01:00
{
2019-05-03 09:25:18 +02:00
MixinMessage.get().messageOne(sender, priorityLines.getLines());
2015-01-10 13:00:29 +01:00
}
});
}
}