diff --git a/.github/workflows/check-system-print.yml b/.github/workflows/check-system-print.yml new file mode 100644 index 000000000..b654c6e87 --- /dev/null +++ b/.github/workflows/check-system-print.yml @@ -0,0 +1,26 @@ +name: Check using System.out/err.print + +on: [ push, pull_request_target ] + +jobs: + check-system-print: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup reviewdog + uses: reviewdog/action-setup@v1 + + - name: Check using System.out.print + run: | + COUNT=`grep -rE "System\.(out|err)\.print" --include=*.java src/main > ../system-prints.txt || true` + cat ../system-prints.txt | reviewdog -efm="%f:%l" -name="Check using System.out/err.print" -reporter=github-pr-review -level=warning + cat ../system-prints.txt + if [ "$COUNT" != "0" ]; then + echo "Found System.out/err.print in Java source files" + exit 1 + fi + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_MCBansLoginCheck.java b/src/main/java/com/jaoafa/mymaid4/event/Event_MCBansLoginCheck.java index 46b115e8e..2198bf32c 100644 --- a/src/main/java/com/jaoafa/mymaid4/event/Event_MCBansLoginCheck.java +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_MCBansLoginCheck.java @@ -157,7 +157,7 @@ public void run() { JSONObject json; try (Response response = client.newCall(request).execute()) { if (response.code() != 200) { - System.out.printf("OnLoginAfterCheck: APIサーバへの接続に失敗: %s -> %d%n", url, response.code()); + Main.getMyMaidLogger().info("OnLoginAfterCheck: APIサーバへの接続に失敗: %s -> %d%n".formatted(url, response.code())); response.close(); return; } diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_NewPlayerAutoBlMap.java b/src/main/java/com/jaoafa/mymaid4/event/Event_NewPlayerAutoBlMap.java index 6ee63bf11..b26458196 100644 --- a/src/main/java/com/jaoafa/mymaid4/event/Event_NewPlayerAutoBlMap.java +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_NewPlayerAutoBlMap.java @@ -78,12 +78,12 @@ public void run() { Response response = client.newCall(request).execute(); if (response.code() != 200 && response.code() != 302) { - System.out.printf("NewPlayerAutoBlMap: APIサーバへの接続に失敗: %d %s\nhttps://jaoafa.com/cp/?uuid=%s%n", response.code(), Objects.requireNonNull(response.body()).string(), player.getUniqueId()); + Main.getMyMaidLogger().info("NewPlayerAutoBlMap: APIサーバへの接続に失敗: %d %s\nhttps://jaoafa.com/cp/?uuid=%s".formatted(response.code(), Objects.requireNonNull(response.body()).string(), player.getUniqueId())); response.close(); return; } if (response.body() == null) { - System.out.printf("NewPlayerAutoBlMap: APIサーバへの接続に失敗: response.body() is null.\nhttps://jaoafa.com/cp/?uuid=%s%n", player.getUniqueId()); + Main.getMyMaidLogger().info("NewPlayerAutoBlMap: APIサーバへの接続に失敗: response.body() is null.\nhttps://jaoafa.com/cp/?uuid=%s".formatted(player.getUniqueId())); response.close(); return; } @@ -91,7 +91,7 @@ public void run() { ResponseBody body = response.body(); if (body == null) { - System.out.printf("NewPlayerAutoBlMap: ブロック編集マップ取得失敗: body is null.\nhttps://jaoafa.com/cp/?uuid=%s%n", player.getUniqueId()); + Main.getMyMaidLogger().info("NewPlayerAutoBlMap: ブロック編集マップ取得失敗: body is null.\nhttps://jaoafa.com/cp/?uuid=%s".formatted(player.getUniqueId())); return; } diff --git a/src/main/java/com/jaoafa/mymaid4/lib/MyMaidLibrary.java b/src/main/java/com/jaoafa/mymaid4/lib/MyMaidLibrary.java index bca11279f..3e7089902 100644 --- a/src/main/java/com/jaoafa/mymaid4/lib/MyMaidLibrary.java +++ b/src/main/java/com/jaoafa/mymaid4/lib/MyMaidLibrary.java @@ -532,7 +532,7 @@ public static void debug(String message) { if (!Main.getMyMaidConfig().isDevelopmentServer()) { return; } - System.out.printf("DEBUG -> %s%n", message); + Main.getMyMaidLogger().info("DEBUG -> %s".formatted(message)); } public static NamedTextColor getNamedTextColor(String color) {