diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 71f50ad47..2c9311b60 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -5,8 +5,11 @@ plugins { repositories { // Repo containing the Configurable library maven("https://repo.spongepowered.org/maven") + // Flow Math + maven("https://oss.sonatype.org/content/groups/public/") } dependencies { + compile("com.flowpowered", "flow-math", "1.0.4-SNAPSHOT") compile("org.spongepowered", "configurate-yaml", "3.6") // Configurable (config library from Sponge) } diff --git a/core/src/main/java/com/gmail/nossr50/core/data/blockmeta/chunkmeta/PrimitiveChunkStore.java b/core/src/main/java/com/gmail/nossr50/core/data/blockmeta/chunkmeta/PrimitiveChunkStore.java index d0acb78ab..16fb7d21c 100644 --- a/core/src/main/java/com/gmail/nossr50/core/data/blockmeta/chunkmeta/PrimitiveChunkStore.java +++ b/core/src/main/java/com/gmail/nossr50/core/data/blockmeta/chunkmeta/PrimitiveChunkStore.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.core.data.blockmeta.chunkmeta; import com.gmail.nossr50.core.data.blockmeta.ChunkletStore; -import com.gmail.nossr50.core.mcmmo.World; +import com.gmail.nossr50.core.mcmmo.world.World; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/core/src/main/java/com/gmail/nossr50/core/datatypes/LimitedSizeList.java b/core/src/main/java/com/gmail/nossr50/core/datatypes/LimitedSizeList.java index 8f3efa7ff..7983a20de 100644 --- a/core/src/main/java/com/gmail/nossr50/core/datatypes/LimitedSizeList.java +++ b/core/src/main/java/com/gmail/nossr50/core/datatypes/LimitedSizeList.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.core.datatypes; -import com.gmail.nossr50.core.mcmmo.Location; +import com.gmail.nossr50.core.mcmmo.world.Location; public class LimitedSizeList { private final int size; diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Nameable.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/Nameable.java index a69a5ca45..435acbfbd 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Nameable.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/Nameable.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.core.mcmmo; +import com.gmail.nossr50.core.mcmmo.Named; + public interface Nameable extends Named { /** * Change the name for this entity diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Unique.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/Unique.java new file mode 100644 index 000000000..d0f1a6395 --- /dev/null +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/Unique.java @@ -0,0 +1,11 @@ +package com.gmail.nossr50.core.mcmmo; + +import java.util.UUID; + +/** + * Many things in MC use UUID to be uniquely identified + * + */ +public interface Unique { + UUID getUUID(); +} diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/World.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/World.java deleted file mode 100644 index a14760be2..000000000 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/World.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.gmail.nossr50.core.mcmmo; - -public interface World { - /** - * Gets the name of this World - * - * @return the name of this world - */ - String getName(); -} diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Block.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Block.java index 9dcfdd847..7aced11ed 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Block.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Block.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.core.mcmmo.block; -import com.gmail.nossr50.core.mcmmo.Property; - /** * Represents a container of properties and values for a Block * diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/BlockState.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/BlockState.java index 574137060..cd99581d1 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/BlockState.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/BlockState.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.core.mcmmo.block; -import com.gmail.nossr50.core.mcmmo.Property; import com.google.common.collect.ImmutableMap; import java.util.Collection; diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Property.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Property.java similarity index 95% rename from core/src/main/java/com/gmail/nossr50/core/mcmmo/Property.java rename to core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Property.java index 1261ad085..da967a1af 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Property.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/block/Property.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.core.mcmmo; +package com.gmail.nossr50.core.mcmmo.block; import java.util.Collection; diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Entity.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Entity.java index f6c6d9ed7..60921d830 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Entity.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Entity.java @@ -1,21 +1,15 @@ package com.gmail.nossr50.core.mcmmo.entity; -import com.gmail.nossr50.core.mcmmo.Location; +import com.gmail.nossr50.core.mcmmo.world.Location; import com.gmail.nossr50.core.mcmmo.Named; - -import java.util.UUID; +import com.gmail.nossr50.core.mcmmo.Unique; +import com.gmail.nossr50.core.mcmmo.meta.MetadataHolder; /** * Entities can be a lot of things in MC * Entities can be monsters, animals, players, etc... */ -public interface Entity extends Location, Named { - /** - * The UUID for this entity - * - * @return this entity's UUID - */ - UUID getUUID(); +public interface Entity extends Location, Named, Unique, MetadataHolder { /** * The Location for this entity diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Player.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Player.java index 99f5e399d..cd7b23493 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Player.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/entity/Player.java @@ -3,8 +3,6 @@ package com.gmail.nossr50.core.mcmmo.entity; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.mcmmo.Nameable; -import java.util.UUID; - /** * Players */ diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/meta/Metadata.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/meta/Metadata.java new file mode 100644 index 000000000..ccc775083 --- /dev/null +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/meta/Metadata.java @@ -0,0 +1,25 @@ +package com.gmail.nossr50.core.mcmmo.meta; + +/** + * Represents custom state in the API + * Mostly provided by plugins + */ +public interface Metadata { + /** + * The metadata key for this metadata + * @return the metadata key + */ + String getKey(); + + /** + * The value for this metadata key + * @return the value of this metadata + */ + Object getValue(); + + /** + * Replace the value in this metadata + * @param newValue the replacement metadata value + */ + void setValue(Object newValue); +} diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/meta/MetadataHolder.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/meta/MetadataHolder.java new file mode 100644 index 000000000..ce2c7e646 --- /dev/null +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/meta/MetadataHolder.java @@ -0,0 +1,20 @@ +package com.gmail.nossr50.core.mcmmo.meta; + +/** + * A metadataHolder is something that can hold metadata + * Both Bukkit and Sponge provide metadata APIs + */ +public interface MetadataHolder { + /** + * Gets the metadata for the appropriate key + * @param key the key for the metadata + * @return the metadata for this key + */ + Metadata getMetadata(String key); + + /** + * Sets the metadata, will replace metadata with an existing key or add metadata if there was none + * @param metadata metadata to add + */ + void setMetadata(Metadata metadata); +} diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/AbstractWorld.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/AbstractWorld.java similarity index 96% rename from core/src/main/java/com/gmail/nossr50/core/mcmmo/AbstractWorld.java rename to core/src/main/java/com/gmail/nossr50/core/mcmmo/world/AbstractWorld.java index 2c587ba5f..4e874d053 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/AbstractWorld.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/AbstractWorld.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.core.mcmmo; +package com.gmail.nossr50.core.mcmmo.world; import java.util.Objects; diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Location.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/Location.java similarity index 66% rename from core/src/main/java/com/gmail/nossr50/core/mcmmo/Location.java rename to core/src/main/java/com/gmail/nossr50/core/mcmmo/world/Location.java index 31377eac9..2ee1343f2 100644 --- a/core/src/main/java/com/gmail/nossr50/core/mcmmo/Location.java +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/Location.java @@ -1,4 +1,7 @@ -package com.gmail.nossr50.core.mcmmo; +package com.gmail.nossr50.core.mcmmo.world; + +import com.flowpowered.math.vector.Vector3d; +import com.gmail.nossr50.core.mcmmo.world.World; /** * This class represents a Location in MC @@ -6,26 +9,32 @@ package com.gmail.nossr50.core.mcmmo; */ public interface Location { + /** + * The Vector3d of this location + * @return this vector + */ + Vector3d getVector(); + /** * Returns the position of this location on the x-axis * * @return x-axis position */ - double getX(); + //double getX(); /** * Returns the position of this location on the y-axis * * @return y-axis position */ - double getY(); + //double getY(); /** * Returns the position of this location on the z-axis * * @return z-axis position */ - double getZ(); + //double getZ(); /** * The world for this Location diff --git a/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/World.java b/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/World.java new file mode 100644 index 000000000..fd59afdce --- /dev/null +++ b/core/src/main/java/com/gmail/nossr50/core/mcmmo/world/World.java @@ -0,0 +1,15 @@ +package com.gmail.nossr50.core.mcmmo.world; + +import com.gmail.nossr50.core.mcmmo.Unique; + +/** + * Represents a world in MC + */ +public interface World extends Unique { + /** + * Gets the name of this World + * + * @return the name of this world + */ + String getName(); +}