From 37060242db839efb87aec783a5918e8be3d7bc76 Mon Sep 17 00:00:00 2001 From: matsu1213 Date: Mon, 15 Jul 2024 17:48:52 +0900 Subject: [PATCH] fix error and update build.yml --- .github/workflows/build.yml | 5 +++++ .../net/azisaba/lgwneo/match/AssistStreaks.java | 7 +++---- .../net/azisaba/lgwneo/match/KillStreaks.java | 16 +++++++--------- .../lgwneo/match/mode/LeaderDeathMatch.java | 5 +++-- .../net/azisaba/lgwneo/match/mode/Match.java | 3 +++ 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cac08236..d4150600 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,3 +40,8 @@ jobs: - run: java -version - run: mvn --version - run: mvn -B package + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + path: /home/runner/work/LeonGunWarNeo/LeonGunWarNeo/target/ diff --git a/src/main/java/net/azisaba/lgwneo/match/AssistStreaks.java b/src/main/java/net/azisaba/lgwneo/match/AssistStreaks.java index c50ddc69..2207c6fa 100644 --- a/src/main/java/net/azisaba/lgwneo/match/AssistStreaks.java +++ b/src/main/java/net/azisaba/lgwneo/match/AssistStreaks.java @@ -16,7 +16,7 @@ @RequiredArgsConstructor public class AssistStreaks { - private final LeonGunWarNeo plugin; + private final Match match; private final Map streaksMap = new HashMap<>(); public void removedBy(UUID uuid) { @@ -34,16 +34,15 @@ public void add(UUID uuid) { Player player = Bukkit.getPlayer(uuid); // 報酬を付与 - plugin.getLeonGunWarNeoConfig().getAssistLevels().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getAssistLevels().entrySet().stream() .filter(entry -> streaks % entry.getKey() == 0) .map(Map.Entry::getValue) .map(Map.Entry::getValue) .flatMap(List::stream) .map(command -> Chat.f(command, player.getName())) .forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command)); - Match match = plugin.getMatchOrganizer().getMatchFromPlayer(player); // アシストストリークをお知らせ - plugin.getLeonGunWarNeoConfig().getAssistLevels().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getAssistLevels().entrySet().stream() .filter(entry -> streaks % entry.getKey() == 0) .map(Map.Entry::getValue) .map(Map.Entry::getKey) diff --git a/src/main/java/net/azisaba/lgwneo/match/KillStreaks.java b/src/main/java/net/azisaba/lgwneo/match/KillStreaks.java index dadac3dc..6100c05f 100644 --- a/src/main/java/net/azisaba/lgwneo/match/KillStreaks.java +++ b/src/main/java/net/azisaba/lgwneo/match/KillStreaks.java @@ -17,7 +17,7 @@ @RequiredArgsConstructor public class KillStreaks { - private final LeonGunWarNeo plugin; + private final Match match; private final Map streaksMap = new HashMap<>(); @@ -26,17 +26,16 @@ public void removedBy(UUID uuid, UUID killerU) { Player killer = Bukkit.getPlayer(killerU); int streaks = get(uuid).get(); int minStreaks = - plugin.getLeonGunWarNeoConfig().getStreaks().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getStreaks().entrySet().stream() .sorted(Map.Entry.comparingByKey()) .map(Map.Entry::getKey) .findFirst() .orElse(-1); if (killer != null && streaks >= minStreaks) { - Match match = plugin.getMatchOrganizer().getMatchFromPlayer(uuid); match.broadcastMessage( Chat.f( - plugin.getLeonGunWarNeoConfig().getRemoved(), + match.getPlugin().getLeonGunWarNeoConfig().getRemoved(), LeonGunWarNeo.getChatPrefix(), killer.getDisplayName(), player.getDisplayName() @@ -54,14 +53,14 @@ public AtomicInteger get(UUID uuid) { private void giveRewards(int streaks, UUID uuid) { Player player = Bukkit.getPlayer(uuid); - plugin.getLeonGunWarNeoConfig().getStreaks().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getStreaks().entrySet().stream() .filter(entry -> streaks == entry.getKey()) .map(Map.Entry::getValue) .map(Map.Entry::getValue) .flatMap(List::stream) .map(command -> Chat.f(command, player.getName())) .forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command)); - plugin.getLeonGunWarNeoConfig().getKillLevels().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getKillLevels().entrySet().stream() .filter(entry -> streaks % entry.getKey() == 0) .map(Map.Entry::getValue) .map(Map.Entry::getValue) @@ -73,7 +72,6 @@ private void giveRewards(int streaks, UUID uuid) { public void add(UUID uuid) { // カウントを追加 int streaks = get(uuid).incrementAndGet(); - Match match = plugin.getMatchOrganizer().getMatchFromPlayer(uuid); Player player = Bukkit.getPlayer(uuid); // 報酬を付与 giveRewards(streaks, uuid); @@ -85,14 +83,14 @@ public void add(UUID uuid) { } // キルストリークをお知らせ - plugin.getLeonGunWarNeoConfig().getStreaks().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getStreaks().entrySet().stream() .filter(entry -> streaks == entry.getKey()) .map(Map.Entry::getValue) .map(Map.Entry::getKey) .flatMap(List::stream) .map(message -> Chat.f(message, LeonGunWarNeo.getChatPrefix(), player.getDisplayName())) .forEach(match::broadcastMessage); - plugin.getLeonGunWarNeoConfig().getKillLevels().entrySet().stream() + match.getPlugin().getLeonGunWarNeoConfig().getKillLevels().entrySet().stream() .filter(entry -> streaks % entry.getKey() == 0) .map(Map.Entry::getValue) .map(Map.Entry::getKey) diff --git a/src/main/java/net/azisaba/lgwneo/match/mode/LeaderDeathMatch.java b/src/main/java/net/azisaba/lgwneo/match/mode/LeaderDeathMatch.java index fcf6694e..ea30685f 100644 --- a/src/main/java/net/azisaba/lgwneo/match/mode/LeaderDeathMatch.java +++ b/src/main/java/net/azisaba/lgwneo/match/mode/LeaderDeathMatch.java @@ -59,6 +59,7 @@ @RequiredArgsConstructor public class LeaderDeathMatch implements Match { + @Getter private final LeonGunWarNeo plugin; @Getter private final String matchId; @@ -103,9 +104,9 @@ public class LeaderDeathMatch implements Match { private final HashMap chestPlateMap = new HashMap<>(); @Getter - private final KillStreaks killStreaks = new KillStreaks(plugin); + private final KillStreaks killStreaks = new KillStreaks(this); @Getter - private final AssistStreaks assistStreaks = new AssistStreaks(plugin); + private final AssistStreaks assistStreaks = new AssistStreaks(this); @Override public Map getMatchInformationAsMap() { diff --git a/src/main/java/net/azisaba/lgwneo/match/mode/Match.java b/src/main/java/net/azisaba/lgwneo/match/mode/Match.java index 9c921d5d..c58f39ad 100644 --- a/src/main/java/net/azisaba/lgwneo/match/mode/Match.java +++ b/src/main/java/net/azisaba/lgwneo/match/mode/Match.java @@ -4,6 +4,7 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; +import net.azisaba.lgwneo.LeonGunWarNeo; import net.azisaba.lgwneo.match.AssistStreaks; import net.azisaba.lgwneo.match.KillDeathAssistCounter; import net.azisaba.lgwneo.match.KillStreaks; @@ -136,4 +137,6 @@ public interface Match { KillStreaks getKillStreaks(); AssistStreaks getAssistStreaks(); + + LeonGunWarNeo getPlugin(); }