TARDIS

TARDIS

228k Downloads

Adding a companion can hang the server

DrPepplies opened this issue ยท 1 comments

commented

Describe the bug

When players on our server do /tardis add, it sometimes causes the server to hang for 20-30 seconds. Especially if the name is not the correct name.

Had a quick look at the error to try and debug if it was anything I could fix, but think it's because the TARDISUtils.getOfflinePlayer() checks through every player. We've had tens of thousands of players, so it takes an age to do that. If they typo the name or add someone who's never played, it has to go through all of those.

I suppose to fix it should use Bukkit's method for getting an offline player by name? Or could check if they're online first or something.

To Reproduce

Think it's specific to our server

Screenshots

No response

Log files

--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH  - git-Paper-98 (MC: 1.20.1) ---
The server has not responded for 10 seconds! Creating thread dump
------------------------------
Server thread dump (Look for plugins here before reporting to Paper!):
------------------------------
Current Thread: Server thread
	PID: 28 | Suspended: false | Native: true | State: RUNNABLE
	Stack:
		[email protected]/java.io.FileInputStream.read0(Native Method)
		[email protected]/java.io.FileInputStream.read(FileInputStream.java:228)
		[email protected]/java.util.zip.CheckedInputStream.read(CheckedInputStream.java:59)
		[email protected]/java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:266)
		[email protected]/java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:258)
		[email protected]/java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:164)
		[email protected]/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:79)
		[email protected]/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:91)
		net.minecraft.nbt.NbtIo.createDecompressorStream(NbtIo.java:49)
		net.minecraft.nbt.NbtIo.readCompressed(NbtIo.java:53)
		net.minecraft.world.level.storage.PlayerDataStorage.getPlayerData(PlayerDataStorage.java:108)
		org.bukkit.craftbukkit.v1_20_R1.CraftOfflinePlayer.getData(CraftOfflinePlayer.java:190)
		org.bukkit.craftbukkit.v1_20_R1.CraftOfflinePlayer.getBukkitData(CraftOfflinePlayer.java:194)
		org.bukkit.craftbukkit.v1_20_R1.CraftOfflinePlayer.getName(CraftOfflinePlayer.java:66)
		TARDIS-b2666.jar//me.eccentric_nz.TARDIS.utility.TARDISStaticUtils.getOfflinePlayer(TARDISStaticUtils.java:284)
		TARDIS-b2666.jar//me.eccentric_nz.TARDIS.commands.tardis.TARDISAddCompanionCommand.doAdd(TARDISAddCompanionCommand.java:99)
		TARDIS-b2666.jar//me.eccentric_nz.TARDIS.commands.tardis.TARDISCommands.onCommand(TARDISCommands.java:120)
		org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
		org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155)
		org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:1006)
		org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64)
		com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265)
		net.minecraft.commands.Commands.performCommand(Commands.java:324)
		net.minecraft.commands.Commands.performCommand(Commands.java:308)
		net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2299)
		net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2259)
		net.minecraft.server.network.PlayerConnection$$Lambda$11285/0x0000000803687a60.run(Unknown Source)
		net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59)
		net.minecraft.util.thread.IAsyncTaskHandler$$Lambda$11286/0x0000000803687c88.get(Unknown Source)
		[email protected]/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
		net.minecraft.server.TickTask.run(TickTask.java:18)
		net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153)
		net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24)
		net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1339)
		net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197)
		net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126)
		net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1316)
		net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1309)
		net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136)
		net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1386)
		net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1171)
		net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318)
		net.minecraft.server.MinecraftServer$$Lambda$4627/0x0000000801a1a4d8.run(Unknown Source)
		[email protected]/java.lang.Thread.run(Thread.java:833)
------------------------------
--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---
------------------------------

'/tardis version' output

Paper v1.20.1 build 98
TARDIS build 2666

commented

Seems much better now, thanks!