SkriptLang / skript-reflect

Powerful reflection utilities for Skript.
MIT License
56 stars 19 forks source link

Using java objects in conditions with "or" #59

Closed UsainSrht closed 1 year ago

UsainSrht commented 1 year ago

Describe the bug When you try to compare an object with more than one java objects condition fails.

To reproduce

set {_ice} to Material.ICE
if {_ice} is (Material.ICE or Material.STONE):
  broadcast "ICE"
else:
  broadcast "NOT ICE"

Expected behavior Using javaobjects with skript's conditions properly.

Server information

Additional context I know you can simply replace if {_ice} is (Material.ICE or Material.STONE): with if (Material.ICE and Material.STONE) contains {_ice}: but that's totally different condition.

Lotzyprod commented 1 year ago

Yes, I also encountered this bug, I solved it in the same way as the author

TPGamesNL commented 1 year ago

This occurs because Skript parses the input as if {_ice} is ((Material.ICE or Material).STONE) (i.e. gets the STONE field of Material.ICE or MATERIAL). You can add parentheses as such: (Material.ICE) and (Material.STONE).

I don't think I can / should do anything about this. Although it doesn't make much sense with the context of Material class and these fields, in general this could be desired.

Same in terms of the Skript side of this, I don't think the parser should be changed. It currently prefers a single expression over a list of expressions, which causes this behaviour.