From ebc33c58c8a3669822a0dba99cbfe8a451782813 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 19 Nov 2019 11:40:07 -0500 Subject: [Update] Publish changes to 0.0.3 --- src/main/java/net/transit/impl/IAcceptor.java | 6 ++-- src/main/java/net/transit/impl/IConsumer.java | 4 +-- src/main/java/net/transit/impl/IGenerator.java | 4 +-- src/main/java/net/transit/impl/IProvider.java | 8 ++--- src/main/java/net/transit/packet/ArrayPacket.java | 37 ++++++++++++++++++++++ src/main/java/net/transit/packet/IPacket.java | 6 ++++ src/main/java/net/transit/packet/StaticPacket.java | 16 ++++++++++ src/main/java/net/transit/type/BaseType.java | 14 ++++++++ src/main/java/net/transit/type/IBaseType.java | 7 ---- src/main/java/net/transit/type/IType.java | 10 ------ src/main/java/net/transit/type/Type.java | 18 +++++++++++ .../java/net/transit/type/typebase/MetaBase.java | 6 ++-- .../java/net/transit/type/typebase/NumberBase.java | 6 ++-- .../java/net/transit/type/typebase/StringBase.java | 6 ++-- .../java/net/transit/type/typegroup/TypeGroup.java | 20 ++++++------ .../net/transit/type/typegroup/TypeRegister.java | 8 +++-- 16 files changed, 127 insertions(+), 49 deletions(-) create mode 100644 src/main/java/net/transit/packet/ArrayPacket.java create mode 100644 src/main/java/net/transit/packet/IPacket.java create mode 100644 src/main/java/net/transit/packet/StaticPacket.java create mode 100644 src/main/java/net/transit/type/BaseType.java delete mode 100644 src/main/java/net/transit/type/IBaseType.java delete mode 100644 src/main/java/net/transit/type/IType.java create mode 100644 src/main/java/net/transit/type/Type.java (limited to 'src') diff --git a/src/main/java/net/transit/impl/IAcceptor.java b/src/main/java/net/transit/impl/IAcceptor.java index 9433ea3..7fe06aa 100644 --- a/src/main/java/net/transit/impl/IAcceptor.java +++ b/src/main/java/net/transit/impl/IAcceptor.java @@ -1,13 +1,13 @@ package net.transit.impl; -import net.transit.type.IType; +import net.transit.packet.IPacket; import net.minecraft.util.math.Direction; -public interface IAcceptor> +public interface IAcceptor { // Direction given if acceptor is a block public boolean canAccept(Direction d); // Accept (or not) a provided T (should trigger ITransferEvent) - public boolean accept(T provided); + public boolean accept(IPacket provided); } \ No newline at end of file diff --git a/src/main/java/net/transit/impl/IConsumer.java b/src/main/java/net/transit/impl/IConsumer.java index d709430..7b3b070 100644 --- a/src/main/java/net/transit/impl/IConsumer.java +++ b/src/main/java/net/transit/impl/IConsumer.java @@ -1,8 +1,6 @@ package net.transit.impl; -import net.transit.type.IType; - -public interface IConsumer> extends IAcceptor +public interface IConsumer extends IAcceptor { public boolean canConsume(); diff --git a/src/main/java/net/transit/impl/IGenerator.java b/src/main/java/net/transit/impl/IGenerator.java index 009f268..f69de2f 100644 --- a/src/main/java/net/transit/impl/IGenerator.java +++ b/src/main/java/net/transit/impl/IGenerator.java @@ -1,8 +1,6 @@ package net.transit.impl; -import net.transit.type.IType; - -public interface IGenerator> extends IProvider +public interface IGenerator extends IProvider { public boolean canGenerate(); diff --git a/src/main/java/net/transit/impl/IProvider.java b/src/main/java/net/transit/impl/IProvider.java index b613436..94e903f 100644 --- a/src/main/java/net/transit/impl/IProvider.java +++ b/src/main/java/net/transit/impl/IProvider.java @@ -1,17 +1,17 @@ package net.transit.impl; -import net.transit.type.IType; +import net.transit.packet.IPacket; import net.minecraft.util.math.Direction; -public interface IProvider> +public interface IProvider { // Direction given if provider is a block public boolean canProvide(Direction d); // Provide the next T (should trigger ITransferEvent) - public T provide(); + public IPacket provide(); // Retain the rejected T if the acceptor did not accept it (should trigger ITransferEvent) - public void accept(T rejected); + public void retain(IPacket rejected); } \ No newline at end of file diff --git a/src/main/java/net/transit/packet/ArrayPacket.java b/src/main/java/net/transit/packet/ArrayPacket.java new file mode 100644 index 0000000..09ef5f1 --- /dev/null +++ b/src/main/java/net/transit/packet/ArrayPacket.java @@ -0,0 +1,37 @@ +package net.transit.packet; + +import java.util.ArrayList; + +public class ArrayPacket implements IPacket +{ + private ArrayList arrayData; + + public ArrayPacket(D startValue) + { + arrayData = new ArrayList(0); + arrayData.add(startValue); + } + + public D getData() + { + if(arrayData.size() > 0) return arrayData.get(0); + return null; + } + + public void addData(D data) + { + arrayData.add(data); + } + + public D popAndShift() + { + D temp = null; + + if(arrayData.size() > 0) + { + temp = arrayData.remove(0); + } + + return temp; + } +} \ No newline at end of file diff --git a/src/main/java/net/transit/packet/IPacket.java b/src/main/java/net/transit/packet/IPacket.java new file mode 100644 index 0000000..2b1753b --- /dev/null +++ b/src/main/java/net/transit/packet/IPacket.java @@ -0,0 +1,6 @@ +package net.transit.packet; + +public interface IPacket +{ + public D getData(); +} \ No newline at end of file diff --git a/src/main/java/net/transit/packet/StaticPacket.java b/src/main/java/net/transit/packet/StaticPacket.java new file mode 100644 index 0000000..fb11dd7 --- /dev/null +++ b/src/main/java/net/transit/packet/StaticPacket.java @@ -0,0 +1,16 @@ +package net.transit.packet; + +public class StaticPacket implements IPacket +{ + private D data; + + public StaticPacket(D dat) + { + data = dat; + } + + public D getData() + { + return data; + } +} \ No newline at end of file diff --git a/src/main/java/net/transit/type/BaseType.java b/src/main/java/net/transit/type/BaseType.java new file mode 100644 index 0000000..1202f95 --- /dev/null +++ b/src/main/java/net/transit/type/BaseType.java @@ -0,0 +1,14 @@ +package net.transit.type; + +public abstract class BaseType +{ + + public static final String TYPE_NAME = "BASE"; + + private T data; + + public T getData() + { + return data; + } +} \ No newline at end of file diff --git a/src/main/java/net/transit/type/IBaseType.java b/src/main/java/net/transit/type/IBaseType.java deleted file mode 100644 index 99ec178..0000000 --- a/src/main/java/net/transit/type/IBaseType.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.transit.type; - -public interface IBaseType -{ - - public T getData(); -} \ No newline at end of file diff --git a/src/main/java/net/transit/type/IType.java b/src/main/java/net/transit/type/IType.java deleted file mode 100644 index ff401f1..0000000 --- a/src/main/java/net/transit/type/IType.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.transit.type; - -public interface IType extends IBaseType -{ - public String getTypeName(); - - public IBaseType convertToBase(); - - public IType convertFromBase(IBaseType base); -} \ No newline at end of file diff --git a/src/main/java/net/transit/type/Type.java b/src/main/java/net/transit/type/Type.java new file mode 100644 index 0000000..0c6fc91 --- /dev/null +++ b/src/main/java/net/transit/type/Type.java @@ -0,0 +1,18 @@ +package net.transit.type; + +import net.transit.packet.IPacket; + +public abstract class Type extends BaseType +{ + public static final String TYPE_NAME = "TYPE"; + + public B convertToBase() + { + return null; + } + + public IPacket convertFromBase(B base) + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/transit/type/typebase/MetaBase.java b/src/main/java/net/transit/type/typebase/MetaBase.java index fdf69a8..e1e6f5c 100644 --- a/src/main/java/net/transit/type/typebase/MetaBase.java +++ b/src/main/java/net/transit/type/typebase/MetaBase.java @@ -1,12 +1,14 @@ package net.transit.type.typebase; -import net.transit.type.IBaseType; +import net.transit.type.BaseType; -public class MetaBase> implements IBaseType +public class MetaBase> extends BaseType { private T data; private String metaData; + public static final String TYPE_NAME = "BASE_META"; + public MetaBase(T dat, String meta) { data = dat; diff --git a/src/main/java/net/transit/type/typebase/NumberBase.java b/src/main/java/net/transit/type/typebase/NumberBase.java index 2a3c013..a8d5ca3 100644 --- a/src/main/java/net/transit/type/typebase/NumberBase.java +++ b/src/main/java/net/transit/type/typebase/NumberBase.java @@ -1,11 +1,13 @@ package net.transit.type.typebase; -import net.transit.type.IBaseType; +import net.transit.type.BaseType; -public class NumberBase implements IBaseType +public class NumberBase extends BaseType { private Number data; + public static final String TYPE_NAME = "BASE_NUMBER"; + public NumberBase(Number dat) { data = dat; diff --git a/src/main/java/net/transit/type/typebase/StringBase.java b/src/main/java/net/transit/type/typebase/StringBase.java index c1e32fe..8138b8d 100644 --- a/src/main/java/net/transit/type/typebase/StringBase.java +++ b/src/main/java/net/transit/type/typebase/StringBase.java @@ -1,11 +1,13 @@ package net.transit.type.typebase; -import net.transit.type.IBaseType; +import net.transit.type.BaseType; -public class StringBase implements IBaseType +public class StringBase extends BaseType { private String data; + public static final String TYPE_NAME = "BASE_STRING"; + public StringBase(String dat) { data = dat; diff --git a/src/main/java/net/transit/type/typegroup/TypeGroup.java b/src/main/java/net/transit/type/typegroup/TypeGroup.java index 4524ae0..4349df6 100644 --- a/src/main/java/net/transit/type/typegroup/TypeGroup.java +++ b/src/main/java/net/transit/type/typegroup/TypeGroup.java @@ -2,43 +2,43 @@ package net.transit.type.typegroup; import java.util.ArrayList; -import net.transit.type.IType; -import net.transit.type.IBaseType; +import net.transit.type.Type; +import net.transit.type.BaseType; public class TypeGroup { - private IBaseType baseType; + private BaseType baseType; private String groupName; - private ArrayList> types; + private ArrayList> types; /**Create a new TypeGroup * * @param base The base type of the group. * @param name The identifier of the group. Should be in all caps. */ - public TypeGroup(IBaseType base, String name) + public TypeGroup(BaseType base, String name) { baseType = base; - types = new ArrayList>(0); + types = new ArrayList>(0); groupName = name; } // Return the base type - public IBaseType getBaseType() + public BaseType getBaseType() { return baseType; } // Returns if the type is supported by the group - public boolean hasType(IType t) + public boolean hasType(Type t) { - for(IType gtype : types) + for(Type gtype : types) { - if(t.getTypeName() == gtype.getTypeName()) return true; + if(t.TYPE_NAME == gtype.TYPE_NAME) return true; } return false; diff --git a/src/main/java/net/transit/type/typegroup/TypeRegister.java b/src/main/java/net/transit/type/typegroup/TypeRegister.java index 8de81a6..d226cbe 100644 --- a/src/main/java/net/transit/type/typegroup/TypeRegister.java +++ b/src/main/java/net/transit/type/typegroup/TypeRegister.java @@ -2,7 +2,7 @@ package net.transit.type.typegroup; import java.util.ArrayList; -import net.transit.type.IType; +import net.transit.type.Type; public final class TypeRegister { @@ -11,10 +11,12 @@ public final class TypeRegister // Hold all the groups private static ArrayList> groups = new ArrayList>(0); + private static ArrayList caster = new ArrayList(0); + // Add a group public static void addTypeGroup(TypeGroup g) { - if(getTypeGroup(g.getGroupName()) == null) return; + if(getTypeGroup(g.getGroupName()) != null) return; groups.add(g); } @@ -30,7 +32,7 @@ public final class TypeRegister return null; } - public static String groupOf(IType t) + public static String groupOf(Type t) { for(TypeGroup g : groups) { -- cgit v1.2.3