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.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.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.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.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.AlreadyUnderSiegeArea, "That area is already under siege. Join the party!", null);
this.addDefault(defaults, Messages.NoSiegeAdminClaim, "Siege is disabled in this area.", 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 no parameter, just tell player cost per block and balance
if(args.length != 1) 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; return false;
} }
@ -1720,7 +1720,7 @@ public class GriefPrevention extends JavaPlugin
} }
//if the player can't afford his purchase, send error message //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; double totalCost = blockCount * GriefPrevention.instance.config_economy_claimBlocksPurchaseCost;
if(totalCost > balance) if(totalCost > balance)
{ {
@ -1731,7 +1731,7 @@ public class GriefPrevention extends JavaPlugin
else else
{ {
//withdraw cost //withdraw cost
economy.withdrawPlayer(player, totalCost); economy.withdrawPlayer(player.getName(), totalCost);
//add blocks //add blocks
playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() + blockCount); playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() + blockCount);
@ -1806,7 +1806,7 @@ public class GriefPrevention extends JavaPlugin
{ {
//compute value and deposit it //compute value and deposit it
double totalValue = blockCount * GriefPrevention.instance.config_economy_claimBlocksSellValue; double totalValue = blockCount * GriefPrevention.instance.config_economy_claimBlocksSellValue;
economy.depositPlayer(player, totalValue); economy.depositPlayer(player.getName(), totalValue);
//subtract blocks //subtract blocks
playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() - blockCount); playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() - blockCount);
@ -2399,6 +2399,13 @@ public class GriefPrevention extends JavaPlugin
return false; 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 //victim must not have the permission which makes him immune to siege
if(defender.hasPermission("griefprevention.siegeimmune")) if(defender.hasPermission("griefprevention.siegeimmune"))
{ {

View File

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