Class Utils

java.lang.Object
com.ldtteam.structurize.api.Utils

public final class Utils extends Object
General purpose utilities class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    checkDirectory(File directory)
    Checks if directory exists, else creates it.
    static String
    Get a filename that's probably safe from a player name that might contain problematic characters.
    static boolean
    nbtContains(net.minecraft.nbt.CompoundTag originTag, net.minecraft.nbt.CompoundTag compareTag)
    Check if a comparison tag has the same or more nbt tags than an origin nbt tag.
    static void
    playErrorSound(@NotNull net.minecraft.world.entity.player.Player player)
    Play an error sound.
    static void
    playSuccessSound(@NotNull net.minecraft.world.entity.player.Player player)
    Play a success sound.

    Methods inherited from class java.lang.Object

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

    • playSuccessSound

      public static void playSuccessSound(@NotNull @NotNull net.minecraft.world.entity.player.Player player)
      Play a success sound.
      Parameters:
      player - the player to play it for.
    • playErrorSound

      public static void playErrorSound(@NotNull @NotNull net.minecraft.world.entity.player.Player player)
      Play an error sound.
      Parameters:
      player - the player to play it for.
    • checkDirectory

      public static void checkDirectory(File directory)
      Checks if directory exists, else creates it.
      Parameters:
      directory - the directory to check.
    • nbtContains

      public static boolean nbtContains(net.minecraft.nbt.CompoundTag originTag, net.minecraft.nbt.CompoundTag compareTag)
      Check if a comparison tag has the same or more nbt tags than an origin nbt tag.
      Parameters:
      originTag - the base tag to start the comparison from.
      compareTag - the tag we try to fit into the origin tag.
      Returns:
      true if they match.
    • getSafePackName

      public static String getSafePackName(String input)
      Get a filename that's probably safe from a player name that might contain problematic characters.
      Parameters:
      input - a player name or other possibly unsafe text.
      Returns:
      the safe filename. This doesn't protect against Windows reserved filenames. Most servers are Linux anyway so this only hurts SP players who will have a lot of Windows things break on them too.