Skip to content

Commit

Permalink
upgrade new property system
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 26, 2019
1 parent f3e35b6 commit 6527ddf
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 72 deletions.
Expand Up @@ -66,8 +66,8 @@ public static void registerTags() {
// @description
// If the entity is an armor stand, returns whether the armor stand can tick.
// -->
PropertyParser.<EntityTag>registerTag("can_tick", (attribute, entity) -> {
return new ElementTag(((ArmorStand) entity.getBukkitEntity()).canTick());
PropertyParser.<EntityCanTick>registerTag("can_tick", (attribute, entity) -> {
return new ElementTag(((ArmorStand) entity.entity.getBukkitEntity()).canTick());
});
}

Expand Down

Large diffs are not rendered by default.

Expand Up @@ -42,7 +42,8 @@ public static void registerTags() {
// Returns the list in a human-readable format.
// EG, a list of "n@3|p@bob|potato" will return "GuardNPC, bob, and potato".
// -->
PropertyParser.<ListTag>registerTag("formatted", (attribute, list) -> {
PropertyParser.<BukkitListProperties>registerTag("formatted", (attribute, listObj) -> {
ListTag list = listObj.list;
if (list.isEmpty()) {
return new ElementTag("");
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ public static BukkitQueueProperties getFrom(ObjectTag queue) {
};

private BukkitQueueProperties(QueueTag queue) {
this.queue = queue.queue;
this.queue = queue.getQueue();
}

ScriptQueue queue;
Expand All @@ -46,7 +46,7 @@ public static void registerTags() {
// @description
// Returns the NPCTag linked to a queue.
// -->
PropertyParser.<QueueTag>registerTag("npc", (attribute, object) -> {
PropertyParser.<BukkitQueueProperties>registerTag("npc", (attribute, object) -> {
NPCTag npc = null;
if (object.queue.getLastEntryExecuted() != null) {
npc = ((BukkitScriptEntryData) object.queue.getLastEntryExecuted().entryData).getNPC();
Expand All @@ -72,7 +72,7 @@ else if (!attribute.hasAlternative()) {
// @description
// Returns the PlayerTag linked to a queue.
// -->
PropertyParser.<QueueTag>registerTag("player", (attribute, object) -> {
PropertyParser.<BukkitQueueProperties>registerTag("player", (attribute, object) -> {
PlayerTag player = null;
if (object.queue.getLastEntryExecuted() != null) {
player = ((BukkitScriptEntryData) object.queue.getLastEntryExecuted().entryData).getPlayer();
Expand Down
Expand Up @@ -45,11 +45,11 @@ public static void registerTags() {
// cooldown present on the script will also be taken into account. Not specifying a player will result in
// using the attached player available in the script entry. Not having a valid player will result in 'null'.
// -->
PropertyParser.<ScriptTag>registerTag("cooled_down", (attribute, script) -> {
PropertyParser.<BukkitScriptProperties>registerTag("cooled_down", (attribute, script) -> {
PlayerTag player = (attribute.hasContext(1) ? PlayerTag.valueOf(attribute.getContext(1))
: ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer());
if (player != null && player.isValid()) {
return new ElementTag(CooldownCommand.checkCooldown(player, script.getContainer().getName()));
return new ElementTag(CooldownCommand.checkCooldown(player, script.script.getContainer().getName()));
}
else {
return null;
Expand All @@ -62,10 +62,10 @@ public static void registerTags() {
// @description
// Returns the time left for the player to cooldown for the script.
// -->
PropertyParser.<ScriptTag>registerTag("cooldown", (attribute, script) -> {
PropertyParser.<BukkitScriptProperties>registerTag("cooldown", (attribute, script) -> {
PlayerTag player = (attribute.hasContext(1) ? PlayerTag.valueOf(attribute.getContext(1))
: ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer());
return CooldownCommand.getCooldownDuration(player, script.getName());
return CooldownCommand.getCooldownDuration(player, script.script.getName());
});

// <--[tag]
Expand All @@ -75,11 +75,11 @@ public static void registerTags() {
// Returns the name of a script step that the player is currently on.
// Must be an INTERACT script.
// -->
PropertyParser.<ScriptTag>registerTag("step", (attribute, script) -> {
PropertyParser.<BukkitScriptProperties>registerTag("step", (attribute, script) -> {
PlayerTag player = (attribute.hasContext(1) ? PlayerTag.valueOf(attribute.getContext(1))
: ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer());
if (player != null && player.isValid()) {
return new ElementTag(InteractScriptHelper.getCurrentStep(player, script.getContainer().getName()));
return new ElementTag(InteractScriptHelper.getCurrentStep(player, script.script.getContainer().getName()));
}
else {
return null;
Expand Down
Expand Up @@ -139,9 +139,7 @@ public static void registerTags() {
// @description
// Returns a list of all items in the inventory.
// -->
PropertyParser.<InventoryTag>registerTag("list_contents", (attribute, object) -> {

InventoryContents contents = getFrom(object);
PropertyParser.<InventoryContents>registerTag("list_contents", (attribute, contents) -> {

// <--[tag]
// @attribute <InventoryTag.list_contents.simple>
Expand Down
Expand Up @@ -169,8 +169,8 @@ public static void registerTags() {
// @description
// Returns Denizen's holder ID for this inventory. (p@joe, l@123,321,123,world, etc.)
// -->
PropertyParser.<InventoryTag>registerTag("id_holder", (attribute, object) -> {
ObjectTag holder = getFrom(object).holder;
PropertyParser.<InventoryHolder>registerTag("id_holder", (attribute, object) -> {
ObjectTag holder = object.holder;
if (holder == null) {
return null;
}
Expand Down
Expand Up @@ -58,8 +58,8 @@ public static void registerTags() {
// @description
// Returns the name of the script that this inventory came from (if any).
// -->
PropertyParser.<InventoryTag>registerTag("script_name", (attribute, inventory) -> {
return new ElementTag(inventory.scriptName);
PropertyParser.<InventoryScriptName>registerTag("script_name", (attribute, inventory) -> {
return new ElementTag(inventory.inventory.scriptName);
});
}

Expand Down
Expand Up @@ -82,8 +82,8 @@ public static void registerTags() {
// @description
// Return the number of slots in the inventory.
// -->
PropertyParser.<InventoryTag>registerTag("size", (attribute, inventory) -> {
return new ElementTag(getFrom(inventory).getSize());
PropertyParser.<InventorySize>registerTag("size", (attribute, inventory) -> {
return new ElementTag(inventory.getSize());
});
}

Expand Down
Expand Up @@ -84,8 +84,8 @@ public static void registerTags() {
// @description
// Returns the title of the inventory.
// -->
PropertyParser.<InventoryTag>registerTag("title", (attribute, inventory) -> {
return new ElementTag(getFrom(inventory).getTitle());
PropertyParser.<InventoryTitle>registerTag("title", (attribute, inventory) -> {
return new ElementTag(inventory.getTitle());
});
}

Expand Down
Expand Up @@ -50,8 +50,8 @@ public static void registerTags() {
// @description
// Returns whether the trade has an experience reward.
// -->
PropertyParser.<TradeTag>registerTag("has_xp", (attribute, recipe) -> {
return new ElementTag(recipe.getRecipe().hasExperienceReward());
PropertyParser.<TradeHasXp>registerTag("has_xp", (attribute, recipe) -> {
return new ElementTag(recipe.recipe.getRecipe().hasExperienceReward());
});
}

Expand Down
Expand Up @@ -40,11 +40,15 @@ public String getPropertyString() {
if (recipe.getRecipe() == null) {
return null;
}
ListTag ingredients = new ListTag();
return getIngredientsList().identify();
}

public ListTag getIngredientsList() {
ListTag result = new ListTag();
for (ItemStack item : recipe.getRecipe().getIngredients()) {
ingredients.addObject(new ItemTag(item));
result.addObject(new ItemTag(item));
}
return ingredients.identify();
return result;
}

public String getPropertyId() {
Expand All @@ -60,12 +64,8 @@ public static void registerTags() {
// @description
// Returns the list of items required to make the trade.
// -->
PropertyParser.<TradeTag>registerTag("inputs", (attribute, recipe) -> {
ListTag result = new ListTag();
for (ItemStack item : recipe.getRecipe().getIngredients()) {
result.addObject(new ItemTag(item));
}
return result;
PropertyParser.<TradeInputs>registerTag("inputs", (attribute, recipe) -> {
return recipe.getIngredientsList();
});
}

Expand Down
Expand Up @@ -50,8 +50,8 @@ public static void registerTags() {
// @description
// Returns the maximum amount of times that the trade can be used.
// -->
PropertyParser.<TradeTag>registerTag("max_uses", (attribute, recipe) -> {
return new ElementTag(recipe.getRecipe().getMaxUses());
PropertyParser.<TradeMaxUses>registerTag("max_uses", (attribute, recipe) -> {
return new ElementTag(recipe.recipe.getRecipe().getMaxUses());
});
}

Expand Down
Expand Up @@ -52,8 +52,8 @@ public static void registerTags() {
// @description
// Returns what the trade will give the player.
// -->
PropertyParser.<TradeTag>registerTag("result", (attribute, recipe) -> {
return new ItemTag(recipe.getRecipe().getResult());
PropertyParser.<TradeResult>registerTag("result", (attribute, recipe) -> {
return new ItemTag(recipe.recipe.getRecipe().getResult());
});
}

Expand Down
Expand Up @@ -50,8 +50,8 @@ public static void registerTags() {
// @description
// Returns how many times the trade has been used.
// -->
PropertyParser.<TradeTag>registerTag("uses", (attribute, recipe) -> {
return new ElementTag(recipe.getRecipe().getUses());
PropertyParser.<TradeUses>registerTag("uses", (attribute, recipe) -> {
return new ElementTag(recipe.recipe.getRecipe().getUses());
});
}

Expand Down

0 comments on commit 6527ddf

Please sign in to comment.