mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
added time and date to error report
This commit is contained in:
parent
a36f487fff
commit
8f6d9209c1
@ -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 <T>
|
||||
* The type of {@link Throwable} which has spawned this {@link ErrorReport}
|
||||
*
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
@ -54,7 +56,7 @@ public class ErrorReport<T extends Throwable> {
|
||||
* 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<T extends Throwable> {
|
||||
/**
|
||||
* 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<T extends Throwable> {
|
||||
@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<T extends Throwable> {
|
||||
|
||||
/**
|
||||
* 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<T extends Throwable> {
|
||||
|
||||
/**
|
||||
* 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<T extends Throwable> {
|
||||
|
||||
/**
|
||||
* This returns the {@link Throwable} that was thrown.
|
||||
*
|
||||
*
|
||||
* @return The {@link Throwable}
|
||||
*/
|
||||
@Nonnull
|
||||
@ -154,7 +160,7 @@ public class ErrorReport<T extends Throwable> {
|
||||
|
||||
/**
|
||||
* 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<T extends Throwable> {
|
||||
* 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
|
||||
|
Loading…
Reference in New Issue
Block a user