-
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:-
CraftPlayerfor Bukkit; -
UserConnectionfor BungeeCord; -
ConnectedPlayerfor Velocity.
-
-
isConfigurationSection(Object object): checks whether the given object is a section of a configuration or not. Uses:-
ConfigurationSectionfor Bukkit; -
Configurationfor BungeeCord; -
Mapfor 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:-
CraftPlayerfor Bukkit; -
UserConnectionfor BungeeCord; -
ConnectedPlayerfor 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
pluginfield from theaClassfor 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 foraClassfor 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