|
| 1 | +package me.loving11ish.clans.api; |
| 2 | + |
| 3 | +import me.loving11ish.clans.api.models.Clan; |
| 4 | +import me.loving11ish.clans.api.models.ClanPlayer; |
| 5 | +import org.bukkit.OfflinePlayer; |
| 6 | +import org.bukkit.entity.Player; |
| 7 | + |
| 8 | +import java.io.IOException; |
| 9 | +import java.util.HashMap; |
| 10 | +import java.util.List; |
| 11 | +import java.util.UUID; |
| 12 | + |
| 13 | +/** |
| 14 | + * This is the main API class for ClansLite. |
| 15 | + * This class contains all the methods that can be used to interact with the plugin. |
| 16 | + * This class must be initialized in order to use any of the methods. |
| 17 | + */ |
| 18 | +public interface ClansLiteAPI { |
| 19 | + |
| 20 | + |
| 21 | + /** |
| 22 | + * |
| 23 | + * @return Returns true if the plugin was enabled successfully, otherwise returns false. |
| 24 | + */ |
| 25 | + public boolean isPluginEnabled(); |
| 26 | + |
| 27 | + /** |
| 28 | + * |
| 29 | + * @return Returns a string of text that contains the full server package. |
| 30 | + */ |
| 31 | + public String getServerPackage(); |
| 32 | + |
| 33 | + /** |
| 34 | + * |
| 35 | + * @return Returns an integer that is the base major server version. |
| 36 | + */ |
| 37 | + public int getMajorServerVersion(); |
| 38 | + |
| 39 | + /** |
| 40 | + * |
| 41 | + * @return Returns `true` if the server or network is able to connect to the Mojang auth servers. Otherwise, returns `false`. |
| 42 | + * |
| 43 | + */ |
| 44 | + public boolean isServerRunningOnline(); |
| 45 | + |
| 46 | + /** |
| 47 | + * |
| 48 | + * @return Returns `true` if your current ClansLite plugin version does NOT mach the latest version listed on SpigotMC. |
| 49 | + */ |
| 50 | + public boolean isClansLitePluginUpdateAvailable(); |
| 51 | + |
| 52 | + /** |
| 53 | + * |
| 54 | + * @return Returns the URL of the development build repository for ClansLite. |
| 55 | + */ |
| 56 | + public String getClansLiteDevelopmentBuildRepository(); |
| 57 | + |
| 58 | + /** |
| 59 | + * |
| 60 | + * @return Returns a HashMap of all connected Bedrock players with a key of the Player and a value of their Java UUID. |
| 61 | + */ |
| 62 | + public HashMap<Player, String> getConnectedBedrockPlayers(); |
| 63 | + |
| 64 | + /** |
| 65 | + * |
| 66 | + * @return Returns a HashMap of all stored Clans. |
| 67 | + */ |
| 68 | + public HashMap<UUID, Clan> getAllClans(); |
| 69 | + |
| 70 | + /** |
| 71 | + * |
| 72 | + * @return Returns a HashMap of all stored ClanPlayers. |
| 73 | + */ |
| 74 | + public HashMap<UUID, ClanPlayer> getAllClanPlayers(); |
| 75 | + |
| 76 | + /** |
| 77 | + * THIS METHOD IS NOT RECOMMENDED FOR USE ON LARGE SERVERS. |
| 78 | + * Please use {@link #getTopClansByClanPointsCache()} instead. |
| 79 | + * |
| 80 | + * @param maxListSize The maximum size of the list of Clans to return. |
| 81 | + * @return Returns a list of Clans sorted by clan points. |
| 82 | + */ |
| 83 | + public List<Clan> getTopClansByClanPointsOnDemand(int maxListSize); |
| 84 | + |
| 85 | + /** |
| 86 | + * The returned list is cached and updated asynchronously every 10 minutes. |
| 87 | + * |
| 88 | + * @return Returns a list of Clans sorted by clan points. |
| 89 | + */ |
| 90 | + public List<Clan> getTopClansByClanPointsCache(); |
| 91 | + |
| 92 | + /** |
| 93 | + * THIS METHOD IS NOT RECOMMENDED FOR USE ON LARGE SERVERS. |
| 94 | + * Please use {@link #getTopClanPlayersByPlayerPointsCache()} instead. |
| 95 | + * |
| 96 | + * @param maxListSize The maximum size of the list of ClanPlayers to return. |
| 97 | + * @return Returns a list of ClanPlayers sorted by clan points. |
| 98 | + */ |
| 99 | + public List<ClanPlayer> getTopClanPlayersByClanPointsOnDemand(int maxListSize); |
| 100 | + |
| 101 | + /** |
| 102 | + * The returned list is cached and updated asynchronously every 10 minutes. |
| 103 | + * |
| 104 | + * @return Returns a list of ClanPlayers sorted by Player points. |
| 105 | + */ |
| 106 | + public List<ClanPlayer> getTopClanPlayersByPlayerPointsCache(); |
| 107 | + |
| 108 | + /** |
| 109 | + * |
| 110 | + * @param player The Bukkit Player object to get a ClanPlayer from. |
| 111 | + * @return Returns a ClanPlayer object or null if not found. |
| 112 | + */ |
| 113 | + public ClanPlayer getClanPlayerByBukkitPlayer(Player player); |
| 114 | + |
| 115 | + /** |
| 116 | + * |
| 117 | + * @param offlinePlayer The Bukkit OfflinePlayer object to get a ClanPlayer from. |
| 118 | + * @return Returns a ClanPlayer object or null if not found. |
| 119 | + */ |
| 120 | + public ClanPlayer getClanPlayerByBukkitOfflinePlayer(OfflinePlayer offlinePlayer); |
| 121 | + |
| 122 | + /** |
| 123 | + * THIS WILL RETURN NULL IF THE PLAYER HAS NEVER JOINED THE SERVER BEFORE. |
| 124 | + * THIS WILL CAUSE AN ERROR IF THE PLAYER CHANGED THEIR NAME AND HAS NOT JOINED THE SERVER SINCE. |
| 125 | + * THIS METHOD IS NOT RECOMMENDED TO BE RELIED ON. |
| 126 | + * Please use {@link #getBukkitOfflinePlayerByUUID(UUID)} instead. |
| 127 | + * |
| 128 | + * @param lastKnownName The last known name of the player to get a Bukkit OfflinePlayer from. |
| 129 | + * @return Returns a Bukkit OfflinePlayer object or null if not found. |
| 130 | + */ |
| 131 | + public OfflinePlayer getBukkitOfflinePlayerByLastKnownName(String lastKnownName); |
| 132 | + |
| 133 | + /** |
| 134 | + * |
| 135 | + * @param uuid The UUID of the player to get a Bukkit OfflinePlayer from. |
| 136 | + * @return Returns a Bukkit OfflinePlayer object or null if not found. |
| 137 | + */ |
| 138 | + public OfflinePlayer getBukkitOfflinePlayerByUUID(UUID uuid); |
| 139 | + |
| 140 | + /** |
| 141 | + * This method will only return a clan if the player is a member of a clan and NOT the clan owner. |
| 142 | + * |
| 143 | + * @param player The Bukkit Player object to get a Clan from. |
| 144 | + * @return Returns a Clan object or null if not found. |
| 145 | + */ |
| 146 | + public Clan getClanByBukkitPlayer(Player player); |
| 147 | + |
| 148 | + /** |
| 149 | + * This method will only return a clan if the offline player is a member of a clan and NOT the clan owner. |
| 150 | + * |
| 151 | + * @param offlinePlayer The Bukkit OfflinePlayer object to get a Clan from. |
| 152 | + * @return Returns a Clan object or null if not found. |
| 153 | + */ |
| 154 | + public Clan getClanByBukkitOfflinePlayer(OfflinePlayer offlinePlayer); |
| 155 | + |
| 156 | + /** |
| 157 | + * This method will only return a clan if the player is the owner of a clan. |
| 158 | + * |
| 159 | + * @param player The Bukkit Player object to get a Clan from. |
| 160 | + * @return Returns a Clan object or null if not found. |
| 161 | + */ |
| 162 | + public Clan getClanByBukkitPlayerOwner(Player player); |
| 163 | + |
| 164 | + /** |
| 165 | + * This method will only return a clan if the offline player is the owner of a clan. |
| 166 | + * |
| 167 | + * @param offlinePlayer The Bukkit OfflinePlayer object to get a Clan from. |
| 168 | + * @return Returns a Clan object or null if not found. |
| 169 | + */ |
| 170 | + public Clan getClanByBukkitOfflinePlayerOwner(OfflinePlayer offlinePlayer); |
| 171 | + |
| 172 | + /** |
| 173 | + * This method will only return a clan if the clan name is found. |
| 174 | + * |
| 175 | + * @param clanName The name of the clan to get a Clan from. |
| 176 | + * @return Returns a Clan object or null if not found. |
| 177 | + */ |
| 178 | + public Clan getClanByClanName(String clanName); |
| 179 | + |
| 180 | + /** |
| 181 | + * This method will perform multiple checks to see if the new clan is valid and can be created. |
| 182 | + * This method will create a Clan object and add it to the HashMap of Clans. |
| 183 | + * This method will fire an AsyncClanCreateEvent upon successful Clan creation. |
| 184 | + * |
| 185 | + * @param player The Bukkit Player object to create a Clan from. |
| 186 | + * @param clanName The name of the clan to create. (This cannot be changed later & cannot contain color codes) |
| 187 | + * @return Returns a Clan object. |
| 188 | + */ |
| 189 | + public Clan createClan(Player player, String clanName); |
| 190 | + |
| 191 | + /** |
| 192 | + * |
| 193 | + * @param player The Bukkit Player object to delete a Clan from. |
| 194 | + * @return Returns true if the Clan was deleted successfully, otherwise returns false. |
| 195 | + * @throws IOException Throws an IOException if the Clan could not be deleted. |
| 196 | + */ |
| 197 | + public boolean deleteClan(Player player) throws IOException; |
| 198 | + |
| 199 | + /** |
| 200 | + * This method will perform multiple checks to see if the new prefix is valid and can be set. |
| 201 | + * This method will fire an AsyncClanPrefixChangeEvent upon successful prefix change. |
| 202 | + * |
| 203 | + * @param player The Bukkit Player object to get the clan from. |
| 204 | + * @param prefix The new prefix to set for the clan. |
| 205 | + */ |
| 206 | + public void setClanPrefix(Player player, String prefix); |
| 207 | + |
| 208 | + /** |
| 209 | + * This method will perform multiple checks to see if the player is not already a member of a clan or a clan owner. |
| 210 | + * |
| 211 | + * @param clan The Clan object to add a member to. |
| 212 | + * @param player The Bukkit Player object to add to the Clan. |
| 213 | + * @return Returns true if the player was added to the Clan successfully, otherwise returns false. |
| 214 | + */ |
| 215 | + public boolean addClanMember(Clan clan, Player player); |
| 216 | + |
| 217 | + /** |
| 218 | + * This method will perform multiple checks to see if the player is in a clan and not a clan owner. |
| 219 | + * |
| 220 | + * @param clan The Clan object to remove a member from. |
| 221 | + * @param player The Bukkit Player object to remove from the Clan. |
| 222 | + * @return Returns true if the player was removed from the Clan successfully, otherwise returns false. |
| 223 | + */ |
| 224 | + public boolean removeClanMember(Clan clan, Player player); |
| 225 | + |
| 226 | + /** |
| 227 | + * This method will perform multiple checks to see if the player is in a clan and not a clan owner. |
| 228 | + * |
| 229 | + * @param clan The Clan object to remove a member from. |
| 230 | + * @param offlinePlayer The Bukkit OfflinePlayer object to remove from the Clan. |
| 231 | + * @return Returns true if the player was removed from the Clan successfully, otherwise returns false. |
| 232 | + */ |
| 233 | + public boolean removeOfflineClanMember(Clan clan, OfflinePlayer offlinePlayer); |
| 234 | + |
| 235 | +} |
0 commit comments