From e0a6cfb0aba631d3a1cd27971f87b0d4a677f294 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 16 Jan 2021 01:12:04 -0500 Subject: Update include paths --- .../transit/network/packet/IStaticPacket.java | 23 +++++++++++ .../cshift/transit/network/packet/MetaPacket.java | 35 +++++++++++++++++ .../transit/network/packet/StaticPacket.java | 36 ++++++++++++++++++ .../network/packet/dynamic/DynamicPacket.java | 43 +++++++++++++++++++++ .../network/packet/dynamic/IDynamicPacket.java | 16 ++++++++ .../network/packet/dynamic/MetaDynamicPacket.java | 44 ++++++++++++++++++++++ 6 files changed, 197 insertions(+) create mode 100644 src/main/java/net/cshift/transit/network/packet/IStaticPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/MetaPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/StaticPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/dynamic/DynamicPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/dynamic/IDynamicPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/dynamic/MetaDynamicPacket.java (limited to 'src/main/java/net/cshift/transit/network/packet') diff --git a/src/main/java/net/cshift/transit/network/packet/IStaticPacket.java b/src/main/java/net/cshift/transit/network/packet/IStaticPacket.java new file mode 100644 index 0000000..bac8745 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/IStaticPacket.java @@ -0,0 +1,23 @@ +package net.cshift.transit.network.packet; + +import net.cshift.transit.type.*; + +/** Interface describing an unchanging packet. + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers. + */ +public interface IStaticPacket +{ + /**Get the packet's data. + * + * @return The packet's data + */ + public D getData(); + + /**Get the packet's type. + * + * @return IType<> The type of the packet + */ + public Type getType(); +} diff --git a/src/main/java/net/cshift/transit/network/packet/MetaPacket.java b/src/main/java/net/cshift/transit/network/packet/MetaPacket.java new file mode 100644 index 0000000..99be83c --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/MetaPacket.java @@ -0,0 +1,35 @@ +package net.cshift.transit.network.packet; + +import net.cshift.transit.type.*; + +/** Static packet with extra data attached. + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers + * @param The type of metadata +*/ +public class MetaPacket extends StaticPacket +{ + private M metaData; + + /** Constructor + * + * @param dat The data to store + * @param t The Type of the data + * @param meta The metadata to store + */ + public MetaPacket(D dat, Type t, M meta) + { + super(dat, t); + metaData = meta; + } + + /** Get the metadata of the packet. + * + * @return The packet's metadata + */ + public M getMetaData() + { + return metaData; + } +} diff --git a/src/main/java/net/cshift/transit/network/packet/StaticPacket.java b/src/main/java/net/cshift/transit/network/packet/StaticPacket.java new file mode 100644 index 0000000..7c95108 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/StaticPacket.java @@ -0,0 +1,36 @@ +package net.cshift.transit.network.packet; + +import net.cshift.transit.type.*; + +/** Simple packet which stores an unchanging value. + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers. + */ +public class StaticPacket implements IStaticPacket +{ + private D data; + private Type type; + + /** Constructor. Stores the given data and uses the given type. + * + * @param dat The packet's data + * @param t The packet's type + */ + public StaticPacket(D dat, Type t) + { + data = dat; + type = t; + } + + @Override + public D getData() + { + return data; + } + + @Override + public Type getType() { + return type; + } +} diff --git a/src/main/java/net/cshift/transit/network/packet/dynamic/DynamicPacket.java b/src/main/java/net/cshift/transit/network/packet/dynamic/DynamicPacket.java new file mode 100644 index 0000000..d5feb92 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/dynamic/DynamicPacket.java @@ -0,0 +1,43 @@ +package net.cshift.transit.network.packet.dynamic; + +import net.cshift.transit.type.Type; + +/** + * Simple packet which stores a fluid value. + * + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers + */ +public class DynamicPacket implements IDynamicPacket { + private D data; + private Type type; + + /** Constructor. Stores the given data and uses the given type. + * + * @param dat The packet's data + * @param t The packet's type + */ + public DynamicPacket(D dat, Type t) + { + data = dat; + type = t; + } + + @Override + public D getData() + { + return data; + } + + @Override + public void setData(D dat) + { + data = dat; + } + + @Override + public Type getType() { + return type; + } +} diff --git a/src/main/java/net/cshift/transit/network/packet/dynamic/IDynamicPacket.java b/src/main/java/net/cshift/transit/network/packet/dynamic/IDynamicPacket.java new file mode 100644 index 0000000..ffb68a3 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/dynamic/IDynamicPacket.java @@ -0,0 +1,16 @@ +package net.cshift.transit.network.packet.dynamic; + +import net.cshift.transit.network.packet.IStaticPacket; + +/** Interface describing a fluid packet. + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers + */ +public interface IDynamicPacket extends IStaticPacket{ + /**Set the packet's data. + * + * @return The packet's data + */ + public void setData(D dat); +} diff --git a/src/main/java/net/cshift/transit/network/packet/dynamic/MetaDynamicPacket.java b/src/main/java/net/cshift/transit/network/packet/dynamic/MetaDynamicPacket.java new file mode 100644 index 0000000..9e7d293 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/dynamic/MetaDynamicPacket.java @@ -0,0 +1,44 @@ +package net.cshift.transit.network.packet.dynamic; + +import net.cshift.transit.type.Type; + +/** Static packet with extra data attached. + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers + * @param The type of metadata +*/ +public class MetaDynamicPacket extends DynamicPacket +{ + private M metaData; + + /** Constructor + * + * @param dat The data to store + * @param t The Type of the data + * @param meta The metadata to store + */ + public MetaDynamicPacket(D dat, Type t, M meta) + { + super(dat, t); + metaData = meta; + } + + /** Get the metadata of the packet. + * + * @return The packet's metadata + */ + public M getMetaData() + { + return metaData; + } + + /** Set the metadata of the packet. + * + * @param meta The packet's new metadata + */ + public void setMetaData(M meta) + { + metaData = meta; + } +} -- cgit v1.2.3