Package com.palmergames.bukkit.util
Class BukkitTools
java.lang.Object
com.palmergames.bukkit.util.BukkitTools
A class of functions related to Bukkit in general.
- Version:
- 1.0
- Author:
- Shade (Chris H, ElgarL)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
calcChunk
(int value) Accepts an X or Z value and returns the associated Towny plot value.static String
convertCoordtoXYZ
(org.bukkit.Location loc) static Collection
<String> convertKeyedToString
(@NotNull Collection<? extends org.bukkit.Keyed> keys) static void
fireEvent
(@NotNull org.bukkit.event.Event event) static org.bukkit.Location
getBedOrRespawnLocation
(org.bukkit.entity.Player player) static @NotNull org.bukkit.command.CommandMap
static org.bukkit.OfflinePlayer
getOfflinePlayer
(String name) Do not use without first usinghasPlayedBefore(String)
static org.bukkit.OfflinePlayer
static @Nullable org.bukkit.OfflinePlayer
getOfflinePlayerIfCached
(@NotNull String name) static Collection
<? extends org.bukkit.entity.Player> Get an array of all online playersstatic @Nullable org.bukkit.entity.Player
static @Nullable org.bukkit.entity.Player
static @Nullable org.bukkit.entity.Player
getPlayerExact
(String name) Count the number of players online in each worldstatic org.bukkit.plugin.PluginManager
static org.bukkit.Server
static UUID
getUUIDSafely
(String name) Given a name this method should only return a UUID that is stored in the server cache, without pinging Mojang servers.static Collection
<? extends org.bukkit.entity.Player> getVisibleOnlinePlayers
(org.bukkit.command.CommandSender sender) static org.bukkit.World
static org.bukkit.World
getWorldNames
(boolean lowercased) static List
<org.bukkit.World> static UUID
getWorldUUID
(String name) static boolean
hasPlayedBefore
(String name) static boolean
hasVanishedMeta
(@NotNull org.bukkit.entity.Player player) static void
ifCancelledThenThrow
(@NotNull CancellableTownyEvent event) static void
initialize
(Towny plugin) static boolean
isEventCancelled
(@NotNull org.bukkit.event.Event event) static boolean
Tests if this player is online.static String
keyAsString
(@NotNull org.bukkit.NamespacedKey key) Converts a namespaced key into a string.static @Nullable String
matchMaterialName
(String name) Used to parse user-inputted material names into valid material names.static List
<org.bukkit.entity.Player> matchPlayer
(String name) static <T extends org.bukkit.Keyed>
TmatchRegistry
(@NotNull org.bukkit.Registry<T> registry, @NotNull String input) Our own copy ofRegistry.match(String)
, since this method did not exist on the currently lowest supported version, 1.16.static org.bukkit.scoreboard.Objective
objective
(org.bukkit.scoreboard.Scoreboard board, @NotNull String name, @NotNull String displayName) static boolean
playerCanSeePlayer
(org.bukkit.entity.Player seeing, org.bukkit.entity.Player seen) Test whether an Player can see another Player.static String
potionEffectName
(@NotNull org.bukkit.potion.PotionEffectType type)
-
Constructor Details
-
BukkitTools
public BukkitTools()
-
-
Method Details
-
initialize
-
getOnlinePlayers
Get an array of all online players- Returns:
- array of online players
-
matchPlayer
-
getUUIDSafely
Given a name this method should only return a UUID that is stored in the server cache, without pinging Mojang servers.- Parameters:
name
- - Resident/Player name to get a UUID for.- Returns:
- UUID of player or null if the player is not in the cache.
-
getPlayerExact
-
getPlayer
-
getPlayer
-
hasVanishedMeta
public static boolean hasVanishedMeta(@NotNull @NotNull org.bukkit.entity.Player player) -
playerCanSeePlayer
public static boolean playerCanSeePlayer(org.bukkit.entity.Player seeing, org.bukkit.entity.Player seen) Test whether an Player can see another Player. Staff on servers tend to enjoy their privacy while vanished.- Parameters:
seeing
- Player who is doing the seeing.seen
- Player who is potentially vanished from the seeing Player.- Returns:
- true if the seeing Player can see the seen Player.
-
getVisibleOnlinePlayers
public static Collection<? extends org.bukkit.entity.Player> getVisibleOnlinePlayers(org.bukkit.command.CommandSender sender) -
isOnline
Tests if this player is online.- Parameters:
name
- the name of the player.- Returns:
- a true value if online
-
getWorlds
-
getWorld
-
getWorld
-
getWorldUUID
-
getServer
public static org.bukkit.Server getServer() -
getPluginManager
public static org.bukkit.plugin.PluginManager getPluginManager() -
getPlayersPerWorld
Count the number of players online in each world- Returns:
- Map of world to online players.
-
calcChunk
public static int calcChunk(int value) Accepts an X or Z value and returns the associated Towny plot value.- Parameters:
value
- - Value to calculate for X or Z (Integer
)- Returns:
- int of the relevant townblock x/z.
-
hasPlayedBefore
-
getOfflinePlayer
Do not use without first usinghasPlayedBefore(String)
- Parameters:
name
- - name of resident- Returns:
- OfflinePlayer
-
getOfflinePlayerIfCached
@Nullable public static @Nullable org.bukkit.OfflinePlayer getOfflinePlayerIfCached(@NotNull @NotNull String name) -
getOfflinePlayerForVault
-
convertCoordtoXYZ
-
getWorldNames
-
getWorldNames
-
getBedOrRespawnLocation
public static org.bukkit.Location getBedOrRespawnLocation(org.bukkit.entity.Player player) -
potionEffectName
-
objective
-
isEventCancelled
public static boolean isEventCancelled(@NotNull @NotNull org.bukkit.event.Event event) - Parameters:
event
- The event to call- Returns:
true
if the event is cancellable and was cancelled, otherwisefalse
.
-
ifCancelledThenThrow
public static void ifCancelledThenThrow(@NotNull @NotNull CancellableTownyEvent event) throws CancelledEventException - Parameters:
event
- CancellableTownyEvent to be fired which might be cancelled.- Throws:
CancelledEventException
- with the Event's cancelMessage.
-
fireEvent
public static void fireEvent(@NotNull @NotNull org.bukkit.event.Event event) -
matchMaterialName
Used to parse user-inputted material names into valid material names.- Parameters:
name
- String which should be a material.- Returns:
- String name of the material or null if no match could be made.
-
matchRegistry
@Nullable public static <T extends org.bukkit.Keyed> T matchRegistry(@NotNull @NotNull org.bukkit.Registry<T> registry, @NotNull @NotNull String input) Our own copy ofRegistry.match(String)
, since this method did not exist on the currently lowest supported version, 1.16. -
keyAsString
Converts a namespaced key into a string. The namespace is included for non minecraft namespaced keys.- Returns:
- The string representation of the key.
-
getCommandMap
@NotNull public static @NotNull org.bukkit.command.CommandMap getCommandMap() throws ReflectiveOperationException- Throws:
ReflectiveOperationException
-
convertKeyedToString
@Internal public static Collection<String> convertKeyedToString(@NotNull @NotNull Collection<? extends org.bukkit.Keyed> keys)
-