2022-12-15 04:54:43 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 14 Dec 2022 15:52:11 -0800
Subject: [PATCH] Improve logging and errors
2023-10-23 19:07:44 +02:00
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2022-12-15 04:54:43 +01:00
2023-10-23 19:07:44 +02:00
diff --git a/src/main/java/net/minecraft/advancements/AdvancementTree.java b/src/main/java/net/minecraft/advancements/AdvancementTree.java
2024-01-16 12:41:40 +01:00
index 938fe76677139e7e99698b61691bfcadf70dbd87..a017ebf550e3430c14a7159baa9a644530a0b5ab 100644
2023-10-23 19:07:44 +02:00
--- a/src/main/java/net/minecraft/advancements/AdvancementTree.java
+++ b/src/main/java/net/minecraft/advancements/AdvancementTree.java
@@ -35,7 +35,7 @@ public class AdvancementTree {
this.remove(advancementnode1);
}
- AdvancementTree.LOGGER.info("Forgot about advancement {}", advancement.holder());
2024-01-16 12:41:40 +01:00
+ AdvancementTree.LOGGER.debug("Forgot about advancement {}", advancement.holder()); // Paper - Improve logging and errors
2023-10-23 19:07:44 +02:00
this.nodes.remove(advancement.holder().id());
if (advancement.parent() == null) {
this.roots.remove(advancement);
2023-12-02 22:17:35 +01:00
@@ -77,7 +77,7 @@ public class AdvancementTree {
}
}
- // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload
2024-01-16 12:41:40 +01:00
+ // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload // Paper - Improve logging and errors; you say it was moved... but it wasn't :) it should be moved however, since this is called when the API creates an advancement
2023-12-02 22:17:35 +01:00
}
private boolean tryInsert(AdvancementHolder advancement) {
diff --git a/src/main/java/net/minecraft/server/ServerAdvancementManager.java b/src/main/java/net/minecraft/server/ServerAdvancementManager.java
2024-01-16 12:41:40 +01:00
index 536f0c496ce36ca3248fc6eeac9bbd77214a36f9..31718823250a1490b783f426fff65bf5a067b6f4 100644
2023-12-02 22:17:35 +01:00
--- a/src/main/java/net/minecraft/server/ServerAdvancementManager.java
+++ b/src/main/java/net/minecraft/server/ServerAdvancementManager.java
2023-12-06 17:21:56 +01:00
@@ -66,6 +66,7 @@ public class ServerAdvancementManager extends SimpleJsonResourceReloadListener {
2023-12-02 22:17:35 +01:00
AdvancementTree advancementtree = new AdvancementTree();
advancementtree.addAll(this.advancements.values());
2024-01-16 12:41:40 +01:00
+ LOGGER.info("Loaded {} advancements", advancementtree.nodes().size()); // Paper - Improve logging and errors; moved from AdvancementTree#addAll
2023-12-02 22:17:35 +01:00
Iterator iterator = advancementtree.roots().iterator();
while (iterator.hasNext()) {
2023-06-17 04:27:45 +02:00
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-02-05 12:31:51 +01:00
index 17c059020eae2c125971b4f6ffe90db46fb85cd2..6e1f1bd674e02426f42d013e2b0995d45e37ace0 100644
2023-06-17 04:27:45 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-02-05 12:31:51 +01:00
@@ -3305,7 +3305,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-06-17 04:27:45 +02:00
2023-09-22 17:51:48 +02:00
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
2023-06-17 04:27:45 +02:00
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {
- ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage());
2024-01-16 12:41:40 +01:00
+ // ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage()); // Paper - Improve logging and errors
2023-06-17 04:27:45 +02:00
this.disconnect(profilepublickey_b.getComponent(), profilepublickey_b.kickCause); // Paper - kick event causes
}
2022-12-15 04:54:43 +01:00
diff --git a/src/main/java/net/minecraft/server/packs/PathPackResources.java b/src/main/java/net/minecraft/server/packs/PathPackResources.java
2024-01-16 12:41:40 +01:00
index 89aa86a49eda563c82ccedc99641e699f8e578b0..3edd14ce90edf98798b89921ad18547809de5d2c 100644
2022-12-15 04:54:43 +01:00
--- a/src/main/java/net/minecraft/server/packs/PathPackResources.java
+++ b/src/main/java/net/minecraft/server/packs/PathPackResources.java
2023-09-22 17:51:48 +02:00
@@ -108,6 +108,12 @@ public class PathPackResources extends AbstractPackResources {
2022-12-15 04:54:43 +01:00
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) {
for(Path path2 : directoryStream) {
String string = path2.getFileName().toString();
2024-01-16 12:41:40 +01:00
+ // Paper start - Improve logging and errors
2022-12-15 04:54:43 +01:00
+ if (!Files.isDirectory(path2)) {
+ LOGGER.error("Invalid directory entry: {} in {}.", string, this.root, new java.nio.file.NotDirectoryException(string));
+ continue;
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - Improve logging and errors
2023-09-22 17:51:48 +02:00
if (ResourceLocation.isValidNamespace(string)) {
2022-12-15 04:54:43 +01:00
set.add(string);
} else {
2023-12-02 22:17:35 +01:00
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
2024-01-16 12:41:40 +01:00
index 4259181bab2dc4f2d0409b56fdf81d966003376d..a0ab3c55826af292d1cdac05648139b4d31f1376 100644
2023-12-02 22:17:35 +01:00
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -84,7 +84,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
return entry1.getValue(); // CraftBukkit // Paper - decompile fix - *shrugs internally* // todo: is this needed anymore?
}));
this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
- RecipeManager.LOGGER.info("Loaded {} recipes", map1.size());
2024-01-16 12:41:40 +01:00
+ RecipeManager.LOGGER.info("Loaded {} recipes", this.byName.size()); // Paper - Improve logging and errors; log correct number of recipes
2023-12-02 22:17:35 +01:00
}
// CraftBukkit start
2022-12-15 04:54:43 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java
2024-01-16 12:41:40 +01:00
index 080cca90f15d90249b7a38f33286ae2f735ba7d9..fde9aadd6c688b9797a6755f9d214918047598a0 100644
2022-12-15 04:54:43 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java
+++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java
@@ -44,6 +44,7 @@ import org.bukkit.material.MaterialData;
*/
@Deprecated
public final class CraftLegacy {
2024-01-16 12:41:40 +01:00
+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper - Improve logging and errors
2022-12-15 04:54:43 +01:00
private static final Map<Byte, Material> SPAWN_EGGS = new HashMap<>();
private static final Set<String> whitelistedStates = new HashSet<>(Arrays.asList("explode", "check_decay", "decayable", "facing"));
@@ -255,7 +256,7 @@ public final class CraftLegacy {
}
static {
- System.err.println("Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!");
2024-01-16 12:41:40 +01:00
+ LOGGER.warn("Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!"); // Paper - Improve logging and errors; doesn't need to be an error
2022-12-15 04:54:43 +01:00
if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) {
new Exception().printStackTrace();
}