Some of the bugs are fixed.

This commit is contained in:
Olof Larsson
2011-10-12 18:48:47 +02:00
parent 2566edfd8c
commit f25daa228a
25 changed files with 132 additions and 105 deletions

View File

@ -48,7 +48,7 @@ public class CmdBalance extends FCommand
return;
}
msg("<a>%s balance: %s", faction.getTag(fme), Econ.moneyString(faction.getAccount().balance()));
msg("<a>%s<i> balance: <h>%s", faction.getTag(fme), Econ.moneyString(faction.getAccount().balance()));
}
}

View File

@ -32,7 +32,7 @@ public class CmdBoom extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostNoBoom)) return;
if ( ! payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return;
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled()));

View File

@ -55,10 +55,7 @@ public class CmdCreate extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostCreate))
{
return;
}
if ( ! payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
Faction faction = Factions.i.create();
faction.setTag(tag);

View File

@ -30,10 +30,7 @@ public class CmdDescription extends FCommand
public void perform()
{
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostDesc))
{
return;
}
if ( ! payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description")) return;
myFaction.setDescription(TextUtil.implode(args, " "));

View File

@ -120,10 +120,7 @@ public class CmdHome extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostHome))
{
return;
}
if ( ! payForCommand(Conf.econCostHome, "to change faction home", "for changing faction home")) return;
me.teleport(myFaction.getHome());
}

View File

@ -38,10 +38,7 @@ public class CmdInvite extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostInvite))
{
return;
}
if ( ! payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return;
myFaction.invite(you);

View File

@ -61,10 +61,7 @@ public class CmdJoin extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostJoin))
{
return;
}
if ( ! payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return;
fme.msg("<i>You successfully joined %s", faction.getTag(fme));
faction.msg("<i>%s joined your faction.", fme.getNameAndRelevant(faction));

View File

@ -65,10 +65,7 @@ public class CmdKick extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostKick))
{
return;
}
if ( ! payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) return;
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.getNameAndRelevant(yourFaction), you.getNameAndRelevant(yourFaction));
you.msg("%s<i> kicked you from %s<i>! :O", fme.getNameAndRelevant(you), yourFaction.getTag(you));

View File

@ -35,7 +35,7 @@ public class CmdList extends FCommand
public void perform()
{
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostList)) return;
if ( ! payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return;
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
factionList.remove(Factions.i.getNone());

View File

@ -35,7 +35,7 @@ public class CmdMap extends FCommand
// Turn on
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostMap)) return;
if ( ! payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return;
fme.setMapAutoUpdating(true);
msg("<i>Map auto update <green>ENABLED.");
@ -53,7 +53,7 @@ public class CmdMap extends FCommand
else
{
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostMap)) return;
if ( ! payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return;
showMap();
}

View File

@ -28,7 +28,7 @@ public class CmdOpen extends FCommand
public void perform()
{
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostOpen)) return;
if ( ! payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return;
myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen()));

View File

@ -102,7 +102,7 @@ public class CmdOwner extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostOwner)) return;
if ( ! payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) return;
myFaction.setPlayerAsOwner(playerName, flocation);
fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName);

View File

@ -34,7 +34,7 @@ public class CmdPower extends FCommand
if (target != me && ! Permission.POWER_ANY.has(sender, true)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostPower)) return;
if ( ! payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) return;
msg("%s<a> - Power / Maxpower: <i>%d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded());
}

View File

@ -62,7 +62,7 @@ public class CmdSethome extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostSethome)) return;
if ( ! payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) return;
faction.setHome(me.getLocation());

View File

@ -41,7 +41,7 @@ public class CmdShow extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostShow)) return;
if ( ! payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return;
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);

View File

@ -49,7 +49,7 @@ public class CmdTag extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostTag)) return;
if ( ! payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) return;
String oldtag = myFaction.getTag();
myFaction.setTag(tag);

View File

@ -36,7 +36,7 @@ public class CmdTitle extends FCommand
if ( ! canIAdministerYou(fme, you)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostTitle)) return;
if ( ! payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) return;
you.setTitle(title);

View File

@ -86,10 +86,21 @@ public class CmdUnclaim extends FCommand
return;
}
String moneyBack = "<i>";
if (Econ.enabled())
//String moneyBack = "<i>";
if (Econ.shouldBeUsed())
{
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
if(Conf.bankFactionPaysLandCosts)
{
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) return;
}
else
{
if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return;
}
/*
// a real refund
if (refund > 0.0)
{
@ -133,10 +144,11 @@ public class CmdUnclaim extends FCommand
{
moneyBack = "";
}
*/
}
Board.removeAt(flocation);
myFaction.msg("%s<i> unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> unclaimed some land.", fme.getNameAndRelevant(myFaction));
}
}

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
public class CmdUnclaimall extends FCommand
@ -28,8 +27,18 @@ public class CmdUnclaimall extends FCommand
@Override
public void perform()
{
String moneyBack = "<i>";
if (Econ.shouldBeUsed())
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
if(Conf.bankFactionPaysLandCosts)
{
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
}
else
{
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
}
//String moneyBack = "<i>";
/*if (Econ.shouldBeUsed())
{
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
// a real refund
@ -76,10 +85,10 @@ public class CmdUnclaimall extends FCommand
{
moneyBack = "";
}
}
}*/
Board.unclaimAll(myFaction.getId());
myFaction.msg("%s<i> unclaimed ALL of your faction's land."+moneyBack, fme.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.getNameAndRelevant(myFaction));
}
}

View File

@ -273,22 +273,17 @@ public abstract class FCommand extends MCommand<P>
}
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost)
public boolean payForCommand(double cost, String toDoThis, String forDoingThis)
{
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing())
{
return true;
}
String desc = this.getHelpShort().toLowerCase();
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
if(Conf.bankFactionPaysLandCosts && fme.hasFaction())
{
if ( ! Econ.modifyMoney(myFaction, -cost, "to "+desc, "for "+desc)) return false;
if ( ! Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis)) return false;
}
else
{
if ( ! Econ.modifyMoney(fme, -cost, "to "+desc, "for "+desc)) return false;
if ( ! Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis)) return false;
}
return true;
/*

View File

@ -46,7 +46,7 @@ public abstract class FRelationCommand extends FCommand
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(targetRelation.getRelationCost())) return;
if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return;
myFaction.setRelationWish(them, targetRelation);
Relation currentRelation = myFaction.getRelationTo(them, true);