Merge pull request #52 from bigpresh/no_siege_yourself

No siege yourself
This commit is contained in:
Ryan Hamshire 2016-08-08 15:42:38 -07:00 committed by GitHub
commit dad90a795f
3 changed files with 13 additions and 4 deletions

View File

@ -1436,6 +1436,7 @@ public abstract class DataStore
this.addDefault(defaults, Messages.AlreadyUnderSiegePlayer, "{0} is already under siege. Join the party!", "0: defending player");
this.addDefault(defaults, Messages.NotSiegableThere, "{0} isn't protected there.", "0: defending player");
this.addDefault(defaults, Messages.SiegeTooFarAway, "You're too far away to siege.", null);
this.addDefault(defaults, Messages.NoSiegeYourself, "You cannot siege yourself, don't be silly", null);
this.addDefault(defaults, Messages.NoSiegeDefenseless, "That player is defenseless. Go pick on somebody else.", null);
this.addDefault(defaults, Messages.AlreadyUnderSiegeArea, "That area is already under siege. Join the party!", null);
this.addDefault(defaults, Messages.NoSiegeAdminClaim, "Siege is disabled in this area.", null);

View File

@ -1695,7 +1695,7 @@ public class GriefPrevention extends JavaPlugin
//if no parameter, just tell player cost per block and balance
if(args.length != 1)
{
GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockPurchaseCost, String.valueOf(GriefPrevention.instance.config_economy_claimBlocksPurchaseCost), String.valueOf(GriefPrevention.economy.getBalance(player)));
GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockPurchaseCost, String.valueOf(GriefPrevention.instance.config_economy_claimBlocksPurchaseCost), String.valueOf(GriefPrevention.economy.getBalance(player.getName())));
return false;
}
@ -1720,7 +1720,7 @@ public class GriefPrevention extends JavaPlugin
}
//if the player can't afford his purchase, send error message
double balance = economy.getBalance(player);
double balance = economy.getBalance(player.getName());
double totalCost = blockCount * GriefPrevention.instance.config_economy_claimBlocksPurchaseCost;
if(totalCost > balance)
{
@ -1731,7 +1731,7 @@ public class GriefPrevention extends JavaPlugin
else
{
//withdraw cost
economy.withdrawPlayer(player, totalCost);
economy.withdrawPlayer(player.getName(), totalCost);
//add blocks
playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() + blockCount);
@ -1806,7 +1806,7 @@ public class GriefPrevention extends JavaPlugin
{
//compute value and deposit it
double totalValue = blockCount * GriefPrevention.instance.config_economy_claimBlocksSellValue;
economy.depositPlayer(player, totalValue);
economy.depositPlayer(player.getName(), totalValue);
//subtract blocks
playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() - blockCount);
@ -2398,6 +2398,13 @@ public class GriefPrevention extends JavaPlugin
{
return false;
}
// First off, you cannot siege yourself, that's just
// silly:
if (attacker.getName().equals( defender.getName() )) {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoSiegeYourself);
return true;
}
//victim must not have the permission which makes him immune to siege
if(defender.hasPermission("griefprevention.siegeimmune"))

View File

@ -66,6 +66,7 @@ public enum Messages
AlreadySieging,
NotSiegableThere,
SiegeTooFarAway,
NoSiegeYourself,
NoSiegeDefenseless,
AlreadyUnderSiegePlayer,
AlreadyUnderSiegeArea,