Fleshing out the abstraction

This commit is contained in:
nossr50 2019-02-12 06:54:32 -08:00
parent b6a56d6865
commit 1ab4645223
16 changed files with 97 additions and 33 deletions

View File

@ -5,8 +5,11 @@ plugins {
repositories { repositories {
// Repo containing the Configurable library // Repo containing the Configurable library
maven("https://repo.spongepowered.org/maven") maven("https://repo.spongepowered.org/maven")
// Flow Math
maven("https://oss.sonatype.org/content/groups/public/")
} }
dependencies { dependencies {
compile("com.flowpowered", "flow-math", "1.0.4-SNAPSHOT")
compile("org.spongepowered", "configurate-yaml", "3.6") // Configurable (config library from Sponge) compile("org.spongepowered", "configurate-yaml", "3.6") // Configurable (config library from Sponge)
} }

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.core.data.blockmeta.chunkmeta; package com.gmail.nossr50.core.data.blockmeta.chunkmeta;
import com.gmail.nossr50.core.data.blockmeta.ChunkletStore; 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.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.core.datatypes; package com.gmail.nossr50.core.datatypes;
import com.gmail.nossr50.core.mcmmo.Location; import com.gmail.nossr50.core.mcmmo.world.Location;
public class LimitedSizeList { public class LimitedSizeList {
private final int size; private final int size;

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.core.mcmmo; package com.gmail.nossr50.core.mcmmo;
import com.gmail.nossr50.core.mcmmo.Named;
public interface Nameable extends Named { public interface Nameable extends Named {
/** /**
* Change the name for this entity * Change the name for this entity

View File

@ -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();
}

View File

@ -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();
}

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.core.mcmmo.block; package com.gmail.nossr50.core.mcmmo.block;
import com.gmail.nossr50.core.mcmmo.Property;
/** /**
* Represents a container of properties and values for a Block * Represents a container of properties and values for a Block
* *

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.core.mcmmo.block; package com.gmail.nossr50.core.mcmmo.block;
import com.gmail.nossr50.core.mcmmo.Property;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.util.Collection; import java.util.Collection;

View File

@ -1,4 +1,4 @@
package com.gmail.nossr50.core.mcmmo; package com.gmail.nossr50.core.mcmmo.block;
import java.util.Collection; import java.util.Collection;

View File

@ -1,21 +1,15 @@
package com.gmail.nossr50.core.mcmmo.entity; 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 com.gmail.nossr50.core.mcmmo.Named;
import com.gmail.nossr50.core.mcmmo.Unique;
import java.util.UUID; import com.gmail.nossr50.core.mcmmo.meta.MetadataHolder;
/** /**
* Entities can be a lot of things in MC * Entities can be a lot of things in MC
* Entities can be monsters, animals, players, etc... * Entities can be monsters, animals, players, etc...
*/ */
public interface Entity extends Location, Named { public interface Entity extends Location, Named, Unique, MetadataHolder {
/**
* The UUID for this entity
*
* @return this entity's UUID
*/
UUID getUUID();
/** /**
* The Location for this entity * The Location for this entity

View File

@ -3,8 +3,6 @@ package com.gmail.nossr50.core.mcmmo.entity;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.mcmmo.Nameable; import com.gmail.nossr50.core.mcmmo.Nameable;
import java.util.UUID;
/** /**
* Players * Players
*/ */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -1,4 +1,4 @@
package com.gmail.nossr50.core.mcmmo; package com.gmail.nossr50.core.mcmmo.world;
import java.util.Objects; import java.util.Objects;

View File

@ -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 * This class represents a Location in MC
@ -6,26 +9,32 @@ package com.gmail.nossr50.core.mcmmo;
*/ */
public interface Location { public interface Location {
/**
* The Vector3d of this location
* @return this vector
*/
Vector3d getVector();
/** /**
* Returns the position of this location on the x-axis * Returns the position of this location on the x-axis
* *
* @return x-axis position * @return x-axis position
*/ */
double getX(); //double getX();
/** /**
* Returns the position of this location on the y-axis * Returns the position of this location on the y-axis
* *
* @return y-axis position * @return y-axis position
*/ */
double getY(); //double getY();
/** /**
* Returns the position of this location on the z-axis * Returns the position of this location on the z-axis
* *
* @return z-axis position * @return z-axis position
*/ */
double getZ(); //double getZ();
/** /**
* The world for this Location * The world for this Location

View File

@ -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();
}