Shopkeepers

Shopkeepers

2M Downloads

LightningStrikeEvent error

blablubbabcDEV opened this issue · 14 comments

commented

Migrated from: https://dev.bukkit.org/projects/shopkeepers/issues/300

Originally posted by Ashley912 (Mar 6, 2015):

[02:46:08 ERROR]: Could not pass event LightningStrikeEvent to Shopkeepers v1.49
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.WorldServer.strikeLightning(WorldServer.java:983) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.WorldServer.h(WorldServer.java:416) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.WorldServer.doTick(WorldServer.java:240) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:756) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot.jar:git-Spigot-c3c767f-33d5de3]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_11]
Caused by: java.lang.IllegalArgumentException: Cannot measure distance between world_nether and world
        at org.bukkit.Location.distanceSquared(Location.java:456) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
        at com.nisovin.shopkeepers.Utils.getNearbyEntities(Utils.java:124) ~[?:?]
        at com.nisovin.shopkeepers.LivingEntityShopListener.onLightningStrike(LivingEntityShopListener.java:143) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor415.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_11]
        at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_11]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
        ... 11 more

commented

Originally commented by Ashley912 (Mar 6, 2015):

I can not reproduce it systematically, it does not happen often. Only admins have access to creating shopkeepers. Nether has 0 shopkeepers, all shopkeepers are located in the overworld - protected by WorldGuard from lightning strikes.

The errors started happening recently after an update of both spigot and shopkeepers, so I think I'll just wait and see if it's fixed in one of the later versions. It doesn't seem like an urgent thing for our server in particular, where lightning strikes cannot happen anywhere near where any of the shopkeepers stand (at least I'm guessing this makes for nothing more than console spam). Thanks for clarifying, and for the great plugin!
Edited Mar 6, 2015

commented

Originally commented by blablubbabc (Mar 7, 2015):

You could try spawning some lightning strikes on your server (/summon LightningBolt) and see if you are able to reproduce it that way on your server. If yes, the issues is probably something specific to your server.
Also try updating to spigot 1.8.3 and see if the issue is still there for you.

        Edited Mar 7, 2015
commented

Originally commented by blablubbabc (Mar 13, 2015):

[at]Ashley912:
Could you give me a list of the plugins you are using?

commented

Originally commented by Jikoo_K (Mar 13, 2015):

As requested in comments...

Plugins (42): AsyncWorldEditInjector, dynmap, WorldEdit, OpenInv, Essentials, ChunkSpawnerLimiter, zPermissions, PluginManager, TuxTwoLib, JukeLoop, BookSuite, WorldBorder, EnchantedFurnace, ProtocolLib, Multiverse-Core, WorldGuard, NoCheatPlus, SimpleBackup, Stables, AsyncWorldEdit, SignEdit, StructureInABox, Shopkeepers, TradeCraft, CheckNameHistory, ChestRegen, InstantDecay, Multiverse-NetherPortals, GoldIsMoney, Vault, Prism, Speedcarts, GriefPrevention, Portals, FastCraft, MultiInv, LWC, HolographicDisplays, CommandSigns, CreeperHeal, BookShelf, Sblock

Spigot: git-Spigot-529ff99-2acb9e4 (MC: 1.8.3) (Implementing API version 1.8.3-R0.1-SNAPSHOT) 4 version(s) behind
I should note, CreeperHeal used to occasionally run into this issue. I don't believe nitnelave ever actually figured out why it was occurring - I'm pretty sure he just added a world check.

        Edited Mar 13, 2015
commented

Originally commented by blablubbabc (Mar 6, 2015):

How did you get this? I tried to reproduce this by creating shopkeepers in different worlds (world and world_nether) and creating lightning strikes in those different worlds as well..
I am not able to reproduce this..
I currently can only explain this error in case location.getWorld().getChunkAt(x, z).getEntities() returns an entity which location is in a different world than location.getWorld() ... In which case this would seem like a spigot bug to me..

Easier summary: I am basically asking the world, in which the lightning strike takes place, to give me a chunk in that world, and that chunk to give me all entities, and one of those entities is reporting to be in a different world than the lightning stirike.. which doesn't make sense.

        Edited Mar 6, 2015
commented

Originally commented by Jikoo_K (Mar 14, 2015):

