Improve logging and errors

Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
This commit is contained in:
Jake Potrebic 2022-12-14 15:52:11 -08:00
parent f64904e777
commit b141cd3d99
6 changed files with 49 additions and 17 deletions

View file

@ -1,11 +1,20 @@
--- a/net/minecraft/advancements/AdvancementTree.java --- a/net/minecraft/advancements/AdvancementTree.java
+++ b/net/minecraft/advancements/AdvancementTree.java +++ b/net/minecraft/advancements/AdvancementTree.java
@@ -35,7 +35,7 @@
this.remove(advancementnode1);
}
- AdvancementTree.LOGGER.info("Forgot about advancement {}", advancement.holder());
+ AdvancementTree.LOGGER.debug("Forgot about advancement {}", advancement.holder()); // Paper - Improve logging and errors
this.nodes.remove(advancement.holder().id());
if (advancement.parent() == null) {
this.roots.remove(advancement);
@@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
} }
} }
- AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); - AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size());
+ // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload + // 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
} }
private boolean tryInsert(AdvancementHolder advancement) { private boolean tryInsert(AdvancementHolder advancement) {

View file

@ -16,7 +16,7 @@
private AdvancementTree tree = new AdvancementTree(); private AdvancementTree tree = new AdvancementTree();
private final HolderLookup.Provider registries; private final HolderLookup.Provider registries;
@@ -37,10 +41,15 @@ @@ -37,13 +41,19 @@
Builder<ResourceLocation, AdvancementHolder> builder = ImmutableMap.builder(); Builder<ResourceLocation, AdvancementHolder> builder = ImmutableMap.builder();
prepared.forEach((minecraftkey, advancement) -> { prepared.forEach((minecraftkey, advancement) -> {
@ -33,3 +33,7 @@
AdvancementTree advancementtree = new AdvancementTree(); AdvancementTree advancementtree = new AdvancementTree();
advancementtree.addAll(this.advancements.values()); advancementtree.addAll(this.advancements.values());
+ LOGGER.info("Loaded {} advancements", advancementtree.nodes().size()); // Paper - Improve logging and errors; moved from AdvancementTree#addAll
Iterator iterator = advancementtree.roots().iterator();
while (iterator.hasNext()) {

View file

@ -215,7 +215,7 @@
InetAddress inetaddress = null; InetAddress inetaddress = null;
if (!this.getLocalIp().isEmpty()) { if (!this.getLocalIp().isEmpty()) {
@@ -143,12 +266,15 @@ @@ -143,34 +266,55 @@
if (this.getPort() < 0) { if (this.getPort() < 0) {
this.setPort(dedicatedserverproperties.serverPort); this.setPort(dedicatedserverproperties.serverPort);
} }
@ -232,7 +232,8 @@
} catch (IOException ioexception) { } catch (IOException ioexception) {
DedicatedServer.LOGGER.warn("**** FAILED TO BIND TO PORT!"); DedicatedServer.LOGGER.warn("**** FAILED TO BIND TO PORT!");
DedicatedServer.LOGGER.warn("The exception was: {}", ioexception.toString()); DedicatedServer.LOGGER.warn("The exception was: {}", ioexception.toString());
@@ -156,21 +282,38 @@ DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
+ if (true) throw new IllegalStateException("Failed to bind to port", ioexception); // Paper - Propagate failed to bind to port error
return false; return false;
} }
@ -276,7 +277,7 @@
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList()); this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME); this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
long i = Util.getNanos(); long i = Util.getNanos();
@@ -178,13 +321,13 @@ @@ -178,13 +322,13 @@
SkullBlockEntity.setup(this.services, this); SkullBlockEntity.setup(this.services, this);
GameProfileCache.setUsesAuthentication(this.usesAuthentication()); GameProfileCache.setUsesAuthentication(this.usesAuthentication());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
@ -292,7 +293,7 @@
} }
if (dedicatedserverproperties.enableQuery) { if (dedicatedserverproperties.enableQuery) {
@@ -197,7 +340,7 @@ @@ -197,7 +341,7 @@
this.rconThread = RconThread.create(this); this.rconThread = RconThread.create(this);
} }
@ -301,7 +302,7 @@
Thread thread1 = new Thread(new ServerWatchdog(this)); Thread thread1 = new Thread(new ServerWatchdog(this));
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER)); thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
@@ -215,6 +358,12 @@ @@ -215,6 +359,12 @@
} }
} }
@ -314,7 +315,7 @@
@Override @Override
public boolean isSpawningMonsters() { public boolean isSpawningMonsters() {
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters(); return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
@@ -227,7 +376,7 @@ @@ -227,7 +377,7 @@
@Override @Override
public void forceDifficulty() { public void forceDifficulty() {
@ -323,7 +324,7 @@
} }
@Override @Override
@@ -286,13 +435,14 @@ @@ -286,13 +436,14 @@
} }
if (this.rconThread != null) { if (this.rconThread != null) {
@ -340,7 +341,7 @@
} }
@Override @Override
@@ -302,19 +452,29 @@ @@ -302,19 +453,29 @@
} }
@Override @Override
@ -376,7 +377,7 @@
} }
} }
@@ -383,7 +543,7 @@ @@ -383,7 +544,7 @@
@Override @Override
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) { public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
@ -385,7 +386,7 @@
return false; return false;
} else if (this.getPlayerList().getOps().isEmpty()) { } else if (this.getPlayerList().getOps().isEmpty()) {
return false; return false;
@@ -453,7 +613,11 @@ @@ -453,7 +614,11 @@
public boolean enforceSecureProfile() { public boolean enforceSecureProfile() {
DedicatedServerProperties dedicatedserverproperties = this.getProperties(); DedicatedServerProperties dedicatedserverproperties = this.getProperties();
@ -398,7 +399,7 @@
} }
@Override @Override
@@ -541,16 +705,52 @@ @@ -541,16 +706,52 @@
@Override @Override
public String getPluginNames() { public String getPluginNames() {
@ -455,7 +456,7 @@
} }
public void storeUsingWhiteList(boolean useWhitelist) { public void storeUsingWhiteList(boolean useWhitelist) {
@@ -660,4 +860,15 @@ @@ -660,4 +861,15 @@
} }
} }
} }

