diff --git a/src/main/java/minevalley/core/api/armorstand/FakeArmorStand.java b/src/main/java/minevalley/core/api/armorstand/FakeArmorStand.java index 0260c21b..efcad044 100644 --- a/src/main/java/minevalley/core/api/armorstand/FakeArmorStand.java +++ b/src/main/java/minevalley/core/api/armorstand/FakeArmorStand.java @@ -1,13 +1,16 @@ package minevalley.core.api.armorstand; -import minevalley.core.api.armorstand.modifiers.*; -import minevalley.core.api.users.OnlineUser; +import minevalley.core.api.armorstand.modifiers.MetadataModifier; +import minevalley.core.api.armorstand.modifiers.PassengerModifier; +import minevalley.core.api.armorstand.modifiers.PoseModifier; +import minevalley.core.api.armorstand.modifiers.RotationModifier; +import minevalley.core.api.modifiers.EquipmentModifier; +import minevalley.core.api.modifiers.InteractionModifier; +import minevalley.core.api.modifiers.LocationModifier; +import minevalley.core.api.modifiers.VisibilityModifier; -import java.util.function.BiConsumer; -import java.util.function.Function; - -public interface FakeArmorStand extends EquipmentModifier, LocationModifier, MetadataModifier, PassengerModifier, - PoseModifier, RotationModifier { +public interface FakeArmorStand extends MetadataModifier, PassengerModifier, PoseModifier, RotationModifier, + EquipmentModifier, InteractionModifier, LocationModifier, VisibilityModifier { /** * Get the custom id from the armorstand @@ -43,40 +46,4 @@ public interface FakeArmorStand extends EquipmentModifier, LocationModifier, Met * @param visibilityRange range in blocks */ void setVisibilityRange(int visibilityRange); - - /** - * Defines the action when a player interacts with the armorstand - * - * @param consumer is called whenever a user interacts with the armorstand - */ - void onClick(BiConsumer consumer); - - /** - * Defines which users can see the armorstand - *
- * Default: Everyone can see the armorstand - * - * @param function defines whether a specific user can see the armorstand - */ - void setVisibility(Function function); - - /** - * Updates the visibility of the armorstand - *
- * Note: This simply calls the function defined in {@link #setVisibility(Function)} for every user that the armorstand is or could be visible to - */ - void updateVisibility(); - - /** - * Updates the visibility of the armorstand for a specific user - *
- * Note: This simply calls the function defined in {@link #setVisibility(Function)} for this user - * - * @param user to update the visibility for - */ - void updateVisibility(OnlineUser user); - - enum InteractType { - LEFT_CLICK, RIGHT_CLICK - } } diff --git a/src/main/java/minevalley/core/api/armorstand/modifiers/MetadataModifier.java b/src/main/java/minevalley/core/api/armorstand/modifiers/MetadataModifier.java index d6822465..cba70632 100644 --- a/src/main/java/minevalley/core/api/armorstand/modifiers/MetadataModifier.java +++ b/src/main/java/minevalley/core/api/armorstand/modifiers/MetadataModifier.java @@ -1,5 +1,6 @@ package minevalley.core.api.armorstand.modifiers; +@SuppressWarnings("unused") public interface MetadataModifier { /** diff --git a/src/main/java/minevalley/core/api/armorstand/modifiers/PassengerModifier.java b/src/main/java/minevalley/core/api/armorstand/modifiers/PassengerModifier.java index 8dafcd99..54c1d429 100644 --- a/src/main/java/minevalley/core/api/armorstand/modifiers/PassengerModifier.java +++ b/src/main/java/minevalley/core/api/armorstand/modifiers/PassengerModifier.java @@ -4,10 +4,11 @@ import java.util.List; +@SuppressWarnings("unused") public interface PassengerModifier { /** - * get the current passenger list + * Get the current passenger list * * @return a list with the passengers as entities */ diff --git a/src/main/java/minevalley/core/api/armorstand/modifiers/PoseModifier.java b/src/main/java/minevalley/core/api/armorstand/modifiers/PoseModifier.java index 1738ee40..635e3aac 100644 --- a/src/main/java/minevalley/core/api/armorstand/modifiers/PoseModifier.java +++ b/src/main/java/minevalley/core/api/armorstand/modifiers/PoseModifier.java @@ -2,6 +2,7 @@ import org.bukkit.util.EulerAngle; +@SuppressWarnings("unused") public interface PoseModifier { /** diff --git a/src/main/java/minevalley/core/api/armorstand/modifiers/RotationModifier.java b/src/main/java/minevalley/core/api/armorstand/modifiers/RotationModifier.java index e69d5171..243671a7 100644 --- a/src/main/java/minevalley/core/api/armorstand/modifiers/RotationModifier.java +++ b/src/main/java/minevalley/core/api/armorstand/modifiers/RotationModifier.java @@ -1,5 +1,6 @@ package minevalley.core.api.armorstand.modifiers; +@SuppressWarnings("unused") public interface RotationModifier { /** diff --git a/src/main/java/minevalley/core/api/enums/InteractionType.java b/src/main/java/minevalley/core/api/enums/InteractionType.java new file mode 100644 index 00000000..f2db54bc --- /dev/null +++ b/src/main/java/minevalley/core/api/enums/InteractionType.java @@ -0,0 +1,22 @@ +package minevalley.core.api.enums; + +@SuppressWarnings("unused") +public enum InteractionType { + + LEFT_CLICK, + SHIFT_LEFT_CLICK, + RIGHT_CLICK, + SHIFT_RIGHT_CLICK; + + public boolean isLeftClick() { + return this == LEFT_CLICK || this == SHIFT_LEFT_CLICK; + } + + public boolean isRightClick() { + return this == RIGHT_CLICK || this == SHIFT_RIGHT_CLICK; + } + + public boolean isShiftClick() { + return this == SHIFT_LEFT_CLICK || this == SHIFT_RIGHT_CLICK; + } +} diff --git a/src/main/java/minevalley/core/api/armorstand/modifiers/EquipmentModifier.java b/src/main/java/minevalley/core/api/modifiers/EquipmentModifier.java similarity index 67% rename from src/main/java/minevalley/core/api/armorstand/modifiers/EquipmentModifier.java rename to src/main/java/minevalley/core/api/modifiers/EquipmentModifier.java index 6e6c7996..16c0668c 100644 --- a/src/main/java/minevalley/core/api/armorstand/modifiers/EquipmentModifier.java +++ b/src/main/java/minevalley/core/api/modifiers/EquipmentModifier.java @@ -1,18 +1,19 @@ -package minevalley.core.api.armorstand.modifiers; +package minevalley.core.api.modifiers; import org.bukkit.inventory.ItemStack; +@SuppressWarnings("unused") public interface EquipmentModifier { /** - * Get the item in the armorstands left hand + * Get the item in the left hand * * @return item in left hand */ ItemStack getLeftHand(); /** - * Set the item in the armorstands left hand + * Set the item in the left hand * * @param itemStack item to set * @return this @@ -20,14 +21,14 @@ public interface EquipmentModifier { EquipmentModifier setLeftHand(ItemStack itemStack); /** - * Get the item in the armorstands right hand + * Get the item in the right hand * * @return item in right hand */ ItemStack getRightHand(); /** - * Set the item in the armorstands right hand + * Set the item in the right hand * * @param itemStack item to set * @return this @@ -35,14 +36,14 @@ public interface EquipmentModifier { EquipmentModifier setRightHand(ItemStack itemStack); /** - * Get the item in the armorstands helmet slot + * Get the item in the helmet slot * * @return item in helmet slot */ ItemStack getHelmet(); /** - * Set the item in the armorstands helmet slot + * Set the item in the helmet slot * * @param helmet item to set * @return this @@ -50,14 +51,14 @@ public interface EquipmentModifier { EquipmentModifier setHelmet(ItemStack helmet); /** - * Get the item in the armorstands chestplate slot + * Get the item in the chestplate slot * * @return item in chestplate slot */ ItemStack getChestplate(); /** - * Set the item in the armorstands chestplate slot + * Set the item in the chestplate slot * * @param chestplate item to set * @return this @@ -65,14 +66,14 @@ public interface EquipmentModifier { EquipmentModifier setChestplate(ItemStack chestplate); /** - * Get the item in the armorstands leggings slot + * Get the item in the leggings slot * * @return item in leggings slot */ ItemStack getLeggings(); /** - * Set the item in the armorstands leggings slot + * Set the item in the leggings slot * * @param leggings item to set * @return this @@ -80,14 +81,14 @@ public interface EquipmentModifier { EquipmentModifier setLeggings(ItemStack leggings); /** - * Get the item in the armorstands boots slot + * Get the item in the boots slot * * @return item in boots slot */ ItemStack getBoots(); /** - * Set the item in the armorstands boots slot + * Set the item in the boots slot * * @param boots item to set * @return this @@ -95,7 +96,7 @@ public interface EquipmentModifier { EquipmentModifier setBoots(ItemStack boots); /** - * Update the armorstands equipment + * Update the equipment */ void updateEquipment(); } diff --git a/src/main/java/minevalley/core/api/modifiers/InteractionModifier.java b/src/main/java/minevalley/core/api/modifiers/InteractionModifier.java new file mode 100644 index 00000000..cd85abaf --- /dev/null +++ b/src/main/java/minevalley/core/api/modifiers/InteractionModifier.java @@ -0,0 +1,17 @@ +package minevalley.core.api.modifiers; + +import minevalley.core.api.enums.InteractionType; +import minevalley.core.api.users.OnlineUser; + +import java.util.function.BiConsumer; + +@SuppressWarnings("unused") +public interface InteractionModifier { + + /** + * Defines the action when a user interacts with this object. + * + * @param consumer is called whenever a user interacts with this object + */ + void onClick(BiConsumer consumer); +} diff --git a/src/main/java/minevalley/core/api/armorstand/modifiers/LocationModifier.java b/src/main/java/minevalley/core/api/modifiers/LocationModifier.java similarity index 59% rename from src/main/java/minevalley/core/api/armorstand/modifiers/LocationModifier.java rename to src/main/java/minevalley/core/api/modifiers/LocationModifier.java index 3fe9376e..a5a9c42f 100644 --- a/src/main/java/minevalley/core/api/armorstand/modifiers/LocationModifier.java +++ b/src/main/java/minevalley/core/api/modifiers/LocationModifier.java @@ -1,27 +1,28 @@ -package minevalley.core.api.armorstand.modifiers; +package minevalley.core.api.modifiers; import org.bukkit.Location; +@SuppressWarnings("unused") public interface LocationModifier { /** - * Get the location of the armorstand + * Get the location * * @return location */ Location getLocation(); /** - * Sets the armorstands location. + * Sets the location *
* Note: This ignores the yaw and pitch values. * - * @param location new location of the armorstand. + * @param location new location. */ LocationModifier setLocation(Location location); /** - * Update the location of the armorstand + * Update the location */ void updateLocation(); } diff --git a/src/main/java/minevalley/core/api/modifiers/VisibilityModifier.java b/src/main/java/minevalley/core/api/modifiers/VisibilityModifier.java new file mode 100644 index 00000000..87c217a3 --- /dev/null +++ b/src/main/java/minevalley/core/api/modifiers/VisibilityModifier.java @@ -0,0 +1,34 @@ +package minevalley.core.api.modifiers; + +import minevalley.core.api.users.OnlineUser; + +import java.util.function.Function; + +@SuppressWarnings("unused") +public interface VisibilityModifier { + + /** + * Defines who can see this object + *
+ * Default: Everyone can see this object + * + * @param function defines whether a specific user can see this object + */ + void setVisibility(Function function); + + /** + * Updates the visibility of this object + *
+ * Note: This simply calls the function defined in {@link #setVisibility(Function)} for every user that this object is or could be visible to + */ + void updateVisibility(); + + /** + * Updates the visibility of this object for a specific user + *
+ * Note: This simply calls the function defined in {@link #setVisibility(Function)} for this user + * + * @param user to update the visibility for + */ + void updateVisibility(OnlineUser user); +} diff --git a/src/main/java/minevalley/core/api/npc/NPC.java b/src/main/java/minevalley/core/api/npc/NPC.java index 274d8f40..5d67e234 100644 --- a/src/main/java/minevalley/core/api/npc/NPC.java +++ b/src/main/java/minevalley/core/api/npc/NPC.java @@ -5,53 +5,26 @@ import lombok.RequiredArgsConstructor; import minevalley.core.api.ChatMenu; import minevalley.core.api.armorstand.FakeArmorStand; +import minevalley.core.api.modifiers.EquipmentModifier; +import minevalley.core.api.modifiers.InteractionModifier; +import minevalley.core.api.modifiers.LocationModifier; +import minevalley.core.api.modifiers.VisibilityModifier; import minevalley.core.api.users.OnlineUser; import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import java.util.List; import java.util.function.BiConsumer; import java.util.function.Consumer; -import java.util.function.Function; -public interface NPC { +@SuppressWarnings("unused") +public interface NPC extends EquipmentModifier, InteractionModifier, LocationModifier, VisibilityModifier { String getName(); - /** - * Defines which users can see the npc - *
- * Default: Everyone can see the npc - * - * @param function defines whether a specific user can see the npc - */ - void setVisibility(Function function); - - /** - * Updates the visibility of the npc - *
- * Note: This simply calls the function defined in {@link #setVisibility(Function)} for every user that the npc is or could be visible to - */ - void updateVisibility(); - - /** - * Updates the visibility of the npc for a specific user - *
- * Note: This simply calls the function defined in {@link #setVisibility(Function)} for this user - * - * @param user to update the visibility for - */ - void updateVisibility(OnlineUser user); - - /** - * Sets & updates the equipment of the npc for everyone - */ - void updateEquipment(); - boolean focusNearPlayers(); void setFocusNearPlayers(boolean focusNearPlayers); @@ -79,7 +52,7 @@ default void zoomIn(OnlineUser user) { void lookAt(Vector vector); void sneak(); - + void unSneak(); boolean isSneaking(); @@ -94,32 +67,6 @@ default void zoomIn(OnlineUser user) { boolean isRiding(); - ItemStack getLeftHand(); - - NPC setLeftHand(ItemStack itemStack); - - ItemStack getRightHand(); - - NPC setRightHand(ItemStack itemStack); - - ItemStack getHelmet(); - - NPC setHelmet(ItemStack helmet); - - ItemStack getChestplate(); - - NPC setChestplate(ItemStack chestplate); - - ItemStack getLeggings(); - - NPC setLeggings(ItemStack leggings); - - ItemStack getBoots(); - - NPC setBoots(ItemStack boots); - - NPC onClick(BiConsumer callback); - NPC onComingClose(Consumer callback); String getChatName(); @@ -166,11 +113,6 @@ default void zoomIn(OnlineUser user) { void hideNameTag(boolean hidden); - enum Click { - RIGHT_CLICK, - LEFT_CLICK - } - @Getter @AllArgsConstructor @RequiredArgsConstructor diff --git a/src/main/java/minevalley/core/api/regions/utils/FakeBlock.java b/src/main/java/minevalley/core/api/regions/utils/FakeBlock.java index 930a1939..322b1c5e 100644 --- a/src/main/java/minevalley/core/api/regions/utils/FakeBlock.java +++ b/src/main/java/minevalley/core/api/regions/utils/FakeBlock.java @@ -1,33 +1,6 @@ package minevalley.core.api.regions.utils; -import minevalley.core.api.users.OnlineUser; +import minevalley.core.api.modifiers.VisibilityModifier; -import java.util.function.Function; - -public interface FakeBlock { - - /** - * Defines which users can see the fake block - *
- * Default: Everyone can see the fake block - * - * @param function defines whether a specific user can see the fake block - */ - void setVisibility(Function function); - - /** - * Updates the visibility of the fake block - *
- * Note: This simply calls the function defined in {@link #setVisibility(Function)} for every user that the fake block is or could be visible to - */ - void updateVisibility(); - - /** - * Updates the visibility of the fake block for a specific user - *
- * Note: This simply calls the function defined in {@link #setVisibility(Function)} for this user - * - * @param user to update the visibility for - */ - void updateVisibility(OnlineUser user); +public interface FakeBlock extends VisibilityModifier { } \ No newline at end of file diff --git a/src/main/java/minevalley/core/api/utils/Hologram.java b/src/main/java/minevalley/core/api/utils/Hologram.java index 20e8c576..83bd918f 100644 --- a/src/main/java/minevalley/core/api/utils/Hologram.java +++ b/src/main/java/minevalley/core/api/utils/Hologram.java @@ -1,12 +1,9 @@ package minevalley.core.api.utils; -import minevalley.core.api.users.OnlineUser; -import org.bukkit.Location; +import minevalley.core.api.modifiers.LocationModifier; +import minevalley.core.api.modifiers.VisibilityModifier; -import java.util.List; -import java.util.function.Function; - -public interface Hologram { +public interface Hologram extends LocationModifier, VisibilityModifier { String[] getLines(); @@ -24,17 +21,5 @@ default void addLine(String text) { void removeLine(int line); - void setVisibility(Function visibilityFunction); - - void updateVisibility(); - - void updateVisibility(OnlineUser user); - - List getNearbyViewingUsers(); - - Location getLocation(); - - void move(Location location); - void delete(); } \ No newline at end of file