IOBE caused by rememberLastDestination.
Pheotis opened this issue ยท 2 comments
Repro Steps
- Under the default config, make a portal network (networked, non-fixed, portals).
- Set
rememberLastDestination
to true in the config and restart the server. - With an OP'd user, right click the activator sign to cycle through destinations.
The action will be cancelled and this stack trace will print to console:
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 67
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
at net.TheDgtl.Stargate.network.portal.NetworkedPortal.reloadSelectedDestination(NetworkedPortal.java:134) ~[Stargate-1.0.0.3-ALPHA.jar:?]
at net.TheDgtl.Stargate.network.portal.NetworkedPortal.update(NetworkedPortal.java:122) ~[Stargate-1.0.0.3-ALPHA.jar:?]
at net.TheDgtl.Stargate.network.portal.NetworkedPortal.onSignClick(NetworkedPortal.java:90) ~[Stargate-1.0.0.3-ALPHA.jar:?]
at net.TheDgtl.Stargate.listeners.PlayerEventListener.handleRelevantClickEvent(PlayerEventListener.java:90) ~[Stargate-1.0.0.3-ALPHA.jar:?]
at net.TheDgtl.Stargate.listeners.PlayerEventListener.onPlayerInteract(PlayerEventListener.java:66) ~[Stargate-1.0.0.3-ALPHA.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor36.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:git-Paper-204]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:629) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:544) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.server.level.ServerPlayerGameMode.useItemOn(ServerPlayerGameMode.java:542) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleUseItemOn(ServerGamePacketListenerImpl.java:1840) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.handle(ServerboundUseItemOnPacket.java:33) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.a(ServerboundUseItemOnPacket.java:9) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1414) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-204]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-204]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
In NetworkedPortal.java, selectedDestination
is set to -1 by default. There is no catch for this case, and it's never initialized as anything else. A possible fix would be to add a condition that sets the selected destination to 0 if it's currently -1 before returning selectedDestination
in the following code block:
if (!previouslyActivated) {
if (!Settings.getBoolean(Setting.REMEMBER_LAST_DESTINATION)) {
return 0;
}
return selectedDestination;
}
b3f2d2c Should fix this problem.