From 9edd770911a9dfd5b350d579e9092a62873e1d4a Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 23 Jul 2020 19:31:09 -0400 Subject: Proper type checking --- .../net/corechg/transit/type/group/GroupRegistry.java | 15 +++++++++++---- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/net/corechg/transit/type/group/GroupRegistry.java b/src/main/java/net/corechg/transit/type/group/GroupRegistry.java index 3929973..0b04913 100644 --- a/src/main/java/net/corechg/transit/type/group/GroupRegistry.java +++ b/src/main/java/net/corechg/transit/type/group/GroupRegistry.java @@ -30,20 +30,27 @@ public class GroupRegistry { return true; } - public static final TypeGroup groupByID(String groupID) + @SuppressWarnings("unchecked") + public static final TypeGroup groupByID(String groupID) { for(TypeGroup g : GROUPS) { - if(g.getGroup().equals(groupID)) return g; + if(g.getGroup().equals(groupID)){ + try{ + return (TypeGroup) g; + }catch(ClassCastException e) { + return null; + } + } } return null; } - public static final Type typeByIdentity(String groupID, String typeID) + public static final Type typeByIdentity(String groupID, String typeID) { - return groupByID(groupID).getType(typeID); + return GroupRegistry.groupByID(groupID).getType(typeID); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d5986f2..d54a617 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "transit-api", - "version": "0.11.3", + "version": "0.11.4", "name": "Transit API", "description": "Move about!", -- cgit v1.2.3