Elytrium / Elytrium/LimboFilter

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

Open Beginner friendly
#122 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
172
Forks
52
PR merge metrics
No merged PRs in 30d

Description

**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:**

- Java: 21
- Velocity: 3.5.0-SNAPSHOT-594
- LimboAPI: a83e1b0
- LimboAuth: bc8ebd9
- LimboFilter: ebbc0bf

- https://pastebin.com/TumYJerJ

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in CachedPackets.createExpPackets, identified at CachedPackets.java:326, and inspect how falling-check-ticks is used when packets are created during LimboFilter.reload. Reproduce with falling-check-ticks set to 1 and confirm startup completes without the reported exception; done means that configuration no longer triggers division by zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.