mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +00:00
Rollforward API changes
This commit is contained in:
1 parent
e4dcd358fd
commit
f7e2b6431f
2 files changed
+19
-12
No files matched your search
@@ -79,11 +79,12 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HuskHomes API
|
* Returns the HuskHomes API
|
||||||
|
* @deprecated Use {@link HuskHomesAPI#getInstance()} instead
|
||||||
* @return an instance of the HuskHomes API
|
* @return an instance of the HuskHomes API
|
||||||
* @see HuskHomesAPI
|
* @see HuskHomesAPI
|
||||||
*/
|
*/
|
||||||
public HuskHomesAPI getAPI() {
|
public HuskHomesAPI getAPI() {
|
||||||
return new HuskHomesAPI();
|
return HuskHomesAPI.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,19 @@ import java.util.logging.Level;
|
|||||||
* Only use methods/events found within the API package
|
* Only use methods/events found within the API package
|
||||||
*/
|
*/
|
||||||
public class HuskHomesAPI {
|
public class HuskHomesAPI {
|
||||||
|
private static HuskHomesAPI instance;
|
||||||
|
private final HuskHomes huskHomes;
|
||||||
|
|
||||||
private static final HuskHomes huskHomes = HuskHomes.getInstance();
|
private HuskHomesAPI() {
|
||||||
private Connection getConnection() {
|
huskHomes = HuskHomes.getInstance();
|
||||||
return HuskHomes.getConnection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HuskHomesAPI() { }
|
public static HuskHomesAPI getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new HuskHomesAPI();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a Home set by a player, or NULL if it does not exist
|
Returns a Home set by a player, or NULL if it does not exist
|
||||||
@@ -48,7 +54,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public Home getHome(String ownerUsername, String homeName) {
|
public Home getHome(String ownerUsername, String homeName) {
|
||||||
try {
|
try {
|
||||||
return DataManager.getHome(ownerUsername, homeName, getConnection());
|
return DataManager.getHome(ownerUsername, homeName, huskHomes.getInstance().getConnection());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||||
return null;
|
return null;
|
||||||
@@ -63,7 +69,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public Warp getWarp(String warpName) {
|
public Warp getWarp(String warpName) {
|
||||||
try {
|
try {
|
||||||
return DataManager.getWarp(warpName, getConnection());
|
return DataManager.getWarp(warpName, huskHomes.getInstance().getConnection());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||||
return null;
|
return null;
|
||||||
@@ -88,7 +94,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public List<Home> getHomes(String ownerUsername) {
|
public List<Home> getHomes(String ownerUsername) {
|
||||||
try {
|
try {
|
||||||
return DataManager.getPlayerHomes(ownerUsername, getConnection());
|
return DataManager.getPlayerHomes(ownerUsername, huskHomes.getInstance().getConnection());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||||
return null;
|
return null;
|
||||||
@@ -130,7 +136,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public List<Home> getPublicHomes() {
|
public List<Home> getPublicHomes() {
|
||||||
try {
|
try {
|
||||||
return DataManager.getPublicHomes(getConnection());
|
return DataManager.getPublicHomes(huskHomes.getInstance().getConnection());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||||
return null;
|
return null;
|
||||||
@@ -153,7 +159,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public List<Warp> getWarps() {
|
public List<Warp> getWarps() {
|
||||||
try {
|
try {
|
||||||
return DataManager.getWarps(getConnection());
|
return DataManager.getWarps(huskHomes.getInstance().getConnection());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
huskHomes.getLogger().log(Level.WARNING, "An SQL exception occurred retrieving data for API access", e);
|
||||||
return null;
|
return null;
|
||||||
@@ -185,7 +191,7 @@ public class HuskHomesAPI {
|
|||||||
* @see TeleportationPoint
|
* @see TeleportationPoint
|
||||||
*/
|
*/
|
||||||
public void teleportPlayer(Player player, TeleportationPoint point, boolean timed) {
|
public void teleportPlayer(Player player, TeleportationPoint point, boolean timed) {
|
||||||
Connection connection = getConnection();
|
Connection connection = huskHomes.getInstance().getConnection();
|
||||||
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
||||||
try {
|
try {
|
||||||
if (timed) {
|
if (timed) {
|
||||||
@@ -207,7 +213,7 @@ public class HuskHomesAPI {
|
|||||||
* @see TeleportationPoint
|
* @see TeleportationPoint
|
||||||
*/
|
*/
|
||||||
public void teleportPlayer(Player player, String targetPlayerName, boolean timed) {
|
public void teleportPlayer(Player player, String targetPlayerName, boolean timed) {
|
||||||
Connection connection = getConnection();
|
Connection connection = huskHomes.getInstance().getConnection();
|
||||||
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
||||||
try {
|
try {
|
||||||
if (timed) {
|
if (timed) {
|
||||||
|
|||||||
Reference in new issue
Block a user