Skip to content

Commit

Permalink
Ditch Log4j for future-proofing
Browse files Browse the repository at this point in the history
  • Loading branch information
Motschen committed Feb 22, 2022
1 parent a9190f2 commit 5183b54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/main/java/eu/midnightdust/hats/web/HatLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.client.MinecraftClient;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -19,7 +16,7 @@

@SuppressWarnings("UnstableApiUsage")
public class HatLoader {
public static final Logger logger = LogManager.getLogger("MidnightLib");
public static final System.Logger logger = System.getLogger("MidnightLib");
private final static String HATS_URL = "https://raw.githubusercontent.com/TeamMidnightDust/MidnightHats/master/hats.json";
public static final Type HAT_TYPE = new TypeToken<Map<UUID, PlayerHatData>>(){}.getType();
public static Map<UUID, PlayerHatData> PLAYER_HATS;
Expand All @@ -31,19 +28,19 @@ public static void init() {
try (Reader reader = new InputStreamReader(new URL(HATS_URL).openStream())) {
return GSON.<Map<UUID, PlayerHatData>>fromJson(reader, HAT_TYPE);
} catch (MalformedURLException error) {
logger.log(Level.ERROR, "Unable to load player hats because of connection problems: " + error.getMessage());
logger.log(System.Logger.Level.ERROR, "Unable to load player hats because of connection problems: " + error.getMessage());
} catch (IOException error) {
logger.log(Level.ERROR, "Unable to load player hats because of an I/O Exception: " + error.getMessage());
logger.log(System.Logger.Level.ERROR, "Unable to load player hats because of an I/O Exception: " + error.getMessage());
}

return null;
}).thenAcceptAsync(playerData -> {
if (playerData != null) {
PLAYER_HATS = playerData;
logger.log(Level.INFO, "Player hats successfully loaded!");
System.out.println("(MidnightLib) Player hats successfully loaded!");
} else {
PLAYER_HATS = Collections.emptyMap();
logger.log(Level.WARN, "A problem with the database occurred, the hats could not be initialized.");
logger.log(System.Logger.Level.WARNING, "A problem with the database occurred, the hats could not be initialized.");
}
}, MinecraftClient.getInstance());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.midnightdust.hats.witch;

import eu.midnightdust.hats.web.HatLoader;
import eu.midnightdust.lib.config.MidnightConfig;
import eu.midnightdust.lib.util.MidnightColorUtil;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down

0 comments on commit 5183b54

Please sign in to comment.