-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modifier): rework modifiers and design better inheritance (#247)
- Loading branch information
1 parent
086a536
commit 7c16a15
Showing
13 changed files
with
121 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java/minevalley/core/api/armorstand/modifiers/MetadataModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import org.bukkit.util.EulerAngle; | ||
|
||
@SuppressWarnings("unused") | ||
public interface PoseModifier { | ||
|
||
/** | ||
|
1 change: 1 addition & 0 deletions
1
src/main/java/minevalley/core/api/armorstand/modifiers/RotationModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/minevalley/core/api/enums/InteractionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
29 changes: 15 additions & 14 deletions
29
...morstand/modifiers/EquipmentModifier.java → ...core/api/modifiers/EquipmentModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,102 @@ | ||
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 | ||
*/ | ||
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 | ||
*/ | ||
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 | ||
*/ | ||
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 | ||
*/ | ||
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 | ||
*/ | ||
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 | ||
*/ | ||
EquipmentModifier setBoots(ItemStack boots); | ||
|
||
/** | ||
* Update the armorstands equipment | ||
* Update the equipment | ||
*/ | ||
void updateEquipment(); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/minevalley/core/api/modifiers/InteractionModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OnlineUser, InteractionType> consumer); | ||
} |
11 changes: 6 additions & 5 deletions
11
...rmorstand/modifiers/LocationModifier.java → .../core/api/modifiers/LocationModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
* <br> | ||
* <b>Note:</b> 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(); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/minevalley/core/api/modifiers/VisibilityModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
* <br> | ||
* <b>Default:</b> Everyone can see this object | ||
* | ||
* @param function defines whether a specific user can see this object | ||
*/ | ||
void setVisibility(Function<OnlineUser, Boolean> function); | ||
|
||
/** | ||
* Updates the visibility of this object | ||
* <br> | ||
* <b>Note:</b> 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 | ||
* <br> | ||
* <b>Note:</b> This simply calls the function defined in {@link #setVisibility(Function)} for this user | ||
* | ||
* @param user to update the visibility for | ||
*/ | ||
void updateVisibility(OnlineUser user); | ||
} |
Oops, something went wrong.