-
Notifications
You must be signed in to change notification settings - Fork 0
ServerUtils
Fulminazzo edited this page Oct 2, 2023
·
2 revisions
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()```: returns ```Bukkit```; - ```getProxyServerInstance()```: returns ```ProxyServer.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()```: returns ```ConfigurationProvider.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 discussed ```getPluginsManager()```to call ```getPlugins()```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 the ```aClass``` 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 for ```aClass``` 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