mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 22:14:45 +00:00
refactor: wip update 6 (fixed 1.19.4)
This commit is contained in:
23 files changed
+149
-188
No files matched your search
@@ -7,7 +7,6 @@ import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.hooks.HookManager;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
import com.github.alathra.AlathranWars.listeners.ListenerHandler;
|
||||
import com.github.alathra.AlathranWars.utility.DB;
|
||||
import com.github.alathra.AlathranWars.utility.SQLQueries;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
@@ -63,7 +62,6 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
warLogger = new AlathranWarsLogger();
|
||||
}*/
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private boolean setupEconomy() {
|
||||
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.github.alathra.AlathranWars.commands;
|
||||
|
||||
import com.github.alathra.AlathranWars.Main;
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.enums.AdminCommandFailEnum;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
@@ -11,8 +13,6 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.arguments.*;
|
||||
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
|
||||
import dev.jorel.commandapi.executors.CommandArguments;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.enums.AdminCommandFailEnum;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -954,7 +954,7 @@ public class AdminCommand {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "<red>Invalid action.").build());
|
||||
|
||||
if (!(args.get("war") instanceof final War war))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "<red>The war does not exist!").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "<red>The war does not exist!").build());
|
||||
|
||||
if (!(args.get("side") instanceof final Side side))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "<red>The side does not exist.").build());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.github.alathra.AlathranWars.commands;
|
||||
import com.github.alathra.AlathranWars.Main;
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.hooks.TownyHook;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
@@ -17,13 +18,14 @@ import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.ArgumentSuggestions;
|
||||
import dev.jorel.commandapi.arguments.CustomArgument;
|
||||
import dev.jorel.commandapi.arguments.StringArgument;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -260,15 +262,15 @@ public class CommandUtil {
|
||||
return nationNames;
|
||||
|
||||
final List<String> removeNames = Stream.concat( // Create a list of all nations & towns in war
|
||||
war.getNations().stream().map(Nation::getName),
|
||||
war.getNations().stream().map(Nation::getName),
|
||||
Stream.concat(
|
||||
war.getSurrenderedNations().stream().map(Nation::getName),
|
||||
Stream.concat(
|
||||
war.getSurrenderedNations().stream().map(Nation::getName),
|
||||
Stream.concat(
|
||||
war.getTowns().stream().map(Town::getName),
|
||||
war.getSurrenderedTowns().stream().map(Town::getName)
|
||||
)
|
||||
war.getTowns().stream().map(Town::getName),
|
||||
war.getSurrenderedTowns().stream().map(Town::getName)
|
||||
)
|
||||
).toList();
|
||||
)
|
||||
).toList();
|
||||
|
||||
nationNames.removeAll(removeNames);
|
||||
|
||||
@@ -440,7 +442,7 @@ public class CommandUtil {
|
||||
|
||||
return side;
|
||||
}).replaceSuggestions(ArgumentSuggestions.stringCollection(info -> {
|
||||
if (!(info.previousArgs().get(warNodeName) instanceof War war))
|
||||
if (!(info.previousArgs().get(warNodeName) instanceof War war))
|
||||
return Collections.emptyList();
|
||||
|
||||
final List<String> sideNames = new ArrayList<>();
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.github.alathra.AlathranWars.commands;
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.data.DataManager;
|
||||
import com.github.alathra.AlathranWars.enums.BattleTeam;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
@@ -19,7 +18,6 @@ import dev.jorel.commandapi.executors.CommandArguments;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
@@ -204,14 +202,15 @@ public class SiegeCommand {
|
||||
// Attacking own side
|
||||
if (side.isTownOnSide(town)) {
|
||||
siegeOwner.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You cannot attack your own towns.").build());
|
||||
if (admin) sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You cannot attack your own towns.").build());
|
||||
if (admin)
|
||||
sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You cannot attack your own towns.").build());
|
||||
return;
|
||||
}
|
||||
|
||||
Siege siege = new Siege(war, town, siegeOwner);
|
||||
war.addSiege(siege);
|
||||
|
||||
Bukkit.broadcast(new ColorParser(UtilsChat.getPrefix() + siege.getTown() + " has been put to siege by " + siege.getAttackerSide() + "!").build());
|
||||
Bukkit.broadcast(new ColorParser(UtilsChat.getPrefix() + siege.getTown() + " has been put to siege by " + siege.getAttackerSide().getName() + "!").build());
|
||||
|
||||
if (admin)
|
||||
sender.sendMessage(new ColorParser("<red>Forcefully started siege from the console.").build());
|
||||
@@ -295,10 +294,10 @@ public class SiegeCommand {
|
||||
|
||||
sender.sendMessage(
|
||||
new ColorParser(
|
||||
color + siege.getTown().getName() + " <gray>- Progress: <progress> - Time: <time>min"
|
||||
color + siege.getTown().getName() + " <gray>- Progress: <progress> - Time: <time>min"
|
||||
)
|
||||
.parseMinimessagePlaceholder("progress", "%.0f%%".formatted(siege.getSiegeProgressPercentage() * 100))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now() , siege.getEndTime()).toMinutes()))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now(), siege.getEndTime()).toMinutes()))
|
||||
.build()
|
||||
);
|
||||
// sender.sendMessage(new ColorParser(war.getName() + " - " + color + siege.getTown().getName().toLowerCase()).build()); // TODO Fix info
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.github.alathra.AlathranWars.commands;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.BattleSide;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.listeners.war.PlayerJoinListener;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
@@ -17,8 +19,6 @@ import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import dev.jorel.commandapi.arguments.PlayerArgument;
|
||||
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
|
||||
import dev.jorel.commandapi.executors.CommandArguments;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -80,7 +80,7 @@ public class WarCommand {
|
||||
.withArguments(
|
||||
CommandUtil.warWarArgument("war", false, true, ""),
|
||||
CommandUtil.warSideCreateArgument("side", "war", false, true, ""),
|
||||
new PlayerArgument("player").setOptional(true).withPermission("AlathranWars.admin")
|
||||
new PlayerArgument("player").setOptional(true).withPermission("AlathranWars.admin.join")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> warJoinPlayer(p, args, false));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.github.alathra.AlathranWars.conflict;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.BattleSide;
|
||||
import com.github.alathra.AlathranWars.enums.BattleTeam;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.listeners.war.PlayerJoinListener;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.github.alathra.AlathranWars.enums.BattleSide;
|
||||
import com.github.alathra.AlathranWars.enums.BattleTeam;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -21,25 +20,22 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Side {
|
||||
private static final Duration SIEGE_COOLDOWN = Duration.ofMinutes(120);
|
||||
private static final Duration RAID_COOLDOWN = Duration.ofMinutes(30);
|
||||
private final UUID warUUID;
|
||||
private final UUID uuid;
|
||||
private final BattleSide side;
|
||||
private final BattleTeam team;
|
||||
private final String name; // A town name
|
||||
|
||||
// TODO Use Town & Nation UUID's when saving to config
|
||||
private final Town town; // The initiating town or capital of the nation
|
||||
private final Set<Town> towns; // A list of participating Towns
|
||||
private final Set<Nation> nations; // A list of participating Nations
|
||||
private final Set<UUID> playersIncludingOffline; // A list of all participating player UUID, (Online & Offline)
|
||||
private final Set<Player> players; // A list of the players who are currently online
|
||||
|
||||
private final Set<Town> surrenderedTowns;
|
||||
private final Set<Nation> surrenderedNations;
|
||||
private final Set<UUID> surrenderedPlayersIncludingOffline;
|
||||
|
||||
private static final Duration SIEGE_COOLDOWN = Duration.ofMinutes(120);
|
||||
private static final Duration RAID_COOLDOWN = Duration.ofMinutes(30);
|
||||
private Instant siegeGrace = Instant.now().minus(SIEGE_COOLDOWN); // The time after which this side can be besieged
|
||||
private Instant raidGrace = Instant.now().minus(RAID_COOLDOWN); // The time after which this side can be raided
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.alathra.AlathranWars.conflict;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.BattleSide;
|
||||
import com.github.alathra.AlathranWars.enums.BattleTeam;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.listeners.war.PlayerJoinListener;
|
||||
import com.github.alathra.AlathranWars.utility.SQLQueries;
|
||||
import com.github.alathra.AlathranWars.utility.UUIDUtil;
|
||||
@@ -10,10 +14,6 @@ import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import dev.jorel.commandapi.CommandAPIBukkit;
|
||||
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.BattleSide;
|
||||
import com.github.alathra.AlathranWars.enums.BattleTeam;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -32,7 +32,7 @@ import java.util.stream.Stream;
|
||||
public class War extends Conflict {
|
||||
private final UUID uuid;
|
||||
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 Side side1;
|
||||
@@ -71,9 +71,9 @@ public class War extends Conflict {
|
||||
/**
|
||||
* Instantiates a new New war.
|
||||
*
|
||||
* @param label the name
|
||||
* @param label the name
|
||||
* @param aggressor the side 1
|
||||
* @param victim the side 2
|
||||
* @param victim the side 2
|
||||
*/
|
||||
public War(final String label, Town aggressor, Town victim) throws WrapperCommandSyntaxException {
|
||||
this.uuid = UUIDUtil.generateWarUUID();
|
||||
@@ -338,28 +338,28 @@ public class War extends Conflict {
|
||||
@NotNull
|
||||
public Set<Player> getPlayers() {
|
||||
return Stream.concat(
|
||||
getSide1().getPlayers().stream(),
|
||||
getSide2().getPlayers().stream()
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
getSide1().getPlayers().stream(),
|
||||
getSide2().getPlayers().stream()
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<OfflinePlayer> getPlayersIncludingOffline() {
|
||||
return Stream.concat(
|
||||
getSide1().getPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer),
|
||||
getSide2().getPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
getSide1().getPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer),
|
||||
getSide2().getPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<OfflinePlayer> getSurrenderedPlayers() {
|
||||
return Stream.concat(
|
||||
getSide1().getSurrenderedPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer),
|
||||
getSide2().getSurrenderedPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
getSide1().getSurrenderedPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer),
|
||||
getSide2().getSurrenderedPlayersIncludingOffline().stream().map(Bukkit::getOfflinePlayer)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public boolean isPlayerInWar(Player p) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.stream.Collectors;
|
||||
public class Siege extends Battle {
|
||||
public static final int MAX_SIEGE_TICKS = 72000; // 60 minute tick constant
|
||||
public static final Duration SIEGE_DURATION = Duration.ofMinutes(60);
|
||||
private static final int MAX_SIEGE_PROGRESS_MINUTES = 8;
|
||||
public static final int MAX_SIEGE_PROGRESS_MINUTES = 8;
|
||||
public static final int MAX_SIEGE_PROGRESS = 60 * MAX_SIEGE_PROGRESS_MINUTES; // On reaching this, the attackers win. 1 point is added per second
|
||||
public static final Duration ATTACKERS_MUST_TOUCH_END = Duration.ofMinutes(40); // If point is not touched in this much time, defenders win
|
||||
public static final Duration ATTACKERS_MUST_TOUCH_REVERT = Duration.ofMinutes(2); // If point is not touched in this much time, siege progress reverts
|
||||
@@ -107,7 +107,7 @@ public class Siege extends Battle {
|
||||
war.removeSiege(this);
|
||||
}
|
||||
|
||||
public void attackersWin(final OfflinePlayer siegeLeader) {
|
||||
public void attackersWin(final OfflinePlayer siegeLeader) {
|
||||
final Resident resident = TownyAPI.getInstance().getResident(siegeLeader.getUniqueId());
|
||||
Nation nation = null;
|
||||
Bukkit.broadcast(new ColorParser(UtilsChat.getPrefix() + "The attackers have won the siege of " + town.getName() + "!").build());
|
||||
@@ -199,14 +199,14 @@ public class Siege extends Battle {
|
||||
return siegeProgress;
|
||||
}
|
||||
|
||||
public float getSiegeProgressPercentage() {
|
||||
return (getSiegeProgress() * 1.0f) / MAX_SIEGE_PROGRESS;
|
||||
}
|
||||
|
||||
public void setSiegeProgress(int siegeProgress) {
|
||||
this.siegeProgress = siegeProgress;
|
||||
}
|
||||
|
||||
public float getSiegeProgressPercentage() {
|
||||
return (getSiegeProgress() * 1.0f) / MAX_SIEGE_PROGRESS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public War getWar() {
|
||||
return war;
|
||||
@@ -241,6 +241,8 @@ public class Siege extends Battle {
|
||||
return side1AreAttackers ? war.getSide2() : war.getSide1();
|
||||
}
|
||||
|
||||
// SECTION Display Bar
|
||||
|
||||
public void updateDisplayBar(CaptureProgressDirection progressDirection) {
|
||||
if (activeBossBar == null)
|
||||
createNewDisplayBar();
|
||||
@@ -249,7 +251,7 @@ public class Siege extends Battle {
|
||||
|
||||
}*/
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
activeBossBar.removeViewer(p);
|
||||
p.hideBossBar(activeBossBar);
|
||||
}
|
||||
|
||||
for (Player p : this.getAttackers()) {
|
||||
@@ -290,7 +292,7 @@ public class Siege extends Battle {
|
||||
activeBossBar.name(
|
||||
new ColorParser("<gray>Capture Progress: %s<progress> <gray>Time: %s<time>min".formatted(color, color))
|
||||
.parseMinimessagePlaceholder("progress", "%.0f%%".formatted(getSiegeProgressPercentage() * 100))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now() , getEndTime()).toMinutes()))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now(), getEndTime()).toMinutes()))
|
||||
.build()
|
||||
);
|
||||
} else {
|
||||
@@ -304,7 +306,7 @@ public class Siege extends Battle {
|
||||
public void createNewDisplayBar() {
|
||||
final Component text = new ColorParser("<gray>Capture Progress: <yellow><progress> <gray>Time: <yellow><time>min")
|
||||
.parseMinimessagePlaceholder("progress", "%.0f%%".formatted(getSiegeProgressPercentage() * 100))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now() , getEndTime()).toMinutesPart()))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now(), getEndTime()).toMinutesPart()))
|
||||
.build();
|
||||
|
||||
this.activeBossBar = BossBar.bossBar(text, 0, BossBar.Color.YELLOW, BossBar.Overlay.NOTCHED_10);
|
||||
@@ -313,7 +315,7 @@ public class Siege extends Battle {
|
||||
public void deleteDisplayBar() {
|
||||
if (activeBossBar != null) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
activeBossBar.removeViewer(p);
|
||||
p.hideBossBar(activeBossBar);
|
||||
}
|
||||
|
||||
activeBossBar = null;
|
||||
@@ -346,7 +348,7 @@ public class Siege extends Battle {
|
||||
return getUUID().equals(siege.getUUID());
|
||||
}
|
||||
|
||||
// Accessors & Getters
|
||||
// SECTION Accessors & Getters
|
||||
|
||||
@Nullable
|
||||
public TownBlock getHomeBlock() {
|
||||
@@ -367,7 +369,7 @@ public class Siege extends Battle {
|
||||
}
|
||||
|
||||
public boolean getSide1AreAttackers() {
|
||||
return this.side1AreAttackers;
|
||||
return side1AreAttackers;
|
||||
}
|
||||
|
||||
public void setSide1AreAttackers(final boolean side1AreAttackers) {
|
||||
@@ -376,22 +378,22 @@ public class Siege extends Battle {
|
||||
|
||||
@NotNull
|
||||
public Set<Player> getAttackers() {
|
||||
return this.attackers;
|
||||
return attackers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<Player> getDefenders() {
|
||||
return this.defenders;
|
||||
return defenders;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<Player> getAttackerPlayers() {
|
||||
return this.attackerPlayers;
|
||||
return attackerPlayers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<Player> getDefenderPlayers() {
|
||||
return this.defenderPlayers;
|
||||
return defenderPlayers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -404,21 +406,21 @@ public class Siege extends Battle {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return this.getWar().getName() + "-" + this.getTown();
|
||||
public String getName() { // TODO Make better siegenames
|
||||
return getWar().getName() + "-" + getTown();
|
||||
}
|
||||
|
||||
// SECTION Time management
|
||||
|
||||
public void setEndTime(Instant time) {
|
||||
endTime = time;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Instant getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Instant time) {
|
||||
endTime = time;
|
||||
}
|
||||
|
||||
// SECTION Player management
|
||||
|
||||
public boolean isPlayerInSiege(UUID uuid) {
|
||||
@@ -525,14 +527,18 @@ public class Siege extends Battle {
|
||||
|
||||
public void calculateBattlefieldPlayers(Location location) {
|
||||
final Set<Player> attackersOnBattlefield = attackerPlayers.stream()
|
||||
.filter(p -> p.isOnline() && location.distance(p.getLocation()) < BATTLEFIELD_RANGE)
|
||||
.filter(OfflinePlayer::isOnline)
|
||||
.filter(p -> location.getWorld().equals(p.getLocation().getWorld()))
|
||||
.filter(p -> location.distance(p.getLocation()) < BATTLEFIELD_RANGE)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
attackers.clear();
|
||||
attackers.addAll(attackersOnBattlefield);
|
||||
|
||||
final Set<Player> defendersOnBattlefield = defenderPlayers.stream()
|
||||
.filter(p -> p.isOnline() && location.distance(p.getLocation()) < BATTLEFIELD_RANGE)
|
||||
.filter(OfflinePlayer::isOnline)
|
||||
.filter(p -> location.getWorld().equals(p.getLocation().getWorld()))
|
||||
.filter(p -> location.distance(p.getLocation()) < BATTLEFIELD_RANGE)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
defenders.clear();
|
||||
|
||||
+23
-43
@@ -16,13 +16,16 @@ import java.time.Instant;
|
||||
|
||||
import static com.github.alathra.AlathranWars.conflict.battle.siege.Siege.*;
|
||||
|
||||
public class SiegeRunnable implements Runnable{
|
||||
public class SiegeRunnable implements Runnable {
|
||||
// Settings
|
||||
private static final Duration ANNOUNCEMENT_COOLDOWN = Duration.ofMinutes(5);
|
||||
|
||||
private final static int CAPTURE_MAX_ELEVATION = 10;
|
||||
private final static int CAPTURE_RANGE = 10;
|
||||
private final Siege siege;
|
||||
// Variables
|
||||
private CaptureProgressDirection oldProgressDirection = CaptureProgressDirection.NONE;
|
||||
private Instant nextAnnouncement;
|
||||
private int taskId = -1;
|
||||
private final Siege siege;
|
||||
private Laser beam;
|
||||
|
||||
/**
|
||||
@@ -48,7 +51,7 @@ public class SiegeRunnable implements Runnable{
|
||||
/**
|
||||
* Resume a siege at tick
|
||||
*
|
||||
* @param siege the siege
|
||||
* @param siege the siege
|
||||
* @param siegeProgress the siege ticks
|
||||
*/
|
||||
public SiegeRunnable(Siege siege, int siegeProgress) {
|
||||
@@ -96,13 +99,13 @@ public class SiegeRunnable implements Runnable{
|
||||
siege.calculateBattlefieldPlayers(townSpawn.toCenterLocation());
|
||||
|
||||
// Progress the siege
|
||||
final CaptureProgressDirection progressDirection = getSiegeProgressDirection(town, townSpawn);
|
||||
final CaptureProgressDirection progressDirection = getSiegeProgressDirection(townSpawn);
|
||||
|
||||
// Siege is past max time or attackers haven't touched in time, defenders won
|
||||
if (
|
||||
!progressDirection.equals(CaptureProgressDirection.UP) &&
|
||||
(Instant.now().isAfter(siege.getEndTime()) ||
|
||||
Instant.now().isAfter(siege.getLastTouched().plus(ATTACKERS_MUST_TOUCH_END)))
|
||||
!progressDirection.equals(CaptureProgressDirection.UP) &&
|
||||
(Instant.now().isAfter(siege.getEndTime()) ||
|
||||
Instant.now().isAfter(siege.getLastTouched().plus(ATTACKERS_MUST_TOUCH_END)))
|
||||
) {
|
||||
cancel();
|
||||
siege.defendersWin();
|
||||
@@ -163,17 +166,6 @@ public class SiegeRunnable implements Runnable{
|
||||
}
|
||||
}
|
||||
|
||||
oldProgressDirection = progressDirection;
|
||||
|
||||
/*Bukkit.broadcast(
|
||||
new ColorParser("<prefix>Progress: <progress> <progress2> <test> <score>")
|
||||
.parseMinimessagePlaceholder("prefix", UtilsChat.getPrefix())
|
||||
.parseMinimessagePlaceholder("progress", "%.0f%%".formatted(siege.getSiegeProgressPercentage() * 100))
|
||||
.parseMinimessagePlaceholder("progress2", String.valueOf(siege.getSiegeProgressPercentage()))
|
||||
.parseMinimessagePlaceholder("test", progressDirection.name())
|
||||
.parseMinimessagePlaceholder("score", String.valueOf(siege.getSiegeProgress()))
|
||||
.build()
|
||||
);*/
|
||||
|
||||
if (Instant.now().isAfter(nextAnnouncement)) {
|
||||
nextAnnouncement = Instant.now().plus(ANNOUNCEMENT_COOLDOWN);
|
||||
@@ -181,52 +173,42 @@ public class SiegeRunnable implements Runnable{
|
||||
siege.getAttackers().forEach(p -> p.sendMessage(
|
||||
new ColorParser("<prefix>Siege time remaining: <time> minutes.")
|
||||
.parseMinimessagePlaceholder("prefix", UtilsChat.getPrefix())
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now() , siege.getEndTime()).toMinutesPart()))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now(), siege.getEndTime()).toMinutesPart()))
|
||||
.build()
|
||||
));
|
||||
siege.getDefenders().forEach(p -> p.sendMessage(
|
||||
new ColorParser("<prefix>Siege time remaining: <time> minutes.")
|
||||
.parseMinimessagePlaceholder("prefix", UtilsChat.getPrefix())
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now() , siege.getEndTime()).toMinutesPart()))
|
||||
.parseMinimessagePlaceholder("time", String.valueOf(Duration.between(Instant.now(), siege.getEndTime()).toMinutesPart()))
|
||||
.build()
|
||||
));
|
||||
}
|
||||
|
||||
siege.updateDisplayBar(progressDirection);
|
||||
oldProgressDirection = progressDirection;
|
||||
}
|
||||
|
||||
private final static int CAPTURE_MAX_ELEVATION = 10;
|
||||
private final static int CAPTURE_RANGE = 10;
|
||||
|
||||
public int getPeopleOnPoint(Town town, Location townSpawn, BattleSide battleSide) {
|
||||
public int getPeopleOnPoint(Location townSpawn, BattleSide battleSide) {
|
||||
int onPoint = 0;
|
||||
|
||||
for (final Player p : (battleSide.equals(BattleSide.ATTACKER) ? siege.getAttackers() : siege.getDefenders())) {
|
||||
// WorldCoord wc = WorldCoord.parseWorldCoord(p);
|
||||
// if (!Objects.equals(wc.getTownOrNull(), town))
|
||||
// continue;
|
||||
if (p.isDead())
|
||||
continue;
|
||||
|
||||
// @Nullable TownBlock homeBlock = town.getHomeBlockOrNull();
|
||||
// if (homeBlock == null)
|
||||
// continue;
|
||||
|
||||
if (/*!homeBlock.getWorldCoord().equals(wc) || */p.isDead())
|
||||
if (townSpawn.getWorld().equals(p.getLocation().getWorld()))
|
||||
continue;
|
||||
|
||||
if (townSpawn.distance(p.getLocation()) <= CAPTURE_RANGE) {
|
||||
onPoint += 1;
|
||||
}
|
||||
// if ((Math.abs(p.getLocation().getBlockY() - townSpawn.getBlockY())) < CAPTURE_MAX_ELEVATION) {
|
||||
// onPoint += 1;
|
||||
// }
|
||||
}
|
||||
|
||||
return onPoint;
|
||||
}
|
||||
|
||||
public CaptureProgressDirection getSiegeProgressDirection(Town town, Location townSpawn) {
|
||||
int attackersOnPoint = getPeopleOnPoint(town, townSpawn, BattleSide.ATTACKER);
|
||||
int defendersOnPoint = getPeopleOnPoint(town, townSpawn, BattleSide.DEFENDER);
|
||||
public CaptureProgressDirection getSiegeProgressDirection(Location townSpawn) {
|
||||
int attackersOnPoint = getPeopleOnPoint(townSpawn, BattleSide.ATTACKER);
|
||||
int defendersOnPoint = getPeopleOnPoint(townSpawn, BattleSide.DEFENDER);
|
||||
final boolean attackersAreOnPoint = attackersOnPoint > 0;
|
||||
final boolean defendersAreOnPoint = defendersOnPoint > 0;
|
||||
|
||||
@@ -263,10 +245,8 @@ public class SiegeRunnable implements Runnable{
|
||||
Location loc1 = siege.getTownSpawn();
|
||||
Location loc2 = new Location(loc1.getWorld(), loc1.getX(), loc1.getY() + 350D, loc1.getZ());
|
||||
|
||||
beam = new Laser.CrystalLaser(loc1, loc2, -1, BATTLEFIELD_RANGE);
|
||||
|
||||
if (beam != null)
|
||||
beam.start(Main.getInstance());
|
||||
beam = new Laser.CrystalLaser(loc1, loc2, -1, -1);
|
||||
beam.start(Main.getInstance());
|
||||
} catch (ReflectiveOperationException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.github.alathra.AlathranWars.utility.SQLQueries;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mariadb.jdbc.MariaDbDataSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -15,7 +14,7 @@ import java.sql.SQLException;
|
||||
|
||||
public class DataManager {
|
||||
private Main instance;
|
||||
// private static DataManager instance;
|
||||
// private static DataManager instance;
|
||||
private HikariConfig hikariConfig;
|
||||
private HikariDataSource hikariDataSource;
|
||||
|
||||
@@ -63,7 +62,7 @@ public class DataManager {
|
||||
public HikariDataSource getDataSource() {
|
||||
return hikariDataSource;
|
||||
}
|
||||
|
||||
|
||||
public void openConnection() {
|
||||
if (hikariDataSource != null)
|
||||
return;
|
||||
@@ -126,7 +125,7 @@ public class DataManager {
|
||||
|
||||
public void closeDatabaseConnection() {
|
||||
instance.getLogger().info("Closing database connection...");
|
||||
|
||||
|
||||
if (hikariDataSource != null) {
|
||||
if (!hikariDataSource.isClosed()) {
|
||||
try {
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.github.alathra.AlathranWars.holder;
|
||||
import com.github.alathra.AlathranWars.conflict.Side;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.utility.SQLQueries;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.github.alathra.AlathranWars.hooks;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import com.github.alathra.AlathranWars.listeners.war.PlayerJoinListener;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.alathra.AlathranWars.conflict.War;
|
||||
import me.neznamy.tab.api.TabAPI;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.api.event.EventBus;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.github.alathra.AlathranWars.items.item;
|
||||
|
||||
import com.github.alathra.AlathranWars.Main;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
import com.github.alathra.AlathranWars.items.IWarItem;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Tag;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.github.alathra.AlathranWars.listeners;
|
||||
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package com.github.alathra.AlathranWars.listeners;
|
||||
|
||||
import com.github.alathra.AlathranWars.utility.Utils;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
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.WorldCoord;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -33,7 +28,7 @@ public final class KillsListener implements Listener {
|
||||
boolean playerCloseToHomeBlockRaid = false;
|
||||
|
||||
// try {
|
||||
//OldRaid logic
|
||||
//OldRaid logic
|
||||
/*for (final OldRaid oldRaid : RaidData.getRaids()) {
|
||||
final int homeBlockXCoordRaided = oldRaid.getRaidedTown().getHomeBlock().getCoord().getX() * 16;
|
||||
final int homeBlockZCoordRaided = oldRaid.getRaidedTown().getHomeBlock().getCoord().getZ() * 16;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.github.alathra.AlathranWars.listeners;
|
||||
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import com.github.alathra.AlathranWars.Main;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.github.alathra.AlathranWars.listeners.siege;
|
||||
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
+2
-12
@@ -1,19 +1,9 @@
|
||||
package com.github.alathra.AlathranWars.listeners.siege;
|
||||
|
||||
import com.github.alathra.AlathranWars.utility.Utils;
|
||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PlayerDeathListener implements Listener {
|
||||
private final static int BATTLE_RADIUS = 300;
|
||||
@@ -90,7 +80,7 @@ public class PlayerDeathListener implements Listener {
|
||||
* They don't lose items from death.
|
||||
*
|
||||
* @param victim killed player
|
||||
* @param e event
|
||||
* @param e event
|
||||
*/
|
||||
private void siegeKill(Player victim, PlayerDeathEvent e) {
|
||||
//Helper
|
||||
@@ -108,7 +98,7 @@ public class PlayerDeathListener implements Listener {
|
||||
* They don't lose items from death.
|
||||
*
|
||||
* @param victim killed player
|
||||
* @param e event
|
||||
* @param e event
|
||||
*/
|
||||
private void oocKill(Player victim, PlayerDeathEvent e) {
|
||||
//Siege specific
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package com.github.alathra.AlathranWars.listeners.siege;
|
||||
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||
import com.github.alathra.AlathranWars.enums.BattleSide;
|
||||
import com.github.alathra.AlathranWars.holder.WarManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.github.alathra.AlathranWars.listeners.war;
|
||||
|
||||
import com.palmergames.bukkit.towny.event.nation.NationKingChangeEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class NationListener implements Listener {
|
||||
|
||||
@@ -146,7 +146,7 @@ public class SQLQueries {
|
||||
try (
|
||||
Connection con = DB.get();
|
||||
PreparedStatement warStatement = con.prepareStatement("INSERT INTO `wars_list` (`uuid`, `name`, `label`, `side1`, `side2`) VALUES (?, ?, ?, ?, ?) "
|
||||
+ "ON DUPLICATE KEY UPDATE `name` = ?, `label` = ?, `side1` = ?, `side2` = ?")
|
||||
+ "ON DUPLICATE KEY UPDATE `name` = ?, `label` = ?, `side1` = ?, `side2` = ?")
|
||||
) {
|
||||
// Save wars
|
||||
for (War war : WarManager.getInstance().getWars()) {
|
||||
@@ -184,8 +184,7 @@ public class SQLQueries {
|
||||
try (
|
||||
PreparedStatement sideStatement = con.prepareStatement("INSERT INTO `wars_sides` (`war`, `uuid`, `side`, `team`, `name`, `town`, `siegeGrace`, `raidGrace`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) "
|
||||
+ "ON DUPLICATE KEY UPDATE `side` = ?, `team` = ?, `name` = ?, `town` = ?, `siegeGrace` = ?, `raidGrace` = ?");
|
||||
)
|
||||
{
|
||||
) {
|
||||
// Insert
|
||||
sideStatement.setString(1, side.getWar().getUUID().toString());
|
||||
sideStatement.setString(2, side.getUUID().toString());
|
||||
@@ -239,7 +238,7 @@ public class SQLQueries {
|
||||
|
||||
// Transaction end
|
||||
con.commit();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
con.rollback();
|
||||
} finally {
|
||||
con.setAutoCommit(true);
|
||||
@@ -269,7 +268,7 @@ public class SQLQueries {
|
||||
|
||||
// Transaction end
|
||||
con.commit();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
con.rollback();
|
||||
} finally {
|
||||
con.setAutoCommit(true);
|
||||
@@ -299,7 +298,7 @@ public class SQLQueries {
|
||||
|
||||
// Transaction end
|
||||
con.commit();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
con.rollback();
|
||||
} finally {
|
||||
con.setAutoCommit(true);
|
||||
|
||||
@@ -13,6 +13,29 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Utils {
|
||||
private static final ArrayList<Material> weaponList = new ArrayList<>(List.of(
|
||||
Material.NETHERITE_SWORD,
|
||||
Material.NETHERITE_AXE,
|
||||
Material.DIAMOND_SWORD,
|
||||
Material.DIAMOND_AXE,
|
||||
Material.IRON_SWORD,
|
||||
Material.IRON_AXE
|
||||
));
|
||||
private static final ArrayList<Material> armorList = new ArrayList<>(List.of(
|
||||
Material.NETHERITE_HELMET,
|
||||
Material.NETHERITE_CHESTPLATE,
|
||||
Material.NETHERITE_LEGGINGS,
|
||||
Material.NETHERITE_BOOTS,
|
||||
Material.DIAMOND_HELMET,
|
||||
Material.DIAMOND_CHESTPLATE,
|
||||
Material.DIAMOND_LEGGINGS,
|
||||
Material.DIAMOND_BOOTS,
|
||||
Material.IRON_HELMET,
|
||||
Material.IRON_CHESTPLATE,
|
||||
Material.IRON_LEGGINGS,
|
||||
Material.IRON_BOOTS
|
||||
));
|
||||
|
||||
/**
|
||||
* Damages all gear in a players inventory
|
||||
*
|
||||
@@ -41,30 +64,6 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ArrayList<Material> weaponList = new ArrayList<>(List.of(
|
||||
Material.NETHERITE_SWORD,
|
||||
Material.NETHERITE_AXE,
|
||||
Material.DIAMOND_SWORD,
|
||||
Material.DIAMOND_AXE,
|
||||
Material.IRON_SWORD,
|
||||
Material.IRON_AXE
|
||||
));
|
||||
|
||||
private static final ArrayList<Material> armorList = new ArrayList<>(List.of(
|
||||
Material.NETHERITE_HELMET,
|
||||
Material.NETHERITE_CHESTPLATE,
|
||||
Material.NETHERITE_LEGGINGS,
|
||||
Material.NETHERITE_BOOTS,
|
||||
Material.DIAMOND_HELMET,
|
||||
Material.DIAMOND_CHESTPLATE,
|
||||
Material.DIAMOND_LEGGINGS,
|
||||
Material.DIAMOND_BOOTS,
|
||||
Material.IRON_HELMET,
|
||||
Material.IRON_CHESTPLATE,
|
||||
Material.IRON_LEGGINGS,
|
||||
Material.IRON_BOOTS
|
||||
));
|
||||
|
||||
private static void setArmorDurability(@Nullable ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return;
|
||||
@@ -168,7 +167,7 @@ public class Utils {
|
||||
return;
|
||||
|
||||
switch (itemStack.getType()) {
|
||||
case NETHERITE_SWORD, NETHERITE_AXE -> {
|
||||
case NETHERITE_SWORD, NETHERITE_AXE -> {
|
||||
damageable.setDamage(damageable.getDamage() + 507);
|
||||
if (damageable.getDamage() > 2000) {
|
||||
damageable.setDamage(2030);
|
||||
|
||||
Reference in new issue
Block a user