Showing Dropping Anvil Something (Ignore)
This commit is contained in:
@@ -16,73 +16,73 @@ import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdClaim extends FCommand {
|
||||
|
||||
public CmdClaim() {
|
||||
super();
|
||||
this.aliases.add("claim");
|
||||
public CmdClaim() {
|
||||
super();
|
||||
this.aliases.add("claim");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("radius", "1");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("radius", "1");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CLAIM)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CLAIM)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
// Read and validate input
|
||||
int radius = context.argAsInt(0, 1); // Default to 1
|
||||
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
|
||||
// Read and validate input
|
||||
int radius = context.argAsInt(0, 1); // Default to 1
|
||||
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
|
||||
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (!(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER)) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (radius < 1) {
|
||||
context.msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 2) {
|
||||
// single chunk
|
||||
context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true);
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(context.sender, true)) {
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (!(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER)) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new SpiralTask(new FLocation(context.player), radius) {
|
||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||
private int failCount = 0;
|
||||
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = context.fPlayer.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
if (radius < 1) {
|
||||
context.msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (radius < 2) {
|
||||
// single chunk
|
||||
context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true);
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(context.sender, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new SpiralTask(new FLocation(context.player), radius) {
|
||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||
private int failCount = 0;
|
||||
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = context.fPlayer.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_CLAIM_DESCRIPTION;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_CLAIM_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user