Fixes some problems with the setOneLocation command
This commit is contained in:
parent
8d7dea9f84
commit
bdc9b35a9b
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
||||
import com.massivecraft.massivecore.command.type.TypeWorld;
|
||||
@ -19,18 +20,23 @@ public class CmdFactionsSetOneLocation extends FactionsCommand {
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private final boolean claim;
|
||||
|
||||
public CmdFactionsSetOneLocation(boolean claim) {
|
||||
// Super
|
||||
super();
|
||||
|
||||
this.setSetupEnabled(false);
|
||||
this.claim = claim;
|
||||
|
||||
// Aliases
|
||||
this.addAliases("onel");
|
||||
|
||||
this.addParameter(TypeFaction.get(), true, "faction").setDesc("you");
|
||||
this.addParameter(TypeWorld.get(), true, "world").setDesc("the world of the location");
|
||||
this.addParameter(TypeDouble.get(), true, "x").setDesc("the x coordinate of the location");
|
||||
this.addParameter(TypeDouble.get(), true, "y").setDesc("the y coordinate of the location");
|
||||
this.addParameter(TypeDouble.get(), true, "z").setDesc("the z coordinate of the location");
|
||||
this.addParameter(TypeFaction.get(), "faction").setDesc("you");
|
||||
|
||||
// Requirements
|
||||
Perm perm = claim ? Perm.CLAIM_ONE : Perm.UNCLAIM_ONE;
|
||||
@ -40,16 +46,20 @@ public class CmdFactionsSetOneLocation extends FactionsCommand {
|
||||
@Override
|
||||
public void perform() throws MassiveException {
|
||||
// Args
|
||||
final Faction newFaction = this.readArgAt(0);
|
||||
World world = this.readArgAt(1);
|
||||
double x = this.readArg(2);
|
||||
double y = this.readArg(3);
|
||||
double z = this.readArg(4);
|
||||
World world = this.readArgAt(0);
|
||||
double x = this.readArgAt(1);
|
||||
double y = this.readArgAt(2);
|
||||
double z = this.readArgAt(3);
|
||||
final Faction newFaction = this.readArgAt(4);
|
||||
|
||||
Set<PS> chunks = Collections.singleton(PS.valueOf(new Location(world, x, y, z)).getChunk());
|
||||
|
||||
// Apply / Inform
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
if (this.claim) {
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
} else {
|
||||
msender.tryClaim(FactionColl.get().getNone(), chunks);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -821,6 +821,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
|
||||
// This is also very suggested cleaning of EventFactionsChunksChange input.
|
||||
Iterator<PS> iter = chunks.iterator();
|
||||
chunks.removeIf(chunk -> BoardColl.get().getFactionAt(chunk) == newFaction);
|
||||
//TODO: This is triggered from console commands, even though it shouldn't happen
|
||||
if (chunks.isEmpty()) {
|
||||
msg("%s<i> already owns this land.", newFaction.describeTo(this, true));
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user