prism / PrismRefracted

A continuation of Prism, a change-tracking plugin for Bukkit-based servers.
Other
43 stars 23 forks source link

[BUG] Block parameter causes exception #15

Closed Bobcat00 closed 1 month ago

Bobcat00 commented 2 years ago

Describe the bug Using b: causes the following exception:

2022-02-17 19:39:38 [WARN] [Prism] Plugin Prism v3.0.4-SNAPSHOT generated an exception while executing task 381
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "s" is null
    at java.util.Collections.unmodifiableSet(Collections.java:1132) ~[?:?]
    at network.darkhelmet.prism.utils.MaterialAliases.materialToAllIds(MaterialAliases.java:246) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at network.darkhelmet.prism.database.sql.SqlSelectQueryBuilder.blockCondition(SqlSelectQueryBuilder.java:229) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at network.darkhelmet.prism.database.sql.SqlSelectQueryBuilder.where(SqlSelectQueryBuilder.java:132) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at network.darkhelmet.prism.database.QueryBuilder.getQuery(QueryBuilder.java:64) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at network.darkhelmet.prism.database.sql.SqlSelectQueryBuilder.executeSelect(SqlSelectQueryBuilder.java:467) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at network.darkhelmet.prism.actionlibs.ActionsQuery.lookup(ActionsQuery.java:66) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at network.darkhelmet.prism.commands.LookupCommand.lambda$handle$2(LookupCommand.java:68) ~[Prism-3.0.4-SNAPSHOT-all.jar:?]
    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-408]
    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[patched_1.17.1.jar:git-Paper-408]
    at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.17.1.jar:git-Paper-408]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]

To Reproduce /pr l t:9w r:global b:minecart

Note the following commands work properly: /pr l t:9w r:global e:creeper /pr l t:9w r:global

Expected behavior No exception and the output of the lookup command.

Server (please complete the following information):

Additional context Problem does not occur with released Prism version 3.0.2

Bobcat00 commented 2 years ago

UPDATE: Problem occurs with released Prism 3.0.3:

2022-02-17 20:05:02 [INFO] Bobcat00 issued server command: /pr l t:9w r:global b:minecart
2022-02-17 20:05:02 [WARN] [Prism] Plugin Prism v3.0.3 generated an exception while executing task 320
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "s" is null
    at java.util.Collections.unmodifiableSet(Collections.java:1132) ~[?:?]
    at network.darkhelmet.prism.utils.MaterialAliases.materialToAllIds(MaterialAliases.java:246) ~[Prism-3.0.3-all.jar:?]
    at network.darkhelmet.prism.database.sql.SqlSelectQueryBuilder.blockCondition(SqlSelectQueryBuilder.java:229) ~[Prism-3.0.3-all.jar:?]
    at network.darkhelmet.prism.database.sql.SqlSelectQueryBuilder.where(SqlSelectQueryBuilder.java:132) ~[Prism-3.0.3-all.jar:?]
    at network.darkhelmet.prism.database.QueryBuilder.getQuery(QueryBuilder.java:64) ~[Prism-3.0.3-all.jar:?]
    at network.darkhelmet.prism.database.sql.SqlSelectQueryBuilder.executeSelect(SqlSelectQueryBuilder.java:467) ~[Prism-3.0.3-all.jar:?]
    at network.darkhelmet.prism.actionlibs.ActionsQuery.lookup(ActionsQuery.java:66) ~[Prism-3.0.3-all.jar:?]
    at network.darkhelmet.prism.commands.LookupCommand.lambda$handle$2(LookupCommand.java:68) ~[Prism-3.0.3-all.jar:?]
    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-408]
    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[patched_1.17.1.jar:git-Paper-408]
    at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.17.1.jar:git-Paper-408]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
Bobcat00 commented 2 years ago

I'm not sure what the solution is. It may be too complicated to bother with for v3.

Basically, when using the b: parameter, the value (block) has to be listed in the prism_id_map table. If not, the exception is thrown instead of issuing an error message. Also, some values (like minecart) are not present in newly-generated tables, but are present in old tables.

I'm not sure what changed to break this.

So I guess the solution would be:

  1. Add entries in prism_id_map for blocks that can be used in the b: parameter but are not present in newly-generated tables.
  2. Detect when the block is not in the table and issue an error message.
Rothes commented 2 years ago

This is fixed in https://github.com/prism/PrismRefracted/pull/43 @viveleroi @Bobcat00

Bobcat00 commented 1 month ago

Closing because this is supposedly fixed.