Class BukkitUtility


  • public class BukkitUtility
    extends java.lang.Object
    Utility methods relating to Bukkit
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @NotNull java.lang.String color​(@Nullable java.lang.Object object)
      Translates & color codes to ChatColor
      static @NotNull java.util.List<java.lang.String> colorCollection​(@Nullable java.util.Collection<?> objects)
      Translates & color codes to ChatColor for a Collection of messages
      static @NotNull java.util.Set<java.lang.String> getAllPlayerNames()
      Gets a Set of all player names
      static @NotNull java.util.Optional<org.bukkit.OfflinePlayer> getOfflinePlayer​(@NotNull java.lang.String name)
      Gets an OfflinePlayer from the specified name
      Returns a Player if they're online
      static @NotNull java.util.Set<java.lang.String> getOfflinePlayerNames()
      Gets a Set of all offline player names
      static @NotNull java.util.Set<java.lang.String> getOnlinePlayerNames()
      Gets a Set of all online player names
      static @NotNull java.util.Optional<java.lang.Integer> getPermissionValue​(@NotNull org.bukkit.entity.Player player, @NotNull java.lang.String permission)
      Gets the value of a permission node from a Player

      Example: player has friends.max.5 permission, getPermissionValue(player, "friends.max.") would return 5
      static @NotNull java.util.Set<java.lang.String> getWorldNames()
      Gets a Set of all world names
      static @NotNull java.lang.String stripUntranslatedColor​(@Nullable java.lang.String string)
      Strips untranslated ChatColors (using &) from a String
      static boolean toggleScoreboardTag​(@NotNull org.bukkit.entity.Entity entity, @NotNull java.lang.String scoreboardTag)
      Toggles a scoreboard tag on an Entity
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • color

        @NotNull
        public static @NotNull java.lang.String color​(@Nullable
                                                      @Nullable java.lang.Object object)
        Translates & color codes to ChatColor
        Parameters:
        object - the object/message to translate
        Returns:
        the translated object/message
      • colorCollection

        @NotNull
        public static @NotNull java.util.List<java.lang.String> colorCollection​(@Nullable
                                                                                @Nullable java.util.Collection<?> objects)
        Translates & color codes to ChatColor for a Collection of messages
        Parameters:
        objects - the objects/messages to translate
        Returns:
        the translated objects/messages
      • stripUntranslatedColor

        @NotNull
        public static @NotNull java.lang.String stripUntranslatedColor​(@Nullable
                                                                       @Nullable java.lang.String string)
        Strips untranslated ChatColors (using &) from a String
        Parameters:
        string - the String to strip
        Returns:
        the stripped String
      • toggleScoreboardTag

        public static boolean toggleScoreboardTag​(@NotNull
                                                  @NotNull org.bukkit.entity.Entity entity,
                                                  @NotNull
                                                  @NotNull java.lang.String scoreboardTag)
        Toggles a scoreboard tag on an Entity
        Parameters:
        entity - the Entity to toggle the scoreboard tag on
        scoreboardTag - the scoreboard tag to toggle
        Returns:
        true if the scoreboard tag was added, false if it was removed (or if it failed)
      • getPermissionValue

        @NotNull
        public static @NotNull java.util.Optional<java.lang.Integer> getPermissionValue​(@NotNull
                                                                                        @NotNull org.bukkit.entity.Player player,
                                                                                        @NotNull
                                                                                        @NotNull java.lang.String permission)
        Gets the value of a permission node from a Player

        Example: player has friends.max.5 permission, getPermissionValue(player, "friends.max.") would return 5
        Parameters:
        player - the Player to get the permission value from
        permission - the permission node to get the value of
        Returns:
        the value of the permission node, or empty if not found
      • getOfflinePlayer

        @NotNull
        public static @NotNull java.util.Optional<org.bukkit.OfflinePlayer> getOfflinePlayer​(@NotNull
                                                                                             @NotNull java.lang.String name)
        Gets an OfflinePlayer from the specified name
        Returns a Player if they're online
        Parameters:
        name - the name of the player
        Returns:
        the OfflinePlayer, or empty if not found
      • getOnlinePlayerNames

        @NotNull
        public static @NotNull java.util.Set<java.lang.String> getOnlinePlayerNames()
        Gets a Set of all online player names
        Returns:
        the Set of player names
      • getOfflinePlayerNames

        @NotNull
        public static @NotNull java.util.Set<java.lang.String> getOfflinePlayerNames()
        Gets a Set of all offline player names
        Returns:
        the Set of player names
      • getAllPlayerNames

        @NotNull
        public static @NotNull java.util.Set<java.lang.String> getAllPlayerNames()
        Gets a Set of all player names
        Returns:
        the Set of player names
      • getWorldNames

        @NotNull
        public static @NotNull java.util.Set<java.lang.String> getWorldNames()
        Gets a Set of all world names
        Returns:
        the Set of world names