From c24fd3a916d368d565cab5f5a8456bc177b46fea Mon Sep 17 00:00:00 2001 From: Morpheus Date: Sat, 29 Jun 2024 19:11:09 +0000 Subject: [PATCH] Abstract saddleable to a separate interface (#2534) update strider interface --- .../spongepowered/api/entity/Saddleable.java | 43 +++++++++++++++++++ .../api/entity/living/animal/Pig.java | 14 +----- .../entity/living/animal/horse/HorseLike.java | 12 +----- .../api/entity/living/monster/Strider.java | 3 +- 4 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/entity/Saddleable.java diff --git a/src/main/java/org/spongepowered/api/entity/Saddleable.java b/src/main/java/org/spongepowered/api/entity/Saddleable.java new file mode 100644 index 00000000000..4a3dfe1dee7 --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/Saddleable.java @@ -0,0 +1,43 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity; + +import org.spongepowered.api.data.Keys; +import org.spongepowered.api.data.value.Value; + +/** + * Represents an {@link Entity} which can be saddled. + */ +public interface Saddleable extends Entity { + + /** + * {@link Keys#IS_SADDLED} + * + * @return Whether the entity is saddled + */ + default Value.Mutable saddled() { + return this.requireValue(Keys.IS_SADDLED).asMutable(); + } +} diff --git a/src/main/java/org/spongepowered/api/entity/living/animal/Pig.java b/src/main/java/org/spongepowered/api/entity/living/animal/Pig.java index f5e2c5398fc..2bb9204d625 100644 --- a/src/main/java/org/spongepowered/api/entity/living/animal/Pig.java +++ b/src/main/java/org/spongepowered/api/entity/living/animal/Pig.java @@ -24,21 +24,11 @@ */ package org.spongepowered.api.entity.living.animal; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.Saddleable; /** * Represents a Pig. */ -public interface Pig extends Animal { - - /** - * {@link Keys#IS_SADDLED} - * - * @return Whether this pig has a saddle, and ready to be ridden - */ - default Value.Mutable saddled() { - return this.requireValue(Keys.IS_SADDLED).asMutable(); - } +public interface Pig extends Animal, Saddleable { } diff --git a/src/main/java/org/spongepowered/api/entity/living/animal/horse/HorseLike.java b/src/main/java/org/spongepowered/api/entity/living/animal/horse/HorseLike.java index 5dcb0d44102..fc9e61b41a4 100644 --- a/src/main/java/org/spongepowered/api/entity/living/animal/horse/HorseLike.java +++ b/src/main/java/org/spongepowered/api/entity/living/animal/horse/HorseLike.java @@ -27,6 +27,7 @@ import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.Ownable; +import org.spongepowered.api.entity.Saddleable; import org.spongepowered.api.entity.living.animal.Animal; import org.spongepowered.api.item.inventory.Carrier; @@ -34,7 +35,7 @@ /** * An abstract representation of a Horse. */ -public interface HorseLike extends Animal, Ownable, Carrier { +public interface HorseLike extends Animal, Ownable, Saddleable, Carrier { /** * {@link Keys#IS_TAMED} @@ -45,13 +46,4 @@ default Value.Mutable tamed() { return this.requireValue(Keys.IS_TAMED).asMutable(); } - /** - * {@link Keys#IS_SADDLED} - * - * @return Whether the horse is saddled - */ - default Value.Mutable saddled() { - return this.requireValue(Keys.IS_SADDLED).asMutable(); - } - } diff --git a/src/main/java/org/spongepowered/api/entity/living/monster/Strider.java b/src/main/java/org/spongepowered/api/entity/living/monster/Strider.java index f2e50dd9cce..bd63f0387ed 100644 --- a/src/main/java/org/spongepowered/api/entity/living/monster/Strider.java +++ b/src/main/java/org/spongepowered/api/entity/living/monster/Strider.java @@ -24,10 +24,11 @@ */ package org.spongepowered.api.entity.living.monster; +import org.spongepowered.api.entity.Saddleable; import org.spongepowered.api.entity.living.Monster; /** * Represents a Strider. */ -public interface Strider extends Monster { +public interface Strider extends Monster, Saddleable { }