Minor touches to the Econ integration
This commit is contained in:
parent
1df5638903
commit
2f8f0713e8
@ -121,7 +121,7 @@ public class ConfServer extends SimpleConfig
|
|||||||
// HeroChat: The Faction Channel
|
// HeroChat: The Faction Channel
|
||||||
public static String herochatFactionName = "Faction";
|
public static String herochatFactionName = "Faction";
|
||||||
public static String herochatFactionNick = "F";
|
public static String herochatFactionNick = "F";
|
||||||
public static String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{faction_roleprefix}&r{color}{faction_title_pr}{sender}{color}] &f{msg}";
|
public static String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}";
|
||||||
public static ChatColor herochatFactionColor = ChatColor.GREEN;
|
public static ChatColor herochatFactionColor = ChatColor.GREEN;
|
||||||
public static int herochatFactionDistance = 0;
|
public static int herochatFactionDistance = 0;
|
||||||
public static boolean herochatFactionIsShortcutAllowed = false;
|
public static boolean herochatFactionIsShortcutAllowed = false;
|
||||||
@ -132,7 +132,7 @@ public class ConfServer extends SimpleConfig
|
|||||||
// HeroChat: The Allies Channel
|
// HeroChat: The Allies Channel
|
||||||
public static String herochatAlliesName = "Allies";
|
public static String herochatAlliesName = "Allies";
|
||||||
public static String herochatAlliesNick = "A";
|
public static String herochatAlliesNick = "A";
|
||||||
public static String herochatAlliesFormat = "{color}[&l{nick}&r&f {faction_relcolor}&l{faction_roleprefix}&r{faction_relcolor}{faction_tag_pr}{sender}{color}] &f{msg}";
|
public static String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_tag|rp}{sender}{color}] &f{msg}";
|
||||||
public static ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
|
public static ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
|
||||||
public static int herochatAlliesDistance = 0;
|
public static int herochatAlliesDistance = 0;
|
||||||
public static boolean herochatAlliesIsShortcutAllowed = false;
|
public static boolean herochatAlliesIsShortcutAllowed = false;
|
||||||
@ -230,7 +230,10 @@ public class ConfServer extends SimpleConfig
|
|||||||
|
|
||||||
public static boolean pistonProtectionThroughDenyBuild = true;
|
public static boolean pistonProtectionThroughDenyBuild = true;
|
||||||
|
|
||||||
// Spout features
|
// -------------------------------------------- //
|
||||||
|
// INTEGRATION: SPOUT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
|
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
|
||||||
public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that
|
public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that
|
||||||
public static boolean spoutHealthBarUnderNames = true; // Show healthbar under player names.
|
public static boolean spoutHealthBarUnderNames = true; // Show healthbar under player names.
|
||||||
|
@ -675,7 +675,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
public void leave(boolean makePay)
|
public void leave(boolean makePay)
|
||||||
{
|
{
|
||||||
Faction myFaction = this.getFaction();
|
Faction myFaction = this.getFaction();
|
||||||
makePay = makePay && Econ.shouldBeUsed() && ! this.isUsingAdminMode();
|
makePay = makePay && Econ.isEnabled() && ! this.isUsingAdminMode();
|
||||||
|
|
||||||
if (myFaction == null)
|
if (myFaction == null)
|
||||||
{
|
{
|
||||||
@ -705,13 +705,13 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
if (leaveEvent.isCancelled()) return;
|
if (leaveEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (makePay && ! Econ.modifyMoney(this, -ConfServer.econCostLeave, "to leave your faction.", "for leaving your faction.")) return;
|
if (makePay && ! Econ.modifyMoney(this, -ConfServer.econCostLeave, "leave your faction")) return;
|
||||||
|
|
||||||
// Am I the last one in the faction?
|
// Am I the last one in the faction?
|
||||||
if (myFaction.getFPlayers().size() == 1)
|
if (myFaction.getFPlayers().size() == 1)
|
||||||
{
|
{
|
||||||
// Transfer all money
|
// Transfer all money
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.isEnabled())
|
||||||
Econ.transferMoney(this, myFaction, this, Econ.getBalance(myFaction.getAccountId()));
|
Econ.transferMoney(this, myFaction, this, Econ.getBalance(myFaction.getAccountId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
|
|
||||||
// TODO: Add flag no costs??
|
// TODO: Add flag no costs??
|
||||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
||||||
boolean mustPay = Econ.shouldBeUsed() && ! this.isUsingAdminMode();
|
boolean mustPay = Econ.isEnabled() && ! this.isUsingAdminMode();
|
||||||
double cost = 0.0;
|
double cost = 0.0;
|
||||||
EconomyParticipator payee = null;
|
EconomyParticipator payee = null;
|
||||||
if (mustPay)
|
if (mustPay)
|
||||||
@ -864,7 +864,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
// TODO: The economy integration should cancel the event above!
|
// TODO: The economy integration should cancel the event above!
|
||||||
if (mustPay && ! Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) return false;
|
if (mustPay && ! Econ.modifyMoney(payee, -cost, "claim this land")) return false;
|
||||||
|
|
||||||
// TODO: The LWC integration should listen to Monitor for the claim event.
|
// TODO: The LWC integration should listen to Monitor for the claim event.
|
||||||
if (LWCFeatures.getEnabled() && forFaction.isNormal() && ConfServer.onCaptureResetLwcLocks)
|
if (LWCFeatures.getEnabled() && forFaction.isNormal() && ConfServer.onCaptureResetLwcLocks)
|
||||||
|
@ -76,7 +76,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
|
|
||||||
Faction ret = super.detachId(oid);
|
Faction ret = super.detachId(oid);
|
||||||
|
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.isEnabled())
|
||||||
{
|
{
|
||||||
Econ.setBalance(accountId, 0);
|
Econ.setBalance(accountId, 0);
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
|
|
||||||
public void econLandRewardRoutine()
|
public void econLandRewardRoutine()
|
||||||
{
|
{
|
||||||
if (!Econ.shouldBeUsed()) return;
|
if (!Econ.isEnabled()) return;
|
||||||
if (ConfServer.econLandReward == 0.0) return;
|
if (ConfServer.econLandReward == 0.0) return;
|
||||||
|
|
||||||
Factions.get().log("Running econLandRewardRoutine...");
|
Factions.get().log("Running econLandRewardRoutine...");
|
||||||
@ -203,7 +203,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
double reward = ConfServer.econLandReward * landCount / playerCount;
|
double reward = ConfServer.econLandReward * landCount / playerCount;
|
||||||
for (FPlayer player : players)
|
for (FPlayer player : players)
|
||||||
{
|
{
|
||||||
Econ.modifyMoney(player, reward, "to own faction land", "for faction owning " + landCount + " land divided among " + playerCount + " member(s)");
|
Econ.modifyMoney(player, reward, "own " + landCount + " faction land divided among " + playerCount + " members");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,6 @@ public class CmdFactionsCreate extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
|
||||||
if ( ! canAffordCommand(ConfServer.econCostCreate, "to create a new faction")) return;
|
|
||||||
|
|
||||||
// trigger the faction creation event (cancellable)
|
// trigger the faction creation event (cancellable)
|
||||||
String factionId = FactionColl.get().getIdStrategy().generate(FactionColl.get());
|
String factionId = FactionColl.get().getIdStrategy().generate(FactionColl.get());
|
||||||
|
|
||||||
@ -62,7 +59,7 @@ public class CmdFactionsCreate extends FCommand
|
|||||||
if(createEvent.isCancelled()) return;
|
if(createEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if ( ! payForCommand(ConfServer.econCostCreate, "to create a new faction", "for creating a new faction")) return;
|
if (!payForCommand(ConfServer.econCostCreate)) return;
|
||||||
|
|
||||||
Faction faction = FactionColl.get().create(factionId);
|
Faction faction = FactionColl.get().create(factionId);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class CmdFactionsDescription extends FCommand
|
|||||||
public void perform()
|
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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostDesc, "to change faction description", "for changing faction description")) return;
|
if (!payForCommand(ConfServer.econCostDesc)) return;
|
||||||
|
|
||||||
myFaction.setDescription(this.argConcatFrom(1));
|
myFaction.setDescription(this.argConcatFrom(1));
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class CmdFactionsDisband extends FCommand
|
|||||||
if (ConfServer.logFactionDisband)
|
if (ConfServer.logFactionDisband)
|
||||||
Factions.get().log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
|
Factions.get().log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
|
||||||
|
|
||||||
if (Econ.shouldBeUsed() && ! senderIsConsole)
|
if (Econ.isEnabled() && ! senderIsConsole)
|
||||||
{
|
{
|
||||||
//Give all the faction's money to the disbander
|
//Give all the faction's money to the disbander
|
||||||
double amount = Econ.getBalance(faction.getAccountId());
|
double amount = Econ.getBalance(faction.getAccountId());
|
||||||
|
@ -123,7 +123,7 @@ public class CmdFactionsHome extends FCommand
|
|||||||
Mixin.teleport(me, myFaction.getHome(), "your faction home", sender);
|
Mixin.teleport(me, myFaction.getHome(), "your faction home", sender);
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return;
|
if (!payForCommand(ConfServer.econCostHome)) return;
|
||||||
}
|
}
|
||||||
catch (TeleporterException e)
|
catch (TeleporterException e)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ public class CmdFactionsInvite extends FCommand
|
|||||||
if (fme != null && ! FPerm.INVITE.has(fme, myFaction)) return;
|
if (fme != null && ! FPerm.INVITE.has(fme, myFaction)) return;
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostInvite, "to invite someone", "for inviting someone")) return;
|
if (!payForCommand(ConfServer.econCostInvite)) return;
|
||||||
|
|
||||||
myFaction.invite(you);
|
myFaction.invite(you);
|
||||||
|
|
||||||
|
@ -74,16 +74,13 @@ public class CmdFactionsJoin extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
|
||||||
if (samePlayer && ! canAffordCommand(ConfServer.econCostJoin, "to join a faction")) return;
|
|
||||||
|
|
||||||
// trigger the join event (cancellable)
|
// trigger the join event (cancellable)
|
||||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||||
if (joinEvent.isCancelled()) return;
|
if (joinEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (samePlayer && ! payForCommand(ConfServer.econCostJoin, "to join a faction", "for joining a faction")) return;
|
if (samePlayer && ! payForCommand(ConfServer.econCostJoin)) return;
|
||||||
|
|
||||||
if (!samePlayer)
|
if (!samePlayer)
|
||||||
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||||
|
@ -54,16 +54,13 @@ public class CmdFactionsKick extends FCommand
|
|||||||
|
|
||||||
if (fme != null && ! FPerm.KICK.has(fme, yourFaction)) return;
|
if (fme != null && ! FPerm.KICK.has(fme, yourFaction)) return;
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
|
||||||
if ( ! canAffordCommand(ConfServer.econCostKick, "to kick someone from the faction")) return;
|
|
||||||
|
|
||||||
// trigger the leave event (cancellable) [reason:kicked]
|
// trigger the leave event (cancellable) [reason:kicked]
|
||||||
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if ( ! payForCommand(ConfServer.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) return;
|
if (!payForCommand(ConfServer.econCostKick)) return;
|
||||||
|
|
||||||
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
|
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
|
||||||
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
|
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
|
||||||
|
@ -32,7 +32,7 @@ public class CmdFactionsList extends FCommand
|
|||||||
if (pageHumanBased == null) return;
|
if (pageHumanBased == null) return;
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostList, "to list the factions", "for listing the factions")) return;
|
if (!payForCommand(ConfServer.econCostList)) return;
|
||||||
|
|
||||||
// Create Messages
|
// Create Messages
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
|
@ -27,7 +27,7 @@ public class CmdFactionsMap extends FCommand
|
|||||||
if (!this.argIsSet(0))
|
if (!this.argIsSet(0))
|
||||||
{
|
{
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostMap, "to show the map", "for showing the map")) return;
|
if (!payForCommand(ConfServer.econCostMap)) return;
|
||||||
|
|
||||||
showMap();
|
showMap();
|
||||||
return;
|
return;
|
||||||
@ -38,7 +38,7 @@ public class CmdFactionsMap extends FCommand
|
|||||||
// Turn on
|
// Turn on
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostMap, "to show the map", "for showing the map")) return;
|
if (!payForCommand(ConfServer.econCostMap)) return;
|
||||||
|
|
||||||
fme.setMapAutoUpdating(true);
|
fme.setMapAutoUpdating(true);
|
||||||
msg("<i>Map auto update <green>ENABLED.");
|
msg("<i>Map auto update <green>ENABLED.");
|
||||||
|
@ -28,7 +28,7 @@ public class CmdFactionsOpen extends FCommand
|
|||||||
if (target == null) return;
|
if (target == null) return;
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return;
|
if (!payForCommand(ConfServer.econCostOpen)) return;
|
||||||
|
|
||||||
myFaction.setOpen(target);
|
myFaction.setOpen(target);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class CmdFactionsPower extends FCommand
|
|||||||
if (target != fme && ! Perm.POWER_ANY.has(sender, true)) return;
|
if (target != fme && ! Perm.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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostPower, "to show player power info", "for showing player power info")) return;
|
if (!payForCommand(ConfServer.econCostPower)) return;
|
||||||
|
|
||||||
double powerBoost = target.getPowerBoost();
|
double powerBoost = target.getPowerBoost();
|
||||||
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||||
|
@ -50,7 +50,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// 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(), "to change a relation wish", "for changing a relation wish")) return;
|
if (!payForCommand(targetRelation.getRelationCost())) return;
|
||||||
|
|
||||||
// try to set the new relation
|
// try to set the new relation
|
||||||
Rel oldRelation = myFaction.getRelationTo(them, true);
|
Rel oldRelation = myFaction.getRelationTo(them, true);
|
||||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
|
import com.massivecraft.factions.event.FactionsHomeChangedEvent;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
@ -38,19 +39,24 @@ public class CmdFactionsSethome extends FCommand
|
|||||||
// Has faction permission?
|
// Has faction permission?
|
||||||
if ( ! FPerm.SETHOME.has(sender, faction, true)) return;
|
if ( ! FPerm.SETHOME.has(sender, faction, true)) return;
|
||||||
|
|
||||||
PS ps = PS.valueOf(me.getLocation());
|
PS newHome = PS.valueOf(me.getLocation());
|
||||||
|
|
||||||
// Can the player set the faction home HERE?
|
// Can the player set the faction home HERE?
|
||||||
if (!fme.isUsingAdminMode() && !faction.isValidHome(ps))
|
if (!fme.isUsingAdminMode() && !faction.isValidHome(newHome))
|
||||||
{
|
{
|
||||||
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FactionsHomeChangedEvent event = new FactionsHomeChangedEvent(sender, FactionsHomeChangedEvent.REASON_COMMAND_SETHOME, faction, newHome);
|
||||||
|
event.run();
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
newHome = event.getNewHome();
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostSethome, "to set the faction home", "for setting the faction home")) return;
|
if (!payForCommand(ConfServer.econCostSethome)) return;
|
||||||
|
|
||||||
faction.setHome(ps);
|
faction.setHome(newHome);
|
||||||
|
|
||||||
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
||||||
faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
|
faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
|
||||||
|
@ -35,7 +35,7 @@ public class CmdFactionsShow extends FCommand
|
|||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostShow, "to show faction information", "for showing faction information")) return;
|
if (!payForCommand(ConfServer.econCostShow)) return;
|
||||||
|
|
||||||
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Rel.LEADER);
|
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Rel.LEADER);
|
||||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Rel.OFFICER);
|
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Rel.OFFICER);
|
||||||
@ -64,7 +64,7 @@ public class CmdFactionsShow extends FCommand
|
|||||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
||||||
|
|
||||||
// show the land value
|
// show the land value
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.isEnabled())
|
||||||
{
|
{
|
||||||
double value = Econ.calculateTotalLandValue(faction.getLandCount());
|
double value = Econ.calculateTotalLandValue(faction.getLandCount());
|
||||||
double refund = value * ConfServer.econClaimRefundMultiplier;
|
double refund = value * ConfServer.econClaimRefundMultiplier;
|
||||||
|
@ -48,16 +48,13 @@ public class CmdFactionsTag extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
|
||||||
if ( ! canAffordCommand(ConfServer.econCostTag, "to change the faction tag")) return;
|
|
||||||
|
|
||||||
// trigger the faction rename event (cancellable)
|
// trigger the faction rename event (cancellable)
|
||||||
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||||
if(renameEvent.isCancelled()) return;
|
if(renameEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if ( ! payForCommand(ConfServer.econCostTag, "to change the faction tag", "for changing the faction tag")) return;
|
if (!payForCommand(ConfServer.econCostTag)) return;
|
||||||
|
|
||||||
String oldtag = myFaction.getTag();
|
String oldtag = myFaction.getTag();
|
||||||
myFaction.setTag(tag);
|
myFaction.setTag(tag);
|
||||||
|
@ -35,7 +35,7 @@ public class CmdFactionsTitle extends FCommand
|
|||||||
if ( ! canIAdministerYou(fme, you)) return;
|
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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostTitle, "to change a players title", "for changing a players title")) return;
|
if (!payForCommand(ConfServer.econCostTitle)) return;
|
||||||
|
|
||||||
you.setTitle(title);
|
you.setTitle(title);
|
||||||
|
|
||||||
|
@ -38,17 +38,17 @@ public class CmdFactionsUnclaim extends FCommand
|
|||||||
if(unclaimEvent.isCancelled()) return;
|
if(unclaimEvent.isCancelled()) return;
|
||||||
|
|
||||||
//String moneyBack = "<i>";
|
//String moneyBack = "<i>";
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.isEnabled())
|
||||||
{
|
{
|
||||||
double refund = Econ.calculateClaimRefund(myFaction.getLandCount());
|
double refund = Econ.calculateClaimRefund(myFaction.getLandCount());
|
||||||
|
|
||||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
|
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
|
||||||
{
|
{
|
||||||
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) return;
|
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim this land")) return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return;
|
if ( ! Econ.modifyMoney(fme, refund, "unclaim this land")) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,16 +26,16 @@ public class CmdFactionsUnclaimall extends FCommand
|
|||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.isEnabled())
|
||||||
{
|
{
|
||||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount());
|
double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount());
|
||||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
|
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
|
||||||
{
|
{
|
||||||
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
|
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim all faction land")) return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
|
if ( ! Econ.modifyMoney(fme, refund, "unclaim all faction land")) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayerColl;
|
import com.massivecraft.factions.FPlayerColl;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
@ -62,24 +61,8 @@ public abstract class FCommand extends MCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
// 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, String toDoThis, String forDoingThis)
|
public boolean payForCommand(double cost)
|
||||||
{
|
{
|
||||||
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isUsingAdminMode()) return true;
|
return Econ.payForAction(cost, sender, this.getDesc());
|
||||||
|
|
||||||
if (ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fme.hasFaction())
|
|
||||||
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
|
||||||
else
|
|
||||||
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
|
|
||||||
}
|
|
||||||
|
|
||||||
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
|
||||||
public boolean canAffordCommand(double cost, String toDoThis)
|
|
||||||
{
|
|
||||||
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isUsingAdminMode()) return true;
|
|
||||||
|
|
||||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fme.hasFaction())
|
|
||||||
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
|
||||||
else
|
|
||||||
return Econ.hasAtLeast(fme, cost, toDoThis);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.mcore.event.MCoreCancellableEvent;
|
||||||
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
|
||||||
|
public class FactionsHomeChangedEvent extends MCoreCancellableEvent
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTANTS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public final static String REASON_COMMAND_SETHOME = "FACTIONS_COMMAND_SETHOME";
|
||||||
|
public final static String REASON_VERIFY_FAILED = "FACTIONS_VERIFY_FAILED";
|
||||||
|
public final static String REASON_UNDEFINED = "FACTIONS_UNDEFINED";
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// REQUIRED EVENT CODE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Override public HandlerList getHandlers() { return handlers; }
|
||||||
|
public static HandlerList getHandlerList() { return handlers; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FIELDS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private final CommandSender sender;
|
||||||
|
public CommandSender getSender() { return this.sender; }
|
||||||
|
|
||||||
|
private final String reason;
|
||||||
|
public String getReason() { return this.reason; }
|
||||||
|
|
||||||
|
private final Faction faction;
|
||||||
|
public Faction getFaction() { return this.faction; }
|
||||||
|
|
||||||
|
private PS newHome;
|
||||||
|
public PS getNewHome() { return this.newHome; }
|
||||||
|
public void setNewHome(PS newHome) { this.newHome = newHome; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public FactionsHomeChangedEvent(CommandSender sender, String reason, Faction faction, PS newHome)
|
||||||
|
{
|
||||||
|
this.sender = sender;
|
||||||
|
this.reason = reason;
|
||||||
|
this.faction = faction;
|
||||||
|
this.newHome = newHome;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
@ -21,11 +22,13 @@ import net.milkbowl.vault.economy.EconomyResponse;
|
|||||||
|
|
||||||
public class Econ
|
public class Econ
|
||||||
{
|
{
|
||||||
private static Economy econ = null;
|
// -------------------------------------------- //
|
||||||
|
// DERPY OLDSCHOOL SETUP
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static void setup()
|
public static void setup()
|
||||||
{
|
{
|
||||||
if (isSetup()) return;
|
if (economy != null) return;
|
||||||
|
|
||||||
String integrationFail = "Economy integration is "+(ConfServer.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" ";
|
String integrationFail = "Economy integration is "+(ConfServer.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" ";
|
||||||
|
|
||||||
@ -41,7 +44,7 @@ public class Econ
|
|||||||
Factions.get().log(integrationFail+"is not hooked into an economy plugin.");
|
Factions.get().log(integrationFail+"is not hooked into an economy plugin.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
econ = rsp.getProvider();
|
economy = rsp.getProvider();
|
||||||
|
|
||||||
Factions.get().log("Economy integration through Vault plugin successful.");
|
Factions.get().log("Economy integration through Vault plugin successful.");
|
||||||
|
|
||||||
@ -49,36 +52,67 @@ public class Econ
|
|||||||
Factions.get().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
Factions.get().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldBeUsed()
|
// -------------------------------------------- //
|
||||||
|
// FIELDS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static Economy economy = null;
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// STATE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static boolean isEnabled()
|
||||||
{
|
{
|
||||||
return ConfServer.econEnabled && econ != null && econ.isEnabled();
|
return ConfServer.econEnabled && economy != null && economy.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSetup()
|
// -------------------------------------------- //
|
||||||
|
// UTIL
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static boolean payForAction(double cost, CommandSender sender, String actionDescription)
|
||||||
{
|
{
|
||||||
return econ != null;
|
if (!isEnabled()) return true;
|
||||||
}
|
if (cost == 0D) return true;
|
||||||
|
|
||||||
|
FPlayer fsender = FPlayer.get(sender);
|
||||||
|
if (fsender.isUsingAdminMode()) return true;
|
||||||
|
Faction fsenderFaction = fsender.getFaction();
|
||||||
|
|
||||||
|
if (ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fsenderFaction.isNormal())
|
||||||
|
{
|
||||||
|
return modifyMoney(fsenderFaction, -cost, actionDescription);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return modifyMoney(fsender, -cost, actionDescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// ASSORTED
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static void modifyUniverseMoney(double delta)
|
public static void modifyUniverseMoney(double delta)
|
||||||
{
|
{
|
||||||
if (!shouldBeUsed()) return;
|
if (!isEnabled()) return;
|
||||||
|
|
||||||
if (ConfServer.econUniverseAccount == null) return;
|
if (ConfServer.econUniverseAccount == null) return;
|
||||||
if (ConfServer.econUniverseAccount.length() == 0) return;
|
if (ConfServer.econUniverseAccount.length() == 0) return;
|
||||||
if ( ! econ.hasAccount(ConfServer.econUniverseAccount)) return;
|
if ( ! economy.hasAccount(ConfServer.econUniverseAccount)) return;
|
||||||
|
|
||||||
modifyBalance(ConfServer.econUniverseAccount, delta);
|
modifyBalance(ConfServer.econUniverseAccount, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about)
|
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about)
|
||||||
{
|
{
|
||||||
if (!shouldBeUsed())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
Factions.get().log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
Factions.get().log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Econ.moneyString(econ.getBalance(about.getAccountId())));
|
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Econ.moneyString(economy.getBalance(about.getAccountId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you)
|
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you)
|
||||||
@ -114,7 +148,7 @@ public class Econ
|
|||||||
}
|
}
|
||||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify)
|
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify)
|
||||||
{
|
{
|
||||||
if ( ! shouldBeUsed()) return false;
|
if ( ! isEnabled()) return false;
|
||||||
|
|
||||||
// The amount must be positive.
|
// The amount must be positive.
|
||||||
// If the amount is negative we must flip and multiply amount with -1.
|
// If the amount is negative we must flip and multiply amount with -1.
|
||||||
@ -130,26 +164,34 @@ public class Econ
|
|||||||
if ( ! canIControllYou(invoker, from)) return false;
|
if ( ! canIControllYou(invoker, from)) return false;
|
||||||
|
|
||||||
// Is there enough money for the transaction to happen?
|
// Is there enough money for the transaction to happen?
|
||||||
if ( ! econ.has(from.getAccountId(), amount))
|
if ( ! economy.has(from.getAccountId(), amount))
|
||||||
{
|
{
|
||||||
// There was not enough money to pay
|
// There was not enough money to pay
|
||||||
if (invoker != null && notify)
|
if (invoker != null && notify)
|
||||||
|
{
|
||||||
invoker.msg("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
invoker.msg("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer money
|
// Transfer money
|
||||||
EconomyResponse erw = econ.withdrawPlayer(from.getAccountId(), amount);
|
EconomyResponse erw = economy.withdrawPlayer(from.getAccountId(), amount);
|
||||||
|
|
||||||
if (erw.transactionSuccess()) {
|
if (erw.transactionSuccess())
|
||||||
EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount);
|
{
|
||||||
if (erd.transactionSuccess()) {
|
EconomyResponse erd = economy.depositPlayer(to.getAccountId(), amount);
|
||||||
if (notify) sendTransferInfo(invoker, from, to, amount);
|
if (erd.transactionSuccess())
|
||||||
|
{
|
||||||
|
if (notify)
|
||||||
|
{
|
||||||
|
sendTransferInfo(invoker, from, to, amount);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// transaction failed, refund account
|
// transaction failed, refund account
|
||||||
econ.depositPlayer(from.getAccountId(), amount);
|
economy.depositPlayer(from.getAccountId(), amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,9 +262,9 @@ public class Econ
|
|||||||
|
|
||||||
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis)
|
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis)
|
||||||
{
|
{
|
||||||
if ( ! shouldBeUsed()) return true;
|
if (!isEnabled()) return true;
|
||||||
|
|
||||||
if ( ! econ.has(ep.getAccountId(), delta))
|
if ( ! economy.has(ep.getAccountId(), delta))
|
||||||
{
|
{
|
||||||
if (toDoThis != null && !toDoThis.isEmpty())
|
if (toDoThis != null && !toDoThis.isEmpty())
|
||||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
||||||
@ -231,34 +273,37 @@ public class Econ
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis)
|
public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription)
|
||||||
{
|
{
|
||||||
if ( ! shouldBeUsed()) return false;
|
if (!isEnabled()) return false;
|
||||||
|
if (delta == 0) return true;
|
||||||
String acc = ep.getAccountId();
|
|
||||||
|
String accountId = ep.getAccountId();
|
||||||
String You = ep.describeTo(ep, true);
|
String You = ep.describeTo(ep, true);
|
||||||
|
|
||||||
if (delta == 0)
|
boolean hasActionDesctription = (actionDescription != null && !actionDescription.isEmpty());
|
||||||
{
|
|
||||||
// no money actually transferred?
|
|
||||||
// ep.msg("<h>%s<i> didn't have to pay anything %s.", You, forDoingThis); // might be for gains, might be for losses
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
{
|
{
|
||||||
// The player should gain money
|
// The player should gain money
|
||||||
// The account might not have enough space
|
// The account might not have enough space
|
||||||
EconomyResponse er = econ.depositPlayer(acc, delta);
|
EconomyResponse er = economy.depositPlayer(accountId, delta);
|
||||||
if (er.transactionSuccess()) {
|
if (er.transactionSuccess())
|
||||||
|
{
|
||||||
modifyUniverseMoney(-delta);
|
modifyUniverseMoney(-delta);
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
if (hasActionDesctription)
|
||||||
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
{
|
||||||
|
ep.msg("<h>%s<i> gained <h>%s<i> since did %s.", You, moneyString(delta), actionDescription);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// transfer to account failed
|
// transfer to account failed
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
if (hasActionDesctription)
|
||||||
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
{
|
||||||
|
ep.msg("<h>%s<i> would have gained <h>%s<i> since did %s, but the deposit failed.", You, moneyString(delta), actionDescription);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,20 +312,24 @@ public class Econ
|
|||||||
{
|
{
|
||||||
// The player should loose money
|
// The player should loose money
|
||||||
// The player might not have enough.
|
// The player might not have enough.
|
||||||
|
EconomyResponse er = economy.withdrawPlayer(accountId, -delta);
|
||||||
if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess())
|
if (er.transactionSuccess())
|
||||||
{
|
{
|
||||||
// There is enough money to pay
|
// There is enough money to pay
|
||||||
modifyUniverseMoney(-delta);
|
modifyUniverseMoney(-delta);
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
if (hasActionDesctription)
|
||||||
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
|
{
|
||||||
|
ep.msg("<h>%s<i> lost <h>%s<i> since did %s.", You, moneyString(delta), actionDescription);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// There was not enough money to pay
|
// There was not enough money to pay
|
||||||
if (toDoThis != null && !toDoThis.isEmpty())
|
if (hasActionDesctription)
|
||||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
{
|
||||||
|
ep.msg("<h>%s<i> can't afford <h>%s<i> to %s.", You, moneyString(-delta), actionDescription);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,17 +338,14 @@ public class Econ
|
|||||||
// format money string based on server's set currency type, like "24 gold" or "$24.50"
|
// format money string based on server's set currency type, like "24 gold" or "$24.50"
|
||||||
public static String moneyString(double amount)
|
public static String moneyString(double amount)
|
||||||
{
|
{
|
||||||
return econ.format(amount);
|
return economy.format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate the cost for claiming land
|
// calculate the cost for claiming land
|
||||||
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction)
|
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction)
|
||||||
{
|
{
|
||||||
if ( ! shouldBeUsed())
|
if (!isEnabled()) return 0D;
|
||||||
{
|
|
||||||
return 0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
||||||
return ConfServer.econCostClaimWilderness
|
return ConfServer.econCostClaimWilderness
|
||||||
+ (ConfServer.econCostClaimWilderness * ConfServer.econClaimAdditionalMultiplier * ownedLand)
|
+ (ConfServer.econCostClaimWilderness * ConfServer.econClaimAdditionalMultiplier * ownedLand)
|
||||||
@ -316,7 +362,8 @@ public class Econ
|
|||||||
public static double calculateTotalLandValue(int ownedLand)
|
public static double calculateTotalLandValue(int ownedLand)
|
||||||
{
|
{
|
||||||
double amount = 0;
|
double amount = 0;
|
||||||
for (int x = 0; x < ownedLand; x++) {
|
for (int x = 0; x < ownedLand; x++)
|
||||||
|
{
|
||||||
amount += calculateClaimCost(x, false);
|
amount += calculateClaimCost(x, false);
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
@ -328,45 +375,44 @@ public class Econ
|
|||||||
return calculateTotalLandValue(ownedLand) * ConfServer.econClaimRefundMultiplier;
|
return calculateTotalLandValue(ownedLand) * ConfServer.econClaimRefundMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Standard account management methods
|
// Standard account management methods
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static boolean hasAccount(String name)
|
public static boolean hasAccount(String name)
|
||||||
{
|
{
|
||||||
return econ.hasAccount(name);
|
return economy.hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getBalance(String account)
|
public static double getBalance(String account)
|
||||||
{
|
{
|
||||||
return econ.getBalance(account);
|
return economy.getBalance(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setBalance(String account, double amount)
|
public static boolean setBalance(String account, double amount)
|
||||||
{
|
{
|
||||||
double current = econ.getBalance(account);
|
double current = economy.getBalance(account);
|
||||||
if (current > amount)
|
if (current > amount)
|
||||||
return econ.withdrawPlayer(account, current - amount).transactionSuccess();
|
return economy.withdrawPlayer(account, current - amount).transactionSuccess();
|
||||||
else
|
else
|
||||||
return econ.depositPlayer(account, amount - current).transactionSuccess();
|
return economy.depositPlayer(account, amount - current).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean modifyBalance(String account, double amount)
|
public static boolean modifyBalance(String account, double amount)
|
||||||
{
|
{
|
||||||
if (amount < 0)
|
if (amount < 0)
|
||||||
return econ.withdrawPlayer(account, -amount).transactionSuccess();
|
return economy.withdrawPlayer(account, -amount).transactionSuccess();
|
||||||
else
|
else
|
||||||
return econ.depositPlayer(account, amount).transactionSuccess();
|
return economy.depositPlayer(account, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deposit(String account, double amount)
|
public static boolean deposit(String account, double amount)
|
||||||
{
|
{
|
||||||
return econ.depositPlayer(account, amount).transactionSuccess();
|
return economy.depositPlayer(account, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean withdraw(String account, double amount)
|
public static boolean withdraw(String account, double amount)
|
||||||
{
|
{
|
||||||
return econ.withdrawPlayer(account, amount).transactionSuccess();
|
return economy.withdrawPlayer(account, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,15 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.chat.ChatFormatter;
|
import com.massivecraft.factions.chat.ChatFormatter;
|
||||||
|
|
||||||
|
|
||||||
public class HerochatListener implements Listener
|
public class HerochatEngine implements Listener
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static HerochatListener i = new HerochatListener();
|
private static HerochatEngine i = new HerochatEngine();
|
||||||
public static HerochatListener get() { return i; }
|
public static HerochatEngine get() { return i; }
|
||||||
private HerochatListener() {}
|
private HerochatEngine() {}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// ACTIVATE & DEACTIVATE
|
// ACTIVATE & DEACTIVATE
|
@ -19,13 +19,13 @@ public class HerochatFeatures extends IntegrationFeaturesAbstract
|
|||||||
@Override
|
@Override
|
||||||
public void activate()
|
public void activate()
|
||||||
{
|
{
|
||||||
HerochatListener.get().activate();
|
HerochatEngine.get().activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deactivate()
|
public void deactivate()
|
||||||
{
|
{
|
||||||
HerochatListener.get().deactivate();
|
HerochatEngine.get().deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user