Skip to content

[BUG] Division by zero if falling-check-ticks option set to 1 #122

Description

@FatSaw

Describe the bug
Division by zero if falling-check-ticks option set to 1.

[04:08:19 ERROR]: Couldn't pass ProxyInitializeEvent to limbofilter 1.1.19
java.lang.ArithmeticException: / by zero
        at net.elytrium.limbofilter.cache.CachedPackets.createExpPackets(CachedPackets.java:326) ~[?:?]
        at net.elytrium.limbofilter.cache.CachedPackets.createPackets(CachedPackets.java:105) ~[?:?]
        at net.elytrium.limbofilter.LimboFilter.reload(LimboFilter.java:329) ~[?:?]
        at net.elytrium.limbofilter.LimboFilter.onProxyInitialization(LimboFilter.java:139) ~[?:?]
        at net.elytrium.limbofilter.Lmbda$7.execute(Unknown Source) ~[?:?]
        at com.velocitypowered.proxy.event.UntargetedEventHandler$VoidHandler.lambda$buildHandler$0(UntargetedEventHandler.java:56) ~[velocity.jar:3.5.0-SNAPSHOT (git-ad8de436-b594)]
        at com.velocitypowered.proxy.event.VelocityEventManager.fire(VelocityEventManager.java:677) ~[velocity.jar:3.5.0-SNAPSHOT (git-ad8de436-b594)]
        at com.velocitypowered.proxy.event.VelocityEventManager.lambda$fire$5(VelocityEventManager.java:542) ~[velocity.jar:3.5.0-SNAPSHOT (git-ad8de436-b594)]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
  private PreparedPacket[] createExpPackets(LimboFactory limboFactory, PacketFactory packetFactory) {
    int ticks = Settings.IMP.MAIN.FALLING_CHECK_TICKS;
    PreparedPacket[] packets = new PreparedPacket[ticks];
    final int ticksM1 = ticks - 1;
    for (int i = 0; i < ticks; ++i) {
      packets[i] = limboFactory.createPreparedPacket().prepare(packetFactory.createSetExperiencePacket((float) i / ticksM1, (i * 100) / ticksM1, 0)).build();
    }

    return packets;
  }

To Reproduce
Steps to reproduce the behavior:

  1. Set falling-check-ticks in config to 1
  2. Start velocity
  3. See error

Expected behavior
Do not devide by zero, catch ArithmeticException

Server Info:

Additional context
It does not appear earlier, before I update Java, Velocity, LimboAPI, LimboAuth, LimboFilter

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions