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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalcChunk(int value) Accepts an X or Z value and returns the associated Towny plot value.static StringconvertCoordtoXYZ(org.bukkit.Location loc) static Collection<String> convertKeyedToString(@NotNull Collection<? extends org.bukkit.Keyed> keys) static voidfireEvent(@NotNull org.bukkit.event.Event event) static org.bukkit.LocationgetBedOrRespawnLocation(org.bukkit.entity.Player player) static @NotNull org.bukkit.command.CommandMapstatic org.bukkit.OfflinePlayergetOfflinePlayer(String name) Do not use without first usinghasPlayedBefore(String)static org.bukkit.OfflinePlayerstatic @Nullable org.bukkit.OfflinePlayergetOfflinePlayerIfCached(@NotNull String name) static Collection<? extends org.bukkit.entity.Player> Get an array of all online playersstatic @Nullable org.bukkit.entity.Playerstatic @Nullable org.bukkit.entity.Playerstatic @Nullable org.bukkit.entity.PlayergetPlayerExact(String name) Count the number of players online in each worldstatic org.bukkit.plugin.PluginManagerstatic org.bukkit.Serverstatic UUIDgetUUIDSafely(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.Worldstatic org.bukkit.WorldgetWorldNames(boolean lowercased) static List<org.bukkit.World> static UUIDgetWorldUUID(String name) static booleanhasPlayedBefore(String name) static booleanhasVanishedMeta(@NotNull org.bukkit.entity.Player player) static voidifCancelledThenThrow(@NotNull CancellableTownyEvent event) static voidinitialize(Towny plugin) static booleanisEventCancelled(@NotNull org.bukkit.event.Event event) static booleanTests if this player is online.static StringkeyAsString(@NotNull org.bukkit.NamespacedKey key) Converts a namespaced key into a string.static @Nullable StringmatchMaterialName(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.Objectiveobjective(org.bukkit.scoreboard.Scoreboard board, @NotNull String name, @NotNull String displayName) static booleanplayerCanSeePlayer(org.bukkit.entity.Player seeing, org.bukkit.entity.Player seen) Test whether an Player can see another Player.static StringpotionEffectName(@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:
trueif 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)
-