Package wbs.utils.util.plugin
Class WbsPlugin
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
wbs.utils.util.plugin.WbsPlugin
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor,org.bukkit.plugin.Plugin
- Direct Known Subclasses:
WbsUtils
public abstract class WbsPlugin
extends org.bukkit.plugin.java.JavaPlugin
Somewhat a utility class, use this
instead of extending JavaPlugin to gain
access to a bunch of messaging options
that allows a consistent layout throughout
the plugin.
- Author:
- Weber588
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionorg.bukkit.plugin.PluginManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSend a formatted message to all online players.voidbroadcastActionBar(String message, double radius, org.bukkit.Location loc) Sends an action bar to all players within a radius of a given locationbuildMessage(String message) Get aWbsPlugin.MessageBuilderthat allows a message to be built using plugin-specific formatting, and supports chat events.buildMessage(String message, org.bukkit.command.CommandSender sender) Deprecated.UsebuildMessage(String)and pass sender in when sendingbuildMessageNoPrefix(String message) Get aWbsPlugin.MessageBuilderthat allows a message to be built using plugin-specific formatting, and supports chat events.buildMessageNoPrefix(String message, org.bukkit.command.CommandSender sender) Deprecated.UsebuildMessageNoPrefix(String)and pass sender in when sendingcolouriseAll(Collection<String> collection) dynamicColourise(String string) Colourize based on the configured plugin colours@NotNull net.md_5.bungee.api.chat.TextComponentformatAsTextComponent(@NotNull String message) <T> intorg.bukkit.ChatColororg.bukkit.ChatColororg.bukkit.ChatColorabstract voidonEnable()protected voidregisterListener(org.bukkit.event.Listener listener) intRuns a block of code asynchronously using a BukkitRunnable, and returns the task Id.intRuns a block of code asynchronously using a BukkitRunnable, and returns the task Id.intRun a block of code in the main thread on the next tick, where it's safe to do minecraft related operations.voidsendActionBar(String message, org.bukkit.entity.Player player) Sends a formatted action bar to the specified playervoidsendMessage(String message, org.bukkit.command.CommandSender sender) Send a formatted message with "&" colour codes, where "&w" becomes the configured error colour, "&h" becomes the configured highlight colour, and "&r" resets to the configured main colour.voidsendMessageNoPrefix(String message, org.bukkit.command.CommandSender sender) Send a formatted message with no prefix and formatted "&" colour codes, where "&w" becomes the configured error colour, and "&h" becomes the configured highlight colourvoidsendPlaceholderMessage(String message, org.bukkit.command.CommandSender sender) Same assendMessage(String, CommandSender), but automatically fills placeholders with PlaceholderAPI if sender is a Player, and PlaceholderAPI is installedvoidsetDisplays(String newPrefix, org.bukkit.ChatColor newColour, org.bukkit.ChatColor newHighlight, org.bukkit.ChatColor newErrorColour) Set the displays used throughout the plugin for formattingMethods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDataFolder, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, isEnabled, isNaggable, onCommand, onDisable, onLoad, onTabComplete, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode
-
Field Details
-
logger
-
pluginManager
public org.bukkit.plugin.PluginManager pluginManager -
prefix
-
-
Constructor Details
-
WbsPlugin
public WbsPlugin()
-
-
Method Details
-
registerListener
protected void registerListener(org.bukkit.event.Listener listener) -
onEnable
public abstract void onEnable()- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin
-
setDisplays
public void setDisplays(String newPrefix, org.bukkit.ChatColor newColour, org.bukkit.ChatColor newHighlight, org.bukkit.ChatColor newErrorColour) Set the displays used throughout the plugin for formatting- Parameters:
newPrefix- The prefix to appear before standard messagesnewColour- The new default plugin colournewHighlight- The new highlight colournewErrorColour- The new errors colour
-
getColour
public org.bukkit.ChatColor getColour() -
getHighlight
public org.bukkit.ChatColor getHighlight() -
getErrorColour
public org.bukkit.ChatColor getErrorColour() -
dynamicColourise
Colourize based on the configured plugin colours- Parameters:
string- The string to colourize- Returns:
- The colourized string
-
colouriseAll
-
formatAsTextComponent
@NotNull public @NotNull net.md_5.bungee.api.chat.TextComponent formatAsTextComponent(@NotNull @NotNull String message) -
sendMessage
Send a formatted message with "&" colour codes, where "&w" becomes the configured error colour, "&h" becomes the configured highlight colour, and "&r" resets to the configured main colour.- Parameters:
message- The message to sendsender- The CommandSender to receive the message
-
buildMessage
@Deprecated public WbsPlugin.MessageBuilder buildMessage(String message, org.bukkit.command.CommandSender sender) Deprecated.UsebuildMessage(String)and pass sender in when sendingGet aWbsPlugin.MessageBuilderthat allows a message to be built using plugin-specific formatting, and supports chat events.- Parameters:
message- The base message to appear after the prefix.sender- The CommandSender to receive the message- Returns:
- The message builder.
-
buildMessage
Get aWbsPlugin.MessageBuilderthat allows a message to be built using plugin-specific formatting, and supports chat events.- Parameters:
message- The base message to appear after the prefix.- Returns:
- The message builder.
-
buildMessageNoPrefix
@Deprecated public WbsPlugin.MessageBuilder buildMessageNoPrefix(String message, org.bukkit.command.CommandSender sender) Deprecated.UsebuildMessageNoPrefix(String)and pass sender in when sendingGet aWbsPlugin.MessageBuilderthat allows a message to be built using plugin-specific formatting, and supports chat events.- Parameters:
message- The message to appear with the plugin's default colour.sender- The CommandSender to receive the message- Returns:
- The message builder.
-
buildMessageNoPrefix
Get aWbsPlugin.MessageBuilderthat allows a message to be built using plugin-specific formatting, and supports chat events.- Parameters:
message- The message to appear with the plugin's default colour.- Returns:
- The message builder.
-
sendPlaceholderMessage
Same assendMessage(String, CommandSender), but automatically fills placeholders with PlaceholderAPI if sender is a Player, and PlaceholderAPI is installed- Parameters:
message- The message to send after filling any placeholderssender- The CommandSender to receive the message
-
sendMessageNoPrefix
Send a formatted message with no prefix and formatted "&" colour codes, where "&w" becomes the configured error colour, and "&h" becomes the configured highlight colour- Parameters:
message- The message to sendsender- The CommandSender to receive the message
-
broadcast
Send a formatted message to all online players.- Parameters:
message- The message to broadcast- See Also:
-
sendActionBar
Sends a formatted action bar to the specified player- Parameters:
message- The action bar message to sendplayer- The player to receive the action bar- See Also:
-
broadcastActionBar
Sends an action bar to all players within a radius of a given location- Parameters:
message- The message to sendradius- The radius to send the action barloc- The location at which to center the broadcast
-
runAsync
Runs a block of code asynchronously using a BukkitRunnable, and returns the task Id. Once the task finishes, the callback runnable is run in the main thread.- Parameters:
runnable- The runnable to execute asynchronouslycallback- The runnable to execute synchronously on the main thread after the async runnable executes- Returns:
- The Id of the task created
-
runAsync
Runs a block of code asynchronously using a BukkitRunnable, and returns the task Id.- Parameters:
runnable- The runnable to execute asynchronously- Returns:
- The Id of the task created
-
runSync
Run a block of code in the main thread on the next tick, where it's safe to do minecraft related operations.- Parameters:
runnable- The block of code to run- Returns:
- The Id of the task created
-
getAsync
-
WbsMessageBuilderandWbsMessageinstead.