2013-04-29 10:23:39 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.RelationParticipator;
|
|
|
|
import com.massivecraft.factions.TerritoryAccess;
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.BoardColl;
|
2013-04-29 10:23:39 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2015-02-12 12:00:55 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.ps.PS;
|
|
|
|
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
|
|
|
|
import com.massivecraft.massivecore.util.Txt;
|
2013-04-29 10:23:39 +02:00
|
|
|
|
|
|
|
|
2014-09-18 13:41:20 +02:00
|
|
|
public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
2013-04-29 10:23:39 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// FIELDS
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
public PS chunk;
|
|
|
|
public TerritoryAccess ta;
|
|
|
|
public Faction hostFaction;
|
|
|
|
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
public CmdFactionsAccessAbstract()
|
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Requirements
|
2015-11-06 02:10:29 +01:00
|
|
|
this.addRequirements(RequirementIsPlayer.get());
|
2013-04-29 10:23:39 +02:00
|
|
|
}
|
|
|
|
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2013-04-29 10:23:39 +02:00
|
|
|
{
|
2014-11-18 10:00:15 +01:00
|
|
|
chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
2014-09-17 13:17:33 +02:00
|
|
|
ta = BoardColl.get().getTerritoryAccessAt(chunk);
|
2014-09-17 13:29:58 +02:00
|
|
|
hostFaction = ta.getHostFaction();
|
2013-04-29 10:23:39 +02:00
|
|
|
|
|
|
|
this.innerPerform();
|
|
|
|
}
|
|
|
|
|
2015-02-12 12:00:55 +01:00
|
|
|
public abstract void innerPerform() throws MassiveException;
|
2013-04-29 10:23:39 +02:00
|
|
|
|
|
|
|
public void sendAccessInfo()
|
|
|
|
{
|
2016-03-15 20:43:54 +01:00
|
|
|
Object title = "Access at " + chunk.toString(PSFormatHumanSpace.get());
|
|
|
|
title = Txt.titleize(title);
|
|
|
|
message(title);
|
|
|
|
|
2014-09-18 13:41:20 +02:00
|
|
|
msg("<k>Host Faction: %s", hostFaction.describeTo(msender, true));
|
2013-04-29 10:23:39 +02:00
|
|
|
msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
|
2014-09-18 13:41:20 +02:00
|
|
|
msg("<k>Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender));
|
|
|
|
msg("<k>Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), msender));
|
2013-04-29 10:23:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static String describeRelationParticipators(Collection<? extends RelationParticipator> relationParticipators, RelationParticipator observer)
|
|
|
|
{
|
|
|
|
if (relationParticipators.size() == 0) return Txt.parse("<silver><em>none");
|
|
|
|
List<String> descriptions = new ArrayList<String>();
|
|
|
|
for (RelationParticipator relationParticipator : relationParticipators)
|
|
|
|
{
|
|
|
|
descriptions.add(relationParticipator.describeTo(observer));
|
|
|
|
}
|
|
|
|
return Txt.implodeCommaAnd(descriptions, Txt.parse("<i>, "), Txt.parse(" <i>and "));
|
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
}
|