Skip to content

Commit

Permalink
use new core update
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 20, 2019
1 parent 2fe2094 commit e1eac3c
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 251 deletions.
28 changes: 4 additions & 24 deletions plugin/src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -787,30 +787,10 @@ public void onEnable() {
dMaterial._initialize();

// register properties that add Bukkit code to core objects
PropertyParser.registerProperty(new PropertyParser.PropertyGetter() {
@Override
public Property get(dObject o) {
return BukkitScriptProperties.getFrom(o);
}
}, dScript.class, "cooled_down", "requirements", "cooldown", "step");
PropertyParser.registerProperty(new PropertyParser.PropertyGetter() {
@Override
public Property get(dObject o) {
return BukkitQueueProperties.getFrom(o);
}
}, ScriptQueue.class, "npc", "player");
PropertyParser.registerProperty(new PropertyParser.PropertyGetter() {
@Override
public Property get(dObject o) {
return BukkitElementProperties.getFrom(o);
}
}, Element.class, BukkitElementProperties.handledAttribs);
PropertyParser.registerProperty(new PropertyParser.PropertyGetter() {
@Override
public Property get(dObject o) {
return BukkitListProperties.getFrom(o);
}
}, dList.class, "formatted", "expiration");
PropertyParser.registerProperty(BukkitScriptProperties.class, dScript.class);
PropertyParser.registerProperty(BukkitQueueProperties.class, ScriptQueue.class);
PropertyParser.registerProperty(BukkitElementProperties.class, Element.class);
PropertyParser.registerProperty(BukkitListProperties.class, dList.class);

// register core dEntity properties
PropertyParser.registerProperty(EntityAge.class, dEntity.class);
Expand Down
23 changes: 4 additions & 19 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dChunk.java
Expand Up @@ -5,8 +5,6 @@
import net.aufdemrand.denizen.utilities.blocks.FakeBlock;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
Expand Down Expand Up @@ -496,12 +494,9 @@ public String getAttribute(Attribute attribute) {
return tr.run(attribute, this);
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand Down Expand Up @@ -621,16 +616,6 @@ public void run() {
NMSHandler.getInstance().getChunkHelper().refreshChunkSections(chunk);
}

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
}

// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
if (mechanism.fulfilled()) {
break;
}
}
CoreUtilities.autoPropertyMechanism(this, mechanism);
}
}
11 changes: 3 additions & 8 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dColor.java
Expand Up @@ -2,8 +2,6 @@

import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
Expand Down Expand Up @@ -400,12 +398,9 @@ public String getAttribute(Attribute attribute) {
return tr.run(attribute, this);
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand Down
23 changes: 4 additions & 19 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dCuboid.java
Expand Up @@ -11,8 +11,6 @@
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.notable.Notable;
import net.aufdemrand.denizencore.objects.notable.Note;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
Expand Down Expand Up @@ -1389,12 +1387,9 @@ public String getAttribute(Attribute attribute) {
return tr.run(attribute, this);
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand Down Expand Up @@ -1461,17 +1456,7 @@ public void adjust(Mechanism mechanism) {
return;
}

// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
if (mechanism.fulfilled()) {
break;
}
}

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
}
CoreUtilities.autoPropertyMechanism(this, mechanism);

}
}
Expand Up @@ -4,8 +4,6 @@
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.notable.Notable;
import net.aufdemrand.denizencore.objects.notable.Note;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
Expand Down Expand Up @@ -294,12 +292,10 @@ public String getAttribute(Attribute attribute) {
}
return tr.run(attribute, this);
}
// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}

