Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e137d6
commit b1d7517
Showing
5 changed files
with
172 additions
and
11 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
73 changes: 73 additions & 0 deletions
73
plugin/src/main/java/com/denizenscript/denizen/objects/properties/trade/TradeDemand.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,73 @@ | ||
package com.denizenscript.denizen.objects.properties.trade; | ||
|
||
import com.denizenscript.denizen.objects.TradeTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.objects.properties.PropertyParser; | ||
|
||
public class TradeDemand implements Property { | ||
|
||
public static boolean describes(ObjectTag recipe) { | ||
return recipe instanceof TradeTag; | ||
} | ||
|
||
public static TradeDemand getFrom(ObjectTag recipe) { | ||
if (!describes(recipe)) { | ||
return null; | ||
} | ||
return new TradeDemand((TradeTag) recipe); | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"demand" | ||
}; | ||
|
||
private TradeTag recipe; | ||
|
||
public TradeDemand(TradeTag recipe) { | ||
this.recipe = recipe; | ||
} | ||
|
||
public String getPropertyString() { | ||
if (recipe.getRecipe() == null) { | ||
return null; | ||
} | ||
return String.valueOf(recipe.getRecipe().getDemand()); | ||
} | ||
|
||
public String getPropertyId() { | ||
return "demand"; | ||
} | ||
|
||
public static void registerTags() { | ||
|
||
// <--[tag] | ||
// @attribute <TradeTag.demand> | ||
// @returns ElementTag(Number) | ||
// @mechanism TradeTag.demand | ||
// @description | ||
// Returns the demand level of the trade. | ||
// --> | ||
PropertyParser.<TradeDemand, ElementTag>registerTag(ElementTag.class, "demand", (attribute, recipe) -> { | ||
return new ElementTag(recipe.recipe.getRecipe().getDemand()); | ||
}); | ||
} | ||
|
||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object TradeTag | ||
// @name demand | ||
// @input ElementTag(Number) | ||
// @description | ||
// Sets the demand level of the trade. | ||
// @tags | ||
// <TradeTag.demand> | ||
// --> | ||
if (mechanism.matches("demand") && mechanism.requireInteger()) { | ||
recipe.getRecipe().setDemand(mechanism.getValue().asInt()); | ||
} | ||
} | ||
} |
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
73 changes: 73 additions & 0 deletions
73
...n/src/main/java/com/denizenscript/denizen/objects/properties/trade/TradeSpecialPrice.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,73 @@ | ||
package com.denizenscript.denizen.objects.properties.trade; | ||
|
||
import com.denizenscript.denizen.objects.TradeTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.objects.properties.PropertyParser; | ||
|
||
public class TradeSpecialPrice implements Property { | ||
|
||
public static boolean describes(ObjectTag recipe) { | ||
return recipe instanceof TradeTag; | ||
} | ||
|
||
public static TradeSpecialPrice getFrom(ObjectTag recipe) { | ||
if (!describes(recipe)) { | ||
return null; | ||
} | ||
return new TradeSpecialPrice((TradeTag) recipe); | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"special_price" | ||
}; | ||
|
||
private TradeTag recipe; | ||
|
||
public TradeSpecialPrice(TradeTag recipe) { | ||
this.recipe = recipe; | ||
} | ||
|
||
public String getPropertyString() { | ||
if (recipe.getRecipe() == null) { | ||
return null; | ||
} | ||
return String.valueOf(recipe.getRecipe().getSpecialPrice()); | ||
} | ||
|
||
public String getPropertyId() { | ||
return "special_price"; | ||
} | ||
|
||
public static void registerTags() { | ||
|
||
// <--[tag] | ||
// @attribute <TradeTag.special_price> | ||
// @returns ElementTag(Number) | ||
// @mechanism TradeTag.special_price | ||
// @description | ||
// Returns the special price for this trade. | ||
// --> | ||
PropertyParser.<TradeSpecialPrice, ElementTag>registerTag(ElementTag.class, "special_price", (attribute, recipe) -> { | ||
return new ElementTag(recipe.recipe.getRecipe().getSpecialPrice()); | ||
}); | ||
} | ||
|
||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object TradeTag | ||
// @name special_price | ||
// @input ElementTag(Number) | ||
// @description | ||
// Sets the special price for this trade. | ||
// @tags | ||
// <TradeTag.special_price> | ||
// --> | ||
if (mechanism.matches("special_price") && mechanism.requireInteger()) { | ||
recipe.getRecipe().setSpecialPrice(mechanism.getValue().asInt()); | ||
} | ||
} | ||
} |