Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified Data API #542

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
64 changes: 49 additions & 15 deletions src/main/java/org/spongepowered/api/CatalogTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,45 @@
import org.spongepowered.api.attribute.Operation;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.tile.TileEntityType;
import org.spongepowered.api.block.tile.data.BannerPatternShape;
import org.spongepowered.api.data.types.Art;
import org.spongepowered.api.data.types.BannerPatternShape;
import org.spongepowered.api.data.types.Career;
import org.spongepowered.api.data.types.CoalType;
import org.spongepowered.api.data.types.Comparison;
import org.spongepowered.api.data.types.CookedFish;
import org.spongepowered.api.data.types.DirtType;
import org.spongepowered.api.data.types.DisgusedBlockType;
import org.spongepowered.api.data.types.DyeColor;
import org.spongepowered.api.data.types.Fish;
import org.spongepowered.api.data.types.GoldenApple;
import org.spongepowered.api.data.types.Hinge;
import org.spongepowered.api.data.types.HorseColor;
import org.spongepowered.api.data.types.HorseStyle;
import org.spongepowered.api.data.types.HorseVariant;
import org.spongepowered.api.data.types.NotePitch;
import org.spongepowered.api.data.types.OcelotType;
import org.spongepowered.api.data.types.PlantType;
import org.spongepowered.api.data.types.PortionType;
import org.spongepowered.api.data.types.PrismarineType;
import org.spongepowered.api.data.types.Profession;
import org.spongepowered.api.data.types.QuartzType;
import org.spongepowered.api.data.types.RabbitType;
import org.spongepowered.api.data.types.RailDirection;
import org.spongepowered.api.data.types.SandstoneType;
import org.spongepowered.api.data.types.SkeletonType;
import org.spongepowered.api.data.types.SkullType;
import org.spongepowered.api.data.types.SlabType;
import org.spongepowered.api.data.types.StairShape;
import org.spongepowered.api.data.types.StoneType;
import org.spongepowered.api.data.types.TreeType;
import org.spongepowered.api.data.types.WallType;
import org.spongepowered.api.effect.particle.ParticleType;
import org.spongepowered.api.effect.sound.SoundType;
import org.spongepowered.api.entity.EntityInteractionType;
import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.entity.hanging.art.Art;
import org.spongepowered.api.entity.living.animal.HorseColor;
import org.spongepowered.api.entity.living.animal.HorseStyle;
import org.spongepowered.api.entity.living.animal.HorseVariant;
import org.spongepowered.api.entity.living.animal.OcelotType;
import org.spongepowered.api.entity.living.animal.RabbitType;
import org.spongepowered.api.entity.living.monster.SkeletonType;
import org.spongepowered.api.entity.living.villager.Career;
import org.spongepowered.api.entity.living.villager.Profession;
import org.spongepowered.api.entity.player.gamemode.GameMode;
import org.spongepowered.api.item.CoalType;
import org.spongepowered.api.item.CookedFish;
import org.spongepowered.api.item.DyeColor;
import org.spongepowered.api.item.Enchantment;
import org.spongepowered.api.item.FireworkShape;
import org.spongepowered.api.item.Fish;
import org.spongepowered.api.item.GoldenApple;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.equipment.EquipmentType;
import org.spongepowered.api.potion.PotionEffectType;
Expand Down Expand Up @@ -87,10 +104,13 @@ public final class CatalogTypes {
public static final Class<Career> CAREER = Career.class;
public static final Class<ChatType> CHAT_TYPE = ChatType.class;
public static final Class<CoalType> COAL_TYPE = CoalType.class;
public static final Class<Comparison> COMPARISON_TYPE = Comparison.class;
public static final Class<CookedFish> COOKED_FISH = CookedFish.class;
public static final Class<Criterion> CRITERION = Criterion.class;
public static final Class<Difficulty> DIFFICULTY = Difficulty.class;
public static final Class<DimensionType> DIMENSION_TYPE = DimensionType.class;
public static final Class<DirtType> DIRT_TYPE = DirtType.class;
public static final Class<DisgusedBlockType> DISGUSED_BLOCK_TYPE = DisgusedBlockType.class;
public static final Class<DyeColor> DYE_COLOR = DyeColor.class;
public static final Class<Enchantment> ENCHANTMENT = Enchantment.class;
public static final Class<EntityInteractionType> ENTITY_INTERACTION_TYPE = EntityInteractionType.class;
Expand All @@ -101,27 +121,41 @@ public final class CatalogTypes {
public static final Class<GameMode> GAME_MODE = GameMode.class;
public static final Class<GeneratorType> GENERATOR_TYPE = GeneratorType.class;
public static final Class<GoldenApple> GOLDEN_APPLE = GoldenApple.class;
public static final Class<Hinge> HINGE = Hinge.class;
public static final Class<HorseColor> HORSE_COLOR = HorseColor.class;
public static final Class<HorseStyle> HORSE_STYLE = HorseStyle.class;
public static final Class<HorseVariant> HORSE_VARIANT = HorseVariant.class;
public static final Class<NotePitch> NOTE_PITCH = NotePitch.class;
public static final Class<ItemType> ITEM_TYPE = ItemType.class;
public static final Class<ObjectiveDisplayMode> OBJECTIVE_DISPLAY_MODE = ObjectiveDisplayMode.class;
public static final Class<OcelotType> OCELOT_TYPE = OcelotType.class;
public static final Class<Operation> OPERATION = Operation.class;
public static final Class<ParticleType> PARTICLE_TYPE = ParticleType.class;
public static final Class<PlantType> PLANT_TYPE = PlantType.class;
public static final Class<PotionEffectType> POTION_EFFECT_TYPE = PotionEffectType.class;
public static final Class<PortionType> PORTION_TYPE = PortionType.class;
public static final Class<PrismarineType> PRISMARINE_TYPE = PrismarineType.class;
public static final Class<Profession> PROFESSION = Profession.class;
public static final Class<QuartzType> QUARTZ_TYPE = QuartzType.class;
public static final Class<RabbitType> RABBIT_TYPE = RabbitType.class;
public static final Class<RailDirection> RAIL_DIRECTION = RailDirection.class;
public static final Class<Rotation> ROTATION = Rotation.class;
public static final Class<SandstoneType> SANDSTONE_TYPE = SandstoneType.class;
public static final Class<SelectorType> SELECTOR_TYPE = SelectorType.class;
public static final Class<SkeletonType> SKELETON_TYPE = SkeletonType.class;
public static final Class<SkullType> SKULL_TYPE = SkullType.class;
public static final Class<SlabType> SLAB_TYPE = SlabType.class;
public static final Class<SoundType> SOUND_TYPE = SoundType.class;
public static final Class<StairShape> STAIR_SHAPE = StairShape.class;
public static final Class<Statistic> STATISTIC = Statistic.class;
public static final Class<StatisticFormat> STATISTIC_FORMAT = StatisticFormat.class;
public static final Class<StatisticGroup> STATISTIC_GROUP = StatisticGroup.class;
public static final Class<StoneType> STONE_TYPE = StoneType.class;
public static final Class<TextColor> TEXT_COLOR = TextColor.class;
public static final Class<TileEntityType> TILE_ENTITY_TYPE = TileEntityType.class;
public static final Class<TreeType> TREE_TYPE = TreeType.class;
public static final Class<Visibility> VISIBILITY = Visibility.class;
public static final Class<WallType> WALL_TYPE = WallType.class;
public static final Class<Weather> WEATHER = Weather.class;

private CatalogTypes() {
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/org/spongepowered/api/GameRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import com.google.common.base.Optional;
import org.spongepowered.api.attribute.AttributeCalculator;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.data.types.Career;
import org.spongepowered.api.data.types.Profession;
import org.spongepowered.api.effect.particle.ParticleEffectBuilder;
import org.spongepowered.api.effect.particle.ParticleType;
import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.entity.living.villager.Career;
import org.spongepowered.api.entity.living.villager.Profession;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.recipe.RecipeRegistry;
import org.spongepowered.api.plugin.PluginContainer;
Expand All @@ -47,11 +47,7 @@
import org.spongepowered.api.status.Favicon;
import org.spongepowered.api.text.format.TextColor;
import org.spongepowered.api.util.rotation.Rotation;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.WorldBuilder;
import org.spongepowered.api.world.WorldCreationSettings;
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
import org.spongepowered.api.world.storage.WorldProperties;

import java.awt.image.BufferedImage;
import java.io.File;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/spongepowered/api/attribute/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@

import com.google.common.base.Predicate;
import org.spongepowered.api.CatalogType;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.util.annotation.CatalogedBy;

/**
* Represents a type of attribute that can be applied to an
* {@link AttributeHolder}.
* {@link DataHolder}.
*/
@CatalogedBy(Attributes.class)
public interface Attribute extends CatalogType {
Expand All @@ -58,11 +59,11 @@ public interface Attribute extends CatalogType {
double getDefaultValue();

/**
* Gets a predicate to decide if a given {@link AttributeHolder} can have
* Gets a predicate to decide if a given {@link DataHolder} can have
* this attribute applied to it.
*
* @return A predicate to decide if this attribute can be applied
*/
Predicate<AttributeHolder> getTargets();
Predicate<DataHolder> getTargets();

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.spongepowered.api.attribute;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.text.Text;

/**
Expand Down Expand Up @@ -71,7 +72,7 @@ public interface AttributeBuilder {
* @param targets A predicate to validate targets
* @return This builder, for chaining
*/
AttributeBuilder targets(Predicate<AttributeHolder> targets);
AttributeBuilder targets(Predicate<DataHolder> targets);

/**
* Sets the name of the {@link Attribute} to be built.
Expand Down
114 changes: 0 additions & 114 deletions src/main/java/org/spongepowered/api/attribute/AttributeHolder.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* A modifier that changes the value of an {@link Attribute} on an
* {@link AttributeHolder}.
* {@link org.spongepowered.api.data.DataHolder}.
*/
public interface AttributeModifier {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
package org.spongepowered.api.attribute;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.DataHolder;

/**
* An enumeration of all attribute targets present in vanilla Minecraft.
*/
public final class AttributeTargets {

public static final Predicate<AttributeHolder> GENERIC = null;
public static final Predicate<AttributeHolder> HORSE = null;
public static final Predicate<AttributeHolder> ZOMBIE = null;
public static final Predicate<DataHolder> GENERIC = null;
public static final Predicate<DataHolder> HORSE = null;
public static final Predicate<DataHolder> ZOMBIE = null;

private AttributeTargets() {
}
Expand Down
Loading