This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ログイン時、不具合報告・フィードバックがクローズされていたら通知する (#954)
- Loading branch information
Showing
4 changed files
with
422 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/java/com/jaoafa/mymaid4/event/Event_ClosedIssueNotifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* jaoLicense | ||
* | ||
* Copyright (c) 2022 jao Minecraft Server | ||
* | ||
* The following license applies to this project: jaoLicense | ||
* | ||
* Japanese: https://github.com/jaoafa/jao-Minecraft-Server/blob/master/jaoLICENSE.md | ||
* English: https://github.com/jaoafa/jao-Minecraft-Server/blob/master/jaoLICENSE-en.md | ||
*/ | ||
|
||
package com.jaoafa.mymaid4.event; | ||
|
||
import com.jaoafa.mymaid4.Main; | ||
import com.jaoafa.mymaid4.lib.EventPremise; | ||
import com.jaoafa.mymaid4.lib.IssueManager; | ||
import com.jaoafa.mymaid4.lib.MyMaidLibrary; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.event.ClickEvent; | ||
import net.kyori.adventure.text.event.HoverEvent; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
public class Event_ClosedIssueNotifier extends MyMaidLibrary implements Listener, EventPremise { | ||
@Override | ||
public String description() { | ||
return "ログイン時、bugコマンドやfeedbackコマンドによって作成されたissueがクローズされていたら通知します。"; | ||
} | ||
|
||
@EventHandler | ||
public void onJoinClearCache(PlayerJoinEvent event) { | ||
Player player = event.getPlayer(); | ||
new BukkitRunnable() { | ||
public void run() { | ||
List<IssueManager.Issue> issues = IssueManager.getPlayerIssues(player); | ||
if (issues.isEmpty()) { | ||
return; | ||
} | ||
List<IssueManager.Issue> closedIssues = issues.stream() | ||
.filter(issue -> IssueManager.isClosedIssue(issue.repository(), issue.issueNumber())) | ||
.toList(); | ||
if (closedIssues.isEmpty()) { | ||
return; | ||
} | ||
player.sendMessage(Component.text().append( | ||
Component.text("["), | ||
Component.text("BugFeedback", NamedTextColor.YELLOW), | ||
Component.text("]"), | ||
Component.space(), | ||
Component.text("あなたが送信した不具合報告・フィードバックが完了済みとしてマークされました。", NamedTextColor.GREEN) | ||
)); | ||
|
||
for (IssueManager.Issue issue : closedIssues) { | ||
String datetime = sdfFormat(new Date(issue.time())); | ||
player.sendMessage(Component.text().append( | ||
Component.text("["), | ||
Component.text("BugFeedback", NamedTextColor.YELLOW), | ||
Component.text("]"), | ||
Component.space(), | ||
Component.text(datetime + " に送信された", NamedTextColor.GREEN), | ||
Component.text(IssueManager.getRepoIssueType(issue.repository()), NamedTextColor.GREEN), | ||
Component.text(":", NamedTextColor.GREEN), | ||
Component.space(), | ||
Component.text("%s#%d".formatted(issue.repository().getRepo(), issue.issueNumber()), NamedTextColor.AQUA) | ||
.hoverEvent(HoverEvent.showText(Component.text("クリックで不具合報告・フィードバックのページを開きます", NamedTextColor.GREEN))) | ||
.clickEvent(ClickEvent.openUrl("https://github.com/%s/issues/%d".formatted(issue.repository().getRepo(), issue.issueNumber()))) | ||
)); | ||
IssueManager.removePlayerIssue(player, issue.issueNumber()); | ||
} | ||
|
||
} | ||
}.runTaskAsynchronously(Main.getJavaPlugin()); | ||
} | ||
} |
Oops, something went wrong.