diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java index cd6a0ffd..f5fa4814 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java @@ -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 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); + } } } diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index d8321fc1..fc5fedc7 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -821,6 +821,7 @@ public class MPlayer extends SenderEntity implements FactionsParticipat // This is also very suggested cleaning of EventFactionsChunksChange input. Iterator 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 already owns this land.", newFaction.describeTo(this, true)); return true;