diff --git a/README.md b/README.md index e265b8b..54ab0b1 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ A real-time Earthquake Early Warning(EEW) plugin for Minecraft Server. * **Supports Spigot/Paper/Folia 1.13+.** * **Receives Japan JMA EEW.** * **Receives JMA final reports.** +* **Receives Taiwan CWB EEW.** * **Receives Sichuan China EEW.** * **Broadcast messages to chat.** * **Broadcast messages to title.** * **Alerts when an earthquake is detected.** * **Allows manual get earthquake information.** * **Customizable broadcast messages.** -* **Customizable intensity colors.** * **Customizable alert sounds.** * **Customizable EEW switch.** * **Supports EEW send test.** @@ -21,7 +21,7 @@ A real-time Earthquake Early Warning(EEW) plugin for Minecraft Server. ## Commands * List available commands: /eew -* Get the JMA final report /eew final +* Get earthquake information: /eew info * Run EEW send test: /eew test (need admin) * Reload configuration: /eew reload (need admin) @@ -35,6 +35,7 @@ A real-time Earthquake Early Warning(EEW) plugin for Minecraft Server. ![1.png](https://s2.loli.net/2023/07/12/QSyfaT8DxYBdcs3.png) ![2.png](https://s2.loli.net/2023/07/12/SB3jP2TslVDnR4F.png) ![3.png](https://s2.loli.net/2023/07/12/d58aXyUEieQDN7Z.png) +![4.png](https://s2.loli.net/2023/07/12/y16andOfi4FhkuU.png) ![5.png](https://s2.loli.net/2023/07/12/XMtCy2UfjOqIdY1.png) ## Bstats diff --git a/README_new.md b/README_new.md deleted file mode 100644 index 54ab0b1..0000000 --- a/README_new.md +++ /dev/null @@ -1,43 +0,0 @@ -# MCEEW - -A real-time Earthquake Early Warning(EEW) plugin for Minecraft Server. - -## Features - -* **Supports Spigot/Paper/Folia 1.13+.** -* **Receives Japan JMA EEW.** -* **Receives JMA final reports.** -* **Receives Taiwan CWB EEW.** -* **Receives Sichuan China EEW.** -* **Broadcast messages to chat.** -* **Broadcast messages to title.** -* **Alerts when an earthquake is detected.** -* **Allows manual get earthquake information.** -* **Customizable broadcast messages.** -* **Customizable alert sounds.** -* **Customizable EEW switch.** -* **Supports EEW send test.** - -## Commands - -* List available commands: /eew -* Get earthquake information: /eew info -* Run EEW send test: /eew test (need admin) -* Reload configuration: /eew reload (need admin) - -## Downloads - -* [SpigotMC (Recommend)](https://acg.kr/mceew) -* [GitHub Releases](https://github.com/TenkyuChimata/MCEEW/releases/latest) - -## Screenshots - -![1.png](https://s2.loli.net/2023/07/12/QSyfaT8DxYBdcs3.png) -![2.png](https://s2.loli.net/2023/07/12/SB3jP2TslVDnR4F.png) -![3.png](https://s2.loli.net/2023/07/12/d58aXyUEieQDN7Z.png) -![4.png](https://s2.loli.net/2023/07/12/y16andOfi4FhkuU.png) -![5.png](https://s2.loli.net/2023/07/12/XMtCy2UfjOqIdY1.png) - -## Bstats - -[![Bstats](https://bstats.org/signatures/bukkit/MCEEW.svg)](https://bstats.org/plugin/bukkit/MCEEW/17261) diff --git a/pom.xml b/pom.xml index de88ce4..ab28343 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ jp.wolfx MCEEW - 2.2.1-b8 + 2.2.1 jar MCEEW diff --git a/src/main/java/jp/wolfx/mceew/MCEEW.java b/src/main/java/jp/wolfx/mceew/MCEEW.java index 209e029..b5f9836 100644 --- a/src/main/java/jp/wolfx/mceew/MCEEW.java +++ b/src/main/java/jp/wolfx/mceew/MCEEW.java @@ -87,24 +87,20 @@ private static boolean isFolia() { } } - private void mceewScheduler(boolean eewBoolean, boolean jpEewBoolean, boolean finalBoolean, boolean scEewBoolean, boolean cwbEewBoolean, boolean updaterBoolean) { + private void mceewScheduler(boolean jpEewBoolean, boolean finalBoolean, boolean scEewBoolean, boolean cwbEewBoolean, boolean updaterBoolean) { if (!folia) { - Bukkit.getLogger().info("[MCEEW] Using Bukkit API for Scheduler"); Bukkit.getScheduler().runTaskTimerAsynchronously(this, this::getEewData, 20L, 20L); - if (eewBoolean) { - Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> eewChecker(jpEewBoolean, finalBoolean, scEewBoolean, cwbEewBoolean), 20L, 20L); - } + Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> eewChecker(jpEewBoolean, finalBoolean, scEewBoolean, cwbEewBoolean), 20L, 20L); if (updaterBoolean) { + Bukkit.getLogger().info("[MCEEW] Using Bukkit API for Scheduler"); Bukkit.getScheduler().runTaskAsynchronously(this, this::updater); } } else { - Bukkit.getLogger().info("[MCEEW] Using Folia API for Scheduler"); Plugin plugin = this; Bukkit.getAsyncScheduler().runAtFixedRate(plugin, task1 -> getEewData(), 1L, 1L, TimeUnit.SECONDS); - if (eewBoolean) { - Bukkit.getAsyncScheduler().runAtFixedRate(plugin, task2 -> eewChecker(jpEewBoolean, finalBoolean, scEewBoolean, cwbEewBoolean), 1L, 1L, TimeUnit.SECONDS); - } + Bukkit.getAsyncScheduler().runAtFixedRate(plugin, task2 -> eewChecker(jpEewBoolean, finalBoolean, scEewBoolean, cwbEewBoolean), 1L, 1L, TimeUnit.SECONDS); if (updaterBoolean) { + Bukkit.getLogger().info("[MCEEW] Using Folia API for Scheduler"); Bukkit.getAsyncScheduler().runNow(plugin, task3 -> updater()); } } @@ -190,14 +186,14 @@ private void eewChecker(boolean jpEewBoolean, boolean finalBoolean, boolean scEe if (jpEewBoolean && jmaEewData != null) { jmaEewExecute(); } - if (finalBoolean && jmaEqlistData != null) { - jmaEqlistExecute(); + if (jmaEqlistData != null) { + jmaEqlistExecute(finalBoolean); } - if (scEewBoolean && scEewData != null) { - scEewExecute(); + if (scEewData != null) { + scEewExecute(scEewBoolean); } - if (cwbEewBoolean && cwbEewData != null) { - cwbEewExecute(); + if (cwbEewData != null) { + cwbEewExecute(cwbEewBoolean); } } @@ -243,7 +239,7 @@ private static void jmaEewExecute() { } } - private static void jmaEqlistExecute() { + private static void jmaEqlistExecute(Boolean finalBoolean) { if (!Objects.equals(jmaEqlistData.get("md5").getAsString(), final_md5)) { String time_str = jmaEqlistData.get("No1").getAsJsonObject().get("time").getAsString(); String region = jmaEqlistData.get("No1").getAsJsonObject().get("location").getAsString(); @@ -256,15 +252,17 @@ private static void jmaEqlistExecute() { if (debug_bool) { Bukkit.getLogger().info("[MCEEW] Japan final report updated."); } - Bukkit.broadcastMessage( - final_broadcast_message. - replaceAll("%origin_time%", origin_time). - replaceAll("%region%", region). - replaceAll("%mag%", mag). - replaceAll("%depth%", depth). - replaceAll("%shindo%", getShindoColor(shindo)). - replaceAll("%info%", info) - ); + if (finalBoolean) { + Bukkit.broadcastMessage( + final_broadcast_message. + replaceAll("%origin_time%", origin_time). + replaceAll("%region%", region). + replaceAll("%mag%", mag). + replaceAll("%depth%", depth). + replaceAll("%shindo%", getShindoColor(shindo)). + replaceAll("%info%", info) + ); + } } final_md5 = jmaEqlistData.get("md5").getAsString(); final_info.clear(); @@ -281,7 +279,7 @@ private static void jmaEqlistExecute() { } } - private static void scEewExecute() { + private static void scEewExecute(Boolean scEewBoolean) { if (!Objects.equals(scEewData.get("EventID").getAsString(), EventID)) { String report_time = scEewData.get("ReportTime").getAsString(); String num = scEewData.get("ReportNum").getAsString(); @@ -299,7 +297,9 @@ private static void scEewExecute() { if (debug_bool) { Bukkit.getLogger().info("[MCEEW] Sichuan EEW detected."); } - scEewAction(report_time, origin_time, num, lat, lon, region, mag, depth + "km", getIntensityColor(intensity)); + if (scEewBoolean) { + scEewAction(report_time, origin_time, num, lat, lon, region, mag, depth + "km", getIntensityColor(intensity)); + } } EventID = scEewData.get("EventID").getAsString(); sc_info.clear(); @@ -319,7 +319,7 @@ private static void scEewExecute() { } } - private static void cwbEewExecute() { + private static void cwbEewExecute(Boolean cwbEewBoolean) { if (!Objects.equals(cwbEewData.get("ReportTime").getAsString(), cwbTS)) { String report_time = cwbEewData.get("ReportTime").getAsString(); String num = cwbEewData.get("ReportNum").getAsString(); @@ -333,7 +333,9 @@ private static void cwbEewExecute() { if (debug_bool) { Bukkit.getLogger().info("[MCEEW] Taiwan EEW detected."); } - cwbEewAction(report_time, origin_time, num, lat, lon, region, mag, depth); + if (cwbEewBoolean) { + cwbEewAction(report_time, origin_time, num, lat, lon, region, mag, depth); + } } cwbTS = cwbEewData.get("ReportTime").getAsString(); cwb_info.clear(); @@ -769,7 +771,7 @@ private void loadEew(boolean first) { cwb_alert_sound_type = this.getConfig().getString("Sound.Taiwan.type"); cwb_alert_sound_volume = this.getConfig().getDouble("Sound.Taiwan.volume"); cwb_alert_sound_pitch = this.getConfig().getDouble("Sound.Taiwan.pitch"); - this.mceewScheduler(this.getConfig().getBoolean("EEW"), this.getConfig().getBoolean("enable_jp"), this.getConfig().getBoolean("Action.final"), this.getConfig().getBoolean("enable_sc"), this.getConfig().getBoolean("enable_cwb"), first); + this.mceewScheduler(this.getConfig().getBoolean("enable_jp"), this.getConfig().getBoolean("Action.final"), this.getConfig().getBoolean("enable_sc"), this.getConfig().getBoolean("enable_cwb"), first); } @Override diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 54265c5..849b61b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -24,16 +24,13 @@ # \n Change to next line ######################## -# Enable all EEW -EEW: true - -# Enable Japan JMA EEW +# Enable Japan JMA EEW broadcast enable_jp: true -# Enable Sichuan EEW +# Enable Sichuan EEW broadcast enable_sc: true -# Enable Taiwan CWB EEW +# Enable Taiwan CWB EEW broadcast enable_cwb: true # Set the time format