diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java index bd0f1c52..dba4d548 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -11,6 +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); + public CmdFactionsSetOneLocation cmdFactionsClaimOneLocation = 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 index f5fa4814..0c4839cc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOneLocation.java @@ -1,16 +1,12 @@ 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.cmd.type.TypeMPlayer; +import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MPlayer; 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.command.requirement.RequirementIsntPlayer; import com.massivecraft.massivecore.ps.PS; -import org.bukkit.Location; -import org.bukkit.World; import java.util.Collections; import java.util.Set; @@ -32,32 +28,34 @@ public class CmdFactionsSetOneLocation extends FactionsCommand { // Aliases this.addAliases("onel"); - 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"); + this.addParameter(TypeMPlayer.get(), true, "player").setDesc("the player to claim for"); // Requirements - Perm perm = claim ? Perm.CLAIM_ONE : Perm.UNCLAIM_ONE; - this.addRequirements(RequirementHasPerm.get(perm)); + this.addRequirements(RequirementIsntPlayer.get()); } @Override public void perform() throws MassiveException { // Args - 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); + MPlayer player = this.readArgAt(0); - Set chunks = Collections.singleton(PS.valueOf(new Location(world, x, y, z)).getChunk()); + if (!player.hasFaction()) { + throw new MassiveException(); + } + + PS chunk = PS.valueOf(player.getPlayer().getLocation()).getChunk(true); + Set chunks = Collections.singleton(chunk); // Apply / Inform if (this.claim) { - msender.tryClaim(newFaction, chunks); + if (!BoardColl.get().getFactionAt(chunk).isNone()) { + throw new MassiveException().setMsg("Only wilderness can be claimed using this method."); + } + msender.tryClaim(player.getFaction(), chunks); } else { + if (!BoardColl.get().getFactionAt(chunk).equals(player.getFaction())) { + throw new MassiveException(); + } msender.tryClaim(FactionColl.get().getNone(), chunks); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index 175fc25d..fd0282f6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -11,6 +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); + public CmdFactionsSetOneLocation cmdFactionsUnclaimOneLocation = new CmdFactionsSetOneLocation(false); } diff --git a/src/main/java/com/massivecraft/factions/engine/EngineChunkChange.java b/src/main/java/com/massivecraft/factions/engine/EngineChunkChange.java index 331827fa..b14c9695 100644 --- a/src/main/java/com/massivecraft/factions/engine/EngineChunkChange.java +++ b/src/main/java/com/massivecraft/factions/engine/EngineChunkChange.java @@ -16,6 +16,7 @@ import com.massivecraft.massivecore.mixin.MixinWorld; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -59,8 +60,8 @@ public class EngineChunkChange extends Engine { final Set currentFactions = currentFactionChunks.keySet(); final Set chunks = event.getChunks(); - // Override Mode? Sure! - if (mplayer.isOverriding()) { + // Override Mode or console? Sure! + if (mplayer.isOverriding() || event.getSender() instanceof ConsoleCommandSender) { return; }