Skip to content

Commit 219e358

Browse files
authored
Add boat data check to prevent error. (#7301)
1 parent 48f931a commit 219e358

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/ch/njol/skript/entity/BoatData.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ public class BoatData extends EntityData<Boat> {
5555
}
5656

5757

58-
58+
5959
public BoatData(){
6060
this(0);
6161
}
62-
62+
6363
public BoatData(@Nullable TreeSpecies type){
6464
this(type != null ? type.ordinal() + 2 : 1);
6565
}
66-
66+
6767
private BoatData(int type){
6868
matchedPattern = type;
6969
}
70-
70+
7171
@Override
7272
protected boolean init(Literal<?>[] exprs, int matchedPattern, ParseResult parseResult) {
73-
73+
7474
return true;
7575
}
7676

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

9797
@Override
9898
public Class<? extends Boat> getType() {
99-
if (IS_RUNNING_1_21_3)
99+
if (IS_RUNNING_1_21_3 && matchedPattern > 1)
100100
return typeToClassMap.get(TreeSpecies.values()[matchedPattern - 2]);
101101
return Boat.class;
102102
}
@@ -124,7 +124,7 @@ public boolean isSupertypeOf(EntityData<?> e) {
124124
return matchedPattern <= 1 || matchedPattern == ((BoatData)e).matchedPattern;
125125
return false;
126126
}
127-
127+
128128
public boolean isOfItemType(ItemType i){
129129
int ordinal = -1;
130130

@@ -142,7 +142,7 @@ else if (type == Material.ACACIA_BOAT)
142142
else if (type == Material.DARK_OAK_BOAT)
143143
ordinal = TreeSpecies.DARK_OAK.ordinal();
144144
return hashCode_i() == ordinal + 2 || (matchedPattern + ordinal == 0) || ordinal == 0;
145-
145+
146146
}
147147

148148
}

0 commit comments

Comments
 (0)