Comment out old API, will use as a reference when writing new API

This commit is contained in:
nossr50 2021-03-16 16:13:08 -07:00
parent 86ba265064
commit 1c63e34dbb
7 changed files with 1854 additions and 1872 deletions

View File

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

View File

@ -1,161 +1,142 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public final class ChatAPI {
private ChatAPI() {}
/**
* Check if a {@link Player} is in the Party chat channel
*
* @param player target player
* @return true if the player is targeting the party chat channel
* @deprecated Use {@link #isUsingPartyChat(OnlineMMOPlayer)} instead
*/
@Deprecated
public static boolean isUsingPartyChat(@NotNull Player player) {
OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer != null)
return mmoPlayer.getChatChannel() == ChatChannel.PARTY;
else
return false;
}
/**
* Check if a {@link OnlineMMOPlayer} is in the Party chat channel
*
* @param mmoPlayer target player
* @return true if the player is targeting the party chat channel
*/
public static boolean isUsingPartyChat(@NotNull OnlineMMOPlayer mmoPlayer) {
return mmoPlayer.getChatChannel() == ChatChannel.PARTY;
}
/**
* Check if a player is currently talking in party chat.
*
* @param playerName The name of the player to check
* @return true if the player is using party chat, false otherwise
* @deprecated use {@link #isUsingPartyChat(OnlineMMOPlayer)} instead for performance reasons
*/
@Deprecated
public static boolean isUsingPartyChat(String playerName) {
if(mcMMO.getUserManager().queryMcMMOPlayer(playerName) != null) {
return mcMMO.getUserManager().queryMcMMOPlayer(playerName).getChatChannel() == ChatChannel.PARTY;
} else {
return false;
}
}
/**
* Check if a {@link Player} is in the Admin chat channel
*
* @param player target player
* @return true if the player is targeting the admin chat channel
* @deprecated Use {@link #isUsingAdminChat(OnlineMMOPlayer)} instead
*/
@Deprecated
public static boolean isUsingAdminChat(@NotNull Player player) {
OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer != null)
return mmoPlayer.getChatChannel() == ChatChannel.ADMIN;
else
return false;
}
/**
* Check if a {@link OnlineMMOPlayer} is in the Admin chat channel
*
* @param mmoPlayer target player
* @return true if the player is targeting the admin chat channel
*/
public static boolean isUsingAdminChat(@NotNull OnlineMMOPlayer mmoPlayer) {
return mmoPlayer.getChatChannel() == ChatChannel.ADMIN;
}
/**
* Check if a player is currently talking in admin chat.
*
* @param playerName The name of the player to check
* @return true if the player is using admin chat, false otherwise
* @deprecated use {@link #isUsingAdminChat(OnlineMMOPlayer)} instead for performance reasons
*/
@Deprecated
public static boolean isUsingAdminChat(String playerName) {
if(mcMMO.getUserManager().queryMcMMOPlayer(playerName) != null) {
return mcMMO.getUserManager().queryMcMMOPlayer(playerName).getChatChannel() == ChatChannel.ADMIN;
} else {
return false;
}
}
/**
* Toggle the party chat channel of a {@link OnlineMMOPlayer}
*
* @param mmoPlayer The player to toggle party chat on.
*/
public static void togglePartyChat(@NotNull OnlineMMOPlayer mmoPlayer) {
mcMMO.p.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.PARTY);
}
/**
* Toggle the party chat mode of a player.
*
* @param player The player to toggle party chat on.
* @deprecated use {@link #togglePartyChat(OnlineMMOPlayer)}
*/
@Deprecated
public static void togglePartyChat(Player player) throws NullPointerException {
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryPlayer(player)), ChatChannel.PARTY);
}
/**
* Toggle the party chat mode of a player.
*
* @param playerName The name of the player to toggle party chat on.
* @deprecated Use {@link #togglePartyChat(OnlineMMOPlayer)} instead
*/
@Deprecated
public static void togglePartyChat(String playerName) throws NullPointerException {
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(playerName)), ChatChannel.PARTY);
}
/**
* Toggle the admin chat channel of a {@link OnlineMMOPlayer}
*
* @param mmoPlayer The player to toggle admin chat on.
*/
public static void toggleAdminChat(@NotNull OnlineMMOPlayer mmoPlayer) {
mcMMO.p.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.ADMIN);
}
/**
* Toggle the admin chat mode of a player.
*
* @param player The player to toggle admin chat on.
* @deprecated Use {@link #toggleAdminChat(OnlineMMOPlayer)} instead
*/
@Deprecated
public static void toggleAdminChat(Player player) throws NullPointerException {
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryPlayer(player)), ChatChannel.ADMIN);
}
/**
* Toggle the admin chat mode of a player.
*
* @param playerName The name of the player to toggle party chat on.
* @deprecated Use {@link #toggleAdminChat(OnlineMMOPlayer)} instead
*/
@Deprecated
public static void toggleAdminChat(String playerName) throws NullPointerException {
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(playerName)), ChatChannel.ADMIN);
}
}
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.chat.ChatChannel;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.entity.Player;
//
//public final class ChatAPI {
// private ChatAPI() {}
//
//// /**
//// * Send a message to all members of a party
//// * </br>
//// * This function is designed for API usage.
//// *
//// * @param plugin The plugin sending the message
//// * @param sender The name of the sender
//// * @param displayName The display name of the sender
//// * @param party The name of the party to send to
//// * @param message The message to send
//// */
//// public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
//// getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
//// }
////
//// /**
//// * Send a message to all members of a party
//// * </br>
//// * This function is designed for API usage.
//// *
//// * @param plugin The plugin sending the message
//// * @param sender The name of the sender to display in the chat
//// * @param party The name of the party to send to
//// * @param message The message to send
//// */
//// public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
//// getPartyChatManager(plugin, party).handleChat(sender, message);
//// }
////
//// /**
//// * Send a message to administrators
//// * </br>
//// * This function is designed for API usage.
//// *
//// * @param plugin The plugin sending the message
//// * @param sender The name of the sender
//// * @param displayName The display name of the sender
//// * @param message The message to send
//// */
//// public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
//// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, displayName, message);
//// }
////
//// /**
//// * Send a message to administrators
//// * </br>
//// * This function is designed for API usage.
//// *
//// * @param plugin The plugin sending the message
//// * @param sender The name of the sender to display in the chat
//// * @param message The message to send
//// */
//// public static void sendAdminChat(Plugin plugin, String sender, String message) {
//// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, message);
//// }
//
// /**
// * Check if a player is currently talking in party chat.
// *
// * @param player The player to check
// * @return true if the player is using party chat, false otherwise
// */
// public static boolean isUsingPartyChat(Player player) {
// return UserManager.getPlayer(player).getChatChannel() == ChatChannel.PARTY;
// }
//
// /**
// * Check if a player is currently talking in party chat.
// *
// * @param playerName The name of the player to check
// * @return true if the player is using party chat, false otherwise
// */
// public static boolean isUsingPartyChat(String playerName) {
// return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.PARTY;
// }
//
// /**
// * Check if a player is currently talking in admin chat.
// *
// * @param player The player to check
// * @return true if the player is using admin chat, false otherwise
// */
// public static boolean isUsingAdminChat(Player player) {
// return UserManager.getPlayer(player).getChatChannel() == ChatChannel.ADMIN;
// }
//
// /**
// * Check if a player is currently talking in admin chat.
// *
// * @param playerName The name of the player to check
// * @return true if the player is using admin chat, false otherwise
// */
// public static boolean isUsingAdminChat(String playerName) {
// return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.ADMIN;
// }
//
// /**
// * Toggle the party chat mode of a player.
// *
// * @param player The player to toggle party chat on.
// */
// public static void togglePartyChat(Player player) {
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.PARTY);
// }
//
// /**
// * Toggle the party chat mode of a player.
// *
// * @param playerName The name of the player to toggle party chat on.
// */
// public static void togglePartyChat(String playerName) {
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.PARTY);
// }
//
// /**
// * Toggle the admin chat mode of a player.
// *
// * @param player The player to toggle admin chat on.
// */
// public static void toggleAdminChat(Player player) {
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.ADMIN);
// }
//
// /**
// * Toggle the admin chat mode of a player.
// *
// * @param playerName The name of the player to toggle party chat on.
// */
// public static void toggleAdminChat(String playerName) {
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.ADMIN);
// }
//}

