Rollback api classes to match master

This commit is contained in:
nossr50 2021-03-16 15:40:46 -07:00
parent e958baf720
commit f837be8e90
3 changed files with 278 additions and 275 deletions

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.api; package com.gmail.nossr50.api;
import com.neetgames.mcmmo.player.OnlineMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,38 +11,38 @@ public final class AbilityAPI {
private AbilityAPI() {} private AbilityAPI() {}
public static boolean berserkEnabled(Player player) { public static boolean berserkEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
} }
public static boolean gigaDrillBreakerEnabled(Player player) { public static boolean gigaDrillBreakerEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
} }
public static boolean greenTerraEnabled(Player player) { public static boolean greenTerraEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
} }
public static boolean serratedStrikesEnabled(Player player) { public static boolean serratedStrikesEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SERRATED_STRIKES); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
} }
public static boolean skullSplitterEnabled(Player player) { public static boolean skullSplitterEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SKULL_SPLITTER); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
} }
public static boolean superBreakerEnabled(Player player) { public static boolean superBreakerEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
} }
public static boolean treeFellerEnabled(Player player) { public static boolean treeFellerEnabled(Player player) {
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
} }
public static boolean isAnyAbilityEnabled(Player player) { public static boolean isAnyAbilityEnabled(Player player) {
OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
for (SuperAbilityType ability : SuperAbilityType.values()) { for (SuperAbilityType ability : SuperAbilityType.values()) {
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(ability)) { if (mcMMOPlayer.getAbilityMode(ability)) {
return true; return true;
} }
} }
@ -51,35 +51,35 @@ public final class AbilityAPI {
} }
public static void resetCooldowns(Player player) { public static void resetCooldowns(Player player) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().resetCooldowns(); UserManager.getPlayer(player).resetCooldowns();
} }
public static void setBerserkCooldown(Player player, long cooldown) { public static void setBerserkCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.BERSERK, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
} }
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) { public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
} }
public static void setGreenTerraCooldown(Player player, long cooldown) { public static void setGreenTerraCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
} }
public static void setSerratedStrikesCooldown(Player player, long cooldown) { public static void setSerratedStrikesCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
} }
public static void setSkullSplitterCooldown(Player player, long cooldown) { public static void setSkullSplitterCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
} }
public static void setSuperBreakerCooldown(Player player, long cooldown) { public static void setSuperBreakerCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
} }
public static void setTreeFellerCooldown(Player player, long cooldown) { public static void setTreeFellerCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown); UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
} }
public static boolean isBleeding(LivingEntity entity) { public static boolean isBleeding(LivingEntity entity) {

View File

@ -22,7 +22,7 @@ public class DatabaseAPI {
* @return true if the player exists in the DB, false if they do not * @return true if the player exists in the DB, false if they do not
*/ */
public boolean doesPlayerExistInDB(UUID uuid) { public boolean doesPlayerExistInDB(UUID uuid) {
PlayerProfile playerProfile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(uuid, null); PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, null);
return playerProfile.isLoaded(); return playerProfile.isLoaded();
} }

View File

@ -1,255 +1,258 @@
//package com.gmail.nossr50.api; package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
//import com.neetgames.mcmmo.party.Party; import com.gmail.nossr50.datatypes.party.Party;
//import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.party.PartyLeader;
//import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.mcMMO;
//import org.bukkit.OfflinePlayer; import com.gmail.nossr50.party.PartyManager;
//import org.bukkit.entity.Player; import com.gmail.nossr50.util.player.NotificationManager;
// import com.gmail.nossr50.util.player.UserManager;
//import java.util.*; import org.bukkit.OfflinePlayer;
// import org.bukkit.entity.Player;
//public final class PartyAPI {
// private PartyAPI() {} import java.util.*;
//
// /** public final class PartyAPI {
// * Get the name of the party a player is in. private PartyAPI() {}
// * </br>
// * This function is designed for API usage. /**
// * * Get the name of the party a player is in.
// * @param player The player to check the party name of * </br>
// * @return the name of the player's party, or null if not in a party * This function is designed for API usage.
// */ *
// public static String getPartyName(Player player) { * @param player The player to check the party name of
// if (!inParty(player)) { * @return the name of the player's party, or null if not in a party
// return null; */
// } public static String getPartyName(Player player) {
// if (!inParty(player)) {
// return mcMMO.getUserManager().queryPlayer(player).getParty().getName(); return null;
// } }
//
// /** return UserManager.getPlayer(player).getParty().getName();
// * Checks if a player is in a party. }
// * </br>
// * This function is designed for API usage. /**
// * * Checks if a player is in a party.
// * @param player The player to check * </br>
// * @return true if the player is in a party, false otherwise * This function is designed for API usage.
// */ *
// public static boolean inParty(Player player) { * @param player The player to check
// if(mcMMO.getUserManager().queryPlayer(player) == null) * @return true if the player is in a party, false otherwise
// return false; */
// public static boolean inParty(Player player) {
// return mcMMO.getUserManager().queryPlayer(player).inParty(); if(UserManager.getPlayer(player) == null)
// } return false;
//
// /** return UserManager.getPlayer(player).inParty();
// * Check if two players are in the same party. }
// * </br>
// * This function is designed for API usage. /**
// * * Check if two players are in the same party.
// * @param playera The first player to check * </br>
// * @param playerb The second player to check * This function is designed for API usage.
// * @return true if the two players are in the same party, false otherwise *
// */ * @param playera The first player to check
// public static boolean inSameParty(Player playera, Player playerb) { * @param playerb The second player to check
// return mcMMO.getPartyManager().inSameParty(playera, playerb); * @return true if the two players are in the same party, false otherwise
// } */
// public static boolean inSameParty(Player playera, Player playerb) {
// /** return PartyManager.inSameParty(playera, playerb);
// * Get a list of all current parties. }
// * </br>
// * This function is designed for API usage. /**
// * * Get a list of all current parties.
// * @return the list of parties. * </br>
// */ * This function is designed for API usage.
// public static List<Party> getParties() { *
// return mcMMO.getPartyManager().getParties(); * @return the list of parties.
// } */
// public static List<Party> getParties() {
// /** return PartyManager.getParties();
// * Add a player to a party. }
// * </br>
// * This function is designed for API usage. /**
// * * Add a player to a party.
// * @param player The player to add to the party * </br>
// * @param partyName The party to add the player to * This function is designed for API usage.
// * @deprecated parties can have limits, use the other method *
// */ * @param player The player to add to the party
// @Deprecated * @param partyName The party to add the player to
// public static void addToParty(Player player, String partyName) { * @deprecated parties can have limits, use the other method
// //Check if player profile is loaded */
// if(mcMMO.getUserManager().queryPlayer(player) == null) @Deprecated
// return; public static void addToParty(Player player, String partyName) {
// //Check if player profile is loaded
// Party party = mcMMO.getPartyManager().getParty(partyName); if(UserManager.getPlayer(player) == null)
// return;
// if (party == null) {
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); Party party = PartyManager.getParty(partyName);
// } else {
// if(mcMMO.getPartyManager().isPartyFull(player, party)) if (party == null) {
// { party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
// NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString()); } else {
// return; if(PartyManager.isPartyFull(player, party))
// } {
// } NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
// return;
// mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party); }
// } }
//
// /** PartyManager.addToParty(UserManager.getPlayer(player), party);
// * The max party size of the server }
// * 0 or less for no size limit
// * @return the max party size on this server /**
// */ * The max party size of the server
// public static int getMaxPartySize() * 0 or less for no size limit
// { * @return the max party size on this server
// return Config.getInstance().getPartyMaxSize(); */
// } public static int getMaxPartySize()
// {
// /** return Config.getInstance().getPartyMaxSize();
// * Add a player to a party. }
// * </br>
// * This function is designed for API usage. /**
// * * Add a player to a party.
// * @param player The player to add to the party * </br>
// * @param partyName The party to add the player to * This function is designed for API usage.
// * @param bypassLimit if true bypasses party size limits *
// */ * @param player The player to add to the party
// //TODO: bypasslimit not used? * @param partyName The party to add the player to
// public static void addToParty(Player player, String partyName, boolean bypassLimit) { * @param bypassLimit if true bypasses party size limits
// //Check if player profile is loaded */
// if(mcMMO.getUserManager().queryPlayer(player) == null) //TODO: bypasslimit not used?
// return; public static void addToParty(Player player, String partyName, boolean bypassLimit) {
// //Check if player profile is loaded
// Party party = mcMMO.getPartyManager().getParty(partyName); if(UserManager.getPlayer(player) == null)
// return;
// if (party == null) {
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); Party party = PartyManager.getParty(partyName);
// }
// if (party == null) {
// mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party); party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
// } }
//
// /** PartyManager.addToParty(UserManager.getPlayer(player), party);
// * Remove a player from a party. }
// * </br>
// * This function is designed for API usage. /**
// * * Remove a player from a party.
// * @param player The player to remove * </br>
// */ * This function is designed for API usage.
// public static void removeFromParty(Player player) { *
// //Check if player profile is loaded * @param player The player to remove
// if(mcMMO.getUserManager().queryPlayer(player) == null) */
// return; public static void removeFromParty(Player player) {
// //Check if player profile is loaded
// mcMMO.getPartyManager().removeFromParty(mcMMO.getUserManager().queryPlayer(player)); if(UserManager.getPlayer(player) == null)
// } return;
//
// /** PartyManager.removeFromParty(UserManager.getPlayer(player));
// * Get the leader of a party. }
// * </br>
// * This function is designed for API usage. /**
// * * Get the leader of a party.
// * @param partyName The party name * </br>
// * @return the leader of the party * This function is designed for API usage.
// */ *
// public static String getPartyLeader(String partyName) { * @param partyName The party name
// return mcMMO.getPartyManager().getPartyLeaderName(partyName); * @return the leader of the party
// } */
// public static String getPartyLeader(String partyName) {
// /** return PartyManager.getPartyLeaderName(partyName);
// * Set the leader of a party. }
// * </br>
// * This function is designed for API usage. /**
// * * Set the leader of a party.
// * @param partyName The name of the party to set the leader of * </br>
// * @param playerName The playerName to set as leader * This function is designed for API usage.
// */ *
// @Deprecated * @param partyName The name of the party to set the leader of
// public static void setPartyLeader(String partyName, String playerName) { * @param playerName The playerName to set as leader
// mcMMO.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.getPartyManager().getParty(partyName)); */
// } @Deprecated
// public static void setPartyLeader(String partyName, String playerName) {
// /** PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName));
// * Get a list of all players in this player's party. }
// * </br>
// * This function is designed for API usage. /**
// * * Get a list of all players in this player's party.
// * @param player The player to check * </br>
// * @return all the players in the player's party * This function is designed for API usage.
// */ *
// @Deprecated * @param player The player to check
// public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) { * @return all the players in the player's party
// List<OfflinePlayer> members = new ArrayList<>(); */
// @Deprecated
// for (UUID memberUniqueId : mcMMO.getPartyManager().getAllMembers(player).keySet()) { public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
// OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); List<OfflinePlayer> members = new ArrayList<>();
// members.add(member);
// } for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
// return members; OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
// } members.add(member);
// }
// /** return members;
// * Get a list of all player names in this player's party. }
// * </br>
// * This function is designed for API usage. /**
// * * Get a list of all player names in this player's party.
// * @param player The player to check * </br>
// * @return all the player names in the player's party * This function is designed for API usage.
// */ *
// @Deprecated * @param player The player to check
// public static LinkedHashSet<String> getMembers(Player player) { * @return all the player names in the player's party
// return (LinkedHashSet<String>) mcMMO.getPartyManager().getAllMembers(player).values(); */
// } @Deprecated
// public static LinkedHashSet<String> getMembers(Player player) {
// /** return (LinkedHashSet<String>) PartyManager.getAllMembers(player).values();
// * Get a list of all player names and uuids in this player's party. }
// * </br>
// * This function is designed for API usage. /**
// * * Get a list of all player names and uuids in this player's party.
// * @param player The player to check * </br>
// * @return all the player names and uuids in the player's party * This function is designed for API usage.
// */ *
// public static LinkedHashMap<UUID, String> getMembersMap(Player player) { * @param player The player to check
// return mcMMO.getPartyManager().getAllMembers(player); * @return all the player names and uuids in the player's party
// } */
// public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
// /** return PartyManager.getAllMembers(player);
// * Get a list of all online players in this party. }
// * </br>
// * This function is designed for API usage. /**
// * * Get a list of all online players in this party.
// * @param partyName The party to check * </br>
// * @return all online players in this party * This function is designed for API usage.
// */ *
// public static List<Player> getOnlineMembers(String partyName) { * @param partyName The party to check
// return mcMMO.getPartyManager().getOnlineMembers(partyName); * @return all online players in this party
// } */
// public static List<Player> getOnlineMembers(String partyName) {
// /** return PartyManager.getOnlineMembers(partyName);
// * Get a list of all online players in this player's party. }
// * </br>
// * This function is designed for API usage. /**
// * * Get a list of all online players in this player's party.
// * @param player The player to check * </br>
// * @return all online players in the player's party * This function is designed for API usage.
// */ *
// public static List<Player> getOnlineMembers(Player player) { * @param player The player to check
// return mcMMO.getPartyManager().getOnlineMembers(player); * @return all online players in the player's party
// } */
// public static List<Player> getOnlineMembers(Player player) {
// public static boolean hasAlly(String partyName) { return PartyManager.getOnlineMembers(player);
// return getAllyName(partyName) != null; }
// }
// public static boolean hasAlly(String partyName) {
// public static String getAllyName(String partyName) { return getAllyName(partyName) != null;
// Party ally = mcMMO.getPartyManager().getParty(partyName).getAlly(); }
// if (ally != null) {
// return ally.getPartyName(); public static String getAllyName(String partyName) {
// } Party ally = PartyManager.getParty(partyName).getAlly();
// if (ally != null) {
// return null; return ally.getName();
// } }
//}
return null;
}
}