2014-10-13 15:14:34 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Perm;
|
|
|
|
import com.massivecraft.factions.entity.BoardColl;
|
|
|
|
import com.massivecraft.factions.entity.Faction;
|
|
|
|
import com.massivecraft.factions.entity.MConf;
|
2019-03-06 17:10:35 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
2014-10-13 15:14:34 +02:00
|
|
|
import com.massivecraft.massivecore.ps.PS;
|
2019-04-15 13:55:20 +02:00
|
|
|
import com.massivecraft.massivecore.util.ChunkUtil;
|
2014-10-13 15:14:34 +02:00
|
|
|
|
2017-03-24 13:05:58 +01:00
|
|
|
import java.util.Set;
|
2019-05-19 21:19:21 +02:00
|
|
|
import java.util.function.Predicate;
|
2017-03-24 13:05:58 +01:00
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
|
|
|
|
public class CmdFactionsSetFill extends CmdFactionsSetXSimple
|
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2014-11-19 10:30:44 +01:00
|
|
|
public CmdFactionsSetFill(boolean claim)
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
2014-11-19 10:30:44 +01:00
|
|
|
// Super
|
|
|
|
super(claim);
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
// Aliases
|
2015-10-21 21:18:00 +02:00
|
|
|
this.addAliases("fill");
|
2014-10-13 15:14:34 +02:00
|
|
|
|
2014-10-14 08:56:07 +02:00
|
|
|
// Format
|
2014-10-14 09:41:20 +02:00
|
|
|
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using fill.");
|
|
|
|
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using fill.");
|
2014-10-14 08:56:07 +02:00
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
// Requirements
|
2015-11-06 02:10:29 +01:00
|
|
|
this.addRequirements(RequirementIsPlayer.get());
|
2016-05-26 10:17:44 +02:00
|
|
|
Perm perm = claim ? Perm.CLAIM_FILL : Perm.UNCLAIM_FILL;
|
|
|
|
this.addRequirements(RequirementHasPerm.get(perm));
|
2014-10-13 15:14:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2019-03-06 17:10:35 +01:00
|
|
|
public Set<PS> getChunks() throws MassiveException
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
|
|
|
// Common Startup
|
2014-11-18 10:00:15 +01:00
|
|
|
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
2014-10-13 15:14:34 +02:00
|
|
|
|
|
|
|
// What faction (aka color) resides there?
|
|
|
|
// NOTE: Wilderness/None is valid.
|
|
|
|
final Faction color = BoardColl.get().getFactionAt(chunk);
|
|
|
|
|
2019-04-15 13:55:20 +02:00
|
|
|
// Calculate
|
2014-10-13 15:14:34 +02:00
|
|
|
int max = MConf.get().setFillMax;
|
2019-04-15 13:55:20 +02:00
|
|
|
Predicate<PS> matcher = ps -> BoardColl.get().getFactionAt(ps) == color;
|
|
|
|
return ChunkUtil.getChunkArea(chunk, matcher, max);
|
2014-10-13 15:14:34 +02:00
|
|
|
}
|
2019-04-15 13:55:20 +02:00
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
}
|