Add config to limit bonus claim blocks (on purchase) (#786)
This commit is contained in:
parent
cd70154f7a
commit
093cbb0e93
|
|
@ -1476,6 +1476,7 @@ public abstract class DataStore
|
||||||
this.addDefault(defaults, Messages.BlockPurchaseCost, "Each claim block costs {0}. Your balance is {1}.", "0: cost of one block; 1: player's account balance");
|
this.addDefault(defaults, Messages.BlockPurchaseCost, "Each claim block costs {0}. Your balance is {1}.", "0: cost of one block; 1: player's account balance");
|
||||||
this.addDefault(defaults, Messages.ClaimBlockLimit, "You've reached your claim block limit. You can't purchase more.", null);
|
this.addDefault(defaults, Messages.ClaimBlockLimit, "You've reached your claim block limit. You can't purchase more.", null);
|
||||||
this.addDefault(defaults, Messages.InsufficientFunds, "You don't have enough money. You need {0}, but you only have {1}.", "0: total cost; 1: player's account balance");
|
this.addDefault(defaults, Messages.InsufficientFunds, "You don't have enough money. You need {0}, but you only have {1}.", "0: total cost; 1: player's account balance");
|
||||||
|
this.addDefault(defaults, Messages.MaxBonusReached, "Can't purchase {0} more claim blocks. The server has a limit of {1} bonus claim blocks.", "0: block count; 1: bonus claims limit");
|
||||||
this.addDefault(defaults, Messages.PurchaseConfirmation, "Withdrew {0} from your account. You now have {1} available claim blocks.", "0: total cost; 1: remaining blocks");
|
this.addDefault(defaults, Messages.PurchaseConfirmation, "Withdrew {0} from your account. You now have {1} available claim blocks.", "0: total cost; 1: remaining blocks");
|
||||||
this.addDefault(defaults, Messages.OnlyPurchaseBlocks, "Claim blocks may only be purchased, not sold.", null);
|
this.addDefault(defaults, Messages.OnlyPurchaseBlocks, "Claim blocks may only be purchased, not sold.", null);
|
||||||
this.addDefault(defaults, Messages.BlockSaleValue, "Each claim block is worth {0}. You have {1} available for sale.", "0: block value; 1: available blocks");
|
this.addDefault(defaults, Messages.BlockSaleValue, "Each claim block is worth {0}. You have {1} available for sale.", "0: block value; 1: available blocks");
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
public boolean config_lockDeathDropsInPvpWorlds; //whether players' dropped on death items are protected in pvp worlds
|
public boolean config_lockDeathDropsInPvpWorlds; //whether players' dropped on death items are protected in pvp worlds
|
||||||
public boolean config_lockDeathDropsInNonPvpWorlds; //whether players' dropped on death items are protected in non-pvp worlds
|
public boolean config_lockDeathDropsInNonPvpWorlds; //whether players' dropped on death items are protected in non-pvp worlds
|
||||||
|
|
||||||
|
public int config_economy_claimBlocksMaxBonus; //max "bonus" blocks a player can buy. set to zero for no limit.
|
||||||
public double config_economy_claimBlocksPurchaseCost; //cost to purchase a claim block. set to zero to disable purchase.
|
public double config_economy_claimBlocksPurchaseCost; //cost to purchase a claim block. set to zero to disable purchase.
|
||||||
public double config_economy_claimBlocksSellValue; //return on a sold claim block. set to zero to disable sale.
|
public double config_economy_claimBlocksSellValue; //return on a sold claim block. set to zero to disable sale.
|
||||||
|
|
||||||
|
|
@ -611,7 +612,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
this.config_pvp_combatTimeoutSeconds = config.getInt("GriefPrevention.PvP.CombatTimeoutSeconds", 15);
|
this.config_pvp_combatTimeoutSeconds = config.getInt("GriefPrevention.PvP.CombatTimeoutSeconds", 15);
|
||||||
this.config_pvp_allowCombatItemDrop = config.getBoolean("GriefPrevention.PvP.AllowCombatItemDrop", false);
|
this.config_pvp_allowCombatItemDrop = config.getBoolean("GriefPrevention.PvP.AllowCombatItemDrop", false);
|
||||||
String bannedPvPCommandsList = config.getString("GriefPrevention.PvP.BlockedSlashCommands", "/home;/vanish;/spawn;/tpa");
|
String bannedPvPCommandsList = config.getString("GriefPrevention.PvP.BlockedSlashCommands", "/home;/vanish;/spawn;/tpa");
|
||||||
|
|
||||||
|
this.config_economy_claimBlocksMaxBonus = config.getInt("GriefPrevention.Economy.ClaimBlocksMaxBonus", 0);
|
||||||
this.config_economy_claimBlocksPurchaseCost = config.getDouble("GriefPrevention.Economy.ClaimBlocksPurchaseCost", 0);
|
this.config_economy_claimBlocksPurchaseCost = config.getDouble("GriefPrevention.Economy.ClaimBlocksPurchaseCost", 0);
|
||||||
this.config_economy_claimBlocksSellValue = config.getDouble("GriefPrevention.Economy.ClaimBlocksSellValue", 0);
|
this.config_economy_claimBlocksSellValue = config.getDouble("GriefPrevention.Economy.ClaimBlocksSellValue", 0);
|
||||||
|
|
||||||
|
|
@ -877,7 +879,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.PvPWorlds", this.config_pvp_allowFireNearPlayers);
|
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.PvPWorlds", this.config_pvp_allowFireNearPlayers);
|
||||||
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.NonPvPWorlds", this.config_pvp_allowFireNearPlayers_NonPvp);
|
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.NonPvPWorlds", this.config_pvp_allowFireNearPlayers_NonPvp);
|
||||||
outConfig.set("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", this.config_pvp_protectPets);
|
outConfig.set("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", this.config_pvp_protectPets);
|
||||||
|
|
||||||
|
outConfig.set("GriefPrevention.Economy.ClaimBlocksMaxBonus", this.config_economy_claimBlocksMaxBonus);
|
||||||
outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost);
|
outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost);
|
||||||
outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue);
|
outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue);
|
||||||
|
|
||||||
|
|
@ -1847,6 +1850,16 @@ public class GriefPrevention extends JavaPlugin
|
||||||
//otherwise carry out transaction
|
//otherwise carry out transaction
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int newBonusClaimBlocks = playerData.getBonusClaimBlocks() + blockCount;
|
||||||
|
|
||||||
|
//if the player is going to reach max bonus limit, send error message
|
||||||
|
int bonusBlocksLimit = GriefPrevention.instance.config_economy_claimBlocksMaxBonus;
|
||||||
|
if (bonusBlocksLimit != 0 && newBonusClaimBlocks > bonusBlocksLimit)
|
||||||
|
{
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Err, Messages.MaxBonusReached, String.valueOf(blockCount), String.valueOf(bonusBlocksLimit));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//withdraw cost
|
//withdraw cost
|
||||||
economy.withdrawPlayer(player.getName(), totalCost);
|
economy.withdrawPlayer(player.getName(), totalCost);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ public enum Messages
|
||||||
BlockPurchaseCost,
|
BlockPurchaseCost,
|
||||||
ClaimBlockLimit,
|
ClaimBlockLimit,
|
||||||
InsufficientFunds,
|
InsufficientFunds,
|
||||||
|
MaxBonusReached,
|
||||||
PurchaseConfirmation,
|
PurchaseConfirmation,
|
||||||
OnlyPurchaseBlocks,
|
OnlyPurchaseBlocks,
|
||||||
BlockSaleValue,
|
BlockSaleValue,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user