Skip to content

Commit

Permalink
fix error and update build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
matsu1213 committed Jul 15, 2024
1 parent a4ead53 commit 3706024
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ jobs:
- run: java -version
- run: mvn --version
- run: mvn -B package

- name: Upload a Build Artifact
uses: actions/[email protected]
with:
path: /home/runner/work/LeonGunWarNeo/LeonGunWarNeo/target/
7 changes: 3 additions & 4 deletions src/main/java/net/azisaba/lgwneo/match/AssistStreaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@RequiredArgsConstructor
public class AssistStreaks {

private final LeonGunWarNeo plugin;
private final Match match;
private final Map<UUID, AtomicInteger> streaksMap = new HashMap<>();

public void removedBy(UUID uuid) {
Expand All @@ -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)
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/net/azisaba/lgwneo/match/KillStreaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@RequiredArgsConstructor
public class KillStreaks {

private final LeonGunWarNeo plugin;
private final Match match;

private final Map<UUID, AtomicInteger> streaksMap = new HashMap<>();

Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
@RequiredArgsConstructor
public class LeaderDeathMatch implements Match {

@Getter
private final LeonGunWarNeo plugin;
@Getter
private final String matchId;
Expand Down Expand Up @@ -103,9 +104,9 @@ public class LeaderDeathMatch implements Match {
private final HashMap<MatchTeam, ItemStack> 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<String, Object> getMatchInformationAsMap() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/azisaba/lgwneo/match/mode/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -136,4 +137,6 @@ public interface Match {

KillStreaks getKillStreaks();
AssistStreaks getAssistStreaks();

LeonGunWarNeo getPlugin();
}

0 comments on commit 3706024

Please sign in to comment.