From ffad13783f1616e995edebad4de55ea08946d292 Mon Sep 17 00:00:00 2001 From: Maxim Van de Wynckel Date: Thu, 12 Jan 2017 14:52:57 +0100 Subject: [PATCH] Beta release --- pom.xml | 2 +- .../maximvdw/spigotsite/api/SpigotSite.java | 2 +- .../spigotsite/api/SpigotSiteAPI.java | 2 +- .../maximvdw/spigotsite/api/forum/Forum.java | 2 +- .../spigotsite/api/forum/ForumCategory.java | 2 +- .../spigotsite/api/forum/ForumManager.java | 5 +- .../maximvdw/spigotsite/api/forum/Thread.java | 6 +- .../spigotsite/api/resource/Buyer.java | 40 +++++++++++++ .../api/resource/ResourceManager.java | 56 ++++++++++++------- .../spigotsite/api/user/Conversation.java | 10 +++- .../api/user/ConversationManager.java | 48 +++++++++------- .../maximvdw/spigotsite/api/user/Medal.java | 6 +- .../spigotsite/api/user/UserManager.java | 40 ++++++++----- 13 files changed, 154 insertions(+), 67 deletions(-) create mode 100644 src/main/java/be/maximvdw/spigotsite/api/resource/Buyer.java diff --git a/pom.xml b/pom.xml index caf7d13..cb899d2 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 be.maximvdw spigotsite-api - 0.0.14-SNAPSHOT + 0.1.0-SNAPSHOT SpigotSite API Spigot Site API diff --git a/src/main/java/be/maximvdw/spigotsite/api/SpigotSite.java b/src/main/java/be/maximvdw/spigotsite/api/SpigotSite.java index e8b8f32..56f0f87 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/SpigotSite.java +++ b/src/main/java/be/maximvdw/spigotsite/api/SpigotSite.java @@ -4,7 +4,7 @@ public final class SpigotSite { /* Spigot Site API */ private static SpigotSiteAPI api = null; /* Spigot Site API Version */ - private static String version = "0.0.14-SNAPSHOT"; + private static String version = "0.1.0-SNAPSHOT"; /** * Get spigot site API diff --git a/src/main/java/be/maximvdw/spigotsite/api/SpigotSiteAPI.java b/src/main/java/be/maximvdw/spigotsite/api/SpigotSiteAPI.java index bc69012..5a20343 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/SpigotSiteAPI.java +++ b/src/main/java/be/maximvdw/spigotsite/api/SpigotSiteAPI.java @@ -27,7 +27,7 @@ public interface SpigotSiteAPI { /** * Get spigot forum manager - * + * * @return {@link be.maximvdw.spigotsite.api.forum.ForumManager} */ ForumManager getForumManager(); diff --git a/src/main/java/be/maximvdw/spigotsite/api/forum/Forum.java b/src/main/java/be/maximvdw/spigotsite/api/forum/Forum.java index 45aa10c..e05dc77 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/forum/Forum.java +++ b/src/main/java/be/maximvdw/spigotsite/api/forum/Forum.java @@ -13,5 +13,5 @@ public interface Forum { * * @return List of {{@link be.maximvdw.spigotsite.api.forum.Forum} */ - public List getSubForums(); + List getSubForums(); } diff --git a/src/main/java/be/maximvdw/spigotsite/api/forum/ForumCategory.java b/src/main/java/be/maximvdw/spigotsite/api/forum/ForumCategory.java index 6d36ec7..09ed616 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/forum/ForumCategory.java +++ b/src/main/java/be/maximvdw/spigotsite/api/forum/ForumCategory.java @@ -13,5 +13,5 @@ public interface ForumCategory { * * @return List of {@link be.maximvdw.spigotsite.api.forum.Forum} */ - public List getForums(); + List getForums(); } diff --git a/src/main/java/be/maximvdw/spigotsite/api/forum/ForumManager.java b/src/main/java/be/maximvdw/spigotsite/api/forum/ForumManager.java index fce1029..2209405 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/forum/ForumManager.java +++ b/src/main/java/be/maximvdw/spigotsite/api/forum/ForumManager.java @@ -1,5 +1,7 @@ package be.maximvdw.spigotsite.api.forum; +import be.maximvdw.spigotsite.api.exceptions.ConnectionFailedException; + /** * Spigot forum manager * @@ -11,6 +13,7 @@ public interface ForumManager { * * @param id Forum id * @return {@link be.maximvdw.spigotsite.api.forum.Forum} + * @throws ConnectionFailedException Connection to Spigot failed */ - Forum getForumById(int id); + Forum getForumById(int id) throws ConnectionFailedException; } diff --git a/src/main/java/be/maximvdw/spigotsite/api/forum/Thread.java b/src/main/java/be/maximvdw/spigotsite/api/forum/Thread.java index a9bec08..f27b35f 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/forum/Thread.java +++ b/src/main/java/be/maximvdw/spigotsite/api/forum/Thread.java @@ -15,19 +15,19 @@ public interface Thread { * * @return List of {@link be.maximvdw.spigotsite.api.forum.Post} */ - public List getReplies(); + List getReplies(); /** * Get original post * * @return {@link be.maximvdw.spigotsite.api.forum.Post} */ - public Post getOriginalPost(); + Post getOriginalPost(); /** * Get thread creator * * @return Thread creator */ - public User getCreator(); + User getCreator(); } diff --git a/src/main/java/be/maximvdw/spigotsite/api/resource/Buyer.java b/src/main/java/be/maximvdw/spigotsite/api/resource/Buyer.java new file mode 100644 index 0000000..19bf16c --- /dev/null +++ b/src/main/java/be/maximvdw/spigotsite/api/resource/Buyer.java @@ -0,0 +1,40 @@ +package be.maximvdw.spigotsite.api.resource; + +import be.maximvdw.spigotsite.api.user.User; + +import java.util.Date; + +/** + * Premium resource Buyer + * + * @author Maxim Van de Wynckel + */ +public interface Buyer extends User { + /** + * Get purchase date time + * + * @return purchase date + */ + Date getPurchaseDateTime(); + + /** + * Get the currency it was bought with + * + * @return currency + */ + String getPurchaseCurrency(); + + /** + * Get the price the buyer paid for + * + * @return purchase price + */ + double getPurchasePrice(); + + /** + * Check if the buyer was actually added by the buyer + * + * @return added by buyer or not + */ + boolean addedByAuthor(); +} diff --git a/src/main/java/be/maximvdw/spigotsite/api/resource/ResourceManager.java b/src/main/java/be/maximvdw/spigotsite/api/resource/ResourceManager.java index 84853d8..8b55bd9 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/resource/ResourceManager.java +++ b/src/main/java/be/maximvdw/spigotsite/api/resource/ResourceManager.java @@ -16,8 +16,9 @@ public interface ResourceManager { * * @param resourceid Resource identifier * @return Spigot Resource + * @throws ConnectionFailedException Connection to Spigot failed */ - Resource getResourceById(int resourceid); + Resource getResourceById(int resourceid) throws ConnectionFailedException; /** * Get a {@link be.maximvdw.spigotsite.api.resource.Resource} by identifier @@ -25,8 +26,9 @@ public interface ResourceManager { * @param resourceid Resource identifier * @param user Authenticated spigot user * @return Spigot Resource + * @throws ConnectionFailedException Connection to Spigot failed */ - Resource getResourceById(int resourceid, User user); + Resource getResourceById(int resourceid, User user) throws ConnectionFailedException; /** * Get a list of {@link be.maximvdw.spigotsite.api.resource.Resource} from a @@ -34,8 +36,9 @@ public interface ResourceManager { * * @param user {@link be.maximvdw.spigotsite.api.user.User} * @return List of {@link be.maximvdw.spigotsite.api.resource.Resource} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getResourcesByUser(User user); + List getResourcesByUser(User user) throws ConnectionFailedException; /** * Get a list of {@link be.maximvdw.spigotsite.api.resource.Resource} from a @@ -44,8 +47,9 @@ public interface ResourceManager { * @param user {@link be.maximvdw.spigotsite.api.user.User} * @param loggedInUser {@link be.maximvdw.spigotsite.api.user.User} used to get hidden plugins * @return List of {@link be.maximvdw.spigotsite.api.resource.Resource} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getResourcesByUser(User user, User loggedInUser); + List getResourcesByUser(User user, User loggedInUser) throws ConnectionFailedException; /** * Get a list of {@link be.maximvdw.spigotsite.api.resource.Resource} from a @@ -53,8 +57,9 @@ public interface ResourceManager { * * @param id User identifier * @return List of {@link be.maximvdw.spigotsite.api.resource.Resource} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getResourcesByUser(int id); + List getResourcesByUser(int id) throws ConnectionFailedException; /** * Get a list of {@link be.maximvdw.spigotsite.api.resource.Resource} from a @@ -63,8 +68,9 @@ public interface ResourceManager { * @param id User identifier * @param loggedInUser {@link be.maximvdw.spigotsite.api.user.User} used to get hidden plugins * @return List of {@link be.maximvdw.spigotsite.api.resource.Resource} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getResourcesByUser(int id, User loggedInUser); + List getResourcesByUser(int id, User loggedInUser) throws ConnectionFailedException; /** * Get a list of {@link be.maximvdw.spigotsite.api.resource.Resource} bought @@ -72,6 +78,7 @@ public interface ResourceManager { * * @param user Authenticated {@link be.maximvdw.spigotsite.api.user.User} * @return List of {@link be.maximvdw.spigotsite.api.resource.Resource} + * @throws ConnectionFailedException Connection to Spigot failed */ List getPurchasedResources(User user) throws ConnectionFailedException; @@ -81,8 +88,9 @@ List getPurchasedResources(User user) * * @return List of * {@link be.maximvdw.spigotsite.api.resource.ResourceCategory} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getResourceCategories(); + List getResourceCategories() throws ConnectionFailedException; /** * Get {@link be.maximvdw.spigotsite.api.resource.ResourceCategory} by @@ -90,33 +98,37 @@ List getPurchasedResources(User user) * * @param id Resource Category identifier * @return Resource Category + * @throws ConnectionFailedException Connection to Spigot failed */ - ResourceCategory getResourceCategoryById(int id); + ResourceCategory getResourceCategoryById(int id) throws ConnectionFailedException; /** * Get all resources from a specific category * * @param category List of {@link be.maximvdw.spigotsite.api.resource.Resource} * @return + * @throws ConnectionFailedException Connection to Spigot failed */ - List getResourcesByCategory(ResourceCategory category); + List getResourcesByCategory(ResourceCategory category) throws ConnectionFailedException; /** * Get the last version of a resource * * @param resourceid Resource identifier * @return Version string + * @throws ConnectionFailedException Connection to Spigot failed */ - String getLastVersion(int resourceid); + String getLastVersion(int resourceid) throws ConnectionFailedException; /** * Get premium resource buyers * * @param resource Premium resource * @param user The authenticated author of the plugin - * @return List of {@link be.maximvdw.spigotsite.api.user.User} + * @return List of {@link be.maximvdw.spigotsite.api.resource.Buyer} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getPremiumResourceBuyers(PremiumResource resource, + List getPremiumResourceBuyers(PremiumResource resource, User user) throws ConnectionFailedException; /** @@ -125,8 +137,9 @@ List getPremiumResourceBuyers(PremiumResource resource, * @param resource Premium resource * @param user The authenticated plugin author * @param buyer The buyer + * @throws ConnectionFailedException Connection to Spigot failed */ - void addBuyer(PremiumResource resource, User user, User buyer); + void addBuyer(PremiumResource resource, User user, User buyer) throws ConnectionFailedException; /** * Add a buyer to a spigot premium resource @@ -134,8 +147,9 @@ List getPremiumResourceBuyers(PremiumResource resource, * @param resource Premium resource * @param user The authenticated plugin author * @param userid User identifier + * @throws ConnectionFailedException Connection to Spigot failed */ - void addBuyer(PremiumResource resource, User user, int userid); + void addBuyer(PremiumResource resource, User user, int userid) throws ConnectionFailedException; /** * Add a buyer to a spigot premium resource @@ -143,8 +157,9 @@ List getPremiumResourceBuyers(PremiumResource resource, * @param resource Premium resource * @param user The authenticated plugin author * @param username The text username + * @throws ConnectionFailedException Connection to Spigot failed */ - void addBuyer(PremiumResource resource, User user, String username); + void addBuyer(PremiumResource resource, User user, String username) throws ConnectionFailedException; /** * Add a buyer to a spigot premium resource @@ -152,8 +167,9 @@ List getPremiumResourceBuyers(PremiumResource resource, * @param resource Premium resource * @param user The authenticated plugin author * @param buyers A list of buyers + * @throws ConnectionFailedException Connection to Spigot failed */ - void addBuyers(PremiumResource resource, User user, List buyers); + void addBuyers(PremiumResource resource, User user, List buyers) throws ConnectionFailedException; /** * Add a buyer to a spigot premium resource @@ -161,16 +177,18 @@ List getPremiumResourceBuyers(PremiumResource resource, * @param resource Premium resource * @param user The authenticated plugin author * @param usernames A list of usernames + * @throws ConnectionFailedException Connection to Spigot failed */ void addBuyers(PremiumResource resource, User user, - String[] usernames); + String[] usernames) throws ConnectionFailedException; /** * Remove a buyer from a spigot premium resource * * @param resource Premium resource * @param user The authenticated plugin author - * @param buyer Buyer to remove + * @param buyer Buyer to remove + * @throws ConnectionFailedException Connection to Spigot failed */ - void removeBuyer(PremiumResource resource, User user, int buyer); + void removeBuyer(PremiumResource resource, User user, int buyer) throws ConnectionFailedException; } \ No newline at end of file diff --git a/src/main/java/be/maximvdw/spigotsite/api/user/Conversation.java b/src/main/java/be/maximvdw/spigotsite/api/user/Conversation.java index 8385d04..e632101 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/user/Conversation.java +++ b/src/main/java/be/maximvdw/spigotsite/api/user/Conversation.java @@ -3,6 +3,7 @@ import java.util.Date; import java.util.List; +import be.maximvdw.spigotsite.api.exceptions.ConnectionFailedException; import be.maximvdw.spigotsite.api.exceptions.SpamWarningException; /** @@ -79,20 +80,23 @@ public interface Conversation { * Leave the conversation * * @param user Authenticated user + * @throws ConnectionFailedException Connection to Spigot failed */ - void leave(User user); + void leave(User user) throws ConnectionFailedException; /** * Mark conversation as read * * @param user Authenticated user + * @throws ConnectionFailedException Connection to Spigot failed */ - void markAsRead(User user); + void markAsRead(User user) throws ConnectionFailedException; /** * Mark conversation as unread * * @param user Authenticated user + * @throws ConnectionFailedException Connection to Spigot failed */ - void markAsUnread(User user); + void markAsUnread(User user) throws ConnectionFailedException; } diff --git a/src/main/java/be/maximvdw/spigotsite/api/user/ConversationManager.java b/src/main/java/be/maximvdw/spigotsite/api/user/ConversationManager.java index 1881b16..30bf29a 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/user/ConversationManager.java +++ b/src/main/java/be/maximvdw/spigotsite/api/user/ConversationManager.java @@ -13,6 +13,7 @@ public interface ConversationManager { * @param user Authenticated {@link be.maximvdw.spigotsite.api.user.User} * @param count * @return List of {@link be.maximvdw.spigotsite.api.user.Conversation} + * @throws ConnectionFailedException Connection to Spigot failed */ List getConversations(User user, int count) throws ConnectionFailedException; @@ -23,17 +24,19 @@ List getConversations(User user, int count) * @param conversation Conversation * @param user Authenticated user * @param reply Reply BB Code + * @throws ConnectionFailedException Connection to Spigot failed */ void replyToConversation(Conversation conversation, User user, - String reply) throws SpamWarningException; + String reply) throws SpamWarningException, ConnectionFailedException; /** * Leave a conversation * * @param conversation Conversation * @param user Authenticated user + * @throws ConnectionFailedException Connection to Spigot failed */ - void leaveConversation(Conversation conversation, User user); + void leaveConversation(Conversation conversation, User user) throws ConnectionFailedException; /** * Create a new conversation @@ -46,54 +49,59 @@ void replyToConversation(Conversation conversation, User user, * @param invite Invite others to the conversation * @param sticky Set sticky * @return Conversation + * @throws ConnectionFailedException Connection to Spigot failed */ Conversation createConversation(User user, Set recipents, String title, String body, boolean locked, boolean invite, - boolean sticky) throws SpamWarningException; + boolean sticky) throws SpamWarningException, ConnectionFailedException; /** * Create a new conversation * - * @param user Authenticated user that sends the message - * @param recipent Username to send it to - * @param title Title BB Code - * @param body Body BB Code - * @param locked Lock the conversation - * @param invite Invite others to the conversation - * @param sticky Set sticky + * @param user Authenticated user that sends the message + * @param recipent Username to send it to + * @param title Title BB Code + * @param body Body BB Code + * @param locked Lock the conversation + * @param invite Invite others to the conversation + * @param sticky Set sticky * @return Conversation + * @throws ConnectionFailedException Connection to Spigot failed */ Conversation createConversation(User user, String recipient, String title, String body, boolean locked, boolean invite, - boolean sticky) throws SpamWarningException; + boolean sticky) throws SpamWarningException, ConnectionFailedException; /** * Create a new conversation * - * @param user Authenticated user that sends the message - * @param recipent Username to send it to - * @param title Title BB Code - * @param body Body BB Code - * @param locked Lock the conversation - * @param invite Invite others to the conversation + * @param user Authenticated user that sends the message + * @param recipent Username to send it to + * @param title Title BB Code + * @param body Body BB Code + * @param locked Lock the conversation + * @param invite Invite others to the conversation * @return Conversation + * @throws ConnectionFailedException Connection to Spigot failed */ Conversation createConversation(User user, String recipient, - String title, String body, boolean locked, boolean invite) throws SpamWarningException; + String title, String body, boolean locked, boolean invite) throws SpamWarningException, ConnectionFailedException; /** * Mark a conversation as read * * @param user Authenticated user * @param conversation Conversation to mark as read + * @throws ConnectionFailedException Connection to Spigot failed */ - void markConversationAsRead(User user, Conversation conversation); + void markConversationAsRead(User user, Conversation conversation) throws ConnectionFailedException; /** * Mark a conversation as unread * * @param user Authenticated user * @param conversation Conversation to mark as unread + * @throws ConnectionFailedException Connection to Spigot failed */ - void markConversationAsUnread(User user, Conversation conversation); + void markConversationAsUnread(User user, Conversation conversation) throws ConnectionFailedException; } diff --git a/src/main/java/be/maximvdw/spigotsite/api/user/Medal.java b/src/main/java/be/maximvdw/spigotsite/api/user/Medal.java index 89222a5..ddc9fe6 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/user/Medal.java +++ b/src/main/java/be/maximvdw/spigotsite/api/user/Medal.java @@ -11,19 +11,19 @@ public interface Medal { * * @return Medal identifier */ - public int getMedalId(); + int getMedalId(); /** * Get medal name * * @return Name */ - public String getName(); + String getName(); /** * Get medal description * * @return Medal description */ - public String getDescription(); + String getDescription(); } diff --git a/src/main/java/be/maximvdw/spigotsite/api/user/UserManager.java b/src/main/java/be/maximvdw/spigotsite/api/user/UserManager.java index ada5b46..1d06191 100644 --- a/src/main/java/be/maximvdw/spigotsite/api/user/UserManager.java +++ b/src/main/java/be/maximvdw/spigotsite/api/user/UserManager.java @@ -2,6 +2,7 @@ import java.util.List; +import be.maximvdw.spigotsite.api.exceptions.ConnectionFailedException; import be.maximvdw.spigotsite.api.user.exceptions.InvalidCredentialsException; import be.maximvdw.spigotsite.api.user.exceptions.TwoFactorAuthenticationException; @@ -16,24 +17,27 @@ public interface UserManager { * * @param userid User identifier * @return {@link be.maximvdw.spigotsite.api.user.User} + * @throws ConnectionFailedException Connection to Spigot failed */ - User getUserById(int userid); + User getUserById(int userid) throws ConnectionFailedException; /** * Get a list of users by their name * * @param name Name * @return List of users + * @throws ConnectionFailedException Connection to Spigot failed */ - List getUsernamesByName(String name); + List getUsernamesByName(String name) throws ConnectionFailedException; /** * Get user by name * * @param name username * @return User instance + * @throws ConnectionFailedException Connection to Spigot failed */ - User getUserByName(String name); + User getUserByName(String name) throws ConnectionFailedException; /** * Get {@link be.maximvdw.spigotsite.api.user.User} by identifier @@ -41,8 +45,9 @@ public interface UserManager { * @param userid User identifier * @param user Authenticated {@link be.maximvdw.spigotsite.api.user.User} * @return {@link be.maximvdw.spigotsite.api.user.User} + * @throws ConnectionFailedException Connection to Spigot failed */ - User getUserById(int userid, User user); + User getUserById(int userid, User user) throws ConnectionFailedException; /** * Authenticate a spigot user @@ -50,9 +55,10 @@ public interface UserManager { * @param username Username or Email address * @param password Password * @return Authenticated Spigot user + * @throws ConnectionFailedException Connection to Spigot failed */ User authenticate(String username, String password) - throws InvalidCredentialsException, TwoFactorAuthenticationException; + throws InvalidCredentialsException, TwoFactorAuthenticationException, ConnectionFailedException; /** * Authenticate a spigot user @@ -61,9 +67,10 @@ User authenticate(String username, String password) * @param password Password * @param twoFactorAuthenticationSecret Two factory authentication BASE 64 secret * @return Authenticated Spigot user + * @throws ConnectionFailedException Connection to Spigot failed */ User authenticate(String username, String password, String twoFactorAuthenticationSecret) - throws InvalidCredentialsException, TwoFactorAuthenticationException; + throws InvalidCredentialsException, TwoFactorAuthenticationException, ConnectionFailedException; /** * Authenticate a spigot user @@ -72,53 +79,60 @@ User authenticate(String username, String password, String twoFactorAuthenticati * @param password Password * @param user Logged off user with cookies * @return Authenticated Spigot user + * @throws ConnectionFailedException Connection to Spigot failed */ User authenticate(String username, String password, User user) - throws InvalidCredentialsException, TwoFactorAuthenticationException; + throws InvalidCredentialsException, TwoFactorAuthenticationException, ConnectionFailedException; /** * Log off a spigot user * * @param user Authenticated Spigot user + * @throws ConnectionFailedException Connection to Spigot failed */ - void logOff(User user); + void logOff(User user) throws ConnectionFailedException; /** * Log off a spigot user * * @param force Force clear the cookies * @param user Authenticated Spigot user + * @throws ConnectionFailedException Connection to Spigot failed */ - void logOff(User user, boolean force); + void logOff(User user, boolean force) throws ConnectionFailedException; /** * Check if the user is logged in * * @param user User to check * @return logged in boolean + * @throws ConnectionFailedException Connection to Spigot failed */ - boolean isLoggedIn(User user); + boolean isLoggedIn(User user) throws ConnectionFailedException; /** * Get user ranks * * @return List of {@link be.maximvdw.spigotsite.api.user.UserRank} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getUserRanks(); + List getUserRanks() throws ConnectionFailedException; /** * Get users by rank * * @param rank * @return List of {@link be.maximvdw.spigotsite.api.user.User} + * @throws ConnectionFailedException Connection to Spigot failed */ - List getUsersByRank(UserRank rank); + List getUsersByRank(UserRank rank) throws ConnectionFailedException; /** * Get online members * * @return List of members + * @throws ConnectionFailedException Connection to Spigot failed */ - List getOnlineUsers(); + List getOnlineUsers() throws ConnectionFailedException; }