diff options
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | src/main/java/net/corechg/transit/network/system/Node.java | 45 | ||||
-rw-r--r-- | src/main/java/net/corechg/transit/network/system/System.java | 17 | ||||
-rw-r--r-- | src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java (renamed from src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java) | 4 | ||||
-rw-r--r-- | src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java (renamed from src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java) | 2 | ||||
-rw-r--r-- | src/main/java/net/corechg/transit/type/Type.java | 4 | ||||
-rw-r--r-- | src/main/java/net/corechg/transit/type/group/TypeGroup.java | 33 | ||||
-rw-r--r-- | src/main/resources/fabric.mod.json | 2 |
8 files changed, 39 insertions, 70 deletions
diff --git a/gradle.properties b/gradle.properties index a178946..e5550dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.8.2+build.194 # Mod Properties - mod_version = 0.8.1 + mod_version = 0.9.2 maven_group = net.transit archives_base_name = transit-api diff --git a/src/main/java/net/corechg/transit/network/system/Node.java b/src/main/java/net/corechg/transit/network/system/Node.java deleted file mode 100644 index 87682ce..0000000 --- a/src/main/java/net/corechg/transit/network/system/Node.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.corechg.transit.network.system; - -/** - * @author Kyle Gunger - * @apiNote A node inside or outside a system. Provides acceptors and providers to other nodes. - */ -public interface Node -{ - - /**Returns the groupIDs of groups the node interacts with - * - * @return String[] - */ - public String[] groupsProvided(); - - - /**Get the system managing the node or {@code null} if there isn't one - * - * @return System - */ - public System getSystem(); - - - /** Get the data of one of the TypeGroups the Node supports - * - * @param groupID - * @return - */ - public Object getData(String groupID); - - - /** Set the group data for the node - * - * @param dat - * @param groupID - */ - public void setData(Object dat, String groupID); - - - /** Get the nodes that this node is connected to - * - * @return Node[] - */ - public Node[] getConnections(); -} diff --git a/src/main/java/net/corechg/transit/network/system/System.java b/src/main/java/net/corechg/transit/network/system/System.java deleted file mode 100644 index dfe3e19..0000000 --- a/src/main/java/net/corechg/transit/network/system/System.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.corechg.transit.network.system; - - -/**ISystem - a group of nodes optimized for performance - * - * A node can exist without a system, but a system can not exist without at least one root node. - * - * @param T The object type stored in the system. - */ -public interface System -{ - /**The nodes stored by the system - * - * @return INode[] - */ - public Node[] getNodes(); -} diff --git a/src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java b/src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java index 720b210..40cd430 100644 --- a/src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java +++ b/src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java @@ -3,7 +3,7 @@ package net.corechg.transit.network.system.swap; import net.corechg.transit.network.packet.IStaticPacket; import net.corechg.transit.network.system.INode; -public interface AcceptorNode extends INode +public interface IAcceptorNode extends INode { /** Link another node as a provider @@ -35,5 +35,5 @@ public interface AcceptorNode extends INode * @param group * @return */ - public boolean accept(IStaticPacket<?> packet, String group); + public <T> boolean accept(IStaticPacket<T> packet, String group); } diff --git a/src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java b/src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java index 06b13f4..84a8f62 100644 --- a/src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java +++ b/src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java @@ -2,7 +2,7 @@ package net.corechg.transit.network.system.swap; import net.corechg.transit.network.system.INode; -public interface ProviderNode extends INode{ +public interface IProviderNode extends INode{ /** Link another node as an acceptor * diff --git a/src/main/java/net/corechg/transit/type/Type.java b/src/main/java/net/corechg/transit/type/Type.java index c5be2bb..2c4d6ac 100644 --- a/src/main/java/net/corechg/transit/type/Type.java +++ b/src/main/java/net/corechg/transit/type/Type.java @@ -19,6 +19,7 @@ public class Type<T> } /** Return the packet's data formatted in the group's base type. + * If creating a new type, extend this class and override this function. * * @param packet The packet (of this type) * @param group The group asking for the conversion @@ -30,6 +31,7 @@ public class Type<T> } /** Create a packet which has the current type from the data in the base type. + * If creating a new type, extend this class and override this function. * * @param base The base data * @param group The group that the data comes from @@ -40,7 +42,7 @@ public class Type<T> return new StaticPacket<T>(base, this); } - /** The type identifier. Must be overridden for any class implementing IType. + /** The type identifier. Gives the normal type identity of the type. * * @return String */ diff --git a/src/main/java/net/corechg/transit/type/group/TypeGroup.java b/src/main/java/net/corechg/transit/type/group/TypeGroup.java index adbd75f..e04df8c 100644 --- a/src/main/java/net/corechg/transit/type/group/TypeGroup.java +++ b/src/main/java/net/corechg/transit/type/group/TypeGroup.java @@ -103,7 +103,6 @@ public class TypeGroup<B> */ public boolean removeType(String typeID) { - return removeType(getGroup(), typeID); } @@ -153,7 +152,8 @@ public class TypeGroup<B> /**Get the type from the group * - * @param type + * @param groupID The ID of the group the type is originally from + * @param typeID The ID of the type * @return Type */ public Type<B> getType(String groupID, String typeID) @@ -166,6 +166,11 @@ public class TypeGroup<B> return null; } + /**Get the type from the group + * + * @param typeID The ID of the type + * @return Type + */ public Type<B> getType(String typeID) { return getType(getGroup(), typeID); @@ -218,6 +223,23 @@ public class TypeGroup<B> return null; } + + /**Convert a packet to a new type + * + * @param packet The packet to convert + * @param typeID The typeID of the Type to convert to + * @return Packet + */ + public IStaticPacket<B> convertPacket(IStaticPacket<B> packet, String typeID) + { + Type<B> toType = getType(typeID); + if(toType != null) + { + return convertPacketRaw(packet, toType); + } + + return null; + } /** The group identifier. Given by the Base Group * @return String @@ -226,4 +248,11 @@ public class TypeGroup<B> { return baseType.getGroup(); } + + /** The base group type + * @return Type + */ + public final Type<B> getBase() { + return baseType; + } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b7c73f7..70852d9 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.8.1", + "version": "0.9.2", "name": "Transit API", "description": "Move about!", |