Skip to content

Commit

Permalink
Fix CENC final report message & Add config checker
Browse files Browse the repository at this point in the history
  • Loading branch information
TenkyuChimata committed Dec 26, 2023
1 parent 35d6330 commit 1e9be81
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>jp.wolfx</groupId>
<artifactId>MCEEW</artifactId>
<version>2.3.0-b4</version>
<version>2.3.0-b5</version>
<packaging>jar</packaging>

<name>MCEEW</name>
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/jp/wolfx/mceew/MCEEW.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.CompletionStage;

public final class MCEEW extends JavaPlugin {
private static final int current_config = 2;
private static boolean jpEewBoolean;
private static boolean scEewBoolean;
private static boolean cwaEewBoolean;
Expand Down Expand Up @@ -65,6 +66,7 @@ public final class MCEEW extends JavaPlugin {
private static String cwa_alert_sound_type;
private static double cwa_alert_sound_volume;
private static double cwa_alert_sound_pitch;
private static int config_version;
private static String jmaEqlist_md5 = null;
private static String cencEqlist_md5 = null;
private static JsonObject jmaEqlistData = null;
Expand Down Expand Up @@ -159,6 +161,12 @@ private static void playSound(String alert_sound_type, double alert_sound_volume
}
}

private static void checkConfig() {
if (current_config > config_version) {
Bukkit.getLogger().warning("[MCEEW] Configuration update detected, please delete the MCEEW configuration file to update it.");
}
}

private void cancelScheduler() {
if (!folia) {
Bukkit.getScheduler().cancelTasks(this);
Expand Down Expand Up @@ -367,7 +375,7 @@ private static void cencEqlistExecute(Boolean cencEqlistBoolean) {
if (cencEqlist_md5 != null && cencEqlistBoolean) {
Bukkit.broadcastMessage(
cencEqlist_broadcast_message.
replaceAll("%origin_time%", type).
replaceAll("%flag%", type).
replaceAll("%origin_time%", origin_time).
replaceAll("%region%", region).
replaceAll("%mag%", mag).
Expand Down Expand Up @@ -764,6 +772,8 @@ private void loadEew(Boolean first) {
cwa_alert_sound_type = this.getConfig().getString("Sound.Taiwan.type");
cwa_alert_sound_volume = this.getConfig().getDouble("Sound.Taiwan.volume");
cwa_alert_sound_pitch = this.getConfig().getDouble("Sound.Taiwan.pitch");
config_version = this.getConfig().getInt("config-version");
checkConfig();
mceewScheduler(first);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ Sound:
pitch: 1.0

# Do not change this
config-version: 1
config-version: 2

0 comments on commit 1e9be81

Please sign in to comment.