Skip to content

Commit

Permalink
Add latitude and longitude to JMA final report
Browse files Browse the repository at this point in the history
and optimize handling of version.
  • Loading branch information
TenkyuChimata committed Aug 14, 2023
1 parent 8c7178f commit f324a98
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 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.2.1</version>
<version>2.2.2-b1</version>
<packaging>jar</packaging>

<name>MCEEW</name>
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/jp/wolfx/mceew/MCEEW.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public final class MCEEW extends JavaPlugin {
private static final ArrayList<String> final_info = new ArrayList<>();
private static final ArrayList<String> sc_info = new ArrayList<>();
private static final ArrayList<String> cwb_info = new ArrayList<>();
private final String version = this.getDescription().getVersion().replace("-b", "");
private final String version = this.getDescription().getVersion();
private static final boolean folia = isFolia();

@Override
Expand Down Expand Up @@ -146,7 +146,7 @@ private void updater() {
if (responseData != null) {
JsonObject json = JsonParser.parseString(responseData).getAsJsonObject();
String api_version = json.get("version").getAsString();
if (Integer.parseInt(api_version.replaceAll("\\.", "")) > Integer.parseInt(version.replaceAll("\\.", ""))) {
if (Integer.parseInt(api_version.replaceAll("\\.", "")) > Integer.parseInt(version.replaceAll("-b.*", "").replaceAll("\\.", ""))) {
Bukkit.getLogger().warning("[MCEEW] New plugin version v" + api_version + " detected, Please download a new version from https://acg.kr/mceew");
} else {
Bukkit.getLogger().info("[MCEEW] You are running the latest version.");
Expand Down Expand Up @@ -216,7 +216,7 @@ private static void jmaEewExecute() {
type = "仮定震源";
}
if (jmaEewData.get("isFinal").getAsBoolean()) {
if (!type.equals("")) {
if (!type.isEmpty()) {
type = type + " (最終報)";
} else {
type = "最終報";
Expand Down Expand Up @@ -245,6 +245,8 @@ private static void jmaEqlistExecute(Boolean finalBoolean) {
String region = jmaEqlistData.get("No1").getAsJsonObject().get("location").getAsString();
String mag = jmaEqlistData.get("No1").getAsJsonObject().get("magnitude").getAsString();
String depth = jmaEqlistData.get("No1").getAsJsonObject().get("depth").getAsString();
String latitude = jmaEqlistData.get("No1").getAsJsonObject().get("latitude").getAsString();
String longitude = jmaEqlistData.get("No1").getAsJsonObject().get("longitude").getAsString();
String shindo = jmaEqlistData.get("No1").getAsJsonObject().get("shindo").getAsString();
String info = jmaEqlistData.get("No1").getAsJsonObject().get("info").getAsString();
String origin_time = getDate("yyyy/MM/dd HH:mm", time_format_final, "Asia/Tokyo", time_str);
Expand All @@ -259,6 +261,8 @@ private static void jmaEqlistExecute(Boolean finalBoolean) {
replaceAll("%region%", region).
replaceAll("%mag%", mag).
replaceAll("%depth%", depth).
replaceAll("%lat%", latitude).
replaceAll("%lon%", longitude).
replaceAll("%shindo%", getShindoColor(shindo)).
replaceAll("%info%", info)
);
Expand All @@ -270,6 +274,8 @@ private static void jmaEqlistExecute(Boolean finalBoolean) {
final_info.add(region);
final_info.add(mag);
final_info.add(depth);
final_info.add(latitude);
final_info.add(longitude);
final_info.add(shindo);
final_info.add(info);
} else {
Expand Down Expand Up @@ -392,8 +398,10 @@ private static void getEewInfo(int flag, CommandSender sender) {
replaceAll("%region%", final_info.get(1)).
replaceAll("%mag%", final_info.get(2)).
replaceAll("%depth%", final_info.get(3)).
replaceAll("%shindo%", getShindoColor(final_info.get(4))).
replaceAll("%info%", final_info.get(5))
replaceAll("%lat%", final_info.get(4)).
replaceAll("%lon%", final_info.get(5)).
replaceAll("%shindo%", getShindoColor(final_info.get(6))).
replaceAll("%info%", final_info.get(7))
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# MCEEW configuration
# Last updated on 2.2.1
# Last updated on 2.2.2
#
# API Source: https://api.wolfx.jp
# Plugin Page: https://acg.kr/mceew
Expand Down Expand Up @@ -65,7 +65,7 @@ Message:
subtitle: "&e%region%で震度%shindo%&eの地震"
# Set the Japan final report message format
Final:
broadcast: "&e地震情報\n &e%origin_time% &f発生\n &f震央: &e%region%\n &fマグニチュード: &e%mag%\n &f深さ: &e%depth%\n &f最大震度: &e%shindo%\n &f津波情報: &e%info%"
broadcast: "&e地震情報\n &e%origin_time% &f発生\n &f震央: &e%region% (北緯: &e%lat%度 東経: &e%lon%度)\n &fマグニチュード: &e%mag%\n &f深さ: &e%depth%\n &f最大震度: &e%shindo%\n &f津波情報: &e%info%"
# Set the Sichuan EEW message format
Sichuan:
broadcast: "&c四川地震预警 | 第%num%报\n &e%origin_time% &f发生\n &f震中: &e%region% (北纬: &e%lat%度 东经: &e%lon%度)\n &f震级: &e%mag%\n &f深度: &e%depth%\n &f最大烈度: &e%shindo%\n &f更新时间: &e%report_time%"
Expand Down

0 comments on commit f324a98

Please sign in to comment.