mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Re-introduce API
This commit is contained in:
1 parent
d7e50b3a37
commit
eac0b7a1d1
3 files changed
+65
-35
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.William278</groupId>
|
||||
<artifactId>HuskHomes</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>2.5-dev</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HuskHomes</name>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.william278.huskhomes2.api;
|
||||
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.data.DataManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import me.william278.huskhomes2.teleport.points.Home;
|
||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||
@@ -10,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,9 @@ import java.util.logging.Level;
|
||||
public class HuskHomesAPI {
|
||||
|
||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||
private Connection getConnection() {
|
||||
return HuskHomes.getConnection();
|
||||
}
|
||||
|
||||
public HuskHomesAPI() { }
|
||||
|
||||
@@ -28,117 +33,142 @@ public class HuskHomesAPI {
|
||||
@param homeName Name of the player's home you wish to retrieve
|
||||
@return the player's Home, or NULL if it does not exist
|
||||
@see Home
|
||||
*//*
|
||||
*/
|
||||
public Home getHome(Player player, String homeName) {
|
||||
return getHome(player.getName(), homeName);
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
Returns a Home set by a player, or NULL if it does not exist
|
||||
@param ownerUsername Username of the player
|
||||
@param homeName Name of the player's home you wish to retrieve
|
||||
@return the player's Home, or NULL if it does not exist
|
||||
@see Home
|
||||
*//*
|
||||
public Home getHome(String ownerUsername, String homeName) {
|
||||
return DataManager.getHome(ownerUsername, homeName);
|
||||
*/
|
||||
public Home getHome(String ownerUsername, String homeName) {
|
||||
try {
|
||||
return DataManager.getHome(ownerUsername, homeName, getConnection());
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
Returns a Warp set on the server, or NULL if it does not exist
|
||||
@param warpName Name of the warp
|
||||
@return a Warp, or NULL if it does not exist
|
||||
@see Warp
|
||||
*//*
|
||||
*/
|
||||
public Warp getWarp(String warpName) {
|
||||
return DataManager.getWarp(warpName);
|
||||
try {
|
||||
return DataManager.getWarp(warpName, getConnection());
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
Returns an ArrayList of homes set by a Player
|
||||
@param player A Player
|
||||
@return an ArrayList of Homes
|
||||
@see Home
|
||||
*//*
|
||||
*/
|
||||
public List<Home> getHomes(Player player) {
|
||||
return DataManager.getPlayerHomes(player.getName());
|
||||
return getHomes(player.getName());
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
Returns an ArrayList of homes set by a player
|
||||
@param ownerUsername Username of the player who's homes you want to get
|
||||
@return an ArrayList of Homes
|
||||
@see Home
|
||||
*//*
|
||||
*/
|
||||
public List<Home> getHomes(String ownerUsername) {
|
||||
return DataManager.getPlayerHomes(ownerUsername);
|
||||
try {
|
||||
return DataManager.getPlayerHomes(ownerUsername, getConnection());
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
* Returns how many Homes a given Player has set
|
||||
* @param player the Player being checked
|
||||
* @return an integer of how many homes a player has set
|
||||
* @see Home
|
||||
*//*
|
||||
*/
|
||||
public int getHomeCount(Player player) {
|
||||
return getHomes(player).size();
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
* Returns the maximum number of homes a player can set
|
||||
* @param player the Player being checked
|
||||
* @return the maximum homes a player can set
|
||||
*//*
|
||||
*/
|
||||
public int getMaxSethomes(Player player) {
|
||||
return Home.getSetHomeLimit(player);
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
* Returns the number of homes a player can set for free
|
||||
* @param player the Player being checked
|
||||
* @return the number of free homes a player can set
|
||||
*//*
|
||||
*/
|
||||
public int getFreeSethomes(Player player) {
|
||||
return Home.getFreeHomes(player);
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
Returns an ArrayList of all the public homes set
|
||||
@return an ArrayList of Homes
|
||||
@see Home
|
||||
*//*
|
||||
*/
|
||||
public List<Home> getPublicHomes() {
|
||||
return DataManager.getPublicHomes();
|
||||
try {
|
||||
return DataManager.getPublicHomes(getConnection());
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
* Returns how many public Homes there are
|
||||
* @return an integer of how many public homes there are
|
||||
* @see Home
|
||||
*//*
|
||||
*/
|
||||
public int getPublicHomeCount() {
|
||||
return getPublicHomes().size();
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
Returns an ArrayList of all the warps set
|
||||
@return an ArrayList of Warps
|
||||
@see Warp
|
||||
*//*
|
||||
*/
|
||||
public List<Warp> getWarps() {
|
||||
return DataManager.getWarps();
|
||||
try {
|
||||
return DataManager.getWarps(getConnection());
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
* Returns how many Warps have been set
|
||||
* @return an integer of how many warps have been set
|
||||
* @see Warp
|
||||
*//*
|
||||
*/
|
||||
public int getWarpCount() {
|
||||
return getWarps().size();
|
||||
}
|
||||
|
||||
*//**
|
||||
/**
|
||||
* Returns the current spawn position as a TeleportationPoint
|
||||
* @return the spawn position as a TeleportationPoint
|
||||
*/
|
||||
|
||||
@@ -33,10 +33,10 @@ edit_home_update_name: '[Successfully changed your home''s name: %1% →](#00fb9
|
||||
error_no_homes_set: '[Error:](#ff3300) [You haven''t set any homes!](#ff7e5e)'
|
||||
error_no_public_homes_set: '[Error:](#ff3300) [There aren''t any public homes set!](#ff7e5e)'
|
||||
error_no_warps_set: '[Error:](#ff3300) [There aren''t any warps set!](#ff7e5e)'
|
||||
private_home_list_page_top: '[%1%''s Homes:](#00fb9a) ([%2%-%3%](#00fb9a bold) [of](#00fb9a) [%4%](#00fb9a bold))'
|
||||
public_home_list_page_top: '[Public Homes:](#00fb9a) ([%1%-%2%](#00fb9a bold) [of](#00fb9a) [%3%](#00fb9a bold))'
|
||||
private_home_list_page_top: '[%1%''s Homes:](#00fb9a) [(](#00fb9a)[%2%-%3%](#00fb9a bold) [of](#00fb9a) [%4%](#00fb9a bold)[)](#00fb9a)'
|
||||
public_home_list_page_top: '[Public Homes:](#00fb9a) [(](#00fb9a)[%1%-%2%](#00fb9a bold) [of](#00fb9a) [%3%](#00fb9a bold)[)](#00fb9a)'
|
||||
home_list_page_empty: '&7(There are no homes to list on this page)'
|
||||
warp_list_page_top: '[Warps:](#00fb9a) ([%1%-%2%](#00fb9a bold) [of](#00fb9a] [%3%](#00fb9a bold))'
|
||||
warp_list_page_top: '[Warps:](#00fb9a) [(](#00fb9a)[%1%-%2%](#00fb9a bold) [of](#00fb9a] [%3%](#00fb9a bold)[)](#00fb9a)'
|
||||
warp_list_page_empty: '&7(There are no warps to list on this page)'
|
||||
error_public_home_invalid: '[Error:](#ff3300) [Could not find a public home owned by %1% called %2%.](#ff7e5e)'
|
||||
error_set_home_invalid_characters: '[Error:](#ff3300) [Home names must be alphanumeric (A-Z, 0-9, -_)](#ff7e5e)'
|
||||
|
||||
Reference in new issue
Block a user