-
Notifications
You must be signed in to change notification settings - Fork 0
ServerUtils
ServerUtils is a utility class offering a pletora of cross-platform and cross-compatible among versions functions.
Many of these functions are being used by BearCommands itself to accomplish its goal of platform independence, but they might be helpful for the end user.
We will cover all the available functions with explanations and examples:
-
getVersion()
: returns the corresponding server version. Uses:-
Bukkit.getBukkitVersion()
for Bukkit; -
ProxyServer.getInstance().getVersion()
for BungeeCord; -
VelocityBearCommandsPlugin.getPlugin().getProxyServer().getVersion()
for Velocity.
-
-
getBukkit()
: returnsBukkit
; -
getProxyServerInstance()
: returnsProxyServer.getInstance()
; -
getPluginManager()
: returns the corresponding plugin manager. Uses:-
Bukkit.getPluginManager()
for Bukkit; -
ProxyServer.getInstance().getPluginManager()
for BungeeCord; -
VelocityBearCommandsPlugin.getPlugin().getProxyServer().getPluginManager()
for Velocity.
-
-
getScheduler()
: returns the corresponding task scheduler. Uses:-
Bukkit.getScheduler()
for Bukkit; -
ProxyServer.getInstance().getScheduler()
for BungeeCord; -
VelocityBearCommandsPlugin.getPlugin().getProxyServer().getScheduler()
for Velocity.
-
-
getConfigurationProvider()
: returnsConfigurationProvider.getProvider(YamlConfiguration.class)
(only available in BungeeCord); -
isPlayer(Object object)
: checks whether the given object is a player or not. Uses:-
CraftPlayer
for Bukkit; -
UserConnection
for BungeeCord; -
ConnectedPlayer
for Velocity.
-
-
isConfigurationSection(Object object)
: checks whether the given object is a section of a configuration or not. Uses:-
ConfigurationSection
for Bukkit; -
Configuration
for BungeeCord; -
Map
for Velocity.
-
-
isBukkit()
: checks whether the server is on Bukkit or not; -
isVelocity()
: checks whether the server is on Velocity or not; -
getPlayerClass()
: returns the corresponding player class. Uses:-
CraftPlayer
for Bukkit; -
UserConnection
for BungeeCord; -
ConnectedPlayer
for Velocity.
-
-
getPlugins()
: uses the previously discussedgetPluginsManager()
to callgetPlugins()
method and return the result; -
getPluginFromClass(Class<?> aClass)
: returns the corresponding plugin from the given class. Uses:-
JavaPlugin.getProvidingPlugin(aClass)
for Bukkit; - returns the
plugin
field from theaClass
for BungeeCord (only works for main classes); - gets all the plugins from
getPlugins()
and check if the plugin main class classloader is the same as the one foraClass
for Velocity.
-
- Home
- How to start a plugin
- Work with Configuration Files
- Work with Enums
- Work with Commands
- Work with Custom Players
- Work with Messaging Channels
- Creating custom SavableObjects
- Timers
- General Utils
- Placeholders
- Bukkit Utils
- Velocity Utils