From 24d41a5bad8ce5d3c9ba7b93ab4bde893826864f Mon Sep 17 00:00:00 2001 From: RIngoame196 <132573268+Ringoame196@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:30:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E9=AF=96=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-server/requirements.txt | 2 ++ python-server/server.py | 25 +++++++++++++++++++ .../ringoame196_s_mcPlugin/core/Main.kt | 2 +- .../ringoame196_s_mcPlugin/events/Events.kt | 12 ++++++++- .../notion/NotifierServerStart.kt | 24 ++++++++++++++++++ src/main/resources/config.yml | 3 ++- 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 python-server/requirements.txt create mode 100644 python-server/server.py create mode 100644 src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt diff --git a/python-server/requirements.txt b/python-server/requirements.txt new file mode 100644 index 0000000..f0615cf --- /dev/null +++ b/python-server/requirements.txt @@ -0,0 +1,2 @@ +fastapi +uvicorn \ No newline at end of file diff --git a/python-server/server.py b/python-server/server.py new file mode 100644 index 0000000..51aaafc --- /dev/null +++ b/python-server/server.py @@ -0,0 +1,25 @@ +import winsound +from fastapi import FastAPI, HTTPException +import uvicorn + +app = FastAPI() + +@app.get("/notify/startup") +@app.post("/notify/startup") +async def notify_startup(): + """マイクラの起動通知を受け取るエンドポイント""" + print("🔔 マイクラの起動通知を受け取りました!") + + try: + winsound.Beep(1000, 200) # 1回目 + winsound.Beep(1500, 300) # 2回目(高めの音) + except Exception as e: + print(f"⚠️ 音の再生に失敗しました: {e}") + + return {"status": "success", "message": "通知を受け取り、音を鳴らしました!"} + + +if __name__ == "__main__": + # ローカルのポート 8000番 でサーバーを起動します + print("🚀 Python通知サーバーを起動します... (http://localhost:8000/notify/startup)") + uvicorn.run(app, host="0.0.0.0", port=8000) \ No newline at end of file diff --git a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/core/Main.kt b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/core/Main.kt index 642b1ad..1598e4d 100644 --- a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/core/Main.kt +++ b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/core/Main.kt @@ -14,7 +14,7 @@ class Main : JavaPlugin() { plugin.saveDefaultConfig() // configファイル生成 - server.pluginManager.registerEvents(Events(), plugin) + server.pluginManager.registerEvents(Events(plugin), plugin) // コマンド val devCommand = getCommand("dev") diff --git a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/events/Events.kt b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/events/Events.kt index bc36c85..c54d660 100644 --- a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/events/Events.kt +++ b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/events/Events.kt @@ -1,5 +1,15 @@ package com.github.ringoame196_s_mcPlugin.events +import com.github.ringoame196_s_mcPlugin.notion.NotifierServerStart +import org.bukkit.event.EventHandler import org.bukkit.event.Listener +import org.bukkit.event.server.ServerLoadEvent +import org.bukkit.plugin.Plugin -class Events : Listener +class Events(private val plugin: Plugin) : Listener { + @EventHandler + fun onServerLoad(e: ServerLoadEvent) { + val notionURL = plugin.config.getString("NotionURL") ?: return + NotifierServerStart.notifier(notionURL) + } +} diff --git a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt new file mode 100644 index 0000000..dd34125 --- /dev/null +++ b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt @@ -0,0 +1,24 @@ +package com.github.ringoame196_s_mcPlugin.notion + +import java.net.HttpURLConnection +import java.net.URL + +object NotifierServerStart { + fun notifier(urlText: String) { + Thread { + try { + val url = URL(urlText) + val conn = url.openConnection() as HttpURLConnection + conn.requestMethod = "POST" + conn.connectTimeout = 3000 // 接続タイムアウト(ms) + conn.readTimeout = 3000 // 読み込みタイムアウト(ms) + + val responseCode = conn.responseCode + println("通知送信結果: $responseCode") + conn.disconnect() + } catch (e: Exception) { + println("⚠️ Pythonサーバーへの通知に失敗しました: ${e.message}") + } + }.start() + } +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 92f5087..825f874 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,2 +1,3 @@ Port: 25585 -ReloadCommand : "pluginmanager reload @pluginName" \ No newline at end of file +ReloadCommand : "pluginmanager reload @pluginName" +NotionURL : "" \ No newline at end of file From 7694e2c776a646c1958c6f505e73062bd4b857bb Mon Sep 17 00:00:00 2001 From: RIngoame196 <132573268+Ringoame196@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:36:48 +0900 Subject: [PATCH 2/2] =?UTF-8?q?style:=20=E3=83=AA=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt index dd34125..0c33104 100644 --- a/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt +++ b/src/main/kotlin/com/github/ringoame196_s_mcPlugin/notion/NotifierServerStart.kt @@ -21,4 +21,4 @@ object NotifierServerStart { } }.start() } -} \ No newline at end of file +}