|
| 1 | +package net.badlion.timers.api; |
| 2 | + |
| 3 | +import org.bukkit.entity.Player; |
| 4 | +import org.bukkit.inventory.ItemStack; |
| 5 | + |
| 6 | +import java.util.Collection; |
| 7 | + |
| 8 | +public interface Timer { |
| 9 | + |
| 10 | + // Getters and setters |
| 11 | + |
| 12 | + /** |
| 13 | + * Get the timer's id |
| 14 | + * |
| 15 | + * @return Id as unique long value |
| 16 | + */ |
| 17 | + long getId(); |
| 18 | + |
| 19 | + /** |
| 20 | + * Get the timer's name |
| 21 | + * |
| 22 | + * @return Name as string |
| 23 | + */ |
| 24 | + String getName(); |
| 25 | + |
| 26 | + /** |
| 27 | + * Set the timer's name |
| 28 | + * Will be the text displayed in the client |
| 29 | + * |
| 30 | + * @param name Name as string |
| 31 | + */ |
| 32 | + void setName(String name); |
| 33 | + |
| 34 | + /** |
| 35 | + * Get the item displayed in the client |
| 36 | + * |
| 37 | + * @return Item as a Bukkit ItemStack |
| 38 | + */ |
| 39 | + ItemStack getItem(); |
| 40 | + |
| 41 | + /** |
| 42 | + * Set the item displayed in the client |
| 43 | + * Cannot be a null value |
| 44 | + * <p> |
| 45 | + * Note : Item metas are currently not implemented, |
| 46 | + * but enchantments should work fine |
| 47 | + * |
| 48 | + * @param item Item as a Bukkit ItemStack |
| 49 | + */ |
| 50 | + void setItem(ItemStack item); |
| 51 | + |
| 52 | + /** |
| 53 | + * Get if the timer is repeating or not |
| 54 | + * |
| 55 | + * @return Repeating value as a boolean |
| 56 | + */ |
| 57 | + boolean isRepeating(); |
| 58 | + |
| 59 | + /** |
| 60 | + * Set whether the timer should repeat when reaching 0 or not |
| 61 | + * |
| 62 | + * @param repeating {@code true} if repeating, {@code false} otherwise |
| 63 | + */ |
| 64 | + void setRepeating(boolean repeating); |
| 65 | + |
| 66 | + /** |
| 67 | + * Get the timer countdown time |
| 68 | + * |
| 69 | + * @return Timer countdown time as a long number of ticks |
| 70 | + */ |
| 71 | + long getTime(); |
| 72 | + |
| 73 | + /** |
| 74 | + * Set the timer countdown time |
| 75 | + * Note : This implies a call to {@link Timer#reset()} |
| 76 | + * |
| 77 | + * @param time Timer countdown time as a long number of ticks |
| 78 | + */ |
| 79 | + void setTime(long time); |
| 80 | + |
| 81 | + // Player functions |
| 82 | + |
| 83 | + /** |
| 84 | + * Add a receiver to the timer |
| 85 | + * Note : A disconnecting player will automatically |
| 86 | + * be removed from the timer |
| 87 | + * |
| 88 | + * @param player Player instance to add |
| 89 | + */ |
| 90 | + void addReceiver(Player player); |
| 91 | + |
| 92 | + /** |
| 93 | + * Manually remove a receiver form the timer |
| 94 | + * |
| 95 | + * @param player Player instance to remove |
| 96 | + */ |
| 97 | + void removeReceiver(Player player); |
| 98 | + |
| 99 | + /** |
| 100 | + * Clear all players receiving this timer |
| 101 | + */ |
| 102 | + void clearReceivers(); |
| 103 | + |
| 104 | + /** |
| 105 | + * Get all the players that are receiving this timer |
| 106 | + * |
| 107 | + * @return Collection of receivers as a thread-safe collection |
| 108 | + */ |
| 109 | + Collection<Player> getReceivers(); |
| 110 | + |
| 111 | + // Other functions |
| 112 | + |
| 113 | + /** |
| 114 | + * Reset the current countdown to the {@link Timer#getTime()} value |
| 115 | + */ |
| 116 | + void reset(); |
| 117 | +} |
0 commit comments