Skip to content

Commit

Permalink
minor updates to villager replenish event
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 8, 2022
1 parent 654ba9e commit fff060c
Showing 1 changed file with 5 additions and 14 deletions.
Expand Up @@ -15,15 +15,13 @@ public class VillagerReplenishesTradeScriptEvent extends BukkitScriptEvent imple
// @Events
// villager replenishes trade
//
// @Regex ^on villager replenishes trade$
//
// @Group Entity
//
// @Location true
//
// @Cancellable true
//
// @Triggers when a villager replenishes a trade.
// @Triggers when a villager replenishes a trade. A trade being "replenished" means its "uses" value is reset to "0".
//
// @Context
// <context.entity> returns the EntityTag of the villager.
Expand All @@ -36,16 +34,12 @@ public class VillagerReplenishesTradeScriptEvent extends BukkitScriptEvent imple
// -->

public VillagerReplenishesTradeScriptEvent() {
registerCouldMatcher("villager replenishes trade");
}

public EntityTag entity;
public VillagerReplenishTradeEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
return path.eventLower.startsWith("villager replenishes trade");
}

@Override
public boolean matches(ScriptPath path) {
if (!runInCheck(path, entity.getLocation())) {
Expand All @@ -71,12 +65,9 @@ else if (determinationObj instanceof ElementTag && ((ElementTag) determinationOb
@Override
public ObjectTag getContext(String name) {
switch (name) {
case "entity":
return entity;
case "trade":
return new TradeTag(event.getRecipe()).duplicate();
case "bonus":
return new ElementTag(event.getBonus());
case "entity": return entity;
case "trade": return new TradeTag(event.getRecipe()).duplicate();
case "bonus": return new ElementTag(event.getBonus());
}
return super.getContext(name);
}
Expand Down

0 comments on commit fff060c

Please sign in to comment.