-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
TradeMaxUses.java
41 lines (33 loc) · 1.13 KB
/
TradeMaxUses.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.denizenscript.denizen.objects.properties.trade;
import com.denizenscript.denizen.objects.TradeTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
public class TradeMaxUses extends TradeProperty<ElementTag> {
// <--[property]
// @object TradeTag
// @name max_uses
// @input ElementTag(Number)
// @description
// Sets the maximum amount of times that the trade can be used.
// -->
public static boolean describes(TradeTag recipe) {
return true;
}
@Override
public ElementTag getPropertyValue() {
return new ElementTag(getRecipe().getMaxUses());
}
@Override
public void setPropertyValue(ElementTag val, Mechanism mechanism) {
if (mechanism.requireInteger()) {
getRecipe().setMaxUses(mechanism.getValue().asInt());
}
}
@Override
public String getPropertyId() {
return "max_uses";
}
public static void register() {
autoRegister("max_uses", TradeMaxUses.class, ElementTag.class, false);
}
}