Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-26 19:02:39 +01:00
Documentation
Dieser Commit ist enthalten in:
Ursprung
25283705f6
Commit
a69d3a07de
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HeadDB</name>
|
||||
<description>Head Database</description>
|
||||
<description>Thousands of heads in a GUI</description>
|
||||
|
||||
<repositories>
|
||||
<!-- Paper Repo -->
|
||||
|
@ -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<Head> 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<Head> 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<Head> getHeads(Category category) {
|
||||
return HeadDatabase.getHeads(category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a {@link List} of all {@link Head}'s
|
||||
*
|
||||
* @return List of all heads
|
||||
*/
|
||||
public static List<Head> 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<Integer> 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<Integer> 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<Head> getFavoriteHeads(UUID uuid) {
|
||||
List<Head> heads = new ArrayList<>();
|
||||
List<Integer> 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<LocalHead> getLocalHeads() {
|
||||
List<LocalHead> 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();
|
||||
}
|
||||
|
@ -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<name> &7- Search for heads matching a name");
|
||||
|
@ -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<Category, List<Head>> HEADS = new HashMap<>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: HeadDB
|
||||
description: Head Database
|
||||
description: Adds a menu with thousands of heads
|
||||
|
||||
main: tsp.headdb.HeadDB
|
||||
version: 1.3
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren