From 3726ce988df8ad0faef3e92b070c29fe8d5f6185 Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Tue, 25 Jan 2022 04:47:06 +0900 Subject: [PATCH 1/5] ci: Added Check using System.out/err.print Action --- .github/workflows/check-system-print.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/check-system-print.yml diff --git a/.github/workflows/check-system-print.yml b/.github/workflows/check-system-print.yml new file mode 100644 index 000000000..203dc3f2b --- /dev/null +++ b/.github/workflows/check-system-print.yml @@ -0,0 +1,24 @@ +name: Check using System.out/err.print + +on: [ push, pull_request ] + +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-check -level=warning + cat ../system-prints.txt + if [ "$COUNT" != "0" ]; then + echo "Found System.out/err.print in Java source files" + exit 1 + fi From 5404d51b1db253695a62c9bd226d48224b6256d8 Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Tue, 25 Jan 2022 04:51:26 +0900 Subject: [PATCH 2/5] ci: Fix REVIEWDOG_GITHUB_API_TOKEN --- .github/workflows/check-system-print.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-system-print.yml b/.github/workflows/check-system-print.yml index 203dc3f2b..c1f720103 100644 --- a/.github/workflows/check-system-print.yml +++ b/.github/workflows/check-system-print.yml @@ -22,3 +22,5 @@ jobs: 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 From 2ba772f57430a97f6e04ad8d607cd8972b45bfe3 Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Tue, 25 Jan 2022 04:54:37 +0900 Subject: [PATCH 3/5] ci: fix github-pr-review --- .github/workflows/check-system-print.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-system-print.yml b/.github/workflows/check-system-print.yml index c1f720103..52a2ff473 100644 --- a/.github/workflows/check-system-print.yml +++ b/.github/workflows/check-system-print.yml @@ -16,7 +16,7 @@ jobs: - 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-check -level=warning + 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" From 35bae1f8f4ed3a2baf3391403e0d8fc92062f605 Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Tue, 25 Jan 2022 04:55:42 +0900 Subject: [PATCH 4/5] ci: fix pull_request_target --- .github/workflows/check-system-print.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-system-print.yml b/.github/workflows/check-system-print.yml index 52a2ff473..b654c6e87 100644 --- a/.github/workflows/check-system-print.yml +++ b/.github/workflows/check-system-print.yml @@ -1,6 +1,6 @@ name: Check using System.out/err.print -on: [ push, pull_request ] +on: [ push, pull_request_target ] jobs: check-system-print: From 0a86e41542822698838fb7630f0d30e58210f2b3 Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Tue, 25 Jan 2022 05:06:26 +0900 Subject: [PATCH 5/5] fix: System.out.print --- .../com/jaoafa/mymaid4/event/Event_MCBansLoginCheck.java | 2 +- .../com/jaoafa/mymaid4/event/Event_NewPlayerAutoBlMap.java | 6 +++--- src/main/java/com/jaoafa/mymaid4/lib/MyMaidLibrary.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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) {