Package dev.jaxydog.astral.utility
Record Class CurrencyHelper.Unit
java.lang.Object
java.lang.Record
dev.jaxydog.astral.utility.CurrencyHelper.Unit
- Record Components:
itemId- The representing item's identifier.value- The value of this currency.dropRewards- Whether to drop rewards when automatically exchanging.exchangeMap- A map containing exchange rates for other namespaces.
- All Implemented Interfaces:
CurrencyHelper.ItemRepresentable,Comparable<CurrencyHelper.Unit>
- Enclosing interface:
CurrencyHelper
public static record CurrencyHelper.Unit(net.minecraft.util.Identifier itemId, int value, boolean dropRewards, Map<String,Integer> exchangeMap)
extends Record
implements CurrencyHelper.ItemRepresentable, Comparable<CurrencyHelper.Unit>
A base unit of currency.
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CurrencyHelper.CurrencyMap<CurrencyHelper.Unit> A map containing all currently active currency units. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(@NotNull CurrencyHelper.Unit o) booleanReturns the value of thedropRewardsrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexchangeMaprecord component.net.minecraft.util.IdentifierReturns the associated item identifier, orminecraft:airif the referenced identifier is invalid.final inthashCode()Returns a hash code value for this object.net.minecraft.util.IdentifieritemId()Returns the value of theitemIdrecord component.Optional<Map.Entry<net.minecraft.util.Identifier, CurrencyHelper.Unit>> next(boolean exactMultiple) Returns the next unit of currency by value.static CurrencyHelper.UnitParses a JSON object and creates a newCurrencyHelper.Unitfrom the resolved data.final StringtoString()Returns a string representation of this record class.intvalue()Returns the value of thevaluerecord component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.jaxydog.astral.utility.CurrencyHelper.ItemRepresentable
getItem
-
Field Details
-
UNITS
A map containing all currently active currency units.- Since:
- 2.0.0
-
-
Constructor Details
-
Unit
public Unit(net.minecraft.util.Identifier itemId, int value, boolean dropRewards, Map<String, Integer> exchangeMap) Creates an instance of aUnitrecord class.- Parameters:
itemId- the value for theitemIdrecord componentvalue- the value for thevaluerecord componentdropRewards- the value for thedropRewardsrecord componentexchangeMap- the value for theexchangeMaprecord component
-
-
Method Details
-
parse
public static CurrencyHelper.Unit parse(String namespace, net.minecraft.util.Identifier itemId, com.google.gson.JsonObject object) throws com.google.gson.JsonSyntaxException Parses a JSON object and creates a newCurrencyHelper.Unitfrom the resolved data.- Parameters:
namespace- The unit's namespace.itemId- The representing item's identifier.object- The JSON object.- Returns:
- A new unit.
- Throws:
com.google.gson.JsonSyntaxException- If a field is invalid or missing from the given object.- Since:
- 2.0.0
-
next
public Optional<Map.Entry<net.minecraft.util.Identifier,CurrencyHelper.Unit>> next(boolean exactMultiple) Returns the next unit of currency by value.- Parameters:
exactMultiple- Whether the value of the unit returned should be an exact multiple of this unit's value.- Returns:
- The next unit by value.
- Since:
- 2.0.0
-
getItemId
public net.minecraft.util.Identifier getItemId()Description copied from interface:CurrencyHelper.ItemRepresentableReturns the associated item identifier, orminecraft:airif the referenced identifier is invalid.- Specified by:
getItemIdin interfaceCurrencyHelper.ItemRepresentable- Returns:
- The associated item identifier, or
minecraft:airif the referenced identifier is invalid.
-
compareTo
- Specified by:
compareToin interfaceComparable<CurrencyHelper.Unit>
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
itemId
public net.minecraft.util.Identifier itemId()Returns the value of theitemIdrecord component.- Returns:
- the value of the
itemIdrecord component
-
value
public int value()Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
dropRewards
public boolean dropRewards()Returns the value of thedropRewardsrecord component.- Returns:
- the value of the
dropRewardsrecord component
-
exchangeMap
Returns the value of theexchangeMaprecord component.- Returns:
- the value of the
exchangeMaprecord component
-