Unifying, simplifying and messing around with land claiming and the related costs.
This commit is contained in:
@@ -9,6 +9,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.event.FactionsEventChunkChangeType;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.Perm;
|
||||
@@ -34,6 +35,8 @@ public class CmdFactionsShow extends FCommand
|
||||
{
|
||||
Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
UConf uconf = UConf.get(faction);
|
||||
|
||||
Collection<UPlayer> leaders = faction.getUPlayersWhereRole(Rel.LEADER);
|
||||
Collection<UPlayer> officers = faction.getUPlayersWhereRole(Rel.OFFICER);
|
||||
@@ -64,18 +67,30 @@ public class CmdFactionsShow extends FCommand
|
||||
// show the land value
|
||||
if (Econ.isEnabled(faction))
|
||||
{
|
||||
double value = Econ.calculateTotalLandValue(faction.getLandCount());
|
||||
long landCount = faction.getLandCount();
|
||||
|
||||
double refund = value * UConf.get(faction).econClaimRefundMultiplier;
|
||||
if (value > 0)
|
||||
for (FactionsEventChunkChangeType type : FactionsEventChunkChangeType.values())
|
||||
{
|
||||
String stringValue = Money.format(faction, value);
|
||||
String stringRefund = (refund > 0.0) ? (" ("+Money.format(faction, refund)+" depreciated)") : "";
|
||||
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
||||
Double money = uconf.econChunkCost.get(type);
|
||||
if (money == null) money = 0D;
|
||||
money *= landCount;
|
||||
|
||||
String word = null;
|
||||
if (money > 0)
|
||||
{
|
||||
word = "cost";
|
||||
}
|
||||
else
|
||||
{
|
||||
word = "reward";
|
||||
money *= -1;
|
||||
}
|
||||
|
||||
msg("<a>Total land %s %s: <i>%s", type.toString().toLowerCase(), word, Money.format(faction, money));
|
||||
}
|
||||
|
||||
// Show bank contents
|
||||
if(UConf.get(faction).bankEnabled)
|
||||
if (UConf.get(faction).bankEnabled)
|
||||
{
|
||||
msg("<a>Bank contains: <i>"+Money.format(faction, Money.get(faction)));
|
||||
}
|
||||
|
@@ -2,10 +2,9 @@ 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.entity.UConf;
|
||||
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.event.FactionsEventChunkChange;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
@@ -30,30 +29,21 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
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
|
||||
FactionsEventLandUnclaim event = new FactionsEventLandUnclaim(sender, otherFaction, chunk);
|
||||
FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
//String moneyBack = "<i>";
|
||||
if (Econ.isEnabled(myFaction))
|
||||
{
|
||||
double refund = Econ.calculateClaimRefund(myFaction);
|
||||
|
||||
if (UConf.get(myFaction).bankEnabled && UConf.get(myFaction).bankFactionPaysLandCosts)
|
||||
{
|
||||
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim this land")) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! Econ.modifyMoney(fme, refund, "unclaim this land")) return;
|
||||
}
|
||||
}
|
||||
|
||||
BoardColls.get().removeAt(chunk);
|
||||
// Apply
|
||||
BoardColls.get().setFactionAt(chunk, newFaction);
|
||||
|
||||
// Inform
|
||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
|
||||
if (MConf.get().logLandUnclaims)
|
||||
|
@@ -1,15 +1,19 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
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.entity.UConf;
|
||||
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.event.FactionsEventChunkChange;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
public class CmdFactionsUnclaimall extends FCommand
|
||||
{
|
||||
@@ -24,32 +28,36 @@ public class CmdFactionsUnclaimall extends FCommand
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// TODO: Put this as a listener and not in here!
|
||||
if (Econ.isEnabled(myFaction))
|
||||
// Args
|
||||
Faction faction = myFaction;
|
||||
|
||||
Faction newFaction = FactionColls.get().get(faction).getNone();
|
||||
|
||||
// Apply
|
||||
BoardColl boardColl = BoardColls.get().get(faction);
|
||||
Set<PS> chunks = boardColl.getChunks(faction);
|
||||
int countTotal = chunks.size();
|
||||
int countSuccess = 0;
|
||||
int countFail = 0;
|
||||
for (PS chunk : chunks)
|
||||
{
|
||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount());
|
||||
|
||||
if (UConf.get(myFaction).bankEnabled && UConf.get(myFaction).bankFactionPaysLandCosts)
|
||||
FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction);
|
||||
event.run();
|
||||
if (event.isCancelled())
|
||||
{
|
||||
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim all faction land")) return;
|
||||
countFail++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! Econ.modifyMoney(fme, refund, "unclaim all faction land")) return;
|
||||
countSuccess++;
|
||||
boardColl.setFactionAt(chunk, newFaction);
|
||||
}
|
||||
}
|
||||
|
||||
// Event
|
||||
FactionsEventLandUnclaimAll event = new FactionsEventLandUnclaimAll(sender, myFaction);
|
||||
event.run();
|
||||
// TODO: this event cannot be cancelled yet.
|
||||
|
||||
// Apply
|
||||
BoardColls.get().removeAll(myFaction);
|
||||
|
||||
// Inform
|
||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||
myFaction.msg("%s<i> unclaimed <h>5 <i> of your <h>200 <i>faction land. You now have <h>23 <i>land left.", fme.describeTo(myFaction, true), countSuccess, countTotal, countFail);
|
||||
|
||||
// Log
|
||||
if (MConf.get().logLandUnclaims)
|
||||
{
|
||||
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
|
||||
|
Reference in New Issue
Block a user