mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-04 06:28:51 +00:00
refactor(War.java): cleanup and add comments
This commit is contained in:
6 files changed
+278
-242
No files matched your search
@@ -242,7 +242,7 @@ public class WarCommands {
|
|||||||
final boolean canKingJoin = (res.hasNation() && res.getNationOrNull().equals(nation) && res.isKing() && nation.isKing(res));
|
final boolean canKingJoin = (res.hasNation() && res.getNationOrNull().equals(nation) && res.isKing() && nation.isKing(res));
|
||||||
final boolean canMayorJoin = (res.hasTown() && res.getTownOrNull().equals(town) && res.isMayor() && town.isMayor(res));
|
final boolean canMayorJoin = (res.hasTown() && res.getTownOrNull().equals(town) && res.isMayor() && town.isMayor(res));
|
||||||
|
|
||||||
if (!war.isEvent()) {
|
if (!war.isEventWar()) {
|
||||||
// Join nation into war
|
// Join nation into war
|
||||||
if (isArgNation && nation != null && !war.isNationInWar(nation) && (asAdmin || canKingJoin)) {
|
if (isArgNation && nation != null && !war.isNationInWar(nation) && (asAdmin || canKingJoin)) {
|
||||||
side.addNation(nation);
|
side.addNation(nation);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import net.kyori.adventure.title.Title;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ public class War extends Conflict {
|
|||||||
private final String name; // Used in commands and such, like "TidalHaven.vs.Meme"
|
private final String name; // Used in commands and such, like "TidalHaven.vs.Meme"
|
||||||
private final String label;
|
private final String label;
|
||||||
private final ConflictType conflictType = ConflictType.WAR;
|
private final ConflictType conflictType = ConflictType.WAR;
|
||||||
private boolean event = false;
|
private boolean event;
|
||||||
|
|
||||||
private @NotNull Side side1;
|
private @NotNull Side side1;
|
||||||
private Side side2;
|
private Side side2;
|
||||||
@@ -54,6 +55,19 @@ public class War extends Conflict {
|
|||||||
private Set<Siege> sieges = new HashSet<>();
|
private Set<Siege> sieges = new HashSet<>();
|
||||||
private Set<Raid> raids = new HashSet<>();
|
private Set<Raid> raids = new HashSet<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a existing War.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
* @param name the name
|
||||||
|
* @param label the label
|
||||||
|
* @param side1 the side 1
|
||||||
|
* @param side2 the side 2
|
||||||
|
* @param sieges the sieges
|
||||||
|
* @param raids the raids
|
||||||
|
* @param event the event
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public War(
|
public War(
|
||||||
UUID uuid,
|
UUID uuid,
|
||||||
String name,
|
String name,
|
||||||
@@ -81,6 +95,18 @@ public class War extends Conflict {
|
|||||||
resume();
|
resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new War.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
* @param label the label
|
||||||
|
* @param aggressor the aggressor
|
||||||
|
* @param victim the victim
|
||||||
|
* @param event the event
|
||||||
|
* @throws SideCreationException the side creation exception
|
||||||
|
* @throws WrapperCommandSyntaxException the wrapper command syntax exception
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public War(
|
public War(
|
||||||
UUID uuid,
|
UUID uuid,
|
||||||
String label,
|
String label,
|
||||||
@@ -95,24 +121,6 @@ public class War extends Conflict {
|
|||||||
if (WarManager.getInstance().getWar(this.name) != null)
|
if (WarManager.getInstance().getWar(this.name) != null)
|
||||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
||||||
|
|
||||||
// final @NotNull UUID side1UUID = UUIDUtil.generateSideUUID(null);
|
|
||||||
// final @NotNull UUID side2UUID = UUIDUtil.generateSideUUID(side1UUID);
|
|
||||||
|
|
||||||
// TODO Side builder that uses aggressorIsNation &
|
|
||||||
// if (!aggressorIsNation && !victimIsNation) {
|
|
||||||
// this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
// this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
// } else if (!aggressorIsNation && victimIsNation) {
|
|
||||||
// this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
// this.side2 = new Side(this.uuid, side2UUID, victim.getNationOrNull(), BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
// } else if (aggressorIsNation && !victimIsNation) {
|
|
||||||
// this.side1 = new Side(this.uuid, side1UUID, aggressor.getNationOrNull(), BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
// this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
// } else if (aggressorIsNation && victimIsNation) {
|
|
||||||
// this.side1 = new Side(this.uuid, side1UUID, aggressor.getNationOrNull(), BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
// this.side2 = new Side(this.uuid, side2UUID, victim.getNationOrNull(), BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.side1 = new SideBuilder()
|
this.side1 = new SideBuilder()
|
||||||
.setWarUUID(this.uuid)
|
.setWarUUID(this.uuid)
|
||||||
.setUuid(UUID.randomUUID())
|
.setUuid(UUID.randomUUID())
|
||||||
@@ -144,187 +152,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new New war.
|
* Gets uuid of the war.
|
||||||
*
|
|
||||||
* @param label the name
|
|
||||||
* @param aggressor the side 1
|
|
||||||
* @param victim the side 2
|
|
||||||
*/
|
|
||||||
/*public War(
|
|
||||||
UUID uuid,
|
|
||||||
String label,
|
|
||||||
Town aggressor,
|
|
||||||
Town victim,
|
|
||||||
boolean aggressorIsNation,
|
|
||||||
boolean victimIsNation,
|
|
||||||
boolean event
|
|
||||||
) throws WrapperCommandSyntaxException {
|
|
||||||
this.uuid = uuid;
|
|
||||||
this.label = label;
|
|
||||||
|
|
||||||
final String aggressorName = aggressorIsNation ? Objects.requireNonNull(aggressor.getNationOrNull()).getName() : aggressor.getName();
|
|
||||||
final String victimName = victimIsNation ? Objects.requireNonNull(victim.getNationOrNull()).getName() : victim.getName();
|
|
||||||
this.name = "%s.vs.%s".formatted(aggressorName, victimName);
|
|
||||||
if (WarManager.getInstance().getWar(this.name) != null)
|
|
||||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
|
||||||
|
|
||||||
final @NotNull UUID side1UUID = UUIDUtil.generateSideUUID(null);
|
|
||||||
final @NotNull UUID side2UUID = UUIDUtil.generateSideUUID(side1UUID);
|
|
||||||
|
|
||||||
// TODO Side builder that uses aggressorIsNation &
|
|
||||||
if (!aggressorIsNation && !victimIsNation) {
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
} else if (!aggressorIsNation && victimIsNation) {
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim.getNationOrNull(), BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
} else if (aggressorIsNation && !victimIsNation) {
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor.getNationOrNull(), BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
} else if (aggressorIsNation && victimIsNation) {
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor.getNationOrNull(), BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim.getNationOrNull(), BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.side1 = new SideBuilder()
|
|
||||||
.setWarUUID(this.uuid)
|
|
||||||
.setUuid(side1UUID)
|
|
||||||
.setLeader(aggressorIsNation ? aggressor.getNationOrNull() : aggressor)
|
|
||||||
.setSide(BattleSide.ATTACKER)
|
|
||||||
.setTeam(BattleTeam.SIDE_1)
|
|
||||||
.buildNew();
|
|
||||||
|
|
||||||
this.attacker = side1.getSide().equals(BattleSide.ATTACKER) ? this.side1 : this.side2;
|
|
||||||
this.defender = side1.getSide().equals(BattleSide.DEFENDER) ? this.side1 : this.side2;
|
|
||||||
this.event = event;
|
|
||||||
|
|
||||||
if (!new PreWarCreateEvent(this).callEvent())
|
|
||||||
return;
|
|
||||||
|
|
||||||
WarManager.getInstance().addWar(this);
|
|
||||||
|
|
||||||
start();
|
|
||||||
|
|
||||||
new WarCreateEvent(this).callEvent();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new New war.
|
|
||||||
*
|
|
||||||
* @param label the name
|
|
||||||
* @param aggressor the side 1
|
|
||||||
* @param victim the side 2
|
|
||||||
*/
|
|
||||||
/*public War(final String label, @NotNull Town aggressor, @NotNull Town victim, boolean event) throws WrapperCommandSyntaxException {
|
|
||||||
this.uuid = UUIDUtil.generateWarUUID();
|
|
||||||
this.name = "%s.vs.%s".formatted(aggressor.getName(), victim.getName());
|
|
||||||
this.label = label;
|
|
||||||
|
|
||||||
if (WarManager.getInstance().getWar(this.name) != null)
|
|
||||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
|
||||||
|
|
||||||
final @NotNull UUID side1UUID = UUIDUtil.generateSideUUID(null);
|
|
||||||
final @NotNull UUID side2UUID = UUIDUtil.generateSideUUID(side1UUID);
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
|
|
||||||
this.attacker = side1.getSide().equals(BattleSide.ATTACKER) ? this.side1 : this.side2;
|
|
||||||
this.defender = side1.getSide().equals(BattleSide.DEFENDER) ? this.side1 : this.side2;
|
|
||||||
this.event = event;
|
|
||||||
|
|
||||||
if (!new PreWarCreateEvent(this).callEvent())
|
|
||||||
return;
|
|
||||||
|
|
||||||
WarManager.getInstance().addWar(this);
|
|
||||||
|
|
||||||
start();
|
|
||||||
|
|
||||||
new WarCreateEvent(this).callEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public War(final String label, @NotNull Nation aggressor, @NotNull Nation victim, boolean event) throws WrapperCommandSyntaxException {
|
|
||||||
this.uuid = UUIDUtil.generateWarUUID();
|
|
||||||
this.name = "%s.vs.%s".formatted(aggressor.getName(), victim.getName());
|
|
||||||
this.label = label;
|
|
||||||
|
|
||||||
if (WarManager.getInstance().getWar(this.name) != null)
|
|
||||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
|
||||||
|
|
||||||
final @NotNull UUID side1UUID = UUIDUtil.generateSideUUID(null);
|
|
||||||
final @NotNull UUID side2UUID = UUIDUtil.generateSideUUID(side1UUID);
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
|
|
||||||
this.attacker = side1.getSide().equals(BattleSide.ATTACKER) ? this.side1 : this.side2;
|
|
||||||
this.defender = side1.getSide().equals(BattleSide.DEFENDER) ? this.side1 : this.side2;
|
|
||||||
this.event = event;
|
|
||||||
|
|
||||||
if (!new PreWarCreateEvent(this).callEvent())
|
|
||||||
return;
|
|
||||||
|
|
||||||
WarManager.getInstance().addWar(this);
|
|
||||||
|
|
||||||
start();
|
|
||||||
|
|
||||||
new WarCreateEvent(this).callEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public War(final String label, @NotNull Town aggressor, @NotNull Nation victim, boolean event) throws WrapperCommandSyntaxException {
|
|
||||||
this.uuid = UUIDUtil.generateWarUUID();
|
|
||||||
this.name = "%s.vs.%s".formatted(aggressor.getName(), victim.getName());
|
|
||||||
this.label = label;
|
|
||||||
|
|
||||||
if (WarManager.getInstance().getWar(this.name) != null)
|
|
||||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
|
||||||
|
|
||||||
final @NotNull UUID side1UUID = UUIDUtil.generateSideUUID(null);
|
|
||||||
final @NotNull UUID side2UUID = UUIDUtil.generateSideUUID(side1UUID);
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
|
|
||||||
this.attacker = side1.getSide().equals(BattleSide.ATTACKER) ? this.side1 : this.side2;
|
|
||||||
this.defender = side1.getSide().equals(BattleSide.DEFENDER) ? this.side1 : this.side2;
|
|
||||||
this.event = event;
|
|
||||||
|
|
||||||
if (!new PreWarCreateEvent(this).callEvent())
|
|
||||||
return;
|
|
||||||
|
|
||||||
WarManager.getInstance().addWar(this);
|
|
||||||
|
|
||||||
start();
|
|
||||||
|
|
||||||
new WarCreateEvent(this).callEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public War(final String label, @NotNull Nation aggressor, @NotNull Town victim, boolean event) throws WrapperCommandSyntaxException {
|
|
||||||
this.uuid = UUIDUtil.generateWarUUID();
|
|
||||||
this.name = "%s.vs.%s".formatted(aggressor.getName(), victim.getName());
|
|
||||||
this.label = label;
|
|
||||||
|
|
||||||
if (WarManager.getInstance().getWar(this.name) != null)
|
|
||||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
|
||||||
|
|
||||||
final @NotNull UUID side1UUID = UUIDUtil.generateSideUUID(null);
|
|
||||||
final @NotNull UUID side2UUID = UUIDUtil.generateSideUUID(side1UUID);
|
|
||||||
this.side1 = new Side(this.uuid, side1UUID, aggressor, BattleSide.ATTACKER, BattleTeam.SIDE_1);
|
|
||||||
this.side2 = new Side(this.uuid, side2UUID, victim, BattleSide.DEFENDER, BattleTeam.SIDE_2);
|
|
||||||
|
|
||||||
this.attacker = side1.getSide().equals(BattleSide.ATTACKER) ? this.side1 : this.side2;
|
|
||||||
this.defender = side1.getSide().equals(BattleSide.DEFENDER) ? this.side1 : this.side2;
|
|
||||||
this.event = event;
|
|
||||||
|
|
||||||
if (!new PreWarCreateEvent(this).callEvent())
|
|
||||||
return;
|
|
||||||
|
|
||||||
WarManager.getInstance().addWar(this);
|
|
||||||
|
|
||||||
start();
|
|
||||||
|
|
||||||
new WarCreateEvent(this).callEvent();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Gets uuid.
|
|
||||||
*
|
*
|
||||||
* @return the uuid
|
* @return the uuid
|
||||||
*/
|
*/
|
||||||
@@ -333,7 +161,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets name.
|
* Gets name of the war.
|
||||||
*
|
*
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
@@ -342,13 +170,18 @@ public class War extends Conflict {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets label of the war.
|
||||||
|
*
|
||||||
|
* @return the label
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equals boolean.
|
* Compare war UUID's.
|
||||||
*
|
*
|
||||||
* @param uuid the uuid
|
* @param uuid the uuid
|
||||||
* @return the boolean
|
* @return the boolean
|
||||||
@@ -358,7 +191,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equals boolean.
|
* Compare war by UUID's.
|
||||||
*
|
*
|
||||||
* @param war the war
|
* @param war the war
|
||||||
* @return the boolean
|
* @return the boolean
|
||||||
@@ -368,7 +201,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equals boolean.
|
* Compare war by names.
|
||||||
*
|
*
|
||||||
* @param warName the war name
|
* @param warName the war name
|
||||||
* @return the boolean
|
* @return the boolean
|
||||||
@@ -397,6 +230,11 @@ public class War extends Conflict {
|
|||||||
return side2;
|
return side2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets sides in a list.
|
||||||
|
*
|
||||||
|
* @return the sides
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Side> getSides() {
|
public Set<Side> getSides() {
|
||||||
return Set.of(
|
return Set.of(
|
||||||
@@ -406,7 +244,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets attacker.
|
* Gets attacker side.
|
||||||
*
|
*
|
||||||
* @return the attacker
|
* @return the attacker
|
||||||
*/
|
*/
|
||||||
@@ -416,7 +254,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets defender.
|
* Gets defender side.
|
||||||
*
|
*
|
||||||
* @return the defender
|
* @return the defender
|
||||||
*/
|
*/
|
||||||
@@ -425,6 +263,12 @@ public class War extends Conflict {
|
|||||||
return defender;
|
return defender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets side by name.
|
||||||
|
*
|
||||||
|
* @param name the name
|
||||||
|
* @return the side
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Side getSide(String name) {
|
public Side getSide(String name) {
|
||||||
if (getSide1().equals(name))
|
if (getSide1().equals(name))
|
||||||
@@ -436,6 +280,12 @@ public class War extends Conflict {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets side by the side UUID.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
* @return the side
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Side getSide(UUID uuid) {
|
public Side getSide(UUID uuid) {
|
||||||
if (getSide1().equals(uuid))
|
if (getSide1().equals(uuid))
|
||||||
@@ -448,7 +298,7 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets sieges.
|
* Gets sieges in a list.
|
||||||
*
|
*
|
||||||
* @return the sieges
|
* @return the sieges
|
||||||
*/
|
*/
|
||||||
@@ -457,30 +307,47 @@ public class War extends Conflict {
|
|||||||
return sieges;
|
return sieges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets sieges for the war.
|
||||||
|
*
|
||||||
|
* @param sieges the sieges
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void setSieges(Set<Siege> sieges) {
|
public void setSieges(Set<Siege> sieges) {
|
||||||
this.sieges = sieges;
|
this.sieges = sieges;
|
||||||
this.sieges.forEach(Siege::resume);
|
this.sieges.forEach(Siege::resume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets siege by the siege UUID.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
* @return the siege
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Siege getSiege(UUID uuid) {
|
public Siege getSiege(UUID uuid) {
|
||||||
for (@NotNull Siege siege : sieges) {
|
return sieges.stream()
|
||||||
if (siege.equals(uuid))
|
.filter(s -> s.equals(uuid))
|
||||||
return siege;
|
.findAny()
|
||||||
}
|
.orElse(null);
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add siege.
|
* Add siege to war.
|
||||||
*
|
*
|
||||||
* @param siege the siege
|
* @param siege the siege
|
||||||
*/
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void addSiege(Siege siege) {
|
public void addSiege(Siege siege) {
|
||||||
sieges.add(siege);
|
sieges.add(siege);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove siege from war.
|
||||||
|
*
|
||||||
|
* @param siege the siege
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void removeSiege(Siege siege) {
|
public void removeSiege(Siege siege) {
|
||||||
sieges.remove(siege);
|
sieges.remove(siege);
|
||||||
}
|
}
|
||||||
@@ -496,28 +363,50 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add raid.
|
* Add raid to war.
|
||||||
*
|
*
|
||||||
* @param raid the raid
|
* @param raid the raid
|
||||||
*/
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void addRaid(Raid raid) {
|
public void addRaid(Raid raid) {
|
||||||
raids.add(raid);
|
raids.add(raid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove raid from war.
|
||||||
|
*
|
||||||
|
* @param raid the raid
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void removeRaid(Raid raid) {
|
public void removeRaid(Raid raid) {
|
||||||
raids.remove(raid);
|
raids.remove(raid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
/**
|
||||||
|
* Is town under siege in this war.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
public boolean isTownUnderSiege(Town town) {
|
public boolean isTownUnderSiege(Town town) {
|
||||||
return sieges.stream().anyMatch(siege -> siege.getTown().equals(town));
|
return sieges.stream().anyMatch(siege -> siege.getTown().equals(town));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
/**
|
||||||
|
* Is town under raid in this war.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
public boolean isTownUnderRaid(Town town) {
|
public boolean isTownUnderRaid(Town town) {
|
||||||
return raids.stream().anyMatch(raid -> raid.getTown().equals(town));
|
return raids.stream().anyMatch(raid -> raid.getTown().equals(town));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all online players in the war.
|
||||||
|
*
|
||||||
|
* @return the players
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Player> getPlayers() {
|
public Set<Player> getPlayers() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -527,6 +416,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all players, including offline ones in the war.
|
||||||
|
*
|
||||||
|
* @return the players including offline
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<OfflinePlayer> getPlayersIncludingOffline() {
|
public Set<OfflinePlayer> getPlayersIncludingOffline() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -536,6 +430,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all surrendered players in the war.
|
||||||
|
*
|
||||||
|
* @return the surrendered players
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<OfflinePlayer> getSurrenderedPlayers() {
|
public Set<OfflinePlayer> getSurrenderedPlayers() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -545,25 +444,43 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerInWar(@NotNull Player p) {
|
/**
|
||||||
|
* Check if player is in war.
|
||||||
|
*
|
||||||
|
* @param p the p
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean isPlayerInWar(Player p) {
|
||||||
return side1.isPlayerOnSide(p) || side2.isPlayerOnSide(p);
|
return side1.isPlayerOnSide(p) || side2.isPlayerOnSide(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if player is in war.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
public boolean isPlayerInWar(UUID uuid) {
|
public boolean isPlayerInWar(UUID uuid) {
|
||||||
return side1.isPlayerOnSide(uuid) || side2.isPlayerOnSide(uuid);
|
return side1.isPlayerOnSide(uuid) || side2.isPlayerOnSide(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the side of the player or null if they are not in the war.
|
||||||
|
*
|
||||||
|
* @param p the p
|
||||||
|
* @return the player side
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Side getPlayerSide(@NotNull Player p) {
|
public Side getPlayerSide(Player p) {
|
||||||
if (side1.isPlayerOnSide(p))
|
return getPlayerSide(p.getUniqueId());
|
||||||
return getSide1();
|
|
||||||
|
|
||||||
if (side2.isPlayerOnSide(p))
|
|
||||||
return getSide2();
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets player side by player UUID or null if they are not in the war.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
* @return the player side
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Side getPlayerSide(UUID uuid) {
|
public Side getPlayerSide(UUID uuid) {
|
||||||
if (side1.isPlayerOnSide(uuid))
|
if (side1.isPlayerOnSide(uuid))
|
||||||
@@ -575,10 +492,22 @@ public class War extends Conflict {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is town in war.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
public boolean isTownInWar(Town town) {
|
public boolean isTownInWar(Town town) {
|
||||||
return side1.isTownOnSide(town) || side2.isTownOnSide(town);
|
return side1.isTownOnSide(town) || side2.isTownOnSide(town);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets town side or null if not in war.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
* @return the town side
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Side getTownSide(Town town) {
|
public Side getTownSide(Town town) {
|
||||||
if (side1.isTownOnSide(town))
|
if (side1.isTownOnSide(town))
|
||||||
@@ -590,10 +519,22 @@ public class War extends Conflict {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is nation in war boolean.
|
||||||
|
*
|
||||||
|
* @param nation the nation
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
public boolean isNationInWar(Nation nation) {
|
public boolean isNationInWar(Nation nation) {
|
||||||
return side1.isNationOnSide(nation) || side2.isNationOnSide(nation);
|
return side1.isNationOnSide(nation) || side2.isNationOnSide(nation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets nation side or null if not in war.
|
||||||
|
*
|
||||||
|
* @param nation the nation
|
||||||
|
* @return the nation side
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Side getNationSide(Nation nation) {
|
public Side getNationSide(Nation nation) {
|
||||||
if (side1.isNationOnSide(nation))
|
if (side1.isNationOnSide(nation))
|
||||||
@@ -605,14 +546,30 @@ public class War extends Conflict {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a side exists with the specified name.
|
||||||
|
*
|
||||||
|
* @param sideName the side name
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
public boolean isSideValid(String sideName) {
|
public boolean isSideValid(String sideName) {
|
||||||
return getSide1().equals(sideName) || getSide2().equals(sideName);
|
return getSide1().equals(sideName) || getSide2().equals(sideName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel all active sieges in the war.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void cancelSieges() {
|
public void cancelSieges() {
|
||||||
getTowns().forEach(this::cancelSieges);
|
getTowns().forEach(this::cancelSieges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel all active sieges in the war. Ends the sieges in a draw.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void cancelSieges(Town town) {
|
public void cancelSieges(Town town) {
|
||||||
if (this != null) {
|
if (this != null) {
|
||||||
Side townSide = getTownSide(town);
|
Side townSide = getTownSide(town);
|
||||||
@@ -631,6 +588,11 @@ public class War extends Conflict {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Surrender a nation and all its towns out of the war.
|
||||||
|
*
|
||||||
|
* @param nation the nation
|
||||||
|
*/
|
||||||
public void surrenderNation(Nation nation) {
|
public void surrenderNation(Nation nation) {
|
||||||
Side nationSide = getNationSide(nation);
|
Side nationSide = getNationSide(nation);
|
||||||
if (nationSide == null) return;
|
if (nationSide == null) return;
|
||||||
@@ -643,6 +605,11 @@ public class War extends Conflict {
|
|||||||
nationSide.processSurrenders();
|
nationSide.processSurrenders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Surrender town and all its players out of a war.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
*/
|
||||||
public void surrenderTown(Town town) {
|
public void surrenderTown(Town town) {
|
||||||
Side townSide = getTownSide(town);
|
Side townSide = getTownSide(town);
|
||||||
if (townSide == null) return;
|
if (townSide == null) return;
|
||||||
@@ -662,6 +629,11 @@ public class War extends Conflict {
|
|||||||
townSide.processSurrenders();
|
townSide.processSurrenders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsurrender a nation and all its towns and players.
|
||||||
|
*
|
||||||
|
* @param nation the nation
|
||||||
|
*/
|
||||||
public void unsurrenderNation(Nation nation) {
|
public void unsurrenderNation(Nation nation) {
|
||||||
Side nationSide = getNationSide(nation);
|
Side nationSide = getNationSide(nation);
|
||||||
if (nationSide == null) return;
|
if (nationSide == null) return;
|
||||||
@@ -670,6 +642,11 @@ public class War extends Conflict {
|
|||||||
nation.getTowns().forEach(this::unsurrenderTown);
|
nation.getTowns().forEach(this::unsurrenderTown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsurrender town and all its players.
|
||||||
|
*
|
||||||
|
* @param town the town
|
||||||
|
*/
|
||||||
public void unsurrenderTown(Town town) {
|
public void unsurrenderTown(Town town) {
|
||||||
Side townSide = getTownSide(town);
|
Side townSide = getTownSide(town);
|
||||||
if (townSide == null) return;
|
if (townSide == null) return;
|
||||||
@@ -679,6 +656,11 @@ public class War extends Conflict {
|
|||||||
townSide.unsurrenderTown(town);
|
townSide.unsurrenderTown(town);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets towns in the war excluding surrendered ones.
|
||||||
|
*
|
||||||
|
* @return the towns
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Town> getTowns() {
|
public Set<Town> getTowns() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -688,6 +670,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all towns in the war including surrendered towns.
|
||||||
|
*
|
||||||
|
* @return the all towns
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Town> getAllTowns() {
|
public Set<Town> getAllTowns() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -700,6 +687,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets nations in the war excluding surrendered ones.
|
||||||
|
*
|
||||||
|
* @return the nations
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Nation> getNations() {
|
public Set<Nation> getNations() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -709,6 +701,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all nations in the war including surrendered.
|
||||||
|
*
|
||||||
|
* @return the all nations
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Nation> getAllNations() {
|
public Set<Nation> getAllNations() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -721,6 +718,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all surrendered towns in the war.
|
||||||
|
*
|
||||||
|
* @return the surrendered towns
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Town> getSurrenderedTowns() {
|
public Set<Town> getSurrenderedTowns() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -730,6 +732,11 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all surrendered nations in the war.
|
||||||
|
*
|
||||||
|
* @return the surrendered nations
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<Nation> getSurrenderedNations() {
|
public Set<Nation> getSurrenderedNations() {
|
||||||
return Stream.concat(
|
return Stream.concat(
|
||||||
@@ -739,6 +746,10 @@ public class War extends Conflict {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a new war after creation.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void start() {
|
public void start() {
|
||||||
Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + "The war of <war> has started between <attacker> and <defender>.")
|
Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + "The war of <war> has started between <attacker> and <defender>.")
|
||||||
.parseMinimessagePlaceholder("war", getLabel())
|
.parseMinimessagePlaceholder("war", getLabel())
|
||||||
@@ -770,11 +781,21 @@ public class War extends Conflict {
|
|||||||
side2.applyNameTags();
|
side2.applyNameTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume a pre-existing war after loading it from db.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void resume() {
|
public void resume() {
|
||||||
side1.applyNameTags();
|
side1.applyNameTags();
|
||||||
side2.applyNameTags();
|
side2.applyNameTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End a war for the specified reason. Triggered internally by {@link War#defeat(Side)} & {@link War#draw()}.
|
||||||
|
*
|
||||||
|
* @param reason the reason
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public void end(WarDeleteReason reason) {
|
public void end(WarDeleteReason reason) {
|
||||||
if (!new PreWarDeleteEvent(this, reason).callEvent())
|
if (!new PreWarDeleteEvent(this, reason).callEvent())
|
||||||
return;
|
return;
|
||||||
@@ -791,6 +812,11 @@ public class War extends Conflict {
|
|||||||
new WarDeleteEvent(this, reason).callEvent();
|
new WarDeleteEvent(this, reason).callEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End the war in defeat for the specified side. Internally runs {@link War#end(WarDeleteReason)}.
|
||||||
|
*
|
||||||
|
* @param loserSide the loser side
|
||||||
|
*/
|
||||||
public void defeat(@NotNull Side loserSide) {
|
public void defeat(@NotNull Side loserSide) {
|
||||||
@NotNull Side loser = loserSide.equals(getSide1()) ? getSide1() : getSide2();
|
@NotNull Side loser = loserSide.equals(getSide1()) ? getSide1() : getSide2();
|
||||||
@NotNull Side winner = loserSide.equals(getSide1()) ? getSide2() : getSide1();
|
@NotNull Side winner = loserSide.equals(getSide1()) ? getSide2() : getSide1();
|
||||||
@@ -805,7 +831,9 @@ public class War extends Conflict {
|
|||||||
end(WarDeleteReason.DEFEAT);
|
end(WarDeleteReason.DEFEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// White defeat/force end war
|
/**
|
||||||
|
* End the war in a white peace/draw. Internally runs {@link War#end(WarDeleteReason)}.
|
||||||
|
*/
|
||||||
public void draw() {
|
public void draw() {
|
||||||
Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + "The war of <war> has ended with a white peace.")
|
Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + "The war of <war> has ended with a white peace.")
|
||||||
.parseMinimessagePlaceholder("war", getLabel())
|
.parseMinimessagePlaceholder("war", getLabel())
|
||||||
@@ -815,11 +843,21 @@ public class War extends Conflict {
|
|||||||
end(WarDeleteReason.DRAW);
|
end(WarDeleteReason.DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEvent(boolean event) {
|
/**
|
||||||
|
* Sets if this is an event war.
|
||||||
|
*
|
||||||
|
* @param event the event
|
||||||
|
*/
|
||||||
|
public void setEventWar(boolean event) {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEvent() {
|
/**
|
||||||
|
* Gets if this is an event war. Event wars skip or execute certain logic as they are for player events.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean isEventWar() {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ public class Raid implements Battle {
|
|||||||
*/
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
raidRunnable = new RaidRunnable(this);
|
raidRunnable = new RaidRunnable(this);
|
||||||
if (!war.isEvent())
|
if (!war.isEventWar())
|
||||||
AlathranWars.econ.withdrawPlayer(raidLeader, SIEGE_VICTORY_MONEY);
|
AlathranWars.econ.withdrawPlayer(raidLeader, SIEGE_VICTORY_MONEY);
|
||||||
|
|
||||||
final Title.Times times = Title.Times.times(Duration.ofMillis(500), Duration.ofMillis(3500), Duration.ofMillis(500));
|
final Title.Times times = Title.Times.times(Duration.ofMillis(500), Duration.ofMillis(3500), Duration.ofMillis(500));
|
||||||
@@ -164,7 +164,7 @@ public class Raid implements Battle {
|
|||||||
public void attackersWin(BattleVictoryReason reason) {
|
public void attackersWin(BattleVictoryReason reason) {
|
||||||
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.ATTACKER, reason).callEvent()) return;
|
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.ATTACKER, reason).callEvent()) return;
|
||||||
|
|
||||||
if (!war.isEvent()) {
|
if (!war.isEventWar()) {
|
||||||
AlathranWars.econ.depositPlayer(raidLeader, SIEGE_VICTORY_MONEY);
|
AlathranWars.econ.depositPlayer(raidLeader, SIEGE_VICTORY_MONEY);
|
||||||
double amt;
|
double amt;
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ public class Raid implements Battle {
|
|||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
if (!war.isEvent()) {
|
if (!war.isEventWar()) {
|
||||||
Side townSide = getWar().getTownSide(town);
|
Side townSide = getWar().getTownSide(town);
|
||||||
Side attackerSide = getAttackerSide();
|
Side attackerSide = getAttackerSide();
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ public class Raid implements Battle {
|
|||||||
public void defendersWin(BattleVictoryReason reason) {
|
public void defendersWin(BattleVictoryReason reason) {
|
||||||
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.DEFENDER, reason).callEvent()) return;
|
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.DEFENDER, reason).callEvent()) return;
|
||||||
|
|
||||||
if (!war.isEvent())
|
if (!war.isEventWar())
|
||||||
town.getAccount().deposit(SIEGE_VICTORY_MONEY, "Raid Victory");
|
town.getAccount().deposit(SIEGE_VICTORY_MONEY, "Raid Victory");
|
||||||
|
|
||||||
if (side1AreAttackers) {
|
if (side1AreAttackers) {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class Siege implements Battle {
|
|||||||
siegeRunnable = new SiegeRunnable(this);
|
siegeRunnable = new SiegeRunnable(this);
|
||||||
stopped = false;
|
stopped = false;
|
||||||
|
|
||||||
if (!war.isEvent())
|
if (!war.isEventWar())
|
||||||
AlathranWars.econ.withdrawPlayer(siegeLeader, SIEGE_VICTORY_MONEY);
|
AlathranWars.econ.withdrawPlayer(siegeLeader, SIEGE_VICTORY_MONEY);
|
||||||
|
|
||||||
new BattleStartEvent(war, this).callEvent();
|
new BattleStartEvent(war, this).callEvent();
|
||||||
@@ -169,7 +169,7 @@ public class Siege implements Battle {
|
|||||||
public void attackersWin(BattleVictoryReason reason) {
|
public void attackersWin(BattleVictoryReason reason) {
|
||||||
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.ATTACKER, reason).callEvent()) return;
|
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.ATTACKER, reason).callEvent()) return;
|
||||||
|
|
||||||
if (!war.isEvent()) {
|
if (!war.isEventWar()) {
|
||||||
AlathranWars.econ.depositPlayer(siegeLeader, SIEGE_VICTORY_MONEY);
|
AlathranWars.econ.depositPlayer(siegeLeader, SIEGE_VICTORY_MONEY);
|
||||||
double amt;
|
double amt;
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ public class Siege implements Battle {
|
|||||||
public void defendersWin(BattleVictoryReason reason) {
|
public void defendersWin(BattleVictoryReason reason) {
|
||||||
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.DEFENDER, reason).callEvent()) return;
|
if (!new PreBattleResultEvent(war, this, BattleType.SIEGE, BattleVictor.DEFENDER, reason).callEvent()) return;
|
||||||
|
|
||||||
if (!war.isEvent())
|
if (!war.isEventWar())
|
||||||
town.getAccount().deposit(SIEGE_VICTORY_MONEY, "Siege Victory");
|
town.getAccount().deposit(SIEGE_VICTORY_MONEY, "Siege Victory");
|
||||||
|
|
||||||
new BattleResultEvent(war, this, BattleVictor.DEFENDER, reason).callEvent();
|
new BattleResultEvent(war, this, BattleVictor.DEFENDER, reason).callEvent();
|
||||||
|
|||||||
@@ -23,14 +23,12 @@ import java.nio.ByteBuffer;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Savepoint;
|
import java.sql.Savepoint;
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static com.github.alathra.AlathranWars.db.schema.Tables.*;
|
import static com.github.alathra.AlathranWars.db.schema.Tables.*;
|
||||||
|
|
||||||
@@ -89,7 +87,7 @@ public abstract class DatabaseQueries {
|
|||||||
// .set(LIST.LABEL, war.getLabel())
|
// .set(LIST.LABEL, war.getLabel())
|
||||||
// .set(LIST.SIDE1, DatabaseQueries.convertUUIDToBytes(war.getSide1().getUUID()))
|
// .set(LIST.SIDE1, DatabaseQueries.convertUUIDToBytes(war.getSide1().getUUID()))
|
||||||
// .set(LIST.SIDE2, DatabaseQueries.convertUUIDToBytes(war.getSide2().getUUID()))
|
// .set(LIST.SIDE2, DatabaseQueries.convertUUIDToBytes(war.getSide2().getUUID()))
|
||||||
// .set(LIST.EVENT, war.isEvent() ? (byte) 1 : (byte) 0)
|
// .set(LIST.EVENT, war.isEventWar() ? (byte) 1 : (byte) 0)
|
||||||
.insertInto(LIST, LIST.UUID, LIST.NAME, LIST.LABEL, LIST.SIDE1, LIST.SIDE2, LIST.EVENT)
|
.insertInto(LIST, LIST.UUID, LIST.NAME, LIST.LABEL, LIST.SIDE1, LIST.SIDE2, LIST.EVENT)
|
||||||
.values(
|
.values(
|
||||||
DatabaseQueries.convertUUIDToBytes(war.getUUID()),
|
DatabaseQueries.convertUUIDToBytes(war.getUUID()),
|
||||||
@@ -97,7 +95,7 @@ public abstract class DatabaseQueries {
|
|||||||
war.getLabel(),
|
war.getLabel(),
|
||||||
DatabaseQueries.convertUUIDToBytes(war.getSide1().getUUID()),
|
DatabaseQueries.convertUUIDToBytes(war.getSide1().getUUID()),
|
||||||
DatabaseQueries.convertUUIDToBytes(war.getSide2().getUUID()),
|
DatabaseQueries.convertUUIDToBytes(war.getSide2().getUUID()),
|
||||||
war.isEvent() ? (byte) 1 : (byte) 0
|
war.isEventWar() ? (byte) 1 : (byte) 0
|
||||||
)
|
)
|
||||||
.onDuplicateKeyUpdate()
|
.onDuplicateKeyUpdate()
|
||||||
.set(LIST.NAME, war.getName())
|
.set(LIST.NAME, war.getName())
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class SiegeListener implements Listener {
|
|||||||
case ATTACKER -> {
|
case ATTACKER -> {
|
||||||
War war = e.getWar();
|
War war = e.getWar();
|
||||||
|
|
||||||
if (war.isEvent()) return;
|
if (war.isEventWar()) return;
|
||||||
|
|
||||||
Town town = siege.getTown();
|
Town town = siege.getTown();
|
||||||
Side townSide = war.getTownSide(town);
|
Side townSide = war.getTownSide(town);
|
||||||
|
|||||||
Reference in new issue
Block a user