mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 07:16:10 +00:00
move API project
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
/**
|
||||
* An interface that contains a platform delegate.
|
||||
*/
|
||||
public interface Handle {
|
||||
/**
|
||||
* Gets the delegate object.
|
||||
*
|
||||
* @return Delegate
|
||||
*/
|
||||
Object getHandle();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
public interface Logger {
|
||||
void info(String message);
|
||||
|
||||
void warning(String message);
|
||||
|
||||
void severe(String message);
|
||||
|
||||
default void stack(Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
public interface StringIdentifiable {
|
||||
String getID();
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.PluginConfig;
|
||||
import com.dfsek.terra.api.event.EventManager;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.lang.Language;
|
||||
import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a Terra mod/plugin instance.
|
||||
*/
|
||||
public interface TerraPlugin extends LoaderRegistrar {
|
||||
Logger logger();
|
||||
|
||||
boolean reload();
|
||||
|
||||
String platformName();
|
||||
|
||||
/**
|
||||
* Runs a task that may or may not be thread safe, depending on platform.
|
||||
* <p>
|
||||
* Allows platforms to define what code is safe to be run asynchronously.
|
||||
*
|
||||
* @param task Task to be run.
|
||||
*/
|
||||
default void runPossiblyUnsafeTask(Runnable task) {
|
||||
task.run();
|
||||
}
|
||||
|
||||
WorldHandle getWorldHandle();
|
||||
|
||||
PluginConfig getTerraConfig();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
Language getLanguage();
|
||||
|
||||
CheckedRegistry<ConfigPack> getConfigRegistry();
|
||||
|
||||
Registry<TerraAddon> getAddons();
|
||||
|
||||
ItemHandle getItemHandle();
|
||||
|
||||
Logger getDebugLogger();
|
||||
|
||||
EventManager getEventManager();
|
||||
|
||||
default String getVersion() {
|
||||
return "@VERSION@";
|
||||
}
|
||||
|
||||
Profiler getProfiler();
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.dfsek.terra.api.addon;
|
||||
|
||||
public interface Addon {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.addon;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
|
||||
|
||||
public interface AddonLoader {
|
||||
/**
|
||||
* Load all addons.
|
||||
* @param main TerraPlugin instance.
|
||||
*/
|
||||
void load(TerraPlugin main, CheckedRegistry<Addon> addons);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.dfsek.terra.api.addon;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an entry point for an com.dfsek.terra.addon. Implementations must be annotated with {@link Addon}.
|
||||
*/
|
||||
public abstract class TerraAddon {
|
||||
/**
|
||||
* Invoked immediately after an com.dfsek.terra.addon is loaded.
|
||||
*/
|
||||
public abstract void initialize();
|
||||
|
||||
/**
|
||||
* Gets the version of this com.dfsek.terra.addon.
|
||||
*
|
||||
* @return Addon version.
|
||||
*/
|
||||
public final @NotNull String getVersion() {
|
||||
Version version = getClass().getAnnotation(Version.class);
|
||||
return version == null ? "0.1.0" : version.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author of this com.dfsek.terra.addon.
|
||||
*
|
||||
* @return Addon author.
|
||||
*/
|
||||
public final @NotNull String getAuthor() {
|
||||
Author author = getClass().getAnnotation(Author.class);
|
||||
return author == null ? "Anon Y. Mous" : author.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name (ID) of this com.dfsek.terra.addon.
|
||||
*
|
||||
* @return Addon ID.
|
||||
*/
|
||||
public final @NotNull String getName() {
|
||||
Addon addon = getClass().getAnnotation(Addon.class);
|
||||
if(addon == null)
|
||||
throw new IllegalStateException(
|
||||
"Addon annotation not present"); // This should never happen; the presence of this annotation is checked by the com
|
||||
// .dfsek.terra.addon loader.
|
||||
return addon.value();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.dfsek.terra.api.addon.annotations;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Specifies that the annotated class is an entry point for a Terra com.dfsek.terra.addon.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Addon {
|
||||
/**
|
||||
* @return The ID of the com.dfsek.terra.addon.
|
||||
*/
|
||||
@NotNull String value();
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.dfsek.terra.api.addon.annotations;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Optional annotation that specifies the author of an com.dfsek.terra.addon.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Author {
|
||||
/**
|
||||
* @return Name of the com.dfsek.terra.addon author.
|
||||
*/
|
||||
@NotNull String value();
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.dfsek.terra.api.addon.annotations;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Optional annotation that specifies dependencies of an com.dfsek.terra.addon.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Depends {
|
||||
/**
|
||||
* @return All addons this com.dfsek.terra.addon is dependent upon.
|
||||
*/
|
||||
@NotNull String[] value();
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.dfsek.terra.api.addon.annotations;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Optional annotation that specifies the version of an com.dfsek.terra.addon.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Version {
|
||||
/**
|
||||
* @return Version of the com.dfsek.terra.addon.
|
||||
*/
|
||||
@NotNull String value();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.block;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
|
||||
public interface BlockType extends Handle {
|
||||
BlockState getDefaultData();
|
||||
|
||||
boolean isSolid();
|
||||
|
||||
boolean isWater();
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.dfsek.terra.api.block.entity;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
|
||||
public interface BlockEntity extends Handle {
|
||||
boolean update(boolean applyPhysics);
|
||||
|
||||
default void applyState(String state) {
|
||||
// Do nothing by default.
|
||||
}
|
||||
|
||||
Vector3 getPosition();
|
||||
|
||||
int getX();
|
||||
|
||||
int getY();
|
||||
|
||||
int getZ();
|
||||
|
||||
BlockState getBlockData();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.dfsek.terra.api.block.entity;
|
||||
|
||||
import com.dfsek.terra.api.inventory.BlockInventoryHolder;
|
||||
|
||||
|
||||
public interface Container extends BlockEntity, BlockInventoryHolder {
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.dfsek.terra.api.block.entity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
|
||||
|
||||
public interface MobSpawner extends BlockEntity {
|
||||
EntityType getSpawnedType();
|
||||
|
||||
void setSpawnedType(@NotNull EntityType creatureType);
|
||||
|
||||
int getDelay();
|
||||
|
||||
void setDelay(int delay);
|
||||
|
||||
int getMinSpawnDelay();
|
||||
|
||||
void setMinSpawnDelay(int delay);
|
||||
|
||||
int getMaxSpawnDelay();
|
||||
|
||||
void setMaxSpawnDelay(int delay);
|
||||
|
||||
int getSpawnCount();
|
||||
|
||||
void setSpawnCount(int spawnCount);
|
||||
|
||||
int getMaxNearbyEntities();
|
||||
|
||||
void setMaxNearbyEntities(int maxNearbyEntities);
|
||||
|
||||
int getRequiredPlayerRange();
|
||||
|
||||
void setRequiredPlayerRange(int requiredPlayerRange);
|
||||
|
||||
int getSpawnRange();
|
||||
|
||||
void setSpawnRange(int spawnRange);
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.dfsek.terra.api.block.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class SerialState {
|
||||
protected final Map<String, Property<?>> properties = new HashMap<>();
|
||||
|
||||
public SerialState() {
|
||||
}
|
||||
|
||||
public static Map<String, String> parse(String props) {
|
||||
String[] sep = props.split(",");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for(String item : sep) {
|
||||
map.put(item.substring(0, item.indexOf('=')), item.substring(item.indexOf('=') + 1));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(String id, Class<T> clazz) {
|
||||
checkExists(id);
|
||||
Property<?> prop = properties.get(id);
|
||||
checkType(clazz, prop.getValue(), id);
|
||||
return (T) prop.getValue();
|
||||
}
|
||||
|
||||
private void checkExists(String prop) {
|
||||
if(!properties.containsKey(prop)) throw new IllegalArgumentException("No such property \"" + prop + "\"");
|
||||
}
|
||||
|
||||
private void checkType(Class<?> clazz, Object o, String id) {
|
||||
if(!clazz.isInstance(o))
|
||||
throw new IllegalArgumentException("Invalid data for property " + id + ": " + o);
|
||||
}
|
||||
|
||||
public void setProperty(String id, Object value) {
|
||||
checkExists(id);
|
||||
Property<?> prop = properties.get(id);
|
||||
checkType(prop.getValueClass(), value, id);
|
||||
prop.setValue(value);
|
||||
}
|
||||
|
||||
public int getInteger(String id) {
|
||||
checkExists(id);
|
||||
Property<?> prop = properties.get(id);
|
||||
checkType(Integer.class, prop.getValue(), id);
|
||||
return (Integer) prop.getValue();
|
||||
}
|
||||
|
||||
public String getString(String id) {
|
||||
checkExists(id);
|
||||
Property<?> prop = properties.get(id);
|
||||
checkType(String.class, prop.getValue(), id);
|
||||
return (String) prop.getValue();
|
||||
}
|
||||
|
||||
public long getLong(String id) {
|
||||
checkExists(id);
|
||||
Property<?> prop = properties.get(id);
|
||||
checkType(Long.class, prop.getValue(), id);
|
||||
return (Long) prop.getValue();
|
||||
}
|
||||
|
||||
public boolean getBoolean(String id) {
|
||||
checkExists(id);
|
||||
Property<?> prop = properties.get(id);
|
||||
checkType(Boolean.class, prop.getValue(), id);
|
||||
return (Boolean) prop.getValue();
|
||||
}
|
||||
|
||||
|
||||
protected static class Property<T> {
|
||||
private final Class<T> clazz;
|
||||
private Object value;
|
||||
|
||||
public Property(Class<T> clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public Class<T> getValueClass() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getValue() {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.block.entity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public interface Sign extends BlockEntity {
|
||||
void setLine(int index, @NotNull String line) throws IndexOutOfBoundsException;
|
||||
|
||||
@NotNull String[] getLines();
|
||||
|
||||
@NotNull String getLine(int index) throws IndexOutOfBoundsException;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
|
||||
|
||||
public interface BlockState extends Cloneable, Handle {
|
||||
|
||||
boolean matches(BlockState other);
|
||||
|
||||
BlockState clone();
|
||||
|
||||
<T> boolean has(Property<T> property);
|
||||
|
||||
<T> T get(Property<T> property);
|
||||
|
||||
<T> BlockState set(Property<T> property, T value);
|
||||
|
||||
default <T> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
||||
if(has(property)) action.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
default <T> BlockState setIfPresent(Property<T> property, T value) {
|
||||
if(has(property)) set(property, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
BlockType getBlockType();
|
||||
|
||||
String getAsString();
|
||||
|
||||
boolean isAir();
|
||||
|
||||
boolean isStructureVoid();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public interface Property<T> {
|
||||
Collection<T> values();
|
||||
|
||||
Class<T> getType();
|
||||
|
||||
String getName();
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.base;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
|
||||
|
||||
public interface BooleanProperty extends Property<Boolean> {
|
||||
static BooleanProperty of(String name) {
|
||||
return new BooleanProperty() {
|
||||
private static final Collection<Boolean> BOOLEANS = Arrays.asList(true, false);
|
||||
|
||||
@Override
|
||||
public Collection<Boolean> values() {
|
||||
return BOOLEANS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
default Class<Boolean> getType() {
|
||||
return Boolean.class;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.base;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
|
||||
|
||||
public interface EnumProperty<T extends Enum<T>> extends Property<T> {
|
||||
static <T extends Enum<T>> EnumProperty<T> of(String name, Class<T> clazz) {
|
||||
return new EnumProperty<T>() {
|
||||
private final Lazy<Collection<T>> constants = Lazy.lazy(() -> Arrays.asList(clazz.getEnumConstants()));
|
||||
|
||||
@Override
|
||||
public Collection<T> values() {
|
||||
return constants.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getType() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
import com.dfsek.terra.api.util.generic.Construct;
|
||||
|
||||
|
||||
public interface IntProperty extends Property<Integer> {
|
||||
static IntProperty of(String name, int min, int max) {
|
||||
return new IntProperty() {
|
||||
private final Collection<Integer> collection = Construct.construct(() -> {
|
||||
List<Integer> ints = new ArrayList<>();
|
||||
for(int i = min; i <= max; i++) {
|
||||
ints.add(i);
|
||||
}
|
||||
return ints;
|
||||
});
|
||||
|
||||
@Override
|
||||
public Collection<Integer> values() {
|
||||
return collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
default Class<Integer> getType() {
|
||||
return Integer.class;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.base;
|
||||
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Axis;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Half;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.RailShape;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
||||
|
||||
|
||||
public final class Properties {
|
||||
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("facing", Direction.class);
|
||||
public static final EnumProperty<Axis> AXIS = EnumProperty.of("axis", Axis.class);
|
||||
|
||||
public static final BooleanProperty NORTH = BooleanProperty.of("north");
|
||||
public static final BooleanProperty SOUTH = BooleanProperty.of("south");
|
||||
public static final BooleanProperty EAST = BooleanProperty.of("east");
|
||||
public static final BooleanProperty WEST = BooleanProperty.of("west");
|
||||
|
||||
public static final EnumProperty<WallHeight> NORTH_HEIGHT = EnumProperty.of("north", WallHeight.class);
|
||||
public static final EnumProperty<WallHeight> SOUTH_HEIGHT = EnumProperty.of("south", WallHeight.class);
|
||||
public static final EnumProperty<WallHeight> EAST_HEIGHT = EnumProperty.of("east", WallHeight.class);
|
||||
public static final EnumProperty<WallHeight> WEST_HEIGHT = EnumProperty.of("west", WallHeight.class);
|
||||
|
||||
public static final EnumProperty<RedstoneConnection> NORTH_CONNECTION = EnumProperty.of("north", RedstoneConnection.class);
|
||||
public static final EnumProperty<RedstoneConnection> SOUTH_CONNECTION = EnumProperty.of("south", RedstoneConnection.class);
|
||||
public static final EnumProperty<RedstoneConnection> EAST_CONNECTION = EnumProperty.of("east", RedstoneConnection.class);
|
||||
public static final EnumProperty<RedstoneConnection> WEST_CONNECTION = EnumProperty.of("west", RedstoneConnection.class);
|
||||
|
||||
|
||||
public static final EnumProperty<RailShape> RAIL_SHAPE = EnumProperty.of("shape", RailShape.class);
|
||||
public static final EnumProperty<Half> HALF = EnumProperty.of("half", Half.class);
|
||||
|
||||
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 15);
|
||||
|
||||
public static final BooleanProperty WATERLOGGED = BooleanProperty.of("waterlogged");
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
public enum Axis {
|
||||
X,
|
||||
Y,
|
||||
Z
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.generic.Construct;
|
||||
|
||||
|
||||
public enum Direction {
|
||||
NORTH(0, 0, 0, -1),
|
||||
EAST(1, 1, 0, 0),
|
||||
SOUTH(2, 0, 0, 1),
|
||||
WEST(3, -1, 0, 0),
|
||||
UP(-1, 0, 1, 0),
|
||||
DOWN(-1, 0, -1, 0);
|
||||
|
||||
private static final Direction[] rotations = Construct.construct(() -> new Direction[]{ NORTH, SOUTH, EAST, WEST });
|
||||
|
||||
private final int rotation;
|
||||
|
||||
private final int modX;
|
||||
private final int modY;
|
||||
private final int modZ;
|
||||
|
||||
Direction(int rotation, int modX, int modY, int modZ) {
|
||||
this.rotation = rotation;
|
||||
this.modX = modX;
|
||||
this.modY = modY;
|
||||
this.modZ = modZ;
|
||||
}
|
||||
|
||||
public Direction rotate(Rotation rotation) {
|
||||
switch(this) {
|
||||
case UP:
|
||||
case DOWN:
|
||||
return this;
|
||||
default:
|
||||
return rotations[(this.rotation + rotation.getDegrees() / 90) % 4];
|
||||
}
|
||||
}
|
||||
|
||||
public Direction opposite() {
|
||||
switch(this) {
|
||||
case DOWN:
|
||||
return UP;
|
||||
case UP:
|
||||
return DOWN;
|
||||
case EAST:
|
||||
return WEST;
|
||||
case WEST:
|
||||
return EAST;
|
||||
case NORTH:
|
||||
return SOUTH;
|
||||
case SOUTH:
|
||||
return NORTH;
|
||||
}
|
||||
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public int getModX() {
|
||||
return modX;
|
||||
}
|
||||
|
||||
public int getModY() {
|
||||
return modY;
|
||||
}
|
||||
|
||||
public int getModZ() {
|
||||
return modZ;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
public enum Half {
|
||||
/**
|
||||
* The top half of the block, normally with the higher y coordinate.
|
||||
*/
|
||||
TOP,
|
||||
/**
|
||||
* The bottom half of the block, normally with the lower y coordinate.
|
||||
*/
|
||||
BOTTOM,
|
||||
|
||||
/**
|
||||
* Some blocks, e.g. slabs, can occupy both halves.
|
||||
*/
|
||||
DOUBLE
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
public enum RailShape {
|
||||
ASCENDING_EAST,
|
||||
ASCENDING_NORTH,
|
||||
ASCENDING_SOUTH,
|
||||
ASCENDING_WEST,
|
||||
EAST_WEST,
|
||||
NORTH_EAST,
|
||||
NORTH_SOUTH,
|
||||
NORTH_WEST,
|
||||
SOUTH_EAST,
|
||||
SOUTH_WEST
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
public enum RedstoneConnection {
|
||||
NONE,
|
||||
SIDE,
|
||||
UP
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
public enum WallHeight {
|
||||
LOW,
|
||||
NONE,
|
||||
TALL
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.dfsek.terra.api.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.command.exception.CommandException;
|
||||
import com.dfsek.terra.api.command.exception.MalformedCommandException;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public interface CommandManager {
|
||||
void execute(String command, CommandSender sender, List<String> args) throws CommandException;
|
||||
|
||||
void register(String name, Class<? extends CommandTemplate> clazz) throws MalformedCommandException;
|
||||
|
||||
List<String> tabComplete(String command, CommandSender sender, List<String> args) throws CommandException;
|
||||
|
||||
int getMaxArgumentDepth();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.command;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public interface CommandTemplate {
|
||||
void execute(CommandSender sender);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.dfsek.terra.api.command.arg.ArgumentParser;
|
||||
import com.dfsek.terra.api.command.arg.StringArgumentParser;
|
||||
import com.dfsek.terra.api.command.tab.NothingCompleter;
|
||||
import com.dfsek.terra.api.command.tab.TabCompleter;
|
||||
|
||||
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Argument {
|
||||
String value();
|
||||
|
||||
boolean required() default true;
|
||||
|
||||
Class<? extends TabCompleter> tabCompleter() default NothingCompleter.class;
|
||||
|
||||
Class<? extends ArgumentParser<?>> argumentParser() default StringArgumentParser.class;
|
||||
|
||||
String defaultValue() default "";
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Command {
|
||||
Argument[] arguments() default { };
|
||||
|
||||
Switch[] switches() default { };
|
||||
|
||||
Subcommand[] subcommands() default { };
|
||||
|
||||
String usage() default "";
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
public @interface Subcommand {
|
||||
String value();
|
||||
|
||||
String[] aliases() default { };
|
||||
|
||||
Class<? extends CommandTemplate> clazz();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
public @interface Switch {
|
||||
String value();
|
||||
|
||||
String[] aliases() default { };
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation.inject;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ArgumentTarget {
|
||||
String value();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation.inject;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface SwitchTarget {
|
||||
String value();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation.type;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Command may only be executed with debug mode enabled.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DebugCommand {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation.type;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Marks command as player-only
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PlayerCommand {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.command.annotation.type;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Command may only be executed in a Terra world.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WorldCommand {
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.command.arg;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public interface ArgumentParser<T> {
|
||||
T parse(CommandSender sender, String arg);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.dfsek.terra.api.command.arg;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public class DoubleArgumentParser implements ArgumentParser<Double> {
|
||||
@Override
|
||||
public Double parse(CommandSender sender, String arg) {
|
||||
return arg == null ? null : Double.parseDouble(arg);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.dfsek.terra.api.command.arg;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public class IntegerArgumentParser implements ArgumentParser<Integer> {
|
||||
@Override
|
||||
public Integer parse(CommandSender sender, String arg) {
|
||||
return arg == null ? null : Integer.parseInt(arg);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.dfsek.terra.api.command.arg;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public class StringArgumentParser implements ArgumentParser<String> {
|
||||
@Override
|
||||
public String parse(CommandSender sender, String arg) {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.command.exception;
|
||||
|
||||
public abstract class CommandException extends Exception {
|
||||
private static final long serialVersionUID = -2955328495045879822L;
|
||||
|
||||
public CommandException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CommandException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.command.exception;
|
||||
|
||||
public class ExecutionException extends CommandException {
|
||||
private static final long serialVersionUID = -6345523475880607959L;
|
||||
|
||||
public ExecutionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ExecutionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.command.exception;
|
||||
|
||||
public class InvalidArgumentsException extends CommandException {
|
||||
private static final long serialVersionUID = 7563619667472569824L;
|
||||
|
||||
public InvalidArgumentsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidArgumentsException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.dfsek.terra.api.command.exception;
|
||||
|
||||
/**
|
||||
* Thrown when command is incorrectly defined.
|
||||
*/
|
||||
public class MalformedCommandException extends CommandException {
|
||||
private static final long serialVersionUID = -5417760860407895496L;
|
||||
|
||||
public MalformedCommandException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MalformedCommandException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.command.exception;
|
||||
|
||||
public class SwitchFormatException extends CommandException {
|
||||
private static final long serialVersionUID = -965858989317844628L;
|
||||
|
||||
public SwitchFormatException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SwitchFormatException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.dfsek.terra.api.command.tab;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public class NothingCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.dfsek.terra.api.command.tab;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public interface TabCompleter {
|
||||
List<String> complete(CommandSender sender);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
|
||||
import com.dfsek.terra.api.StringIdentifiable;
|
||||
|
||||
|
||||
public interface AbstractableTemplate extends ConfigTemplate, StringIdentifiable {
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
|
||||
|
||||
public interface ConfigFactory<C extends ConfigTemplate, O> {
|
||||
O build(C config, TerraPlugin main) throws LoadException;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.StringIdentifiable;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryFactory;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryHolder;
|
||||
import com.dfsek.terra.api.tectonic.LoaderHolder;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
|
||||
|
||||
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder, StringIdentifiable {
|
||||
WorldConfig toWorldConfig(World world);
|
||||
|
||||
void registerConfigType(ConfigType<?, ?> type, String id, int priority);
|
||||
|
||||
Set<TerraAddon> addons();
|
||||
|
||||
boolean vanillaMobs();
|
||||
|
||||
boolean vanillaStructures();
|
||||
|
||||
boolean vanillaCaves();
|
||||
|
||||
boolean disableStructures();
|
||||
|
||||
boolean doBetaCarvers();
|
||||
|
||||
boolean vanillaFlora();
|
||||
|
||||
BiomeProvider getBiomeProviderBuilder();
|
||||
|
||||
<T> CheckedRegistry<T> getOrCreateRegistry(Type clazz);
|
||||
|
||||
default <T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz) {
|
||||
return getOrCreateRegistry((Type) clazz);
|
||||
}
|
||||
|
||||
default <T> CheckedRegistry<T> getOrCreateRegistry(TypeKey<T> type) {
|
||||
return getOrCreateRegistry(type.getType());
|
||||
}
|
||||
|
||||
List<GenerationStageProvider> getStages();
|
||||
|
||||
Loader getLoader();
|
||||
|
||||
String getAuthor();
|
||||
|
||||
String getVersion();
|
||||
|
||||
Map<String, String> getLocatable();
|
||||
|
||||
RegistryFactory getRegistryFactory();
|
||||
|
||||
ChunkGeneratorProvider getGeneratorProvider();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
|
||||
public interface ConfigType<T extends AbstractableTemplate, R> {
|
||||
Supplier<OpenRegistry<R>> registrySupplier(ConfigPack pack);
|
||||
|
||||
T getTemplate(ConfigPack pack, TerraPlugin main);
|
||||
|
||||
ConfigFactory<T, R> getFactory();
|
||||
|
||||
TypeKey<R> getTypeKey();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
public interface Loader {
|
||||
|
||||
Loader thenNames(Consumer<List<String>> consumer) throws ConfigException;
|
||||
|
||||
Loader thenEntries(Consumer<Set<Map.Entry<String, InputStream>>> consumer) throws ConfigException;
|
||||
|
||||
/**
|
||||
* Get a single file from this Loader.
|
||||
*
|
||||
* @param singleFile File to get
|
||||
*
|
||||
* @return InputStream from file.
|
||||
*/
|
||||
InputStream get(String singleFile) throws IOException;
|
||||
|
||||
/**
|
||||
* Open a subdirectory.
|
||||
*
|
||||
* @param directory Directory to open
|
||||
* @param extension
|
||||
*/
|
||||
Loader open(String directory, String extension);
|
||||
|
||||
/**
|
||||
* Close all InputStreams opened.
|
||||
*/
|
||||
Loader close();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
|
||||
|
||||
public interface PluginConfig {
|
||||
void load(TerraPlugin main);
|
||||
|
||||
boolean dumpDefaultConfig();
|
||||
|
||||
String getLanguage();
|
||||
|
||||
boolean isDebugCommands();
|
||||
|
||||
boolean isDebugLogging();
|
||||
|
||||
boolean isDebugProfiler();
|
||||
|
||||
boolean isDebugScript();
|
||||
|
||||
long getDataSaveInterval();
|
||||
|
||||
int getBiomeSearchResolution();
|
||||
|
||||
int getCarverCacheSize();
|
||||
|
||||
int getStructureCache();
|
||||
|
||||
int getSamplerCache();
|
||||
|
||||
int getMaxRecursion();
|
||||
|
||||
int getBiomeCache();
|
||||
|
||||
int getProviderCache();
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.StringIdentifiable;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||
|
||||
|
||||
public interface WorldConfig extends StringIdentifiable {
|
||||
int elevationBlend();
|
||||
|
||||
boolean disableTrees();
|
||||
|
||||
boolean disableCarving();
|
||||
|
||||
boolean disableOres();
|
||||
|
||||
boolean disableFlora();
|
||||
|
||||
boolean disableStructures();
|
||||
|
||||
<T> Registry<T> getRegistry(Class<T> clazz);
|
||||
|
||||
World getWorld();
|
||||
|
||||
SamplerCache getSamplerCache();
|
||||
|
||||
BiomeProvider getProvider();
|
||||
|
||||
ConfigPack getPack();
|
||||
|
||||
String getAuthor();
|
||||
|
||||
String getVersion();
|
||||
|
||||
Map<String, String> getLocatable();
|
||||
|
||||
boolean isDisableSaplings();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.config.meta;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_USE)
|
||||
public @interface Meta {
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.entity;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
public interface CommandSender extends Handle {
|
||||
void sendMessage(String message);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.entity;
|
||||
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
|
||||
public interface Entity extends CommandSender {
|
||||
Vector3 position();
|
||||
|
||||
void position(Vector3 position);
|
||||
|
||||
void world(World world);
|
||||
|
||||
World world();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.dfsek.terra.api.entity;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
public interface EntityType extends Handle {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.dfsek.terra.api.entity;
|
||||
|
||||
public interface Player extends Entity {
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.event;
|
||||
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
|
||||
|
||||
public interface EventHandler {
|
||||
void handle(Event event);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.dfsek.terra.api.event;
|
||||
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
|
||||
|
||||
/**
|
||||
* Manages event registration and triggering.
|
||||
*/
|
||||
public interface EventManager {
|
||||
/**
|
||||
* Call an event, and return the execution status.
|
||||
*
|
||||
* @param event Event to pass to all registered EventListeners.
|
||||
*/
|
||||
void callEvent(Event event);
|
||||
|
||||
<T extends EventHandler> void registerHandler(Class<T> clazz, T handler);
|
||||
|
||||
<T extends EventHandler> T getHandler(Class<T> clazz);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events;
|
||||
|
||||
import com.dfsek.terra.api.util.mutable.MutableBoolean;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract class containing basic {@link Cancellable} implementation.
|
||||
*/
|
||||
public abstract class AbstractCancellable implements Cancellable {
|
||||
private final MutableBoolean cancelled = new MutableBoolean(false);
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled.set(cancelled);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events;
|
||||
|
||||
/**
|
||||
* Events that implement this interface may be cancelled.
|
||||
* <p>
|
||||
* Cancelling an event is assumed to stop the execution of whatever action triggered the event.
|
||||
*/
|
||||
public interface Cancellable extends Event {
|
||||
/**
|
||||
* Get the cancellation status of the event.
|
||||
*
|
||||
* @return Whether event is cancelled.
|
||||
*/
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Set the cancellation status of the event.
|
||||
*
|
||||
* @param cancelled Whether event is cancelled.
|
||||
*/
|
||||
void setCancelled(boolean cancelled);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events;
|
||||
|
||||
/**
|
||||
* An event that addons may listen to.
|
||||
*/
|
||||
public interface Event {
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events;
|
||||
|
||||
/**
|
||||
* An event which (optionally) passes exceptions thrown by listeners to
|
||||
* the event caller.
|
||||
*/
|
||||
public interface FailThroughEvent extends Event {
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
|
||||
/**
|
||||
* An event with functionality directly linked to a {@link ConfigPack}.
|
||||
* <p>
|
||||
* PackEvents are only invoked when the pack specifies the addon in its
|
||||
* {@code addon} key (or when the listener is global).
|
||||
*/
|
||||
@SuppressWarnings("InterfaceMayBeAnnotatedFunctional")
|
||||
public interface PackEvent extends Event {
|
||||
/**
|
||||
* Get the {@link ConfigPack} associated with this event.
|
||||
*
|
||||
* @return ConfigPack associated with the event.
|
||||
*/
|
||||
ConfigPack getPack();
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config;
|
||||
|
||||
import com.dfsek.tectonic.config.Configuration;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.Loader;
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Fired when a pack is searched for {@link Configuration}s.
|
||||
* <p>
|
||||
* Addons should listen to this event if they wish to add
|
||||
* another configuration format.
|
||||
*/
|
||||
public class ConfigurationDiscoveryEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigPack pack;
|
||||
private final Loader loader;
|
||||
|
||||
private final BiConsumer<String, Configuration> consumer;
|
||||
|
||||
public ConfigurationDiscoveryEvent(ConfigPack pack, Loader loader, BiConsumer<String, Configuration> consumer) {
|
||||
this.pack = pack;
|
||||
this.loader = loader;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void register(String identifier, Configuration config) {
|
||||
consumer.accept(identifier, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public Loader getLoader() {
|
||||
return loader;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config;
|
||||
|
||||
import com.dfsek.tectonic.abstraction.AbstractConfiguration;
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Fired when each individual configuration is loaded.
|
||||
* <p>
|
||||
* Addons should listen to this event if they wish to add
|
||||
* config values to existing {@link ConfigType}s.
|
||||
*/
|
||||
public class ConfigurationLoadEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigPack pack;
|
||||
private final AbstractConfiguration configuration;
|
||||
private final Consumer<ConfigTemplate> loader;
|
||||
private final ConfigType<?, ?> type;
|
||||
|
||||
private final Object loaded;
|
||||
|
||||
public ConfigurationLoadEvent(ConfigPack pack, AbstractConfiguration configuration, Consumer<ConfigTemplate> loader,
|
||||
ConfigType<?, ?> type, Object loaded) {
|
||||
this.pack = pack;
|
||||
this.configuration = configuration;
|
||||
this.loader = loader;
|
||||
this.type = type;
|
||||
this.loaded = loaded;
|
||||
}
|
||||
|
||||
public <T extends ConfigTemplate> T load(T template) {
|
||||
loader.accept(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
public boolean is(Class<?> clazz) {
|
||||
return clazz.isAssignableFrom(type.getTypeKey().getRawType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public AbstractConfiguration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public ConfigType<?, ?> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getLoadedObject(Class<T> clazz) {
|
||||
if(!clazz.isAssignableFrom(type.getTypeKey().getRawType()))
|
||||
throw new ClassCastException(
|
||||
"Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeKey().getType()) + " to class " +
|
||||
clazz.getCanonicalName());
|
||||
return (T) loaded;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getLoadedObject() {
|
||||
return (T) loaded;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
|
||||
/**
|
||||
* An event related to the loading process of config packs.
|
||||
*/
|
||||
public abstract class ConfigPackLoadEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigPack pack;
|
||||
private final ExceptionalConsumer<ConfigTemplate> configLoader;
|
||||
|
||||
public ConfigPackLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader) {
|
||||
this.pack = pack;
|
||||
this.configLoader = configLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a custom {@link ConfigTemplate} using the pack manifest.
|
||||
*
|
||||
* @param template Template to register.
|
||||
*/
|
||||
public void loadTemplate(ConfigTemplate template) throws ConfigException {
|
||||
configLoader.accept(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public interface ExceptionalConsumer<T extends ConfigTemplate> {
|
||||
void accept(T value) throws ConfigException;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a config pack has finished loading.
|
||||
*/
|
||||
public class ConfigPackPostLoadEvent extends ConfigPackLoadEvent {
|
||||
public ConfigPackPostLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> loader) {
|
||||
super(pack, loader);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
|
||||
/**
|
||||
* Called before a config pack's registries are filled.
|
||||
*/
|
||||
public class ConfigPackPreLoadEvent extends ConfigPackLoadEvent {
|
||||
public ConfigPackPreLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader) {
|
||||
super(pack, configLoader);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config.type;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
|
||||
|
||||
public abstract class ConfigTypeLoadEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigType<?, ?> type;
|
||||
private final CheckedRegistry<?> registry;
|
||||
|
||||
private final ConfigPack pack;
|
||||
|
||||
public ConfigTypeLoadEvent(ConfigType<?, ?> type, CheckedRegistry<?> registry, ConfigPack pack) {
|
||||
this.type = type;
|
||||
this.registry = registry;
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
public boolean is(Class<?> clazz) {
|
||||
return clazz.isAssignableFrom(type.getTypeKey().getRawType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> CheckedRegistry<T> getRegistry(Class<T> clazz) {
|
||||
if(!clazz.isAssignableFrom(type.getTypeKey().getRawType()))
|
||||
throw new ClassCastException(
|
||||
"Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeKey().getType()) + " to class " +
|
||||
clazz.getCanonicalName());
|
||||
return (CheckedRegistry<T>) registry;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config.type;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
|
||||
|
||||
public class ConfigTypePostLoadEvent extends ConfigTypeLoadEvent {
|
||||
public ConfigTypePostLoadEvent(ConfigType<?, ?> type, CheckedRegistry<?> registry, ConfigPack pack) {
|
||||
super(type, registry, pack);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.config.type;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
|
||||
|
||||
public class ConfigTypePreLoadEvent extends ConfigTypeLoadEvent {
|
||||
public ConfigTypePreLoadEvent(ConfigType<?, ?> type, CheckedRegistry<?> registry, ConfigPack pack) {
|
||||
super(type, registry, pack);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.platform;
|
||||
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
|
||||
|
||||
/**
|
||||
* Called when the platform is initialized.
|
||||
*/
|
||||
public class PlatformInitializationEvent implements Event {
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.world.generation;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Called when an entity is spawned.
|
||||
*/
|
||||
public class EntitySpawnEvent implements PackEvent {
|
||||
private final ConfigPack pack;
|
||||
private final Entity entity;
|
||||
|
||||
public EntitySpawnEvent(ConfigPack pack, Entity entity) {
|
||||
this.pack = pack;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity that triggered the event.
|
||||
*
|
||||
* @return The entity.
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.dfsek.terra.api.event.events.world.generation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.event.events.AbstractCancellable;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
|
||||
/**
|
||||
* Called when loot is populated.
|
||||
*/
|
||||
public class LootPopulateEvent extends AbstractCancellable implements PackEvent {
|
||||
private final Container container;
|
||||
private final ConfigPack pack;
|
||||
private final Structure structure;
|
||||
private LootTable table;
|
||||
|
||||
public LootPopulateEvent(Container container, LootTable table, ConfigPack pack, Structure structure) {
|
||||
this.container = container;
|
||||
this.table = table;
|
||||
this.pack = pack;
|
||||
this.structure = structure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public Vector3 getPosition() {
|
||||
return container.getPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Container} representing the inventory.
|
||||
*
|
||||
* @return Inventory recieving loot.
|
||||
*/
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the loot table to be populated.
|
||||
*
|
||||
* @return Loot table.
|
||||
*/
|
||||
public LootTable getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the loot table to be populated.
|
||||
*
|
||||
* @param table New loot table.
|
||||
*/
|
||||
public void setTable(@NotNull LootTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the script used to generate the structure.
|
||||
*
|
||||
* @return Structure script.
|
||||
*/
|
||||
public Structure getStructure() {
|
||||
return structure;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.dfsek.terra.api.event.functional;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
|
||||
|
||||
public interface EventContext<T extends Event> {
|
||||
EventContext<T> then(Consumer<T> action);
|
||||
|
||||
EventContext<T> priority(int priority);
|
||||
|
||||
EventContext<T> failThrough();
|
||||
|
||||
EventContext<T> global();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.event.functional;
|
||||
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.event.EventHandler;
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
|
||||
public interface FunctionalEventHandler extends EventHandler {
|
||||
<T extends Event> EventContext<T> register(TerraAddon addon, Class<T> clazz);
|
||||
|
||||
<T extends Event> EventContext<T> register(TerraAddon addon, TypeKey<T> clazz);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.dfsek.terra.api.handle;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.inventory.Item;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
|
||||
|
||||
public interface ItemHandle {
|
||||
|
||||
Item createItem(String data);
|
||||
|
||||
Enchantment getEnchantment(String id);
|
||||
|
||||
Set<Enchantment> getEnchantments();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.dfsek.terra.api.handle;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to be implemented for world manipulation.
|
||||
*/
|
||||
public interface WorldHandle {
|
||||
BlockState createBlockData(String data);
|
||||
|
||||
BlockState air();
|
||||
|
||||
BlockEntity createBlockEntity(Vector3 location, BlockState block, String snbt);
|
||||
|
||||
EntityType getEntity(String id);
|
||||
|
||||
/**
|
||||
* Get the locations selected by a player. (Usually via WorldEdit)
|
||||
*
|
||||
* @param player Player to get locations for
|
||||
*
|
||||
* @return Pair of locations.
|
||||
*/
|
||||
default Pair<Vector3, Vector3> getSelectedLocation(Player player) {
|
||||
throw new UnsupportedOperationException("Cannot get selection on this platform.");
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.dfsek.terra.api.injection;
|
||||
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.injection.exception.InjectionException;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic dependency injector.
|
||||
* <p>
|
||||
* Stores an object to inject, and injects it into objects passed to {@link #inject(Object)}.
|
||||
*
|
||||
* @param <T> Type of object to inject.
|
||||
*/
|
||||
public interface Injector<T> {
|
||||
/**
|
||||
* Add an explicit class as a target. Useful for applications where subclasses may cause issues with DI.
|
||||
*
|
||||
* @param target Target class type.
|
||||
*/
|
||||
void addExplicitTarget(Class<? extends T> target);
|
||||
|
||||
/**
|
||||
* Inject the stored object into an object.
|
||||
* <p>
|
||||
* Injects the stored object into any non-static, non-final fields
|
||||
* annotated with {@link Inject},
|
||||
* with type matching the stored object or any explicit targets
|
||||
* ({@link #addExplicitTarget(Class)}.
|
||||
*
|
||||
* @param object Object to inject into
|
||||
*
|
||||
* @throws InjectionException If:
|
||||
* <ul>
|
||||
* <li>Matching field annotated with {@link Inject} is final</li>
|
||||
* <li>Matching field annotated with {@link Inject} is static</li>
|
||||
* <li>A reflective access exception occurs</li>
|
||||
* </ul>
|
||||
*/
|
||||
void inject(Object object) throws InjectionException;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.injection.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Specifies that a field is a target for dependency injection.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Inject {
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.dfsek.terra.api.injection.exception;
|
||||
|
||||
import com.dfsek.terra.api.injection.Injector;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when dynamic dependency injection cannot be completed by an {@link Injector}.
|
||||
*/
|
||||
public class InjectionException extends Exception {
|
||||
private static final long serialVersionUID = -6929631447064215387L;
|
||||
|
||||
public InjectionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InjectionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory;
|
||||
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
|
||||
public interface BlockInventoryHolder extends InventoryHolder {
|
||||
Vector3 getPosition();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
public interface Inventory extends Handle {
|
||||
void setItem(int slot, ItemStack newStack);
|
||||
|
||||
int getSize();
|
||||
|
||||
ItemStack getItem(int slot);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
public interface InventoryHolder extends Handle {
|
||||
Inventory getInventory();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
/**
|
||||
* An inventory item.
|
||||
*/
|
||||
public interface Item extends Handle {
|
||||
ItemStack newItemStack(int amount);
|
||||
|
||||
double getMaxDurability();
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.inventory.item.Damageable;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
|
||||
public interface ItemStack extends Handle {
|
||||
int getAmount();
|
||||
|
||||
void setAmount(int i);
|
||||
|
||||
Item getType();
|
||||
|
||||
ItemMeta getItemMeta();
|
||||
|
||||
void setItemMeta(ItemMeta meta);
|
||||
|
||||
default boolean isDamageable() {
|
||||
return getItemMeta() instanceof Damageable;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory.item;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
public interface Damageable extends Handle {
|
||||
int getDamage();
|
||||
|
||||
void setDamage(int damage);
|
||||
|
||||
boolean hasDamage();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory.item;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface Enchantment extends Handle {
|
||||
boolean canEnchantItem(ItemStack itemStack);
|
||||
|
||||
boolean conflictsWith(Enchantment other);
|
||||
|
||||
String getID();
|
||||
|
||||
int getMaxLevel();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.api.inventory.item;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
|
||||
public interface ItemMeta extends Handle {
|
||||
void addEnchantment(Enchantment enchantment, int level);
|
||||
|
||||
Map<Enchantment, Integer> getEnchantments();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.dfsek.terra.api.lang;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public interface Language {
|
||||
void log(String messageID, Level level, Logger logger, String... args);
|
||||
|
||||
void send(String messageID, CommandSender sender, String... args);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Message getMessage(String id);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.dfsek.terra.api.lang;
|
||||
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
|
||||
|
||||
public interface Message {
|
||||
void log(Logger logger, Level level, String... args);
|
||||
|
||||
void send(CommandSender sender, String... args);
|
||||
|
||||
boolean isEmpty();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.dfsek.terra.api.noise;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
|
||||
public interface NoiseSampler {
|
||||
static NoiseSampler zero() {
|
||||
return new NoiseSampler() {
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default double getNoiseSeeded(Vector3 vector3, long seed) {
|
||||
return getNoiseSeeded(seed, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
}
|
||||
|
||||
default double getNoiseSeeded(Vector2 vector2, long seed) {
|
||||
return getNoiseSeeded(seed, vector2.getX(), vector2.getZ());
|
||||
}
|
||||
|
||||
double getNoiseSeeded(long seed, double x, double y);
|
||||
|
||||
double getNoiseSeeded(long seed, double x, double y, double z);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
|
||||
public class ProfileFrame implements AutoCloseable {
|
||||
private final Runnable action;
|
||||
|
||||
public ProfileFrame(Runnable action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user