Some tweaking of the faction bank code...
The new help page with bank related commands will now only be shown if banks are enabled and the Economy is enabled and hooked in. Shortened a couple of command descriptions to fit on one line. Made Deposit, Pay, and Withdraw commands additionally log to the server console/log. When bank is given to person disbanding a faction, it now lets them know and logs it to the server log. Added commands to commandDisable list in plugin.yml, along with "permanent" command which I'd missed adding before Added new permission node factions.viewAnyFactionBalance (granted by default if using superperms), which is required to view the bank balance of other factions For reference, about the faction bank addition as a whole... New conf.json settings: "bankEnabled": true, - enable faction banks "bankMembersCanWithdraw": false, - have to be at least moderator to withdraw or pay money to another faction, unless this is set to true "bankFactionPaysCosts": true, - if true, payments for faction command costs are charged to faction bank "bankFactionPaysLandCosts": true, - if true, payments for land claims are charged to faction bank New commands: /f balance *<faction tag> - Shows the bank balance of a specified faction (if permission checks out), or the player's faction if none is specified /f deposit <amount> - Deposit money into your faction's bank /f pay <faction tag> <amount> - Pay money from your faction bank to another faction (requires moderator or admin status) /f withdraw <amount> - Withdraw money from your faction's bank (requires moderator or admin status, unless "bankMembersCanWithdraw" is set to true) New permission node: factions.viewAnyFactionBalance - Allows the player to view the faction bank balance of all factions (default)
This commit is contained in:
parent
4cab42ec6e
commit
feac58c6d6
@ -22,12 +22,6 @@ public class Conf {
|
||||
public static ChatColor colorCommand = ChatColor.AQUA;
|
||||
public static ChatColor colorParameter = ChatColor.DARK_AQUA;
|
||||
|
||||
//Money
|
||||
public static boolean bankEnabled = true;
|
||||
public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
||||
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
|
||||
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
||||
|
||||
// Power
|
||||
public static double powerPlayerMax = 10.0;
|
||||
public static double powerPlayerMin = -10.0;
|
||||
@ -225,6 +219,12 @@ public class Conf {
|
||||
public static double econCostNeutral = 0.0;
|
||||
public static double econCostNoBoom = 0.0;
|
||||
|
||||
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
|
||||
public static boolean bankEnabled = true;
|
||||
public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
||||
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
|
||||
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
||||
|
||||
public static Set<String> worldsNoClaiming = new HashSet<String>();
|
||||
public static Set<String> worldsNoPowerLoss = new HashSet<String>();
|
||||
public static Set<String> worldsIgnorePvP = new HashSet<String>();
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.massivecraft.factions.listeners.FactionsServerListener;
|
||||
import com.massivecraft.factions.commands.FCommandHelp;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.nijikokun.register.payment.Methods;
|
||||
@ -55,6 +56,7 @@ public class Econ {
|
||||
else {
|
||||
Factions.log("Un-hooked from Register.");
|
||||
}
|
||||
FCommandHelp.updateHelp();
|
||||
}
|
||||
|
||||
public static void iConomySet(boolean enable) {
|
||||
@ -65,6 +67,7 @@ public class Econ {
|
||||
else {
|
||||
Factions.log("Un-hooked from iConomy.");
|
||||
}
|
||||
FCommandHelp.updateHelp();
|
||||
}
|
||||
|
||||
public static void essentialsEcoSet(boolean enable) {
|
||||
@ -75,6 +78,7 @@ public class Econ {
|
||||
else {
|
||||
Factions.log("Un-hooked from EssentialsEco.");
|
||||
}
|
||||
FCommandHelp.updateHelp();
|
||||
}
|
||||
|
||||
public static boolean registerHooked() {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.massivecraft.factions.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
|
||||
|
||||
public class FCommandBalance extends FBaseCommand {
|
||||
|
||||
@ -12,9 +12,9 @@ public class FCommandBalance extends FBaseCommand {
|
||||
aliases.add("balance");
|
||||
aliases.add("money");
|
||||
|
||||
optionalParameters.add("faction name");
|
||||
optionalParameters.add("faction tag");
|
||||
|
||||
helpDescription = "Shows a faction's current balance";
|
||||
helpDescription = "Show faction's current balance";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,11 +30,20 @@ public class FCommandBalance extends FBaseCommand {
|
||||
Faction faction;
|
||||
|
||||
if (parameters.size() > 0) {
|
||||
if (!Factions.hasPermViewAnyFactionBalance(sender)) {
|
||||
sendMessage("You do not have sufficient permissions to view the bank balance of other factions.");
|
||||
return;
|
||||
}
|
||||
faction = findFaction(parameters.get(0), true);
|
||||
} else {
|
||||
faction = me.getFaction();
|
||||
}
|
||||
|
||||
if(faction == null) {
|
||||
sendMessage("Faction "+parameters.get(0)+" could not be found.");
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessage(Conf.colorChrome+faction.getTag()+" balance: "+ Econ.moneyString(faction.getMoney()));
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,10 @@ package com.massivecraft.factions.commands;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
|
||||
|
||||
public class FCommandDeposit extends FBaseCommand {
|
||||
|
||||
@ -36,9 +38,9 @@ public class FCommandDeposit extends FBaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
String amountString = Econ.moneyString(amount);
|
||||
|
||||
if( amount > 0.0 ) {
|
||||
String amountString = Econ.moneyString(amount);
|
||||
|
||||
if( !Econ.deductMoney(me.getName(), amount ) ) {
|
||||
sendMessage("You cannot afford to deposit that much.");
|
||||
}
|
||||
@ -47,6 +49,7 @@ public class FCommandDeposit extends FBaseCommand {
|
||||
faction.addMoney(amount);
|
||||
sendMessage("You have deposited "+amountString+" into "+faction.getTag()+"'s bank.");
|
||||
sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney()));
|
||||
Factions.log(player.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank.");
|
||||
|
||||
for (FPlayer fplayer : FPlayer.getAllOnline()) {
|
||||
if (fplayer.getFaction() == faction) {
|
||||
|
@ -70,7 +70,13 @@ public class FCommandDisband extends FBaseCommand {
|
||||
}
|
||||
|
||||
if (Conf.bankEnabled) {
|
||||
Econ.addMoney(me.getName(), me.getFaction().getMoney() ); //Give all the faction's money to the disbander
|
||||
double amount = faction.getMoney();
|
||||
Econ.addMoney(me.getName(), amount ); //Give all the faction's money to the disbander
|
||||
if (amount > 0.0) {
|
||||
String amountString = Econ.moneyString(amount);
|
||||
sendMessage("You have been given the disbanded faction's bank, totaling "+amountString+".");
|
||||
Factions.log(player.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
|
||||
}
|
||||
}
|
||||
|
||||
Faction.delete( faction.getId() );
|
||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.util.TextUtil;
|
||||
|
||||
|
||||
@ -48,9 +49,9 @@ public class FCommandHelp extends FBaseCommand {
|
||||
// Build the help pages
|
||||
//----------------------------------------------//
|
||||
|
||||
public static final ArrayList<ArrayList<String>> helpPages;
|
||||
public static ArrayList<ArrayList<String>> helpPages;
|
||||
|
||||
static {
|
||||
public static void updateHelp() {
|
||||
helpPages = new ArrayList<ArrayList<String>>();
|
||||
ArrayList<String> pageLines;
|
||||
|
||||
@ -78,12 +79,19 @@ public class FCommandHelp extends FBaseCommand {
|
||||
pageLines.add( new FCommandSethome().getUseageTemplate() );
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( new FCommandBalance().getUseageTemplate() );
|
||||
pageLines.add( new FCommandDeposit().getUseageTemplate() );
|
||||
pageLines.add( new FCommandWithdraw().getUseageTemplate() );
|
||||
pageLines.add( new FCommandPay().getUseageTemplate() );
|
||||
helpPages.add(pageLines);
|
||||
if (Econ.enabled() && Conf.bankEnabled) {
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( "" );
|
||||
pageLines.add( "Your faction has a bank which is used to pay for certain" );
|
||||
pageLines.add( "things, so it will need to have money deposited into it." );
|
||||
pageLines.add( "" );
|
||||
pageLines.add( new FCommandBalance().getUseageTemplate() );
|
||||
pageLines.add( new FCommandDeposit().getUseageTemplate() );
|
||||
pageLines.add( new FCommandWithdraw().getUseageTemplate() );
|
||||
pageLines.add( new FCommandPay().getUseageTemplate() );
|
||||
pageLines.add( "" );
|
||||
helpPages.add(pageLines);
|
||||
}
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( new FCommandClaim().getUseageTemplate() );
|
||||
@ -169,6 +177,9 @@ public class FCommandHelp extends FBaseCommand {
|
||||
pageLines.add( new FCommandConfig().getUseageTemplate() );
|
||||
helpPages.add(pageLines);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
updateHelp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,18 @@ package com.massivecraft.factions.commands;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
|
||||
|
||||
public class FCommandPay extends FBaseCommand {
|
||||
|
||||
public FCommandPay() {
|
||||
aliases.add("pay");
|
||||
|
||||
helpDescription = "Pay another faction money from your faction's bank";
|
||||
helpDescription = "Pay another faction from your bank";
|
||||
requiredParameters.add("faction");
|
||||
requiredParameters.add("amount");
|
||||
}
|
||||
@ -46,13 +48,13 @@ public class FCommandPay extends FBaseCommand {
|
||||
}
|
||||
|
||||
if(them == null) {
|
||||
sendMessage(parameters.get(0)+" could not be found.");
|
||||
sendMessage("Faction "+parameters.get(0)+" could not be found.");
|
||||
return;
|
||||
}
|
||||
|
||||
String amountString = Econ.moneyString(amount);
|
||||
|
||||
|
||||
if( amount > 0.0 ) {
|
||||
String amountString = Econ.moneyString(amount);
|
||||
|
||||
if( amount > us.getMoney() ) {
|
||||
amount = us.getMoney();
|
||||
}
|
||||
@ -61,6 +63,7 @@ public class FCommandPay extends FBaseCommand {
|
||||
them.addMoney(amount);
|
||||
sendMessage("You have paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
|
||||
sendMessage(us.getTag()+" now has "+Econ.moneyString(us.getMoney()));
|
||||
Factions.log(player.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
|
||||
|
||||
for (FPlayer fplayer : FPlayer.getAllOnline()) {
|
||||
if (fplayer.getFaction() == us || fplayer.getFaction() == them) {
|
||||
|
@ -2,10 +2,12 @@ package com.massivecraft.factions.commands;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
|
||||
|
||||
public class FCommandWithdraw extends FBaseCommand {
|
||||
|
||||
public FCommandWithdraw() {
|
||||
@ -42,9 +44,9 @@ public class FCommandWithdraw extends FBaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
String amountString = Econ.moneyString(amount);
|
||||
|
||||
if( amount > 0.0 ) {
|
||||
String amountString = Econ.moneyString(amount);
|
||||
|
||||
if( amount > faction.getMoney() ) {
|
||||
amount = faction.getMoney();
|
||||
}
|
||||
@ -53,6 +55,7 @@ public class FCommandWithdraw extends FBaseCommand {
|
||||
Econ.addMoney(me.getName(), amount);
|
||||
sendMessage("You have withdrawn "+amountString+" from "+faction.getTag()+"'s bank.");
|
||||
sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney()));
|
||||
Factions.log(player.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank.");
|
||||
|
||||
for (FPlayer fplayer : FPlayer.getAllOnline()) {
|
||||
if (fplayer.getFaction() == faction) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: Factions
|
||||
version: 1.5.1
|
||||
version: 1.5.1_dev
|
||||
main: com.massivecraft.factions.Factions
|
||||
softdepend:
|
||||
- Permissions
|
||||
@ -27,6 +27,7 @@ permissions:
|
||||
factions.participate: true
|
||||
factions.create: true
|
||||
factions.viewAnyPower: true
|
||||
factions.viewAnyFactionBalance: true
|
||||
factions.peacefulExplosionToggle: true
|
||||
factions.adminBypass: true
|
||||
factions.config: true
|
||||
@ -49,6 +50,9 @@ permissions:
|
||||
factions.viewAnyPower:
|
||||
description: Allows the player to view the power level of anyone else
|
||||
default: true
|
||||
factions.viewAnyFactionBalance:
|
||||
description: Allows the player to view the faction bank balance for any faction
|
||||
default: true
|
||||
factions.peacefulExplosionToggle:
|
||||
description: Allows peaceful faction admins and moderators to disable explosions in their territory
|
||||
default: true
|
||||
@ -100,6 +104,9 @@ permissions:
|
||||
factions.commandDisable.autowar:
|
||||
description: autowar command disabled
|
||||
default: false
|
||||
factions.commandDisable.balance:
|
||||
description: balance/money command disabled
|
||||
default: false
|
||||
factions.commandDisable.bypass:
|
||||
description: bypass command disabled
|
||||
default: false
|
||||
@ -121,6 +128,9 @@ permissions:
|
||||
factions.commandDisable.deinv:
|
||||
description: deinvite command disabled
|
||||
default: false
|
||||
factions.commandDisable.deposit:
|
||||
description: deposit command disabled
|
||||
default: false
|
||||
factions.commandDisable.desc:
|
||||
description: desc command disabled
|
||||
default: false
|
||||
@ -169,6 +179,9 @@ permissions:
|
||||
factions.commandDisable.mod:
|
||||
description: mod command disabled
|
||||
default: false
|
||||
factions.commandDisable.money:
|
||||
description: balance/money command disabled
|
||||
default: false
|
||||
factions.commandDisable.noboom:
|
||||
description: noboom command disabled
|
||||
default: false
|
||||
@ -184,9 +197,15 @@ permissions:
|
||||
factions.commandDisable.ownerlist:
|
||||
description: ownerlist command disabled
|
||||
default: false
|
||||
factions.commandDisable.pay:
|
||||
description: pay command disabled
|
||||
default: false
|
||||
factions.commandDisable.peaceful:
|
||||
description: peaceful command disabled
|
||||
default: false
|
||||
factions.commandDisable.permanent:
|
||||
description: permanent command disabled
|
||||
default: false
|
||||
factions.commandDisable.power:
|
||||
description: power command disabled
|
||||
default: false
|
||||
@ -265,6 +284,9 @@ permissions:
|
||||
factions.commandDisable.wardeclaimall:
|
||||
description: warunclaimall command disabled
|
||||
default: false
|
||||
factions.commandDisable.withdraw:
|
||||
description: withdraw command disabled
|
||||
default: false
|
||||
factions.commandDisable.worldnoclaim:
|
||||
description: worldnoclaim command disabled
|
||||
default: false
|
||||
|
Loading…
Reference in New Issue
Block a user