View File

@ -1,30 +1,30 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import java.util.UUID;
public class DatabaseAPI {
/**
* Checks if a player exists in the mcMMO Database
* @param uuid player UUID
* @return true if the player exists in the DB, false if they do not
*/
public boolean doesPlayerExistInDB(String uuid) {
return doesPlayerExistInDB(UUID.fromString(uuid));
}
/**
* Checks if a player exists in the mcMMO Database
* @param uuid player UUID
* @return true if the player exists in the DB, false if they do not
*/
public boolean doesPlayerExistInDB(UUID uuid) {
PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, null);
return playerProfile.isLoaded();
}
}
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.player.PlayerProfile;
//import com.gmail.nossr50.mcMMO;
//
//import java.util.UUID;
//
//public class DatabaseAPI {
//
// /**
// * Checks if a player exists in the mcMMO Database
// * @param uuid player UUID
// * @return true if the player exists in the DB, false if they do not
// */
// public boolean doesPlayerExistInDB(String uuid) {
// return doesPlayerExistInDB(UUID.fromString(uuid));
// }
//
// /**
// * Checks if a player exists in the mcMMO Database
// * @param uuid player UUID
// * @return true if the player exists in the DB, false if they do not
// */
// public boolean doesPlayerExistInDB(UUID uuid) {
// PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, null);
//
// return playerProfile.isLoaded();
// }
//
//}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,17 @@
package com.gmail.nossr50.api;
public enum ItemSpawnReason {
ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob
EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this
FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this
FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake
HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck
BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining
BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining
BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills
UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon
SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form
SALVAGE_MATERIALS, //When you salvage an item and get materials back
TREE_FELLER_DISPLACED_BLOCK,
BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc
}
//package com.gmail.nossr50.api;
//
//public enum ItemSpawnReason {
// ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob
// EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this
// FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this
// FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake
// HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck
// BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining
// BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining
// BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills
// UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon
// SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form
// SALVAGE_MATERIALS, //When you salvage an item and get materials back
// TREE_FELLER_DISPLACED_BLOCK,
// BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc
//}

View File

@ -1,258 +1,258 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.*;
public final class PartyAPI {
private PartyAPI() {}
/**
* Get the name of the party a player is in.
* </br>
* This function is designed for API usage.
*
* @param player The player to check the party name of
* @return the name of the player's party, or null if not in a party
*/
public static String getPartyName(Player player) {
if (!inParty(player)) {
return null;
}
return UserManager.getPlayer(player).getParty().getName();
}
/**
* Checks if a player is in a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to check
* @return true if the player is in a party, false otherwise
*/
public static boolean inParty(Player player) {
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.
*
* @param playera The first player to check
* @param playerb The second player to check
* @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.
*
* @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.
*
* @param player The player to add to the party
* @param partyName The party to add the player to
* @deprecated parties can have limits, use the other method
*/
@Deprecated
public static void addToParty(Player player, String partyName) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
return;
Party party = PartyManager.getParty(partyName);
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else {
if(PartyManager.isPartyFull(player, party))
{
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
return;
}
}
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
*/
public static int getMaxPartySize()
{
return Config.getInstance().getPartyMaxSize();
}
/**
* Add a player to a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to add to the party
* @param partyName The party to add the player to
* @param bypassLimit if true bypasses party size limits
*/
//TODO: bypasslimit not used?
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
return;
Party party = PartyManager.getParty(partyName);
if (party == null) {
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.
*
* @param player The player to remove
*/
public static void removeFromParty(Player player) {
//Check if player profile is loaded
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.
*
* @param partyName The party name
* @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.
*
* @param partyName The name of the party to set the leader of
* @param playerName The playerName to set as leader
*/
@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.
*
* @param player The player to check
* @return all the players in the player's party
*/
@Deprecated
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
List<OfflinePlayer> members = new ArrayList<>();
for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
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.
*
* @param player The player to check
* @return all the player names in the player's party
*/
@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.
*
* @param player The player to check
* @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.
*
* @param partyName The party to check
* @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.
*
* @param player The player to check
* @return all online players in the player's party
*/
public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getOnlineMembers(player);
}
public static boolean hasAlly(String partyName) {
return getAllyName(partyName) != null;
}
public static String getAllyName(String partyName) {
Party ally = PartyManager.getParty(partyName).getAlly();
if (ally != null) {
return ally.getName();
}
return null;
}
}
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.interactions.NotificationType;
//import com.gmail.nossr50.datatypes.party.Party;
//import com.gmail.nossr50.datatypes.party.PartyLeader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.party.PartyManager;
//import com.gmail.nossr50.util.player.NotificationManager;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.OfflinePlayer;
//import org.bukkit.entity.Player;
//
//import java.util.*;
//
//public final class PartyAPI {
// private PartyAPI() {}
//
// /**
// * Get the name of the party a player is in.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check the party name of
// * @return the name of the player's party, or null if not in a party
// */
// public static String getPartyName(Player player) {
// if (!inParty(player)) {
// return null;
// }
//
// return UserManager.getPlayer(player).getParty().getName();
// }
//
// /**
// * Checks if a player is in a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check
// * @return true if the player is in a party, false otherwise
// */
// public static boolean inParty(Player player) {
// 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.
// *
// * @param playera The first player to check
// * @param playerb The second player to check
// * @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.
// *
// * @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.
// *
// * @param player The player to add to the party
// * @param partyName The party to add the player to
// * @deprecated parties can have limits, use the other method
// */
// @Deprecated
// public static void addToParty(Player player, String partyName) {
// //Check if player profile is loaded
// if(UserManager.getPlayer(player) == null)
// return;
//
// Party party = PartyManager.getParty(partyName);
//
// if (party == null) {
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
// } else {
// if(PartyManager.isPartyFull(player, party))
// {
// NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
// return;
// }
// }
//
// 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
// */
// public static int getMaxPartySize()
// {
// return Config.getInstance().getPartyMaxSize();
// }
//
// /**
// * Add a player to a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to add to the party
// * @param partyName The party to add the player to
// * @param bypassLimit if true bypasses party size limits
// */
// //TODO: bypasslimit not used?
// public static void addToParty(Player player, String partyName, boolean bypassLimit) {
// //Check if player profile is loaded
// if(UserManager.getPlayer(player) == null)
// return;
//
// Party party = PartyManager.getParty(partyName);
//
// if (party == null) {
// 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.
// *
// * @param player The player to remove
// */
// public static void removeFromParty(Player player) {
// //Check if player profile is loaded
// 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.
// *
// * @param partyName The party name
// * @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.
// *
// * @param partyName The name of the party to set the leader of
// * @param playerName The playerName to set as leader
// */
// @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.
// *
// * @param player The player to check
// * @return all the players in the player's party
// */
// @Deprecated
// public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
// List<OfflinePlayer> members = new ArrayList<>();
//
// for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
// 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.
// *
// * @param player The player to check
// * @return all the player names in the player's party
// */
// @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.
// *
// * @param player The player to check
// * @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.
// *
// * @param partyName The party to check
// * @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.
// *
// * @param player The player to check
// * @return all online players in the player's party
// */
// public static List<Player> getOnlineMembers(Player player) {
// return PartyManager.getOnlineMembers(player);
// }
//
// public static boolean hasAlly(String partyName) {
// return getAllyName(partyName) != null;
// }
//
// public static String getAllyName(String partyName) {
// Party ally = PartyManager.getParty(partyName).getAlly();
// if (ally != null) {
// return ally.getName();
// }
//
// return null;
// }
//}

View File

@ -1,93 +1,93 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public final class SkillAPI {
private SkillAPI() {}
/**
* Returns a list of strings with mcMMO's skills
* This includes parent and child skills
* </br>
* This function is designed for API usage.
*
* @return a list of strings with valid skill names
*/
public static List<String> getSkills() {
return getListFromEnum(Arrays.asList(PrimarySkillType.values()));
}
/**
* Returns a list of strings with mcMMO's skills
* This only includes parent skills
* </br>
* This function is designed for API usage.
*
* @return a list of strings with valid skill names
*/
public static List<String> getNonChildSkills() {
return getListFromEnum(PrimarySkillType.NON_CHILD_SKILLS);
}
/**
* Returns a list of strings with mcMMO's skills
* This only includes child skills
* </br>
* This function is designed for API usage.
*
* @return a list of strings with valid skill names
*/
public static List<String> getChildSkills() {
return getListFromEnum(PrimarySkillType.CHILD_SKILLS);
}
/**
* Returns a list of strings with mcMMO's skills
* This only includes combat skills
* </br>
* This function is designed for API usage.
*
* @return a list of strings with valid skill names
*/
public static List<String> getCombatSkills() {
return getListFromEnum(PrimarySkillType.COMBAT_SKILLS);
}
/**
* Returns a list of strings with mcMMO's skills
* This only includes gathering skills
* </br>
* This function is designed for API usage.
*
* @return a list of strings with valid skill names
*/
public static List<String> getGatheringSkills() {
return getListFromEnum(PrimarySkillType.GATHERING_SKILLS);
}
/**
* Returns a list of strings with mcMMO's skills
* This only includes misc skills
* </br>
* This function is designed for API usage.
*
* @return a list of strings with valid skill names
*/
public static List<String> getMiscSkills() {
return getListFromEnum(PrimarySkillType.MISC_SKILLS);
}
private static List<String> getListFromEnum(List<PrimarySkillType> skillsTypes) {
List<String> skills = new ArrayList<>();
for (PrimarySkillType primarySkillType : skillsTypes) {
skills.add(primarySkillType.name());
}
return skills;
}
}
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//public final class SkillAPI {
// private SkillAPI() {}
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This includes parent and child skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getSkills() {
// return getListFromEnum(Arrays.asList(PrimarySkillType.values()));
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes parent skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getNonChildSkills() {
// return getListFromEnum(PrimarySkillType.NON_CHILD_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes child skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getChildSkills() {
// return getListFromEnum(PrimarySkillType.CHILD_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes combat skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getCombatSkills() {
// return getListFromEnum(PrimarySkillType.COMBAT_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes gathering skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getGatheringSkills() {
// return getListFromEnum(PrimarySkillType.GATHERING_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes misc skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getMiscSkills() {
// return getListFromEnum(PrimarySkillType.MISC_SKILLS);
// }
//
// private static List<String> getListFromEnum(List<PrimarySkillType> skillsTypes) {
// List<String> skills = new ArrayList<>();
//
// for (PrimarySkillType primarySkillType : skillsTypes) {
// skills.add(primarySkillType.name());
// }
//
// return skills;
// }
//}