From 8f6d9209c1491abfad32bfcff5887181c7fee4e9 Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Fri, 28 May 2021 18:16:24 +0200 Subject: [PATCH 1/6] added time and date to error report --- .../slimefun4/api/ErrorReport.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index b0673c927..e8832f179 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -3,9 +3,11 @@ package io.github.thebusybiscuit.slimefun4.api; import java.io.File; import java.io.PrintStream; import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; @@ -34,10 +36,10 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; * To ensure that the console doesn't get too spammy, we destroy the block and generate * an {@link ErrorReport} instead. * Error reports get saved in the plugin folder. - * + * * @param * The type of {@link Throwable} which has spawned this {@link ErrorReport} - * + * * @author TheBusyBiscuit * */ @@ -54,7 +56,7 @@ public class ErrorReport { * This is the base constructor for an {@link ErrorReport}. It will only * print the necessary info and provides a {@link Consumer} for any more detailed * needs. - * + * * @param throwable * The {@link Throwable} which caused this {@link ErrorReport}. * @param addon @@ -73,7 +75,7 @@ public class ErrorReport { /** * This constructs a new {@link ErrorReport} for the given {@link Location} and * {@link SlimefunItem}. - * + * * @param throwable * The {@link Throwable} which caused this {@link ErrorReport}. * @param l @@ -84,6 +86,10 @@ public class ErrorReport { @ParametersAreNonnullByDefault public ErrorReport(T throwable, Location l, SlimefunItem item) { this(throwable, item.getAddon(), stream -> { + Date date = new Date(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + stream.println(formatter.format(date)); stream.println("Block Info:"); stream.println(" World: " + l.getWorld().getName()); stream.println(" X: " + l.getBlockX()); @@ -116,7 +122,7 @@ public class ErrorReport { /** * This constructs a new {@link ErrorReport} for the given {@link SlimefunItem}. - * + * * @param throwable * The {@link Throwable} which caused this {@link ErrorReport}. * @param item @@ -134,7 +140,7 @@ public class ErrorReport { /** * This method returns the {@link File} this {@link ErrorReport} has been written to. - * + * * @return The {@link File} for this {@link ErrorReport} */ @Nonnull @@ -144,7 +150,7 @@ public class ErrorReport { /** * This returns the {@link Throwable} that was thrown. - * + * * @return The {@link Throwable} */ @Nonnull @@ -154,7 +160,7 @@ public class ErrorReport { /** * This method returns the amount of {@link ErrorReport ErrorReports} created in this session. - * + * * @return The amount of {@link ErrorReport ErrorReports} created. */ public static int count() { @@ -259,7 +265,7 @@ public class ErrorReport { * This helper method wraps the given {@link Runnable} into a try-catch block. * When an {@link Exception} occurs, a new {@link ErrorReport} will be generated using * the provided {@link Function}. - * + * * @param function * The {@link Function} to generate a new {@link ErrorReport} * @param runnable From 3205d83e3599329dbc9d014fab4da4637fcd197b Mon Sep 17 00:00:00 2001 From: J3fftw <44972470+J3fftw1@users.noreply.github.com> Date: Fri, 28 May 2021 18:23:17 +0200 Subject: [PATCH 2/6] Update src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java Co-authored-by: Daniel Walsh --- .../io/github/thebusybiscuit/slimefun4/api/ErrorReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index e8832f179..f76baace4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -89,7 +89,7 @@ public class ErrorReport { Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - stream.println(formatter.format(date)); + stream.println("Error Generated: " + formatter.format(new Date())); stream.println("Block Info:"); stream.println(" World: " + l.getWorld().getName()); stream.println(" X: " + l.getBlockX()); From ba4767ae05bfffec7328c630c05b909552cb1903 Mon Sep 17 00:00:00 2001 From: J3fftw <44972470+J3fftw1@users.noreply.github.com> Date: Fri, 28 May 2021 18:24:28 +0200 Subject: [PATCH 3/6] Update ErrorReport.java --- .../java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index f76baace4..9788aae91 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -86,7 +86,6 @@ public class ErrorReport { @ParametersAreNonnullByDefault public ErrorReport(T throwable, Location l, SlimefunItem item) { this(throwable, item.getAddon(), stream -> { - Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); stream.println("Error Generated: " + formatter.format(new Date())); From ab534dc4f43d2d73992c5576dbb0724603f1798d Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Fri, 28 May 2021 18:28:49 +0200 Subject: [PATCH 4/6] did requested changes --- .../io/github/thebusybiscuit/slimefun4/api/ErrorReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 9788aae91..a2c922bee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -47,6 +47,7 @@ public class ErrorReport { private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm", Locale.ROOT); private static final AtomicInteger count = new AtomicInteger(0); + private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private SlimefunAddon addon; private T throwable; @@ -86,7 +87,6 @@ public class ErrorReport { @ParametersAreNonnullByDefault public ErrorReport(T throwable, Location l, SlimefunItem item) { this(throwable, item.getAddon(), stream -> { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); stream.println("Error Generated: " + formatter.format(new Date())); stream.println("Block Info:"); From 1b2d3e683eb4535e5ea89d8d72e77e5733c9b565 Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Fri, 28 May 2021 18:30:35 +0200 Subject: [PATCH 5/6] removed redundant formatter --- .../io/github/thebusybiscuit/slimefun4/api/ErrorReport.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index a2c922bee..6c37f7cab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -47,7 +47,6 @@ public class ErrorReport { private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm", Locale.ROOT); private static final AtomicInteger count = new AtomicInteger(0); - private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private SlimefunAddon addon; private T throwable; @@ -88,7 +87,7 @@ public class ErrorReport { public ErrorReport(T throwable, Location l, SlimefunItem item) { this(throwable, item.getAddon(), stream -> { - stream.println("Error Generated: " + formatter.format(new Date())); + stream.println("Error Generated: " + dateFormat.format(LocalDateTime.now())); stream.println("Block Info:"); stream.println(" World: " + l.getWorld().getName()); stream.println(" X: " + l.getBlockX()); From 990cc48feb56e61cc3695f1d4e72e74b8ec1049e Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Fri, 28 May 2021 19:38:22 +0200 Subject: [PATCH 6/6] did requested changes --- .../github/thebusybiscuit/slimefun4/api/ErrorReport.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 6c37f7cab..64e6ae59c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -3,11 +3,9 @@ package io.github.thebusybiscuit.slimefun4.api; import java.io.File; import java.io.PrintStream; import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; @@ -86,8 +84,6 @@ public class ErrorReport { @ParametersAreNonnullByDefault public ErrorReport(T throwable, Location l, SlimefunItem item) { this(throwable, item.getAddon(), stream -> { - - stream.println("Error Generated: " + dateFormat.format(LocalDateTime.now())); stream.println("Block Info:"); stream.println(" World: " + l.getWorld().getName()); stream.println(" X: " + l.getBlockX()); @@ -172,6 +168,9 @@ public class ErrorReport { try (PrintStream stream = new PrintStream(file, StandardCharsets.UTF_8.name())) { stream.println(); + stream.println("Error Generated: " + dateFormat.format(LocalDateTime.now())); + stream.println(); + stream.println("Java Environment:"); stream.println(" Operating System: " + System.getProperty("os.name")); stream.println(" Java Version: " + System.getProperty("java.version"));