Skip to content

Commit

Permalink
keepinv for siege participants only
Browse files Browse the repository at this point in the history
  • Loading branch information
Gl0W1E committed Jun 25, 2022
1 parent 59d5856 commit 9936218
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package me.darthpeti.townytweaks.Towny.listeners;

import com.gmail.goosius.siegewar.SiegeController;
import com.gmail.goosius.siegewar.objects.Siege;
import com.gmail.goosius.siegewar.utils.SiegeWarAllegianceUtil;
import com.gmail.goosius.siegewar.utils.SiegeWarDistanceUtil;
import me.darthpeti.townytweaks.Main;
import com.palmergames.bukkit.towny.TownyUniverse;
import com.palmergames.bukkit.towny.object.Resident;
import me.darthpeti.townytweaks.Towny.util.ConfigUtil;
import org.bukkit.Location;
import org.bukkit.entity.Player;
Expand All @@ -12,12 +16,16 @@
public class KeepInvSiege implements Listener {
@EventHandler
public void onDeath(PlayerDeathEvent event) {
if(ConfigUtil.keepInventoryInSiege()) {
if (ConfigUtil.keepInventoryInSiege()) {
Location deathloc = event.getPlayer().getLocation();
Player player = event.getPlayer();
if(player.hasPermission("siegewar.nation.siege.battle.points") || player.hasPermission("siegewar.town.siege.battle.points")){
Resident resident = TownyUniverse.getInstance().getResident(player.getName());
if (player.hasPermission("siegewar.nation.siege.battle.points") || player.hasPermission("siegewar.town.siege.battle.points")) {
if (SiegeWarDistanceUtil.isLocationInActiveSiegeZone(deathloc)) {
event.setKeepInventory(true);
Siege siege = SiegeController.getActiveSiegeAtLocation(deathloc);
if (SiegeWarAllegianceUtil.isPlayerOnTownFriendlySide(player, resident, siege) || SiegeWarAllegianceUtil.isPlayerOnTownHostileSide(player, resident, siege)) {
event.setKeepInventory(true);
}
}
}
}
Expand Down

0 comments on commit 9936218

Please sign in to comment.