Removed WorldGuard integration. Can be readded later in a proper manner if anyone need it. Also moved some more Econ stuff to the listener.
This commit is contained in:
@@ -36,7 +36,7 @@ public class CmdFactionsAutoClaim extends FCommand
|
||||
fme.setAutoClaimFor(forFaction);
|
||||
|
||||
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
|
||||
fme.attemptClaim(forFaction, PS.valueOf(me), true);
|
||||
fme.tryClaim(forFaction, PS.valueOf(me), true, true);
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
@@ -28,34 +29,44 @@ public class CmdFactionsClaim extends FCommand
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
final Faction forFaction = this.arg(0, ARFaction.get(me));
|
||||
if (forFaction == null) return;
|
||||
|
||||
Integer radius = this.arg(1, ARInteger.get(), 1);
|
||||
if (radius == null) return;
|
||||
|
||||
|
||||
// FPerm
|
||||
if (!FPerm.TERRITORY.has(sender, forFaction, true)) return;
|
||||
|
||||
// Validate
|
||||
if (radius < 1)
|
||||
{
|
||||
msg("<b>If you specify a radius, it must be at least 1.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply
|
||||
|
||||
// single chunk
|
||||
if (radius < 2)
|
||||
{
|
||||
// single chunk
|
||||
fme.attemptClaim(forFaction, PS.valueOf(me), true);
|
||||
fme.tryClaim(forFaction, PS.valueOf(me), true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// radius claim
|
||||
if (! Perm.CLAIM_RADIUS.has(sender, false))
|
||||
if (!Perm.CLAIM_RADIUS.has(sender, false))
|
||||
{
|
||||
msg("<b>You do not have permission to claim in a radius.");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: I do not beleive in the spiral-task. Get rid of this. The failcount can be precalculated.
|
||||
// TODO: There must be a better way than using a spiral task.
|
||||
// TODO: Do some research to allow for claming sets of chunks in a batch with atomicity.
|
||||
// This will probably result in an alteration to the owner change event.
|
||||
// It would possibly contain a set of chunks instead of a single chunk.
|
||||
|
||||
new SpiralTask(PS.valueOf(me), radius)
|
||||
{
|
||||
private int failCount = 0;
|
||||
@@ -64,15 +75,16 @@ public class CmdFactionsClaim extends FCommand
|
||||
@Override
|
||||
public boolean work()
|
||||
{
|
||||
boolean success = fme.attemptClaim(forFaction, PS.valueOf(this.currentLocation()), true);
|
||||
boolean success = fme.tryClaim(forFaction, PS.valueOf(this.currentLocation()), true, true);
|
||||
if (success)
|
||||
failCount = 0;
|
||||
else if ( ! success && failCount++ >= limit)
|
||||
{
|
||||
this.failCount = 0;
|
||||
}
|
||||
else if (this.failCount++ >= this.limit)
|
||||
{
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@@ -9,13 +9,11 @@ import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.event.FactionsEventDisband;
|
||||
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.mcore.money.Money;
|
||||
|
||||
public class CmdFactionsDisband extends FCommand
|
||||
{
|
||||
@@ -78,19 +76,7 @@ public class CmdFactionsDisband extends FCommand
|
||||
Factions.get().log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
|
||||
}
|
||||
|
||||
if (Econ.isEnabled(faction))
|
||||
{
|
||||
//Give all the faction's money to the disbander
|
||||
double amount = Money.get(faction);
|
||||
Econ.transferMoney(fme, faction, fme, amount, false);
|
||||
|
||||
if (amount > 0.0)
|
||||
{
|
||||
String amountString = Money.format(faction, amount);
|
||||
msg("<i>You have been given the disbanded faction's bank, totaling %s.", amountString);
|
||||
Factions.get().log(fme.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
faction.detach();
|
||||
}
|
||||
|
@@ -1,12 +1,8 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.entity.BoardColls;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColls;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.event.FactionsEventChunkChange;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||
@@ -27,29 +23,22 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
{
|
||||
// Args
|
||||
PS chunk = PS.valueOf(me).getChunk(true);
|
||||
Faction otherFaction = BoardColls.get().getFactionAt(chunk);
|
||||
|
||||
Faction newFaction = FactionColls.get().get(me).getNone();
|
||||
|
||||
// FPerm
|
||||
// TODO: Recode so that pillage is possible
|
||||
if ( ! FPerm.TERRITORY.has(sender, otherFaction, true)) return;
|
||||
|
||||
// Event
|
||||
FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
if (!FPerm.TERRITORY.has(sender, myFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
BoardColls.get().setFactionAt(chunk, newFaction);
|
||||
if (fme.tryClaim(newFaction, chunk, true, true)) return;
|
||||
|
||||
// Inform
|
||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
// TODO: Move the logging stuff into the try-method
|
||||
/*myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
|
||||
if (MConf.get().logLandUnclaims)
|
||||
{
|
||||
Factions.get().log(fme.getName()+" unclaimed land at ("+chunk.getChunkX()+","+chunk.getChunkZ()+") from the faction: "+otherFaction.getTag());
|
||||
}
|
||||
Factions.get().log(fme.getName()+" unclaimed land at ("+chunk.getChunkX()+","+chunk.getChunkZ()+") from the faction: "+oldFaction.getTag());
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
@@ -30,8 +31,10 @@ public class CmdFactionsUnclaimall extends FCommand
|
||||
{
|
||||
// Args
|
||||
Faction faction = myFaction;
|
||||
|
||||
Faction newFaction = FactionColls.get().get(faction).getNone();
|
||||
|
||||
// FPerm
|
||||
if (!FPerm.TERRITORY.has(sender, faction, true)) return;
|
||||
|
||||
// Apply
|
||||
BoardColl boardColl = BoardColls.get().get(faction);
|
||||
|
Reference in New Issue
Block a user