Class ListenableResourceList
java.lang.Object
com.refinedmods.refinedstorage.api.resource.list.AbstractProxyResourceList
com.refinedmods.refinedstorage.api.resource.list.listenable.ListenableResourceList
- All Implemented Interfaces:
ResourceList
@API(status=STABLE,
since="2.0.0-milestone.1.2")
public class ListenableResourceList
extends AbstractProxyResourceList
A resource list that can have listeners to track changes.
Can easily be used with an existing list by passing it in the constructor.
The
ResourceListListener.onChanged(OperationResult)
method is only called when the change
is being performed through this list, not the delegate list.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.refinedmods.refinedstorage.api.resource.list.ResourceList
ResourceList.OperationResult
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(ResourceKey resource, long amount) Adds a given resource to the list.void
addListener
(ResourceListListener listener) remove
(ResourceKey resource, long amount) Removes an amount of a certain resource in the list.void
removeListener
(ResourceListListener listener) Methods inherited from class com.refinedmods.refinedstorage.api.resource.list.AbstractProxyResourceList
clear, contains, copy, copyState, get, getAll
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.refinedmods.refinedstorage.api.resource.list.ResourceList
add, remove
-
Constructor Details
-
ListenableResourceList
-
-
Method Details
-
add
Description copied from interface:ResourceList
Adds a given resource to the list.- Specified by:
add
in interfaceResourceList
- Overrides:
add
in classAbstractProxyResourceList
- Parameters:
resource
- the resource, may not be nullamount
- the amount, must be larger than 0- Returns:
- the result of the operation
-
remove
Description copied from interface:ResourceList
Removes an amount of a certain resource in the list. If the amount reaches 0 due to this removal, the resource is removed from the list.- Specified by:
remove
in interfaceResourceList
- Overrides:
remove
in classAbstractProxyResourceList
- Parameters:
resource
- the resource, may not be nullamount
- the amount, must be larger than 0- Returns:
- a result if the removal operation was successful, otherwise an empty
Optional
-
addListener
-
removeListener
-