Prevent Teleport commands during raid

This commit is contained in:
Aubri Seebauer committed 2023-04-03 16:04:51 -04:00
1 parent aca1a685aa
commit 8c413ba158
4 files changed
+104 -1

No files matched your search

@@ -1,6 +1,7 @@
package me.ShermansWorld.AlathraWar;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.exceptions.TownyException;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock;
@@ -183,6 +184,24 @@ public class Raid {
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!");
}
//Prevent players from leaving gather town prematurely
for (String playerName : getActiveRaiders()) {
try {
Player p = Bukkit.getPlayer(playerName);
if(!WorldCoord.parseWorldCoord(p).getTownBlock().getTown().equals(Raid.this.getGatherTown())) {
Raid.this.removeActiveRaider(p.getName());
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!");
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "To rejoin, do /raid join [war] [town]");
}
} catch (NullPointerException e) {
e.printStackTrace();
} catch (NotRegisteredException e) {
e.printStackTrace();
}
}
}
//Raid Travel phase behavior