Skip to content

Commit

Permalink
fix: BmAPI null plugin reference (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
confuser committed Aug 31, 2024
1 parent 9ef5583 commit d64397d
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions common/src/main/java/me/confuser/banmanager/common/api/BmAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@
*/
public class BmAPI {

private static BanManagerPlugin plugin = BanManagerPlugin.getInstance();

/**
* @param uuid Player UUID
* @return PlayerData
* @throws SQLException
*/
public static PlayerData getPlayer(UUID uuid) throws SQLException {
return plugin.getPlayerStorage().queryForId(UUIDUtils.toBytes(uuid));
return BanManagerPlugin.getInstance().getPlayerStorage().queryForId(UUIDUtils.toBytes(uuid));
}

/**
Expand All @@ -40,7 +38,7 @@ public static PlayerData getPlayer(UUID uuid) throws SQLException {
* @throws SQLException
*/
public static PlayerData getPlayer(String name) throws SQLException {
return plugin.getPlayerStorage().retrieve(name, false);
return BanManagerPlugin.getInstance().getPlayerStorage().retrieve(name, false);
}

/**
Expand All @@ -49,7 +47,7 @@ public static PlayerData getPlayer(String name) throws SQLException {
* @throws SQLException
*/
public static List<PlayerData> getPlayers(IPAddress ip) throws SQLException {
return plugin.getPlayerStorage().getDuplicatesInTime(ip, plugin.getConfig().getTimeAssociatedAlts());
return BanManagerPlugin.getInstance().getPlayerStorage().getDuplicatesInTime(ip, BanManagerPlugin.getInstance().getConfig().getTimeAssociatedAlts());
}

/**
Expand All @@ -58,7 +56,7 @@ public static List<PlayerData> getPlayers(IPAddress ip) throws SQLException {
* @return PlayerData
*/
public static PlayerData getConsole() {
return plugin.getPlayerStorage().getConsole();
return BanManagerPlugin.getInstance().getPlayerStorage().getConsole();
}

/**
Expand All @@ -80,7 +78,7 @@ public static IPAddress toIp(String ip) {
* @throws SQLException
*/
public static boolean ban(PlayerBanData ban) throws SQLException {
return plugin.getPlayerBanStorage().ban(ban);
return BanManagerPlugin.getInstance().getPlayerBanStorage().ban(ban);
}

/**
Expand Down Expand Up @@ -120,7 +118,7 @@ public static boolean ban(PlayerData player, PlayerData actor, String reason, bo
* @throws SQLException
*/
public static boolean unban(PlayerBanData ban, PlayerData actor) throws SQLException {
return plugin.getPlayerBanStorage().unban(ban, actor);
return BanManagerPlugin.getInstance().getPlayerBanStorage().unban(ban, actor);
}

/**
Expand All @@ -130,7 +128,7 @@ public static boolean unban(PlayerBanData ban, PlayerData actor) throws SQLExcep
* @return Returns true if player is banned
*/
public static boolean isBanned(UUID uuid) {
return plugin.getPlayerBanStorage().isBanned(uuid);
return BanManagerPlugin.getInstance().getPlayerBanStorage().isBanned(uuid);
}

/**
Expand All @@ -140,7 +138,7 @@ public static boolean isBanned(UUID uuid) {
* @return Returns true if player is banned
*/
public static boolean isBanned(String name) {
return plugin.getPlayerBanStorage().isBanned(name);
return BanManagerPlugin.getInstance().getPlayerBanStorage().isBanned(name);
}


Expand All @@ -151,7 +149,7 @@ public static boolean isBanned(String name) {
* @return Returns the active ban of a player; if the player is not banned this returns null
*/
public static PlayerBanData getCurrentBan(String name) {
return plugin.getPlayerBanStorage().getBan(name);
return BanManagerPlugin.getInstance().getPlayerBanStorage().getBan(name);
}

/**
Expand All @@ -161,7 +159,7 @@ public static PlayerBanData getCurrentBan(String name) {
* @return Returns the active ban of a player; if the player is not banned this returns null
*/
public static PlayerBanData getCurrentBan(UUID uuid) {
return plugin.getPlayerBanStorage().getBan(uuid);
return BanManagerPlugin.getInstance().getPlayerBanStorage().getBan(uuid);
}

/**
Expand All @@ -170,7 +168,7 @@ public static PlayerBanData getCurrentBan(UUID uuid) {
* @throws SQLException
*/
public static CloseableIterator<PlayerBanRecord> getBanRecords(PlayerData player) throws SQLException {
return plugin.getPlayerBanRecordStorage().getRecords(player);
return BanManagerPlugin.getInstance().getPlayerBanRecordStorage().getRecords(player);
}

/**
Expand All @@ -182,7 +180,7 @@ public static CloseableIterator<PlayerBanRecord> getBanRecords(PlayerData player
* @throws SQLException
*/
public static boolean mute(PlayerMuteData mute) throws SQLException {
return plugin.getPlayerMuteStorage().mute(mute);
return BanManagerPlugin.getInstance().getPlayerMuteStorage().mute(mute);
}

/**
Expand Down Expand Up @@ -256,7 +254,7 @@ public static boolean mute(PlayerData player, PlayerData actor, String reason, b
* @throws SQLException
*/
public static boolean mute(IpMuteData mute) throws SQLException {
return plugin.getIpMuteStorage().mute(mute);
return BanManagerPlugin.getInstance().getIpMuteStorage().mute(mute);
}

/**
Expand All @@ -266,7 +264,7 @@ public static boolean mute(IpMuteData mute) throws SQLException {
* @throws SQLException
*/
public static boolean unmute(PlayerMuteData mute, PlayerData actor) throws SQLException {
return plugin.getPlayerMuteStorage().unmute(mute, actor);
return BanManagerPlugin.getInstance().getPlayerMuteStorage().unmute(mute, actor);
}

/**
Expand All @@ -276,7 +274,7 @@ public static boolean unmute(PlayerMuteData mute, PlayerData actor) throws SQLEx
* @throws SQLException
*/
public static boolean unmute(IpMuteData mute, PlayerData actor) throws SQLException {
return plugin.getIpMuteStorage().unmute(mute, actor);
return BanManagerPlugin.getInstance().getIpMuteStorage().unmute(mute, actor);
}

/**
Expand All @@ -286,7 +284,7 @@ public static boolean unmute(IpMuteData mute, PlayerData actor) throws SQLExcept
* @return Returns true if player muted
*/
public static boolean isMuted(UUID uuid) {
return plugin.getPlayerMuteStorage().isMuted(uuid);
return BanManagerPlugin.getInstance().getPlayerMuteStorage().isMuted(uuid);
}

/**
Expand All @@ -296,7 +294,7 @@ public static boolean isMuted(UUID uuid) {
* @return Returns true if player muted
*/
public static boolean isMuted(String name) {
return plugin.getPlayerMuteStorage().isMuted(name);
return BanManagerPlugin.getInstance().getPlayerMuteStorage().isMuted(name);
}

/**
Expand All @@ -306,7 +304,7 @@ public static boolean isMuted(String name) {
* @return Returns true if IP address muted
*/
public static boolean isMuted(IPAddress ip) {
return plugin.getIpMuteStorage().isMuted(ip);
return BanManagerPlugin.getInstance().getIpMuteStorage().isMuted(ip);
}

/**
Expand All @@ -316,7 +314,7 @@ public static boolean isMuted(IPAddress ip) {
* @return Returns the active mute of a player; if the player is not muted this returns null
*/
public static PlayerMuteData getCurrentMute(String name) {
return plugin.getPlayerMuteStorage().getMute(name);
return BanManagerPlugin.getInstance().getPlayerMuteStorage().getMute(name);
}

/**
Expand All @@ -326,7 +324,7 @@ public static PlayerMuteData getCurrentMute(String name) {
* @return Returns the active mute of a player; if the player is not muted this returns null
*/
public static PlayerMuteData getCurrentMute(UUID uuid) {
return plugin.getPlayerMuteStorage().getMute(uuid);
return BanManagerPlugin.getInstance().getPlayerMuteStorage().getMute(uuid);
}

/**
Expand All @@ -335,7 +333,7 @@ public static PlayerMuteData getCurrentMute(UUID uuid) {
* @throws SQLException
*/
public static CloseableIterator<PlayerMuteRecord> getMuteRecords(PlayerData player) throws SQLException {
return plugin.getPlayerMuteRecordStorage().getRecords(player);
return BanManagerPlugin.getInstance().getPlayerMuteRecordStorage().getRecords(player);
}

/**
Expand All @@ -347,7 +345,7 @@ public static CloseableIterator<PlayerMuteRecord> getMuteRecords(PlayerData play
* @throws SQLException
*/
public static boolean ban(IpBanData ban) throws SQLException {
return plugin.getIpBanStorage().ban(ban);
return BanManagerPlugin.getInstance().getIpBanStorage().ban(ban);
}

/**
Expand Down Expand Up @@ -388,7 +386,7 @@ public static boolean ban(IPAddress ip, PlayerData actor, String reason, boolean
* @throws SQLException
*/
public static boolean unban(IpBanData ban, PlayerData actor) throws SQLException {
return plugin.getIpBanStorage().unban(ban, actor);
return BanManagerPlugin.getInstance().getIpBanStorage().unban(ban, actor);
}

/**
Expand All @@ -398,7 +396,7 @@ public static boolean unban(IpBanData ban, PlayerData actor) throws SQLException
* @return Returns true if ip is banned
*/
public static boolean isBanned(IPAddress ip) {
return plugin.getIpBanStorage().isBanned(ip);
return BanManagerPlugin.getInstance().getIpBanStorage().isBanned(ip);
}

/**
Expand All @@ -408,7 +406,7 @@ public static boolean isBanned(IPAddress ip) {
* @return Returns the active ban of an ip if the ip is not banned this returns null
*/
public static IpBanData getCurrentBan(IPAddress ip) {
return plugin.getIpBanStorage().getBan(ip);
return BanManagerPlugin.getInstance().getIpBanStorage().getBan(ip);
}

/**
Expand All @@ -417,7 +415,7 @@ public static IpBanData getCurrentBan(IPAddress ip) {
* @throws SQLException
*/
public static CloseableIterator<IpBanRecord> getBanRecords(IPAddress ip) throws SQLException {
return plugin.getIpBanRecordStorage().getRecords(ip);
return BanManagerPlugin.getInstance().getIpBanRecordStorage().getRecords(ip);
}

/**
Expand Down Expand Up @@ -474,7 +472,7 @@ public static boolean warn(PlayerWarnData data) throws SQLException {
* @throws SQLException
*/
public static boolean warn(PlayerWarnData data, boolean silent) throws SQLException {
return plugin.getPlayerWarnStorage().addWarning(data, silent);
return BanManagerPlugin.getInstance().getPlayerWarnStorage().addWarning(data, silent);
}

/**
Expand All @@ -486,7 +484,7 @@ public static boolean warn(PlayerWarnData data, boolean silent) throws SQLExcept
* @throws SQLException
*/
public static CloseableIterator<PlayerWarnData> getWarnings(PlayerData player) throws SQLException {
return plugin.getPlayerWarnStorage().getWarnings(player);
return BanManagerPlugin.getInstance().getPlayerWarnStorage().getWarnings(player);
}

/**
Expand All @@ -498,7 +496,7 @@ public static Message getMessage(String key) {
}

public static ConnectionSource getLocalConnection() {
return plugin.getLocalConn();
return BanManagerPlugin.getInstance().getLocalConn();
}

public static long toTimestamp(String time, boolean future) throws Exception {
Expand Down

0 comments on commit d64397d

Please sign in to comment.