Utils.java 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package de.Linus122.TimeIsMoney.tools;
  2. import org.bukkit.Bukkit;
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.entity.Player;
  5. /**
  6. * Utility class.
  7. *
  8. * @author Linus122
  9. * @since 1.9.6.1
  10. */
  11. public class Utils {
  12. /**
  13. * @throws RuntimeException utils class should not be instantiated.
  14. */
  15. public Utils() {
  16. throw new RuntimeException("Utils class should not be instantiated!");
  17. }
  18. /**
  19. * Converts &color to {@link org.bukkit.ChatColor}.
  20. *
  21. * @param s The string to convert to {@link org.bukkit.ChatColor}.
  22. * @return The converted string with {@link org.bukkit.ChatColor}.
  23. */
  24. public static String CC(String s) {
  25. // return an empty string if given string is null
  26. if(s == null) {
  27. return "";
  28. }
  29. return ChatColor.translateAlternateColorCodes('&', s);
  30. }
  31. public static String applyPlaceholders(Player player, String s) {
  32. if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
  33. s = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, s);
  34. }
  35. return s;
  36. }
  37. }