Skip to content

Commit

Permalink
- Fix nation-alliance invite showing the wrong nation in the
Browse files Browse the repository at this point in the history
confirmation.
  - Fix nation deletion not removing the nation from the towns.
    - Closes #4320.
  - Fix incorrect information being seen on /n ally received output.
    - Closes #4319.
  • Loading branch information
LlmDl committed Sep 16, 2020
1 parent 8222423 commit 20715fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
9 changes: 8 additions & 1 deletion resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4919,4 +4919,11 @@ v0.92.0.11:
- Add Hyperverse to plugin.yml's soft-depend.
- Further improve config comments.
- Add fire and air to the list of blocks Towny will not try an explosion regen task on.
- Improves but doesn't completely solve #4306.
- Improves but doesn't completely solve #4306.
- Optimize `hasNationZone()` method, courtesy of silverwolfg11 with PR #4312.
- Also adds MathUtil.
- Fix nation-alliance invite showing the wrong nation in the confirmation.
- Fix nation deletion not removing the nation from the towns.
- Closes #4320.
- Fix incorrect information being seen on /n ally received output.
- Closes #4319.
6 changes: 3 additions & 3 deletions src/com/palmergames/bukkit/towny/command/NationCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ private void nationAlly(Player player, String[] split) throws TownyException {
}
if (TownySettings.isDisallowOneWayAlliance()) {
String received = Translation.of("nation_received_requests")
.replace("%a", Integer.toString(resident.getTown().getNation().getSentInvites().size())
.replace("%a", Integer.toString(resident.getTown().getNation().getReceivedInvites().size())
)
.replace("%m", Integer.toString(InviteHandler.getReceivedInvitesMaxAmount(resident.getTown().getNation())));
String sent = Translation.of("nation_sent_ally_requests")
Expand Down Expand Up @@ -1801,7 +1801,7 @@ private void nationAlly(Player player, String[] split) throws TownyException {
} catch (NumberFormatException e) {
}
}
InviteCommand.sendInviteList(player, receivedinvites, page, true);
InviteCommand.sendInviteList(player, receivedinvites, page, false);
player.sendMessage(received);
return;

Expand Down Expand Up @@ -1915,7 +1915,7 @@ private void nationRemoveAllyRequest(Object sender,Nation nation, ArrayList<Nati
}

private void nationCreateAllyRequest(CommandSender sender, Nation nation, Nation receiver) throws TownyException {
NationAllyNationInvite invite = new NationAllyNationInvite(sender, nation, receiver);
NationAllyNationInvite invite = new NationAllyNationInvite(sender, receiver, nation);
try {
if (!InviteHandler.inviteIsActive(invite)) {
receiver.newReceivedInvite(invite);
Expand Down
20 changes: 11 additions & 9 deletions src/com/palmergames/bukkit/towny/db/TownyDatabaseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.palmergames.bukkit.towny.event.DeleteNationEvent;
import com.palmergames.bukkit.towny.event.DeletePlayerEvent;
import com.palmergames.bukkit.towny.event.DeleteTownEvent;
import com.palmergames.bukkit.towny.event.NationRemoveTownEvent;
import com.palmergames.bukkit.towny.event.PreDeleteTownEvent;
import com.palmergames.bukkit.towny.event.RenameNationEvent;
import com.palmergames.bukkit.towny.event.RenameResidentEvent;
Expand Down Expand Up @@ -565,20 +566,21 @@ public void removeNation(Nation nation) {

for (Town town : toSave) {

/*
* Remove all resident titles before saving the town itself.
*/
List<Resident> titleRemove = new ArrayList<>(town.getResidents());

for (Resident res : titleRemove) {
for (Resident res : getResidents()) {
if (res.hasTitle() || res.hasSurname()) {
res.setTitle("");
res.setSurname("");
saveResident(res);
}
res.updatePermsForNationRemoval();
TownyUniverse.getInstance().getDataSource().saveResident(res);
}

saveTown(town);
try {
town.setNation(null);
} catch (AlreadyRegisteredException ignored) {
// Cannot reach AlreadyRegisteredException
}
TownyUniverse.getInstance().getDataSource().saveTown(town);
BukkitTools.getPluginManager().callEvent(new NationRemoveTownEvent(town, nation));
}

plugin.resetCache();
Expand Down

0 comments on commit 20715fa

Please sign in to comment.