From a69d3a07dec4d842de749dfdffbd619e1343964c Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 20 Nov 2020 14:52:50 +0100 Subject: [PATCH] Documentation --- pom.xml | 2 +- src/main/java/tsp/headdb/api/HeadAPI.java | 92 +++++++++++++++++++ .../tsp/headdb/command/Command_headdb.java | 2 +- .../tsp/headdb/database/HeadDatabase.java | 5 + src/main/resources/plugin.yml | 2 +- 5 files changed, 100 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index fa0998e..26a6b21 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ jar HeadDB - Head Database + Thousands of heads in a GUI diff --git a/src/main/java/tsp/headdb/api/HeadAPI.java b/src/main/java/tsp/headdb/api/HeadAPI.java index 2f9ce39..4be3612 100644 --- a/src/main/java/tsp/headdb/api/HeadAPI.java +++ b/src/main/java/tsp/headdb/api/HeadAPI.java @@ -12,48 +12,119 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +/** + * This class provides simple methods + * for interacting with the HeadDB plugin + * + * @author TheSilentPro + */ public class HeadAPI { + /** + * Opens the database for a player + * + * @param player Target player + */ public static void openDatabase(Player player) { InventoryUtils.openDatabase(player); } + /** + * Opens a specific category of the database for a player + * + * @param player Target player + * @param category Category to open + */ public static void openDatabase(Player player, Category category) { InventoryUtils.openCategoryDatabase(player, category); } + /** + * Opens the database with results of a specific search term + * + * @param player Target player + * @param search Search term + */ public static void openDatabase(Player player, String search) { InventoryUtils.openSearchDatabase(player, search); } + /** + * Retrieve a {@link Head} by it's ID + * + * @param id The ID of the head + * @return The head + */ public static Head getHeadByID(int id) { return HeadDatabase.getHeadByID(id); } + /** + * Retrieve a {@link Head} by it's UUID + * + * @param uuid The UUID of the head + * @return The head + */ public static Head getHeadByUUID(UUID uuid) { return HeadDatabase.getHeadByUUID(uuid); } + /** + * Retrieves a {@link List} of {@link Head}'s matching a name + * + * @param name The name to match for + * @return List of heads + */ public static List getHeadsByName(String name) { return HeadDatabase.getHeadsByName(name); } + /** + * Retrieves a {@link List} of {@link Head}'s in a {@link Category} matching a name + * + * @param category The category to search in + * @param name The name to match for + * @return List of heads + */ public static List getHeadsByName(Category category, String name) { return HeadDatabase.getHeadsByName(category, name); } + /** + * Retrieve a {@link Head} by it's value + * + * @param value The texture value + * @return The head + */ public static Head getHeadByValue(String value) { return HeadDatabase.getHeadByValue(value); } + /** + * Retrieve a {@link List} of {@link Head}'s in a specific {@link Category} + * + * @param category The category to search in + * @return List of heads + */ public static List getHeads(Category category) { return HeadDatabase.getHeads(category); } + /** + * Retrieve a {@link List} of all {@link Head}'s + * + * @return List of all heads + */ public static List getHeads() { return HeadDatabase.getHeads(); } + /** + * Add a {@link Head} to a players favorites + * + * @param uuid The UUID of the player + * @param id The ID of the head + */ public static void addFavoriteHead(UUID uuid, int id) { List favs = HeadDB.getPlayerdata().getIntList(uuid.toString() + ".favorites"); if (!favs.contains(id)) { @@ -63,6 +134,12 @@ public class HeadAPI { HeadDB.getPlayerdata().save(); } + /** + * Remove a {@link Head} from a players favorites + * + * @param uuid The UUID of the player + * @param id The ID of the head + */ public static void removeFavoriteHead(UUID uuid, int id) { List favs = HeadDB.getPlayerdata().getIntList(uuid.toString() + ".favorites"); for (int i = 0; i < favs.size(); i++) { @@ -75,6 +152,12 @@ public class HeadAPI { HeadDB.getPlayerdata().save(); } + /** + * Retrieve a {@link List} of favorite {@link Head} for a player + * + * @param uuid The UUID of the player + * @return List of favorite heads + */ public static List getFavoriteHeads(UUID uuid) { List heads = new ArrayList<>(); List ids = HeadDB.getPlayerdata().getIntList(uuid.toString() + ".favorites"); @@ -86,6 +169,12 @@ public class HeadAPI { return heads; } + /** + * Retrieve a {@link List} of local heads. + * These heads are from players that have joined the server at least once. + * + * @return List of {@link LocalHead}'s + */ public static List getLocalHeads() { List heads = new ArrayList<>(); for (String key : HeadDB.getPlayerdata().getKeys(false)) { @@ -99,6 +188,9 @@ public class HeadAPI { return heads; } + /** + * Update the Head Database + */ public static void updateDatabase() { HeadDatabase.update(); } diff --git a/src/main/java/tsp/headdb/command/Command_headdb.java b/src/main/java/tsp/headdb/command/Command_headdb.java index 9bb712f..93d243f 100644 --- a/src/main/java/tsp/headdb/command/Command_headdb.java +++ b/src/main/java/tsp/headdb/command/Command_headdb.java @@ -104,7 +104,7 @@ public class Command_headdb implements CommandExecutor { Utils.sendMessage(sender, " "); Utils.sendMessage(sender, "&c&lHeadDB &c- &5Commands"); - Utils.sendMessage(sender, "&7&oParameters:&c command &9(aliases) &7- Description"); + Utils.sendMessage(sender, "&7&oParameters:&c command &9(aliases)&c arguments... &7- Description"); Utils.sendMessage(sender, " > &c/hdb &7- Opens the database"); Utils.sendMessage(sender, " > &c/hdb info &9(i) &7- Plugin Information"); Utils.sendMessage(sender, " > &c/hdb search &9(s) &c &7- Search for heads matching a name"); diff --git a/src/main/java/tsp/headdb/database/HeadDatabase.java b/src/main/java/tsp/headdb/database/HeadDatabase.java index a20b6ef..8b57f9e 100644 --- a/src/main/java/tsp/headdb/database/HeadDatabase.java +++ b/src/main/java/tsp/headdb/database/HeadDatabase.java @@ -16,6 +16,11 @@ import java.net.URLConnection; import java.util.*; import java.util.concurrent.TimeUnit; +/** + * This is the Database that holds all heads + * + * @author TheSilentPro + */ public class HeadDatabase { private static final Map> HEADS = new HashMap<>(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index bae6c85..4953194 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: HeadDB -description: Head Database +description: Adds a menu with thousands of heads main: tsp.headdb.HeadDB version: 1.3