Stargate Rewritten

Stargate Rewritten

241 Downloads

NPE caused by gate conflict

Pheotis opened this issue ยท 2 comments

commented

It is currently possible to destroy another gate via activator conflicts.
This creates a situation wherein a severe bug occurs.

Repro Steps

  1. Make two portal frames directly besides each other.
    image
  2. For the right gate, create a networked gate on an empty network (must not be an A gate).
    image
  3. For the left gate, create a networked gate on that same network (must not be an A gate).
    image
    Bug One: The newer control surface will break the older control surface!
  4. Break both of the portals.
    image

Bug Two: A null pointer will be printed to console every tick, and a message will be spammed in chat every tick.
image

[15:25:42 WARN]: [Stargate] Task #9 for Stargate v1.0.0.3-ALPHA generated an exception
java.lang.NullPointerException: Cannot invoke "net.TheDgtl.Stargate.network.portal.Portal.getName()" because the return value of "java.util.Map.get(Object)" is null
        at net.TheDgtl.Stargate.network.StargateRegistry.unRegisterLocation(StargateRegistry.java:165) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at net.TheDgtl.Stargate.network.portal.AbstractPortal.destroy(AbstractPortal.java:344) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at net.TheDgtl.Stargate.listeners.BlockEventListener.lambda$0(BlockEventListener.java:69) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at net.TheDgtl.Stargate.actions.SupplierAction.run(SupplierAction.java:24) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at net.TheDgtl.Stargate.SynchronousPopulator.cycleQueue(SynchronousPopulator.java:104) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at net.TheDgtl.Stargate.SynchronousPopulator.cycleQueues(SynchronousPopulator.java:78) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at net.TheDgtl.Stargate.SynchronousPopulator.run(SynchronousPopulator.java:37) ~[Stargate-1.0.0.3-ALPHA.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.18.1.jar:git-Paper-204]
        at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.18.1.jar:git-Paper-204]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1548) ~[paper-1.18.1.jar:git-Paper-204]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:480) ~[paper-1.18.1.jar:git-Paper-204]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1471) ~[paper-1.18.1.jar:git-Paper-204]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1264) ~[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) ~[?:?]

image

The server will fail to save all subsequently created portals when it is next stopped.

[15:27:29 INFO]: [Stargate] Disabling Stargate v1.0.0.3-ALPHA
[15:27:29 ERROR]: Error occurred while disabling Stargate v1.0.0.3-ALPHA (Is it up to date?)
java.lang.NullPointerException: null```

As no such data saved, the server appears to be usable again once it gets restarted.
commented

It seems a check is missing to test if any of the portal positions for the new Stargate are already registered to another Stargate. There is already an existing conflict message that should cover this case.

commented

Commit 41c18a0 should fix this by removing the root problem of letting a conflicting gate from being created.