View file

@ -2436,11 +2436,13 @@
} else { } else {
try { try {
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator(); SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
@@ -2046,7 +3503,7 @@ @@ -2045,8 +3502,8 @@
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator)); this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
} catch (ProfilePublicKey.ValidationException profilepublickey_b) { } catch (ProfilePublicKey.ValidationException profilepublickey_b) {
ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage()); - ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage());
- this.disconnect(profilepublickey_b.getComponent()); - this.disconnect(profilepublickey_b.getComponent());
+ // ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage()); // Paper - Improve logging and errors
+ this.disconnect(profilepublickey_b.getComponent(), profilepublickey_b.kickCause); // Paper - kick event causes + this.disconnect(profilepublickey_b.getComponent(), profilepublickey_b.kickCause); // Paper - kick event causes
} }

View file

@ -0,0 +1,15 @@
--- a/net/minecraft/server/packs/PathPackResources.java
+++ b/net/minecraft/server/packs/PathPackResources.java
@@ -103,6 +103,12 @@
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) {
for (Path path2 : directoryStream) {
String string = path2.getFileName().toString();
+ // Paper start - Improve logging and errors
+ if (!Files.isDirectory(path2)) {
+ LOGGER.error("Invalid directory entry: {} in {}.", string, this.root, new java.nio.file.NotDirectoryException(string));
+ continue;
+ }
+ // Paper end - Improve logging and errors
if (ResourceLocation.isValidNamespace(string)) {
set.add(string);
} else {

View file

@ -44,6 +44,7 @@ import org.bukkit.material.MaterialData;
*/ */
@Deprecated @Deprecated
public final class CraftLegacy { public final class CraftLegacy {
private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper - Improve logging and errors
private static final Map<Byte, Material> SPAWN_EGGS = new HashMap<>(); 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")); private static final Set<String> whitelistedStates = new HashSet<>(Arrays.asList("explode", "check_decay", "decayable", "facing"));
@ -264,7 +265,7 @@ public final class CraftLegacy {
} }
static { static {
System.err.println("Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!"); 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
if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) { if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) {
new Exception().printStackTrace(); new Exception().printStackTrace();
} }