From 219e358711e3db3172d836d5c86ec54f5b7d2af5 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Thu, 26 Dec 2024 20:44:35 +0000 Subject: [PATCH] Add boat data check to prevent error. (#7301) --- .../java/ch/njol/skript/entity/BoatData.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/ch/njol/skript/entity/BoatData.java b/src/main/java/ch/njol/skript/entity/BoatData.java index 22b8d58b251..47d647ee61f 100644 --- a/src/main/java/ch/njol/skript/entity/BoatData.java +++ b/src/main/java/ch/njol/skript/entity/BoatData.java @@ -55,22 +55,22 @@ public class BoatData extends EntityData { } - + 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; } @@ -96,7 +96,7 @@ protected boolean match(Boat entity) { @Override public Class 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; } @@ -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; @@ -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; - + } }