String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand Down
77 changes: 35 additions & 42 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dInventory.java
Expand Up @@ -17,7 +17,6 @@
import net.aufdemrand.denizencore.objects.aH.PrimitiveType;
import net.aufdemrand.denizencore.objects.notable.Notable;
import net.aufdemrand.denizencore.objects.notable.Note;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.tags.Attribute;
Expand Down Expand Up @@ -2129,12 +2128,9 @@ else if (slot > getInventory().getSize() - 1) {
return new Element("Inventory").getAttribute(attribute.fulfill(1));
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand All @@ -2157,27 +2153,20 @@ else if (!(idType.equals("location") && mechanism.matches("title"))) {
@Override
public void adjust(Mechanism mechanism) {

// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
if (mechanism.fulfilled()) {
break;
}
}

if (inventory instanceof CraftingInventory) {
CraftingInventory craftingInventory = (CraftingInventory) inventory;
CoreUtilities.autoPropertyMechanism(this, mechanism);

// <--[mechanism]
// @object dInventory
// @name matrix
// @input dList(dItem)
// @description
// Sets the items in the matrix slots of this crafting inventory.
// @tags
// <in@inventory.matrix>
// -->
if (mechanism.matches("matrix") && mechanism.requireObject(dList.class)) {
// <--[mechanism]
// @object dInventory
// @name matrix
// @input dList(dItem)
// @description
// Sets the items in the matrix slots of this crafting inventory.
// @tags
// <in@inventory.matrix>
// -->
if (mechanism.matches("matrix") && mechanism.requireObject(dList.class)) {
if (inventory instanceof CraftingInventory) {
CraftingInventory craftingInventory = (CraftingInventory) inventory;
List<dItem> items = mechanism.getValue().asType(dList.class).filter(dItem.class);
ItemStack[] itemStacks = new ItemStack[9];
for (int i = 0; i < 9 && i < items.size(); i++) {
Expand All @@ -2186,25 +2175,29 @@ public void adjust(Mechanism mechanism) {
craftingInventory.setMatrix(itemStacks);
((Player) inventory.getHolder()).updateInventory();
}
else {
dB.echoError("Inventory is not a crafting inventory, cannot set matrix.");
}
}

// <--[mechanism]
// @object dInventory
// @name result
// @input dItem
// @description
// Sets the item in the result slot of this crafting inventory.
// @tags
// <in@inventory.result>
// -->
if (mechanism.matches("result") && mechanism.requireObject(dItem.class)) {
// <--[mechanism]
// @object dInventory
// @name result
// @input dItem
// @description
// Sets the item in the result slot of this crafting inventory.
// @tags
// <in@inventory.result>
// -->
if (mechanism.matches("result") && mechanism.requireObject(dItem.class)) {
if (inventory instanceof CraftingInventory) {
CraftingInventory craftingInventory = (CraftingInventory) inventory;
craftingInventory.setResult(mechanism.getValue().asType(dItem.class).getItemStack());
((Player) inventory.getHolder()).updateInventory();
}
else {
dB.echoError("Inventory is not a crafting inventory, cannot set result.");
}
}

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
}

}
}
23 changes: 4 additions & 19 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dItem.java
Expand Up @@ -15,7 +15,6 @@
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.notable.Notable;
import net.aufdemrand.denizencore.objects.notable.Note;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.tags.Attribute;
Expand Down Expand Up @@ -1039,12 +1038,9 @@ public String getAttribute(Attribute attribute) {
}
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand All @@ -1058,17 +1054,6 @@ public void applyProperty(Mechanism mechanism) {
@Override
public void adjust(Mechanism mechanism) {

// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
if (mechanism.fulfilled()) {
break;
}
}

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
}

CoreUtilities.autoPropertyMechanism(this, mechanism);
}
}
15 changes: 4 additions & 11 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -19,8 +19,6 @@
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.notable.Notable;
import net.aufdemrand.denizencore.objects.notable.Note;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.tags.core.EscapeTags;
Expand Down Expand Up @@ -2168,12 +2166,9 @@ else if (this.getWorld() == toLocation.getWorld()) {
}
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
Expand Down Expand Up @@ -2538,8 +2533,6 @@ else if (getBlock().getType() == Material.FLOWER_POT) {
}
}

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
}
CoreUtilities.autoPropertyMechanism(this, mechanism);
}
}

0 comments on commit e1eac3c

Please sign in to comment.