Enabled debug this morning, couldn't manage to replicate it yet. I'll leave it on and grep my logs when I can.
An aside - Wouldn't it be better to calculate distance after ensuring that the entity is a valid type? Probably just my penchant for microoptimization, but..
if ((types == null || types.contains(entity.getType())
&& entityLoc.distanceSquared(location) <= radius2) {
entities.add(entity);
}

instead of
if (entityLoc.distanceSquared(location) <= radius2) {
if (types == null) {
entities.add(entity);
} else {
EntityType type = entity.getType();
for (EntityType t : types) {
if (type.equals(t)) {
entities.add(entity);
break;
}
}
}
}

Seems cleaner and saves a teensy bit on math.

commented

Originally commented by blablubbabc (Mar 14, 2015):

[at]Jikoo_K:
The distanceSquared function is very performant, it consists of only 3 subtractions and 3 multiplications.
So I consider going through the array of searched entity types to be slower, especially if the array contains multiple entity types. For shopkeepers I am really only looking for 1 entity type here, but as the method is meant to be generic, doing it in this order seems to be more stable to me: the performance of distanceSquared will always be the same (those 6 basic arithmetic operations), while the performance of the type check will vary depending on the amount of entity types I am searching for. So I try do do the type check only when really needed.

        Edited Mar 14, 2015
commented

Originally commented by Jikoo_K (Mar 15, 2015):

[at]blablubbabc:
Ah, thank you, I'll keep that in mind.
[Shopkeepers] Found an entity which reports to be in a different world than the chunk we got it from:
[Shopkeepers] Location=Location{world=CraftWorld{name=Earth},x=-1691.0,y=63.0,z=-579.0,pitch=0.0,yaw=0.0}, Chunk=CraftChunk{x=-
107z=-36}, ChunkWorld=CraftWorld{name=Earth}entityType=PIG_ZOMBIE, entityLocation=Location{world=CraftWorld{name=Earth_nether},x=-212.84713162053123,y=54.0,z=-6
9.45717010713484,pitch=0.0,yaw=-90.0}

Sorry my formatting is crap, I'm on mobile and it was a long enough process finding and copying as it was.

        Edited Mar 15, 2015
commented

Originally commented by blablubbabc (Mar 15, 2015):

[at]Jikoo_K:
Thanks.
If you go to that location (world=CraftWorld{name=Earth},x=-1691.0,y=63.0,z=-579.0,pitch=0.0,yaw=0.0}, Chunk=CraftChunk{x=-107z=-36}), could you check out if there is something 'special' at this place? Any specific entities there? Nether portals? Other plugins invovled, like worldguard regions, etc.
Also try out if you can reproduce the issue by spawning lightning strikes at that location.

        Edited Mar 15, 2015
commented

Originally commented by blablubbabc (Mar 13, 2015):

The error should no longer occur in v1.51. I also added some debug prints in v1.51. The debugging might be pretty spammy when trades are going on, but it might be helpful if someone of you could turn the debug mode on and post the debug messages from log once an entity reporting to be in a different world is detected.
In case you want to search through your logs for this debug message: it contains the following sentence:

Found an entity which reports to be in a different world than the chunk we got it from:

        Edited Mar 13, 2015
commented

Originally commented by blablubbabc (Mar 15, 2015):

[at]Jikoo_K:
I have experimented with the nether portal as well, but wasn't able to reproduce it yet. Also tried turning pigs into zombie pigmans via the lightning, near and next to nether portals. That as well didn't trigger it.

commented

Originally commented by blablubbabc (May 19, 2015):

I will mark this as fixed for now, as the error should be gone with the additional check. If somebody know what is causing this, or if this is some kind of spigot bug, let me know.

commented

Originally closed by blablubbabc (May 19, 2015)

commented

Originally commented by Jikoo_K (Mar 15, 2015):

[at]blablubbabc:
There is a nether portal in the chunk. I cannot seem to replicate it by spawning lighting. The only theory I have so far is that a pigman could have traveled through it or been spawned by the portal block, but that still doesn't account for the world and location being wrong - as far as I know, entities are removed and respawned when traveling through portals, and pigmen spawned by portal block should never have had a thing to do with the nether at all.
There is also a GriefPrevention claim around the area in question.