mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
refactor: rename WarManeger to WarController
This commit is contained in:
19 files changed
+70
-70
No files matched your search
@@ -2,7 +2,7 @@ package com.github.alathra.AlathranWars;
|
||||
|
||||
import com.github.alathra.AlathranWars.commands.CommandManager;
|
||||
import com.github.alathra.AlathranWars.config.ConfigHandler;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.db.DatabaseHandler;
|
||||
import com.github.alathra.AlathranWars.db.DatabaseQueries;
|
||||
import com.github.alathra.AlathranWars.hooks.HookManager;
|
||||
@@ -44,7 +44,7 @@ public class AlathranWars extends JavaPlugin {
|
||||
public void onLoad() {
|
||||
instance = this;
|
||||
paperLib = new MorePaperLib(instance);
|
||||
WarManager.getInstance();
|
||||
WarController.getInstance();
|
||||
configHandler = new ConfigHandler(instance);
|
||||
databaseHandler = new DatabaseHandler(instance);
|
||||
commandManager = new CommandManager(instance);
|
||||
@@ -68,7 +68,7 @@ public class AlathranWars extends JavaPlugin {
|
||||
commandManager.onEnable();
|
||||
listenerHandler.onEnable();
|
||||
hookManager.onEnable();
|
||||
WarManager.getInstance().loadAll();
|
||||
WarController.getInstance().loadAll();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.github.alathra.AlathranWars.commands;
|
||||
import com.github.alathra.AlathranWars.AlathranWars;
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.CommandArgsSiege;
|
||||
import com.github.alathra.AlathranWars.enums.CommandArgsWar;
|
||||
@@ -302,7 +302,7 @@ public class CommandUtil {
|
||||
throw CustomArgument.CustomArgumentException.fromAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>The town is not in that war!").parseLegacy().build());
|
||||
|
||||
if (checkIfSieged) {
|
||||
for (@NotNull Siege siege : WarManager.getInstance().getSieges()) {
|
||||
for (@NotNull Siege siege : WarController.getInstance().getSieges()) {
|
||||
if (siege.getTown().getUUID() == town.getUUID())
|
||||
throw CustomArgument.CustomArgumentException.fromAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>The town is already under siege!").parseLegacy().build());
|
||||
}
|
||||
@@ -342,13 +342,13 @@ public class CommandUtil {
|
||||
final String argSiegeName = info.input();
|
||||
|
||||
@Nullable UUID siegeUUID = null;
|
||||
for (Siege siege : WarManager.getInstance().getSieges()) {
|
||||
for (Siege siege : WarController.getInstance().getSieges()) {
|
||||
if (siege.getName().equals(argSiegeName)) {
|
||||
siegeUUID = siege.getUUID();
|
||||
}
|
||||
}
|
||||
|
||||
final @Nullable Siege siege = WarManager.getInstance().getSiege(siegeUUID);
|
||||
final @Nullable Siege siege = WarController.getInstance().getSiege(siegeUUID);
|
||||
if (siege == null)
|
||||
throw CustomArgument.CustomArgumentException.fromAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>The siege <siege> does not exist!").parseMinimessagePlaceholder("siege", argSiegeName).build());
|
||||
|
||||
@@ -394,7 +394,7 @@ public class CommandUtil {
|
||||
}
|
||||
|
||||
private static List<String> siegeAll(SuggestionInfo<CommandSender> info, final boolean isAdmin) {
|
||||
return WarManager.getInstance().getSieges().stream().map(Siege::getName).toList();
|
||||
return WarController.getInstance().getSieges().stream().map(Siege::getName).toList();
|
||||
}
|
||||
|
||||
private static List<String> siegeOutside(SuggestionInfo<CommandSender> info, final boolean isAdmin, final String playerNodeName) {
|
||||
@@ -402,11 +402,11 @@ public class CommandUtil {
|
||||
|
||||
if (isAdmin) {
|
||||
if (info.previousArgs().get(playerNodeName) instanceof Player player) {
|
||||
siegeNames = WarManager.getInstance().getSieges().stream().filter(siege -> !siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
siegeNames = WarController.getInstance().getSieges().stream().filter(siege -> !siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
}
|
||||
} else {
|
||||
if (info.sender() instanceof Player player) {
|
||||
siegeNames = WarManager.getInstance().getSieges().stream().filter(siege -> !siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
siegeNames = WarController.getInstance().getSieges().stream().filter(siege -> !siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,11 +418,11 @@ public class CommandUtil {
|
||||
|
||||
if (isAdmin) {
|
||||
if (info.previousArgs().get(playerNodeName) instanceof Player player) {
|
||||
siegeNames = WarManager.getInstance().getSieges().stream().filter(siege -> siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
siegeNames = WarController.getInstance().getSieges().stream().filter(siege -> siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
}
|
||||
} else {
|
||||
if (info.sender() instanceof Player player) {
|
||||
siegeNames = WarManager.getInstance().getSieges().stream().filter(siege -> siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
siegeNames = WarController.getInstance().getSieges().stream().filter(siege -> siege.isPlayerInSiege(player)).map(Siege::getName).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ public class CommandUtil {
|
||||
return new CustomArgument<>(new StringArgument(nodeName), info -> {
|
||||
final String argWarName = info.input();
|
||||
|
||||
final @Nullable War war = WarManager.getInstance().getWar(argWarName);
|
||||
final @Nullable War war = WarController.getInstance().getWar(argWarName);
|
||||
if (war == null)
|
||||
throw CustomArgument.CustomArgumentException.fromAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>The war <war> does not exist!").parseMinimessagePlaceholder("war", argWarName).build());
|
||||
|
||||
@@ -479,7 +479,7 @@ public class CommandUtil {
|
||||
}
|
||||
|
||||
private static List<String> warsAll(SuggestionInfo<CommandSender> info, final boolean isAdmin) {
|
||||
return WarManager.getInstance().getWarNames();
|
||||
return WarController.getInstance().getWarNames();
|
||||
}
|
||||
|
||||
private static List<String> warsOutside(SuggestionInfo<CommandSender> info, final boolean isAdmin, final String playerNodeName) {
|
||||
@@ -487,11 +487,11 @@ public class CommandUtil {
|
||||
|
||||
if (isAdmin) {
|
||||
if (info.previousArgs().get(playerNodeName) instanceof Player player) {
|
||||
warNames = WarManager.getInstance().getWars().stream().filter(war -> !war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
warNames = WarController.getInstance().getWars().stream().filter(war -> !war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
}
|
||||
} else {
|
||||
if (info.sender() instanceof Player player) {
|
||||
warNames = WarManager.getInstance().getWars().stream().filter(war -> !war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
warNames = WarController.getInstance().getWars().stream().filter(war -> !war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,11 +503,11 @@ public class CommandUtil {
|
||||
|
||||
if (isAdmin) {
|
||||
if (info.previousArgs().get(playerNodeName) instanceof Player player) {
|
||||
warNames = WarManager.getInstance().getWars().stream().filter(war -> war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
warNames = WarController.getInstance().getWars().stream().filter(war -> war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
}
|
||||
} else {
|
||||
if (info.sender() instanceof Player player) {
|
||||
warNames = WarManager.getInstance().getWars().stream().filter(war -> war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
warNames = WarController.getInstance().getWars().stream().filter(war -> war.isPlayerInWar(player)).map(War::getName).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.github.alathra.AlathranWars.commands;
|
||||
import com.github.alathra.AlathranWars.AlathranWars;
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
@@ -211,7 +211,7 @@ public class SiegeCommands {
|
||||
}
|
||||
|
||||
private static void siegeList(@NotNull Player sender, CommandArguments args) throws WrapperCommandSyntaxException {
|
||||
Set<Siege> sieges = WarManager.getInstance().getSieges();
|
||||
Set<Siege> sieges = WarController.getInstance().getSieges();
|
||||
|
||||
if (sieges.isEmpty()) {
|
||||
sender.sendMessage(ColorParser.of("<red>There are no sieges at the moment.").build());
|
||||
|
||||
@@ -449,7 +449,7 @@ public class WarCommands {
|
||||
}
|
||||
|
||||
private static void warList(@NotNull Player p, CommandArguments args) throws WrapperCommandSyntaxException {
|
||||
Set<War> wars = WarManager.getInstance().getWars();
|
||||
Set<War> wars = WarController.getInstance().getWars();
|
||||
|
||||
if (wars.isEmpty()) {
|
||||
p.sendMessage(ColorParser.of("<red>There are no wars at the moment, the world is at peace.").build());
|
||||
|
||||
@@ -517,7 +517,7 @@ public class Side {
|
||||
|
||||
@Nullable
|
||||
public War getWar() {
|
||||
return WarManager.getInstance().getWar(warUUID); // The war must exist, or this object wouldn't
|
||||
return WarController.getInstance().getWar(warUUID); // The war must exist, or this object wouldn't
|
||||
}
|
||||
|
||||
public void processSurrenders() {
|
||||
|
||||
@@ -118,7 +118,7 @@ public class War extends Conflict {
|
||||
this.label = label;
|
||||
|
||||
this.name = "%s.vs.%s".formatted(aggressor.getName(), victim.getName());
|
||||
if (WarManager.getInstance().getWar(this.name) != null)
|
||||
if (WarController.getInstance().getWar(this.name) != null)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "<red>A war already exists with that name!").build());
|
||||
|
||||
this.side1 = new SideBuilder()
|
||||
@@ -144,7 +144,7 @@ public class War extends Conflict {
|
||||
return;
|
||||
|
||||
// TODO All logic below this point should be separated out
|
||||
WarManager.getInstance().addWar(this);
|
||||
WarController.getInstance().addWar(this);
|
||||
|
||||
start();
|
||||
|
||||
@@ -804,7 +804,7 @@ public class War extends Conflict {
|
||||
getAllTowns().forEach(Occupation::removeOccupied);
|
||||
|
||||
DatabaseQueries.deleteWar(this);
|
||||
WarManager.getInstance().removeWar(this);
|
||||
WarController.getInstance().removeWar(this);
|
||||
|
||||
// Run check after war is removed to cleanup player tags
|
||||
getPlayers().forEach(p -> NameColorHandler.getInstance().calculatePlayerColors(p));
|
||||
|
||||
+5
-5
@@ -18,19 +18,19 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Singleton
|
||||
public class WarManager {
|
||||
private static WarManager instance;
|
||||
public class WarController {
|
||||
private static WarController instance;
|
||||
private @NotNull Set<War> wars = new HashSet<>();
|
||||
|
||||
private WarManager() {
|
||||
private WarController() {
|
||||
if (instance != null)
|
||||
Bukkit.getServer().getLogger().warning("Tried to re-initialize singleton");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static WarManager getInstance() {
|
||||
public static WarController getInstance() {
|
||||
if (instance == null)
|
||||
instance = new WarManager();
|
||||
instance = new WarController();
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public abstract class DatabaseQueries {
|
||||
) {
|
||||
DSLContext context = DB.getContext(con);
|
||||
|
||||
for (War war : WarManager.getInstance().getWars()) {
|
||||
for (War war : WarController.getInstance().getWars()) {
|
||||
context
|
||||
// .insertInto(LIST)
|
||||
// .set(LIST.UUID, DatabaseQueries.convertUUIDToBytes(war.getUUID()))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.alathra.AlathranWars.hooks;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.utility.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -28,14 +28,14 @@ public class NameColorHandler {
|
||||
}
|
||||
|
||||
public void calculatePlayerColors(Player p) {
|
||||
if (!WarManager.getInstance().isPlayerInAnyWars(p)) {
|
||||
if (!WarController.getInstance().isPlayerInAnyWars(p)) {
|
||||
playerHasChanges.remove(p);
|
||||
playerColor.remove(p);
|
||||
playerInitial.remove(p);
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<War> war = WarManager.getInstance().getPlayerWars(p).stream().findFirst();
|
||||
Optional<War> war = WarController.getInstance().getPlayerWars(p).stream().findFirst();
|
||||
|
||||
if (war.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.github.alathra.AlathranWars.listeners;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.utility.Utils;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
@@ -148,7 +148,7 @@ public class CommandsListener implements Listener {
|
||||
Prevent players from teleporting during a siege
|
||||
*/
|
||||
|
||||
for (Siege siege : WarManager.getInstance().getPlayerSieges(p)) {
|
||||
for (Siege siege : WarController.getInstance().getPlayerSieges(p)) {
|
||||
//payment check
|
||||
if (args.length >= 2) {
|
||||
//parse what we have, remove the starting sslash
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.github.alathra.AlathranWars.listeners.items;
|
||||
|
||||
import com.github.alathra.AlathranWars.AlathranWars;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
@@ -71,7 +71,7 @@ public class PlayerInteractListener implements Listener {
|
||||
if (item.equals(WarItemRegistry.getInstance().getOrNull("ram"))) {
|
||||
boolean inSiegeOrRaid = false;
|
||||
//siege check
|
||||
for (@NotNull Siege s : WarManager.getInstance().getSieges()) {
|
||||
for (@NotNull Siege s : WarController.getInstance().getSieges()) {
|
||||
for (@NotNull TownBlock townBlock : s.getTown().getTownBlocks()) {
|
||||
if (WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||
// if we find one, just end no need to continue
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.github.alathra.AlathranWars.listeners.siege;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,8 +13,8 @@ public class PlayerJoinListener implements Listener {
|
||||
@EventHandler
|
||||
private void onPlayerJoin(@NotNull PlayerJoinEvent e) {
|
||||
final @NotNull Player p = e.getPlayer();
|
||||
if (WarManager.getInstance().isPlayerInAnySiege(p)) {
|
||||
for (@NotNull Siege siege : WarManager.getInstance().getPlayerSieges(p)) {
|
||||
if (WarController.getInstance().isPlayerInAnySiege(p)) {
|
||||
for (@NotNull Siege siege : WarController.getInstance().getPlayerSieges(p)) {
|
||||
final @NotNull BattleSide side = siege.getPlayerSideInSiege(p);
|
||||
siege.addOnlinePlayer(p, side);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.github.alathra.AlathranWars.listeners.siege;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,8 +13,8 @@ public class PlayerQuitListener implements Listener {
|
||||
@EventHandler
|
||||
private void onPlayerQuit(@NotNull PlayerQuitEvent e) {
|
||||
final @NotNull Player p = e.getPlayer();
|
||||
if (WarManager.getInstance().isPlayerInAnySiege(p)) {
|
||||
for (@NotNull Siege siege : WarManager.getInstance().getPlayerSieges(p)) {
|
||||
if (WarController.getInstance().isPlayerInAnySiege(p)) {
|
||||
for (@NotNull Siege siege : WarController.getInstance().getPlayerSieges(p)) {
|
||||
final @NotNull BattleSide side = siege.getPlayerSideInSiege(p);
|
||||
siege.removeOnlinePlayer(p, side);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.github.alathra.AlathranWars.listeners.war;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||
import com.palmergames.bukkit.towny.event.NationAddTownEvent;
|
||||
import com.palmergames.bukkit.towny.event.NationPreRenameEvent;
|
||||
@@ -23,7 +23,7 @@ public class NationListener implements Listener {
|
||||
private void onRename(NationPreRenameEvent e) {
|
||||
Nation nation = e.getNation();
|
||||
|
||||
if (WarManager.getInstance().isNationInAnyWars(nation)) {
|
||||
if (WarController.getInstance().isNationInAnyWars(nation)) {
|
||||
e.setCancelMessage("You can't rename a nation while it's in a war.");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class NationListener implements Listener {
|
||||
Town town = e.getTown();
|
||||
|
||||
// Add town to all nation wars
|
||||
for (War war : WarManager.getInstance().getNationWars(nation)) {
|
||||
for (War war : WarController.getInstance().getNationWars(nation)) {
|
||||
Side side = war.getNationSide(nation);
|
||||
if (side == null) continue;
|
||||
|
||||
@@ -43,14 +43,14 @@ public class NationListener implements Listener {
|
||||
}
|
||||
|
||||
// TODO Add nation to towns' wars
|
||||
for (War war : WarManager.getInstance().getTownWars(town)) {
|
||||
for (War war : WarController.getInstance().getTownWars(town)) {
|
||||
Side side = war.getTownSide(town);
|
||||
if (side == null) continue;
|
||||
|
||||
side.addNation(nation);
|
||||
}
|
||||
|
||||
for (War war : WarManager.getInstance().getNationWars(nation)) {
|
||||
for (War war : WarController.getInstance().getNationWars(nation)) {
|
||||
Side side = war.getNationSide(nation);
|
||||
if (side == null) continue;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class NationListener implements Listener {
|
||||
Nation nation = e.getRemainingNation();
|
||||
Nation nation1 = e.getNation();
|
||||
|
||||
if (WarManager.getInstance().isNationInAnyWars(nation) || WarManager.getInstance().isNationInAnyWars(nation1)) {
|
||||
if (WarController.getInstance().isNationInAnyWars(nation) || WarController.getInstance().isNationInAnyWars(nation1)) {
|
||||
e.setCancelMessage("You can't merge nations while they are in a war.");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.github.alathra.AlathranWars.listeners.war;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,8 +15,8 @@ public class PlayerJoinListener implements Listener {
|
||||
@EventHandler
|
||||
private void onPlayerJoin(@NotNull PlayerJoinEvent e) {
|
||||
final @NotNull Player p = e.getPlayer();
|
||||
if (WarManager.getInstance().isPlayerInAnyWars(p)) {
|
||||
for (@NotNull War war : WarManager.getInstance().getWars()) {
|
||||
if (WarController.getInstance().isPlayerInAnyWars(p)) {
|
||||
for (@NotNull War war : WarController.getInstance().getWars()) {
|
||||
if (war.isPlayerInWar(p)) {
|
||||
@Nullable Side side = war.getPlayerSide(p);
|
||||
if (side != null) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.github.alathra.AlathranWars.listeners.war;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,8 +15,8 @@ public class PlayerQuitListener implements Listener {
|
||||
@EventHandler
|
||||
private void onPlayerQuit(@NotNull PlayerQuitEvent e) {
|
||||
final @NotNull Player p = e.getPlayer();
|
||||
if (WarManager.getInstance().isPlayerInAnyWars(p)) {
|
||||
for (@NotNull War war : WarManager.getInstance().getWars()) {
|
||||
if (WarController.getInstance().isPlayerInAnyWars(p)) {
|
||||
for (@NotNull War war : WarController.getInstance().getWars()) {
|
||||
if (war.isPlayerInWar(p)) {
|
||||
@Nullable Side side = war.getPlayerSide(p);
|
||||
if (side != null) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.github.alathra.AlathranWars.listeners.war;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import com.palmergames.bukkit.towny.event.TownAddResidentEvent;
|
||||
@@ -26,7 +26,7 @@ public class TownListener implements Listener {
|
||||
private void onRename(TownPreRenameEvent e) {
|
||||
Town town = e.getTown();
|
||||
|
||||
if (WarManager.getInstance().isTownInAnyWars(town)) {
|
||||
if (WarController.getInstance().isTownInAnyWars(town)) {
|
||||
e.setCancelMessage("You can't rename a town while it's in a war.");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class TownListener implements Listener {
|
||||
Player p = e.getResident().getPlayer();
|
||||
if (p == null) return;
|
||||
|
||||
for (War war : WarManager.getInstance().getTownWars(town)) {
|
||||
for (War war : WarController.getInstance().getTownWars(town)) {
|
||||
Side side = war.getTownSide(town);
|
||||
if (side == null) continue;
|
||||
side.addPlayer(p);
|
||||
@@ -68,7 +68,7 @@ public class TownListener implements Listener {
|
||||
Player p = e.getResident().getPlayer();
|
||||
if (p == null) return;
|
||||
|
||||
for (War war : WarManager.getInstance().getTownWars(town)) {
|
||||
for (War war : WarController.getInstance().getTownWars(town)) {
|
||||
Side side = war.getTownSide(town);
|
||||
if (side == null) continue;
|
||||
side.removePlayer(p);
|
||||
@@ -83,7 +83,7 @@ public class TownListener implements Listener {
|
||||
Player p = e.getKickedResident().getPlayer();
|
||||
if (p == null) return;
|
||||
|
||||
for (War war : WarManager.getInstance().getTownWars(town)) {
|
||||
for (War war : WarController.getInstance().getTownWars(town)) {
|
||||
Side side = war.getTownSide(town);
|
||||
if (side == null) continue;
|
||||
side.removePlayer(p);
|
||||
@@ -118,7 +118,7 @@ public class TownListener implements Listener {
|
||||
Town town = e.getRemainingTown();
|
||||
Town town2 = e.getSuccumbingTown();
|
||||
|
||||
if (WarManager.getInstance().isTownInAnyWars(town) || WarManager.getInstance().isTownInAnyWars(town2)) {
|
||||
if (WarController.getInstance().isTownInAnyWars(town) || WarController.getInstance().isTownInAnyWars(town2)) {
|
||||
e.setCancelMessage("You can't merge towns while they are in a war.");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class TownListener implements Listener {
|
||||
private void onRuin(TownRuinedEvent e) {
|
||||
Town town = e.getTown();
|
||||
|
||||
for (War war : WarManager.getInstance().getTownWars(town)) {
|
||||
for (War war : WarController.getInstance().getTownWars(town)) {
|
||||
Side side = war.getTownSide(town);
|
||||
if (side == null) continue;
|
||||
war.unsurrenderTown(town);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.github.alathra.AlathranWars.utility;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -13,7 +13,7 @@ public abstract class UUIDUtil {
|
||||
public static @NotNull UUID generateWarUUID() {
|
||||
@NotNull UUID uuid = UUID.randomUUID();
|
||||
|
||||
while (WarManager.getInstance().getWar(uuid) != null) {
|
||||
while (WarController.getInstance().getWar(uuid) != null) {
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class UUIDUtil {
|
||||
public static @NotNull UUID generateSideUUID(@Nullable UUID previousSideUUID) {
|
||||
@NotNull UUID uuid = UUID.randomUUID();
|
||||
|
||||
while (WarManager.getInstance().getSide(uuid) != null || uuid == previousSideUUID) {
|
||||
while (WarController.getInstance().getSide(uuid) != null || uuid == previousSideUUID) {
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class UUIDUtil {
|
||||
public static @NotNull UUID generateSiegeUUID() {
|
||||
@NotNull UUID uuid = UUID.randomUUID();
|
||||
|
||||
while (WarManager.getInstance().getSiege(uuid) != null) {
|
||||
while (WarController.getInstance().getSiege(uuid) != null) {
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.github.alathra.AlathranWars.utility;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.WarController;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import org.bukkit.Location;
|
||||
@@ -199,8 +199,8 @@ public abstract class Utils {
|
||||
// TODO Implement usage in siege commands to make siege optional argument
|
||||
public static @Nullable Siege getClosestSiege(Player p, boolean checkIfInSiege) {
|
||||
Set<Siege> sieges = checkIfInSiege
|
||||
? WarManager.getInstance().getSieges().stream().filter(siege -> siege.isPlayerInSiege(p)).collect(Collectors.toSet())
|
||||
: WarManager.getInstance().getSieges();
|
||||
? WarController.getInstance().getSieges().stream().filter(siege -> siege.isPlayerInSiege(p)).collect(Collectors.toSet())
|
||||
: WarController.getInstance().getSieges();
|
||||
|
||||
@Nullable Siege siegeResult = null;
|
||||
final Location playerLoc = p.getLocation();
|
||||
|
||||
Reference in new issue
Block a user