Adds a command for claiming a specific location

This commit is contained in:
Kristian Knarvik 2023-04-02 02:09:20 +02:00
parent 45782ec94d
commit ebcd92c2fc
3 changed files with 57 additions and 0 deletions

View File

@ -11,5 +11,6 @@ public class CmdFactionsClaim extends FactionsCommand {
public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true); public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true);
public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true); public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true);
public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true); public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true);
public CmdFactionsSetOneLocation cmdFactionsSetOneLocation = new CmdFactionsSetOneLocation(true);
} }

View File

@ -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<PS> chunks = Collections.singleton(PS.valueOf(new Location(world, x, y, z)).getChunk());
// Apply / Inform
msender.tryClaim(newFaction, chunks);
}
}

View File

@ -11,5 +11,6 @@ public class CmdFactionsUnclaim extends FactionsCommand {
public CmdFactionsSetSquare cmdFactionsUnclaimSquare = new CmdFactionsSetSquare(false); public CmdFactionsSetSquare cmdFactionsUnclaimSquare = new CmdFactionsSetSquare(false);
public CmdFactionsSetCircle cmdFactionsUnclaimCircle = new CmdFactionsSetCircle(false); public CmdFactionsSetCircle cmdFactionsUnclaimCircle = new CmdFactionsSetCircle(false);
public CmdFactionsSetAll cmdFactionsUnclaimAll = new CmdFactionsSetAll(false); public CmdFactionsSetAll cmdFactionsUnclaimAll = new CmdFactionsSetAll(false);
public CmdFactionsSetOneLocation cmdFactionsSetOneLocation = new CmdFactionsSetOneLocation(false);
} }