Civcraft / Citadel

Do not open issues here; open them on the maintained fork @ DevotedMC
https://github.com/DevotedMC/Citadel
BSD 3-Clause "New" or "Revised" License
6 stars 23 forks source link

Stacktrace on block break #140

Closed ProgrammerDan closed 8 years ago

ProgrammerDan commented 8 years ago

Placeholder so I can look at this later.

[12:02:03 ERROR]: Could not pass event BlockBreakEvent to Citadel v3.3.4
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.PlayerInteractManager.breakBlock(PlayerInteractManager.java:286) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.PlayerInteractManager.a(PlayerInteractManager.java:215) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:637) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.a(SourceFile:40) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.a(SourceFile:10) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_80]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_80]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_80]
Caused by: java.lang.ArithmeticException: / by zero
        at vg.civcraft.mc.citadel.Utility.reinforcementDamaged(Utility.java:297) ~[?:?]
        at vg.civcraft.mc.citadel.listener.BlockListener.blockBreakEvent(BlockListener.java:194) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_80]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_80]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-efd6cb0]
        ... 17 more
rourke750 commented 8 years ago

Already now what the issue is, which server is this for?

ProgrammerDan commented 8 years ago

Devoted. Fix already merged? I haven't updated Citadel since that server went live.

rourke750 commented 8 years ago

https://github.com/Civcraft/Citadel/blob/master/src/vg/civcraft/mc/citadel/Utility.java#L296

I assume this is rounding down to 0. Is his maturation time for a reinforcement == 0. Honestly I think that login right there needs to be rewritten if you want to take a look at it.

ProgrammerDan commented 8 years ago

None of the configured reinforcements have a maturation time of 0, so I'll have to investigate closer. Could be parse error or who knows what

rourke750 commented 8 years ago

Any luck tracking this down?

ProgrammerDan commented 8 years ago

I think an earlier revision of the configuration had a number of block types with maturation time of "0" -- and everytime someone interacts with those blocks, this exception is thrown.

Definitely this block should be wrapped with divide-by-zero sanity check, but at least for Devoted looks like I'll just "fix" it in the database layer.

Sound reasonable?

rourke750 commented 8 years ago

Sure, want to fix it in citadel too?

ProgrammerDan commented 8 years ago

Yeah, I'll take care of it :)

ProgrammerDan commented 8 years ago

Spent some time on this (finally): https://trello.com/c/i57EkarT/32-scaled-citadel-maturation-is-100-broken

Basically the math was wrong, damage rate would have increased as the block got more mature, instead of decreasing, and integer math always produces integers immediately in java, so all the "percentage" math was just resolving to 0, leading to the divide-by-zero.

Now the math is done with explicit double casting, and truncated to integers only after everything is computed.

Fix: https://github.com/Civcraft/Citadel/tree/maturation_Fix

rourke750 commented 8 years ago

Can this be closed?

ProgrammerDan commented 8 years ago

Yeah, I think we merged that fix