mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Rollback API changes, adjust method of obtaining API
This commit is contained in:
1 parent
302ff0757a
commit
49ea2237c7
2 files changed
+13
-23
No files matched your search
@@ -78,13 +78,12 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
public static PlayerList getPlayerList() { return playerList; }
|
public static PlayerList getPlayerList() { return playerList; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use HuskHomesAPI#getInstance() instead
|
|
||||||
* Returns the HuskHomes API
|
* Returns the HuskHomes API
|
||||||
* @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 HuskHomesAPI.getInstance();
|
return new HuskHomesAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package me.william278.huskhomes2.api;
|
package me.william278.huskhomes2.api;
|
||||||
|
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
@@ -21,22 +22,12 @@ import java.util.logging.Level;
|
|||||||
public class HuskHomesAPI {
|
public class HuskHomesAPI {
|
||||||
|
|
||||||
private static final HuskHomes huskHomes = HuskHomes.getInstance();
|
private static final HuskHomes huskHomes = HuskHomes.getInstance();
|
||||||
|
private Connection getConnection() {
|
||||||
private static HuskHomesAPI instance;
|
return HuskHomes.getConnection();
|
||||||
|
|
||||||
private HuskHomesAPI() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the HuskHomes API
|
|
||||||
* @return instance of the HuskHomes API
|
|
||||||
*/
|
|
||||||
public static HuskHomesAPI getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new HuskHomesAPI();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HuskHomesAPI() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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
|
||||||
@param player A player
|
@param player A player
|
||||||
@@ -57,7 +48,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, HuskHomes.getConnection());
|
return DataManager.getHome(ownerUsername, homeName, 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;
|
||||||
@@ -72,7 +63,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public Warp getWarp(String warpName) {
|
public Warp getWarp(String warpName) {
|
||||||
try {
|
try {
|
||||||
return DataManager.getWarp(warpName, HuskHomes.getConnection());
|
return DataManager.getWarp(warpName, 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;
|
||||||
@@ -97,7 +88,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public List<Home> getHomes(String ownerUsername) {
|
public List<Home> getHomes(String ownerUsername) {
|
||||||
try {
|
try {
|
||||||
return DataManager.getPlayerHomes(ownerUsername, HuskHomes.getConnection());
|
return DataManager.getPlayerHomes(ownerUsername, 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;
|
||||||
@@ -139,7 +130,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public List<Home> getPublicHomes() {
|
public List<Home> getPublicHomes() {
|
||||||
try {
|
try {
|
||||||
return DataManager.getPublicHomes(HuskHomes.getConnection());
|
return DataManager.getPublicHomes(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;
|
||||||
@@ -162,7 +153,7 @@ public class HuskHomesAPI {
|
|||||||
*/
|
*/
|
||||||
public List<Warp> getWarps() {
|
public List<Warp> getWarps() {
|
||||||
try {
|
try {
|
||||||
return DataManager.getWarps(HuskHomes.getConnection());
|
return DataManager.getWarps(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;
|
||||||
@@ -194,7 +185,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 = HuskHomes.getConnection();
|
Connection connection = getConnection();
|
||||||
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
||||||
try {
|
try {
|
||||||
if (timed) {
|
if (timed) {
|
||||||
@@ -216,7 +207,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 = HuskHomes.getConnection();
|
Connection connection = getConnection();
|
||||||
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
Bukkit.getScheduler().runTask(huskHomes, () -> {
|
||||||
try {
|
try {
|
||||||
if (timed) {
|
if (timed) {
|
||||||
|
|||||||
Reference in new issue
Block a user