diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java index 364db894..bd0f1c52 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -11,5 +11,6 @@ public class CmdFactionsClaim extends FactionsCommand { public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true); public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true); public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true); + public CmdFactionsSetOneLocation cmdFactionsSetOneLocation = new CmdFactionsSetOneLocation(true); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java new file mode 100644 index 00000000..cd6a0ffd --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java @@ -0,0 +1,55 @@ +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.massivecore.MassiveException; +import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; +import com.massivecraft.massivecore.command.type.TypeWorld; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.ps.PS; +import org.bukkit.Location; +import org.bukkit.World; + +import java.util.Collections; +import java.util.Set; + +public class CmdFactionsSetOneLocation extends FactionsCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public CmdFactionsSetOneLocation(boolean claim) { + // Super + super(); + + // 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"); + + // Requirements + Perm perm = claim ? Perm.CLAIM_ONE : Perm.UNCLAIM_ONE; + this.addRequirements(RequirementHasPerm.get(perm)); + } + + @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); + + Set chunks = Collections.singleton(PS.valueOf(new Location(world, x, y, z)).getChunk()); + + // Apply / Inform + msender.tryClaim(newFaction, chunks); + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index 1196694f..175fc25d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -11,5 +11,6 @@ public class CmdFactionsUnclaim extends FactionsCommand { public CmdFactionsSetSquare cmdFactionsUnclaimSquare = new CmdFactionsSetSquare(false); public CmdFactionsSetCircle cmdFactionsUnclaimCircle = new CmdFactionsSetCircle(false); public CmdFactionsSetAll cmdFactionsUnclaimAll = new CmdFactionsSetAll(false); + public CmdFactionsSetOneLocation cmdFactionsSetOneLocation = new CmdFactionsSetOneLocation(false); }