Skip to content

Commit

Permalink
Add boat data check to prevent error. (#7301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Moderocky authored Dec 26, 2024
1 parent 48f931a commit 219e358
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/ch/njol/skript/entity/BoatData.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ public class BoatData extends EntityData<Boat> {
}



public BoatData(){
this(0);
}

public BoatData(@Nullable TreeSpecies type){
this(type != null ? type.ordinal() + 2 : 1);
}

private BoatData(int type){
matchedPattern = type;
}

@Override
protected boolean init(Literal<?>[] exprs, int matchedPattern, ParseResult parseResult) {

return true;
}

Expand All @@ -96,7 +96,7 @@ protected boolean match(Boat entity) {

@Override
public Class<? extends Boat> getType() {
if (IS_RUNNING_1_21_3)
if (IS_RUNNING_1_21_3 && matchedPattern > 1)
return typeToClassMap.get(TreeSpecies.values()[matchedPattern - 2]);
return Boat.class;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public boolean isSupertypeOf(EntityData<?> e) {
return matchedPattern <= 1 || matchedPattern == ((BoatData)e).matchedPattern;
return false;
}

public boolean isOfItemType(ItemType i){
int ordinal = -1;

Expand All @@ -142,7 +142,7 @@ else if (type == Material.ACACIA_BOAT)
else if (type == Material.DARK_OAK_BOAT)
ordinal = TreeSpecies.DARK_OAK.ordinal();
return hashCode_i() == ordinal + 2 || (matchedPattern + ordinal == 0) || ordinal == 0;

}

}

0 comments on commit 219e358

Please sign in to comment.