Class MetaDataUtil

java.lang.Object
com.palmergames.bukkit.towny.utils.MetaDataUtil

public class MetaDataUtil extends Object
Author:
LlmDl
  • Constructor Details

    • MetaDataUtil

      public MetaDataUtil()
  • Method Details

    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, String key)
      Does the TownyObject have meta stored with the given key?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String representing the meta's Key.
      Returns:
      true if the TownyObject has meta using the given key.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, StringDataField sdf)
      Does the TownyObject have the StringDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      sdf - StringDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the StringDataField meta.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, BooleanDataField bdf)
      Does the TownyObject have the BooleanDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - BooleanDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the BooleanDataField meta.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, LongDataField ldf)
      Does the TownyObject have the LongDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LongDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the LongDataField meta.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, IntegerDataField idf)
      Does the TownyObject have the IntegerDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      idf - IntegerDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the IntegerDataField meta.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, DecimalDataField ddf)
      Does the TownyObject have the DecimalDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ddf - DecimalDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the DecimalDataField meta.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, ByteDataField bdf)
      Does the TownyObject have the ByteDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - ByteDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the ByteDataField meta.
    • hasMeta

      public static boolean hasMeta(TownyObject townyObject, LocationDataField ldf)
      Does the TownyObject have the LocationDataField meta?
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LocationDataField to check for on the TownyObject.
      Returns:
      true if the TownyObject has the LocationDataField meta.
    • getString

      public static String getString(TownyObject townyObject, StringDataField sdf)
      Get a string from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      sdf - StringDataField to get from the TownyObject.
      Returns:
      String from the metadata or an empty string.
    • getBoolean

      public static boolean getBoolean(TownyObject townyObject, BooleanDataField bdf)
      Get a boolean from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - BooleanDataField to get from the TownyObject.
      Returns:
      boolean from the metadata or false.
    • getLong

      public static long getLong(TownyObject townyObject, LongDataField ldf)
      Get a long from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LongDataField to get from the TownyObject.
      Returns:
      long from the metadata or 0l.
    • getInt

      public static int getInt(TownyObject townyObject, IntegerDataField idf)
      Get a int from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      idf - IntegerDataField to get from the TownyObject.
      Returns:
      int from the metadata or 0.
    • getDouble

      public static double getDouble(TownyObject townyObject, DecimalDataField ddf)
      Get a double from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ddf - DecimalDataField to get from the TownyObject.
      Returns:
      double from the metadata or 0.0.
    • getByte

      public static byte getByte(TownyObject townyObject, ByteDataField bdf)
      Get a byte from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - ByteDataField to get from the TownyObject.
      Returns:
      byte from the metadata or 0.
    • getLocation

      @Nullable public static @Nullable org.bukkit.Location getLocation(TownyObject townyObject, LocationDataField ldf)
      Get a Location from a TownyObject's metadata.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LocationDataField to get from the TownyObject.
      Returns:
      Location from the metadata or null.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, StringDataField sdf, boolean save)
      Adds a new StringDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      sdf - StringDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, BooleanDataField bdf, boolean save)
      Adds a new BooleanDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - BooleanDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, LongDataField ldf, boolean save)
      Adds a new LongDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LongDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, IntegerDataField idf, boolean save)
      Adds a new IntegerDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      idf - IntegerDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, DecimalDataField ddf, boolean save)
      Adds a new DecimalDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ddf - DecimalDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, ByteDataField bdf, boolean save)
      Adds a new ByteDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - ByteDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewMeta

      public static void addNewMeta(TownyObject townyObject, LocationDataField ldf, boolean save)
      Adds a new LocationDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LocationDataField to apply to the TownyObject.
      save - set true to save the object after applying the MetaData.
    • addNewStringMeta

      public static void addNewStringMeta(TownyObject townyObject, String key, String value, boolean save)
      Creates and adds a new StringDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new StringDataField key.
      value - String value of the StringDataField key.
      save - set true to save the object after applying the MetaData.
    • addNewBooleanMeta

      public static void addNewBooleanMeta(TownyObject townyObject, String key, boolean value, boolean save)
      Creates and adds a new BooleanDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new BooleanDataField key.
      value - boolean value of the BooleanDataField key.
      save - set true to save the object after applying the MetaData.
    • addNewLongMeta

      public static void addNewLongMeta(TownyObject townyObject, String key, long value, boolean save)
      Creates and adds a new LongDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new LongDataField key.
      value - long value of the LongDataField key.
      save - set true to save the object after applying the MetaData.
    • addNewIntegerMeta

      public static void addNewIntegerMeta(TownyObject townyObject, String key, int value, boolean save)
      Creates and adds a new IntegerDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new IntegerDataField key.
      value - long value of the IntegerDataField key.
      save - set true to save the object after applying the MetaData.
    • addNewDoubleMeta

      public static void addNewDoubleMeta(TownyObject townyObject, String key, double value, boolean save)
      Creates and adds a new DecimalDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new DecimalDataField key.
      value - double value of the DecimalDataField key.
      save - set true to save the object after applying the MetaData.
    • addNewByteMeta

      public static void addNewByteMeta(TownyObject townyObject, String key, byte value, boolean save)
      Creates and adds a new ByteDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new ByteDataField key.
      value - byte value of the ByteDataField key.
      save - set true to save the object after applying the MetaData.
    • addNewLocationMeta

      public static void addNewLocationMeta(TownyObject townyObject, String key, org.bukkit.Location value, boolean save)
      Creates and adds a new LocationDataField MetaData to a TownyObject, overriding any existing MetaData with the same key.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      key - String name of the new ByteDataField key.
      value - Location value of the LocationDataField key.
      save - set true to save the object after applying the MetaData.
    • setString

      public static void setString(TownyObject townyObject, StringDataField sdf, String string, boolean save)
      Sets a StringDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      sdf - StringDataField to apply to the TownyObject.
      string - String to apply to the StringDataField.
      save - True to save the TownyObject after setting the metadata.
    • setBoolean

      public static void setBoolean(TownyObject townyObject, BooleanDataField bdf, boolean bool, boolean save)
      Sets a BooleanDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - BooleanDataField to apply to the TownyObject.
      bool - boolean to apply to the BooleanDataField.
      save - True to save the TownyObject after setting the metadata.
    • setLong

      public static void setLong(TownyObject townyObject, LongDataField ldf, long num, boolean save)
      Sets a LongDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LongDataField to apply to the TownyObject.
      num - long to apply to the LongDataField.
      save - True to save the TownyObject after setting the metadata.
    • setInt

      public static void setInt(TownyObject townyObject, IntegerDataField idf, int num, boolean save)
      Sets a IntegerDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      idf - IntegerDataField to apply to the TownyObject.
      num - int to apply to the IntegerDataField.
      save - True to save the TownyObject after setting the metadata.
    • setDouble

      public static void setDouble(TownyObject townyObject, DecimalDataField ddf, double num, boolean save)
      Sets a DecimalDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ddf - DecimalDataField to apply to the TownyObject.
      num - double to apply to the DecimalDataField.
      save - True to save the TownyObject after setting the metadata.
    • setByte

      public static void setByte(TownyObject townyObject, ByteDataField bdf, byte num, boolean save)
      Sets a ByteDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      bdf - ByteDataField to apply to the TownyObject.
      num - value to apply to the ByteDataField.
      save - True to save the TownyObject after setting the metadata.
    • setLocation

      public static void setLocation(TownyObject townyObject, LocationDataField ldf, org.bukkit.Location loc, boolean save)
      Sets a LocationDataField metadata on a TownyObject, creating the metadata if it doesn't exist.
      Parameters:
      townyObject - TownyObject, ie: Resident, Town, Nation, TownBlock.
      ldf - LocationDataField to apply to the TownyObject.
      loc - value to apply to the ByteDataField.
      save - True to save the TownyObject after setting the metadata.