Class Utils
java.lang.Object
uk.radialbog9.spigot.manhunt.utils.Utils
Utilities that are used throughout the plugin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidBroadcasts message to all playersstatic net.md_5.bungee.api.chat.TextComponentgenTextComponentHoverOnly(@NotNull String text, @NotNull String hover) Generate a text component with hoverstatic net.md_5.bungee.api.chat.TextComponentgenTextComponentRunCommand(@NotNull String text, @NotNull String command) Generate a text component and run command click eventstatic net.md_5.bungee.api.chat.TextComponentgenTextComponentRunCommand(@NotNull String text, @NotNull String command, String hover) Generate a text component with hover and run command click eventstatic net.md_5.bungee.api.chat.TextComponentgenTextComponentSuggestCommand(@NotNull String text, @NotNull String command) Generate a text component and run suggest command click eventstatic net.md_5.bungee.api.chat.TextComponentgenTextComponentSuggestCommand(@NotNull String text, @NotNull String command, String hover) Generate a text component with hover and run suggest command click eventgetClasses(File jarFile, String packageName) Get classes in specific package in a jarstatic StringgetMsgColor(String msg) Shorter way to get chat message colorsstatic intgetRandomInt(int min, int max) Generates random integers between 2 integers (inclusive)static booleanhasNoManhuntPermissions(org.bukkit.command.CommandSender s) Checks for all manhunt permissionsstatic voidswapLocation(org.bukkit.entity.Player player1, org.bukkit.entity.Player player2) Swaps the location of two playersstatic booleanvanishCanSee(org.bukkit.command.CommandSender viewer, org.bukkit.entity.Player viewed) Utility method for detecting if a player can see another player.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
getMsgColor
Shorter way to get chat message colors- Parameters:
msg- String Chat message- Returns:
- String Decoded message
-
broadcastServerMessage
Broadcasts message to all players- Parameters:
msg- Message
-
hasNoManhuntPermissions
public static boolean hasNoManhuntPermissions(org.bukkit.command.CommandSender s) Checks for all manhunt permissions- Parameters:
s- CommandSender- Returns:
- boolean if sender has no manhunt permissions
-
genTextComponentRunCommand
public static net.md_5.bungee.api.chat.TextComponent genTextComponentRunCommand(@NotNull @NotNull String text, @NotNull @NotNull String command, String hover) Generate a text component with hover and run command click event- Parameters:
text- String contents of messagecommand- String command to runhover- String hover- Returns:
- TextComponent the generated text component
-
genTextComponentRunCommand
public static net.md_5.bungee.api.chat.TextComponent genTextComponentRunCommand(@NotNull @NotNull String text, @NotNull @NotNull String command) Generate a text component and run command click event- Parameters:
text- String contents of messagecommand- String command to run- Returns:
- TextComponent the generated text component
-
genTextComponentSuggestCommand
public static net.md_5.bungee.api.chat.TextComponent genTextComponentSuggestCommand(@NotNull @NotNull String text, @NotNull @NotNull String command, String hover) Generate a text component with hover and run suggest command click event- Parameters:
text- String contents of messagecommand- String command to runhover- String hover- Returns:
- TextComponent the generated text component
-
genTextComponentSuggestCommand
public static net.md_5.bungee.api.chat.TextComponent genTextComponentSuggestCommand(@NotNull @NotNull String text, @NotNull @NotNull String command) Generate a text component and run suggest command click event- Parameters:
text- contents of messagecommand- command to run- Returns:
- The generated text component
-
genTextComponentHoverOnly
public static net.md_5.bungee.api.chat.TextComponent genTextComponentHoverOnly(@NotNull @NotNull String text, @NotNull @NotNull String hover) Generate a text component with hover- Parameters:
text- String contents of messagehover- String hover- Returns:
- TextComponent the generated text component
-
getRandomInt
public static int getRandomInt(int min, int max) Generates random integers between 2 integers (inclusive)- Parameters:
min- minimum (inclusive)max- maximum (inclusive)- Returns:
- Random integer between min and max
-
getClasses
Get classes in specific package in a jar- Parameters:
jarFile- The jar file to search inpackageName- Name of the package to get from- Returns:
- Set of classes in the package
-
vanishCanSee
public static boolean vanishCanSee(org.bukkit.command.CommandSender viewer, org.bukkit.entity.Player viewed) Utility method for detecting if a player can see another player. If a supported vanish plugin is detected then the result is determined by the API call to the vanish plugin. If the viewer is not a player (i.e. console) or a supported vanish plugin is not detected, it returns true.- Parameters:
viewer- Player who is viewing (or console sender)viewed- Player who is being viewed- Returns:
- if viewer can see viewed
-
swapLocation
public static void swapLocation(org.bukkit.entity.Player player1, org.bukkit.entity.Player player2) Swaps the location of two players- Parameters:
player1- Player 1player2- Player 2
-