Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial experimental inventory retaining system
- Loading branch information
1 parent
4141e05
commit 1a6a767
Showing
5 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...main/java/com/denizenscript/denizen/objects/properties/inventory/InventoryUniquifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.denizenscript.denizen.objects.properties.inventory; | ||
|
||
import com.denizenscript.denizen.objects.InventoryTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
|
||
public class InventoryUniquifier implements Property { | ||
|
||
public static boolean describes(ObjectTag inventory) { | ||
// All inventories can potentially have a uniquifier | ||
return inventory instanceof InventoryTag; | ||
} | ||
|
||
public static InventoryUniquifier getFrom(ObjectTag inventory) { | ||
if (!describes(inventory)) { | ||
return null; | ||
} | ||
return new InventoryUniquifier((InventoryTag) inventory); | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"uniquifier" | ||
}; | ||
|
||
/////////////////// | ||
// Instance Fields and Methods | ||
///////////// | ||
|
||
InventoryTag inventory; | ||
|
||
public InventoryUniquifier(InventoryTag inventory) { | ||
this.inventory = inventory; | ||
} | ||
|
||
///////// | ||
// Property Methods | ||
/////// | ||
|
||
@Override | ||
public String getPropertyString() { | ||
if (inventory.uniquifier == null) { | ||
return null; | ||
} | ||
return String.valueOf(inventory.uniquifier); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "uniquifier"; | ||
} | ||
|
||
public static void registerTags() { | ||
// Intentionally no tags. | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// Undocumented / internal | ||
if (mechanism.matches("uniquifier")) { | ||
inventory.uniquifier = mechanism.getValue().asLong(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters