Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a fix to prevent outpost exploit. Added a new flag war setting to only conquer outposts. Fixed negative upkeep #110

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/com/palmergames/bukkit/config/ConfigNodes.java
Expand Up @@ -1065,6 +1065,10 @@ public enum ConfigNodes {
"war.enemy.only_attack_borders",
"true",
"# If true, enemy's can only attack the edge plots of a town with war flags."),
WAR_ENEMY_ONLY_ATTACK_OUTPOSTS(
"war.enemy.only_attack_outposts",
"false",
"# If true, enemy's can only attack a town's outposts"),
WAR_ENEMY_MIN_PLAYERS_ONLINE_IN_TOWN(
"war.enemy.min_players_online_in_town",
"2",
Expand Down
2 changes: 1 addition & 1 deletion src/com/palmergames/bukkit/towny/command/TownCommand.java
Expand Up @@ -1970,7 +1970,7 @@ public static boolean isEdgeBlock(TownBlockOwner owner, WorldCoord worldCoord) {
for (int i = 0; i < 4; i++)
try {
TownBlock edgeTownBlock = worldCoord.getTownyWorld().getTownBlock(new Coord(worldCoord.getX() + offset[i][0], worldCoord.getZ() + offset[i][1]));
if (edgeTownBlock.isOwner(owner)) {
if (edgeTownBlock.isOwner(owner) && !edgeTownBlock.isOutpost()) {
if (TownySettings.getDebug())
System.out.println("true");
return true;
Expand Down
Expand Up @@ -47,7 +47,8 @@ private boolean _pay(double amount) throws EconomyException {

if (canPayFromHoldings(amount)) {
if (TownyEconomyHandler.isActive())
return TownyEconomyHandler.subtract(getEconomyName(), amount, getBukkitWorld());
if(amount > 0)return TownyEconomyHandler.subtract(getEconomyName(), amount, getBukkitWorld());
else return TownyEconomyHandler.add(getEconomyName(), -amount, getBukkitWorld());
}
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/com/palmergames/bukkit/towny/war/flagwar/TownyWar.java
Expand Up @@ -210,6 +210,10 @@ public static boolean callAttackCellEvent(Towny plugin, Player player, Block blo
// Check that attack takes place on the edge of a town
if (TownyWarConfig.isAttackingBordersOnly() && !AreaSelectionUtil.isOnEdgeOfOwnership(landOwnerTown, worldCoord))
throw new TownyException(TownySettings.getLangString("msg_err_enemy_war_not_on_edge_of_town"));

// Check that attack takes place on the outpost of a town
if (TownyWarConfig.isAttackingOutpostsOnly() && !townBlock.isOutpost())
throw new TownyException(TownySettings.getLangString("msg_err_enemy_war_not_on_outpost"));

// Check that the user can pay for the warflag + fines from losing/winning.
double costToPlaceWarFlag = TownyWarConfig.getCostToPlaceWarFlag();
Expand Down
Expand Up @@ -180,4 +180,8 @@ public static boolean isAttackingBordersOnly() {

return TownySettings.getBoolean(ConfigNodes.WAR_ENEMY_ONLY_ATTACK_BORDER);
}
public static boolean isAttackingOutpostsOnly() {

return TownySettings.getBoolean(ConfigNodes.WAR_ENEMY_ONLY_ATTACK_OUTPOSTS);
}
}
1 change: 1 addition & 0 deletions src/english.yml
Expand Up @@ -339,6 +339,7 @@ msg_err_enemy_war_not_part_of_nation: '&6[War]&c This area doesn''t belong to a
msg_err_enemy_war_is_neutral: '&6[War]&c %s is neutral.'
msg_err_enemy_war_require_online: '&6[War]&c Require at least %d people online in %s to attack.'
msg_err_enemy_war_not_on_edge_of_town: '&6[War]&c Only allowed to attack the borders of a town.'
msg_err_enemy_war_not_on_outpost: '&6[War]&c Only allowed to attack the outposts of a town.'
msg_err_enemy_war_cell_already_under_attack: '&6[War]&c This area is already under attack by %s.'
msg_err_enemy_war_reached_max_active_flags: '&6[War]&c You can''t attack more than %d areas at once.'

Expand Down
1 change: 1 addition & 0 deletions src/german.yml
Expand Up @@ -337,6 +337,7 @@ msg_err_enemy_war_not_part_of_nation: '&6[Krieg]&c dieser Bereich gehoert zu kei
msg_err_enemy_war_is_neutral: '&6[Krieg]&c %s ist neutral.'
msg_err_enemy_war_require_online: '&6[Krieg]&c Es erfordert mindestens %d aktive Spieler in %s um einen Krieg erklaeren zu koennen.'
msg_err_enemy_war_not_on_edge_of_town: '&6[Krieg]&c Der Krieg wird nicht am Stadtrand gefuehrt.'
msg_err_enemy_war_not_on_outpost: '&6[War]&c Only allowed to attack the outposts of a town.'
msg_err_enemy_war_cell_already_under_attack: '&6[Krieg]&c Dieser Bereich wird bereits von %s attackiert.'
msg_err_enemy_war_reached_max_active_flags: '&6[Krieg]&c Du kannst nicht mehr als %s Bereiche gleichzeitig angreifen.'

Expand Down
1 change: 1 addition & 0 deletions src/spanish.yml
Expand Up @@ -336,6 +336,7 @@ msg_err_enemy_war_not_part_of_nation: '&6[War]&c This area doesn''t belong to a
msg_err_enemy_war_is_neutral: '&6[War]&c %s is neutral.'
msg_err_enemy_war_require_online: '&6[War]&c Require at least %d people online in %s to attack.'
msg_err_enemy_war_not_on_edge_of_town: '&6[War]&c Only allowed to attack the borders of a town.'
msg_err_enemy_war_not_on_outpost: '&6[War]&c Only allowed to attack the outposts of a town.'
msg_err_enemy_war_cell_already_under_attack: '&6[War]&c This area is already under attack by %s.'
msg_err_enemy_war_reached_max_active_flags: '&6[War]&c You can''t attack more than %d areas at once.'

Expand Down