Siege Fixes
This commit is contained in:
parent
9750e585cb
commit
acca5f3dee
|
@ -69,13 +69,15 @@ public class City {
|
|||
return state.equals(CityState.SIEGE);
|
||||
}
|
||||
|
||||
public void startSiege(Nation nation) {
|
||||
public boolean startSiege(Nation nation) {
|
||||
if(state.equals(CityState.RECOVERY)) return false;
|
||||
state = CityState.SIEGE;
|
||||
Bukkit.broadcast(Component.text(ChatColor.RED + nation.getName() + ChatColor.GOLD + " has begun a siege against the city of " + ChatColor.AQUA + getName()));
|
||||
for(var player : Bukkit.getOnlinePlayers()) {
|
||||
player.playSound(player.getLocation(), Sound.ITEM_TRIDENT_THUNDER, 1F, 1F);
|
||||
}
|
||||
attacker = nation;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void damage() {
|
||||
|
@ -117,6 +119,7 @@ public class City {
|
|||
}
|
||||
OpenNAW.getInstance().getActionLogger().cancelDefenseActions(this);
|
||||
attacker = null;
|
||||
this.state = CityState.RECOVERY; //Start recovery, prohibit sieges until restart.
|
||||
}
|
||||
|
||||
public void capture() {
|
||||
|
|
|
@ -4,5 +4,7 @@ public enum CityState {
|
|||
|
||||
NORMAL,
|
||||
|
||||
SIEGE
|
||||
SIEGE,
|
||||
|
||||
RECOVERY
|
||||
}
|
||||
|
|
|
@ -25,11 +25,20 @@ public class CityAttackAction extends Action{
|
|||
}
|
||||
|
||||
public void initiation() {
|
||||
city.getPoint().getWorld().playSound(city.getPoint(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1, 1);
|
||||
if(!city.underSiege()) {
|
||||
var nation = OpenNAW.getInstance().getNationHandler().getNationByPlayer(player.getUniqueId());
|
||||
//Initiate siege.
|
||||
city.startSiege(nation);
|
||||
if(city.startSiege(nation)) {
|
||||
city.getPoint().getWorld().playSound(city.getPoint(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1, 1);
|
||||
} else {
|
||||
//Cancel action.
|
||||
if(getPlayer().isOnline()) {
|
||||
var player = getPlayer().getPlayer();
|
||||
player.sendMessage(ChatColor.RED + "This city is in recovery! " +
|
||||
"The guards are on heightened alert and it cannot be attacked until it has finished recovering!");
|
||||
}
|
||||
this.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue