API stuff

This commit is contained in:
YouHaveTrouble
2021-03-08 11:46:06 +01:00
parent e895cab31d
commit 74835aa283
2 changed files with 36 additions and 17 deletions
@@ -1,6 +1,7 @@
package eu.endermite.togglepvp.api;
import eu.endermite.togglepvp.TogglePvp;
import eu.endermite.togglepvp.util.CombatTimer;
import org.bukkit.entity.Player;
import java.util.UUID;
@@ -8,7 +9,7 @@ public class TogglePvpAPI {
/**
* Sets players PvP state. This will always save to database.
* @param player player to set pvp state to
* @param player Player to set pvp state to
* @param newState State to set
*/
public static void setPvpEnabled(Player player, boolean newState) {
@@ -17,7 +18,7 @@ public class TogglePvpAPI {
/**
* Sets players PvP state. This will always save to database.
* @param uuid uuid of player to set pvp state to
* @param uuid UUID of player to set pvp state to
* @param newState State to set
*/
public static void setPvpEnabled(UUID uuid, boolean newState) {
@@ -27,7 +28,7 @@ public class TogglePvpAPI {
/**
* Gets player's PvP state. If player is not cached this will query the database.
* @param uuid UUID of the player to get data from.
* @return true if enabled, false if disabled
* @return True if enabled, false if disabled
*/
public static boolean getPvpEnabled(UUID uuid) {
return TogglePvp.getPlugin().getSmartCache().getPlayerData(uuid).isPvpEnabled();
@@ -36,7 +37,7 @@ public class TogglePvpAPI {
/**
* Gets player's PvP state. If player is not cached this will query the database.
* @param player Player to get data from.
* @return true if enabled, false if disabled
* @return True if enabled, false if disabled
*/
public static boolean getPvpEnabled(Player player) {
return TogglePvp.getPlugin().getSmartCache().getPlayerData(player.getUniqueId()).isPvpEnabled();
@@ -44,10 +45,10 @@ public class TogglePvpAPI {
/**
* Checks if player can be damaged by another. Providing UUID of entity other than player may result in exceptions
* @param attackerUuid attacker's UUID
* @param victimUuid victim's UUID
* @param sendDenyMessage true if check should send deny message to attacker
* @return true if victim can be attacked by attacker, false if not
* @param attackerUuid Attacker's UUID
* @param victimUuid Victim's UUID
* @param sendDenyMessage True if check should send deny message to attacker
* @return True if victim can be attacked by attacker, false if not
*/
public static boolean canDamage(UUID attackerUuid, UUID victimUuid, boolean sendDenyMessage) {
return TogglePvp.getPlugin().getPlayerManager().canDamage(attackerUuid, victimUuid, sendDenyMessage);
@@ -55,10 +56,10 @@ public class TogglePvpAPI {
/**
* Checks if player can be damaged by another.
* @param attacker attacker
* @param victim victim
* @param sendDenyMessage true if check should send deny message to attacker
* @return true if victim can be attacked by attacker, false if not
* @param attacker Attacker
* @param victim Victim
* @param sendDenyMessage True if check should send deny message to attacker
* @return True if victim can be attacked by attacker, false if not
*/
public static boolean canDamage(Player attacker, Player victim, boolean sendDenyMessage) {
return TogglePvp.getPlugin().getPlayerManager().canDamage(attacker.getUniqueId(), victim.getUniqueId(), sendDenyMessage);
@@ -66,8 +67,8 @@ public class TogglePvpAPI {
/**
* Checks if player has login protection.
* @param uuid uuid of player to check
* @return true if player has login protection, false if not
* @param uuid UUID of player to check
* @return True if player has login protection, false if not
*/
public static boolean hasLoginProtection(UUID uuid) {
return TogglePvp.getPlugin().getPlayerManager().hasLoginProtection(uuid);
@@ -75,12 +76,30 @@ public class TogglePvpAPI {
/**
* Checks if player has login protection.
* @param player player to check
* @return true if player has login protection, false if not
* @param player Player to check
* @return True if player has login protection, false if not
*/
public static boolean hasLoginProtection(Player player) {
return TogglePvp.getPlugin().getPlayerManager().hasLoginProtection(player.getUniqueId());
}
/**
* Checks if player is in combat.
* @param uuid UUID of player to check
* @return True if player is in combat, false if they are not or if they are offline
*/
public static boolean isInCombat(UUID uuid) {
return CombatTimer.isInCombat(uuid);
}
/**
* Checks if player is in combat.
* @param player Player to check
* @return True if player is in combat, false if they are not or if they are offline
*/
public static boolean isInCombat(Player player) {
return CombatTimer.isInCombat(player.getUniqueId());
}
}