Skip to content
Permalink
Browse files

use new property update

  • Loading branch information...
mcmonkey4eva committed Jan 20, 2019
1 parent 3aa5de4 commit e9a265dd811b603df6469264950785fdb0a98f50
@@ -1,7 +1,5 @@
package 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;
@@ -10,8 +8,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
@@ -200,7 +196,7 @@ public Duration(int seconds) {
* @param ticks the number of ticks.
*/
public Duration(long ticks) {
this.seconds = ticks / 20;
this.seconds = ticks / 20.0;
if (this.seconds < 0) {
this.seconds = 0;
}
@@ -654,7 +650,7 @@ public String run(Attribute attribute, dObject object) {

}

public static HashMap<String, TagRunnable> registeredTags = new HashMap<String, TagRunnable>();
public static HashMap<String, TagRunnable> registeredTags = new HashMap<>();

public static void registerTag(String name, TagRunnable runnable) {
if (runnable.name == null) {
@@ -682,12 +678,9 @@ public String getAttribute(Attribute attribute) {
return tr.run(attribute, this);
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this, attrLow)) {
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);
@@ -1,7 +1,5 @@
package net.aufdemrand.denizencore.objects;

import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.scripts.commands.core.Comparable;
import net.aufdemrand.denizencore.scripts.queues.ScriptQueue;
import net.aufdemrand.denizencore.tags.Attribute;
@@ -238,7 +236,7 @@ public boolean isBoolean() {

public boolean isDouble() {
try {
if (Double.valueOf(element) != null) {
if (!Double.valueOf(element).isNaN()) {
return true;
}
}
@@ -249,7 +247,7 @@ public boolean isDouble() {

public boolean isFloat() {
try {
if (Float.valueOf(element) != null) {
if (!Float.valueOf(element).isNaN()) {
return true;
}
}
@@ -260,7 +258,8 @@ public boolean isFloat() {

public boolean isInt() {
try {
if (Integer.valueOf(element.replaceAll("(%)|(\\.\\d+)", "")) != null) {
Integer val = Integer.valueOf(element.replaceAll("(%)|(\\.\\d+)", ""));
if (val.hashCode() != 0.5) { // if intentionally always passes
return true;
}
}
@@ -2373,7 +2372,7 @@ public dObject run(Attribute attribute, dObject object) {

//public static HashMap<String, TagRunnable> registeredTags = new HashMap<String, TagRunnable>();

public static HashMap<String, TagRunnable.ObjectForm> registeredObjectTags = new HashMap<String, TagRunnable.ObjectForm>();
public static HashMap<String, TagRunnable.ObjectForm> registeredObjectTags = new HashMap<>();

public static void registerTag(String name, TagRunnable.ObjectForm runnable) {
if (runnable.name == null) {
@@ -2485,15 +2484,9 @@ public dObject getObjectAttribute(Attribute attribute) {
}
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this, attrLow)) {
dObject returned = CoreUtilities.autoAttrib(property, attribute);
if (returned != null) {
if (dB.verbose) {
dB.log("Element - Property success! Return " + returned.toString());
}
return returned;
}
dObject returned = CoreUtilities.autoPropertyTagObject(this, attribute);
if (returned != null) {
return returned;
}

if (attribute.isComplete()) {
@@ -1,8 +1,6 @@
package net.aufdemrand.denizencore.objects;

import net.aufdemrand.denizencore.DenizenCore;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.scripts.ScriptBuilder;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.commands.core.DetermineCommand;
@@ -117,15 +115,15 @@ public static boolean matches(String arg) {

// A list of dObjects
public dList(Collection<? extends dObject> dObjectList) {
objectForms = new ArrayList<dObject>(dObjectList);
objectForms = new ArrayList<>(dObjectList);
for (dObject obj : dObjectList) {
super.add(obj.identify());
}
}

// Empty dList
public dList() {
objectForms = new ArrayList<dObject>();
objectForms = new ArrayList<>();
}

// A string of items, split by '|'
@@ -158,7 +156,7 @@ else if ((brackets == 0) && (chr == '|' || chr == internal_escape_char)) {
super.add(items.substring(start, items.length()));
}
}
objectForms = new ArrayList<dObject>(size());
objectForms = new ArrayList<>(size());
for (String str : this) {
objectForms.add(new Element(str));
}
@@ -171,14 +169,14 @@ public dList(String flag, boolean is_flag, List<String> flag_contents) {
for (String it : flag_contents) {
super.add(it);
}
objectForms = new ArrayList<dObject>(size());
objectForms = new ArrayList<>(size());
for (String str : this) {
objectForms.add(new Element(str));
}
}

public dList(dList input) {
objectForms = new ArrayList<dObject>(input.objectForms);
objectForms = new ArrayList<>(input.objectForms);
super.ensureCapacity(input.size());
for (String str : input) {
super.add(str);
@@ -192,15 +190,15 @@ public dList(List<String> items) {
super.add(it);
}
}
objectForms = new ArrayList<dObject>(size());
objectForms = new ArrayList<>(size());
for (String str : this) {
objectForms.add(new Element(str));
}
}

// A Set<Object> of items
public dList(Set<? extends Object> items) {
objectForms = new ArrayList<dObject>();
public dList(Set<?> items) {
objectForms = new ArrayList<>();
if (items != null) {
for (Object o : items) {
String strd = o.toString();
@@ -220,7 +218,7 @@ public dList(List<String> items, String prefix) {
for (String element : items) {
super.add(prefix + element);
}
objectForms = new ArrayList<dObject>(size());
objectForms = new ArrayList<>(size());
for (String str : this) {
objectForms.add(new Element(str));
}
@@ -255,7 +253,7 @@ public dList addObjects(List<dObject> dObjects) {
* @return the array copy
*/
public String[] toArray(int arraySize) { // TODO: Why does this exist?
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();

for (String string : this) {
list.add(string); // TODO: Why is this a manual copy?
@@ -287,7 +285,7 @@ public boolean containsObjectsFrom(Class<? extends dObject> dClass) {
* @return a filtered list
*/
public List<String> filter(Enum[] values) {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();

for (String string : this) {
for (Enum value : values) {
@@ -313,7 +311,7 @@ public boolean containsObjectsFrom(Class<? extends dObject> dClass) {


public <T extends dObject> List<T> filter(Class<T> dClass, ScriptEntry entry) {
List<T> results = new ArrayList<T>();
List<T> results = new ArrayList<>();

TagContext context = (entry == null ? DenizenCore.getImplementation().getTagContext(null) :
entry.entryData.getTagContext());
@@ -916,7 +914,7 @@ public dObject run(Attribute attribute, dObject object) {
registerTag("reverse", new TagRunnable.ObjectForm() {
@Override
public dObject run(Attribute attribute, dObject object) {
ArrayList<dObject> objs = new ArrayList<dObject>(((dList) object).objectForms);
ArrayList<dObject> objs = new ArrayList<>(((dList) object).objectForms);
Collections.reverse(objs);
return new dList(objs).getObjectAttribute(attribute.fulfill(1));
}
@@ -1273,7 +1271,7 @@ public dObject run(Attribute attribute, dObject object) {
registerTag("numerical", new TagRunnable.ObjectForm() {
@Override
public dObject run(Attribute attribute, dObject object) {
ArrayList<String> sortable = new ArrayList<String>((dList) object);
ArrayList<String> sortable = new ArrayList<>((dList) object);
Collections.sort(sortable, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
@@ -1304,7 +1302,7 @@ else if (value > 0) {
registerTag("alphanumeric", new TagRunnable.ObjectForm() {
@Override
public dObject run(Attribute attribute, dObject object) {
ArrayList<String> sortable = new ArrayList<String>((dList) object);
ArrayList<String> sortable = new ArrayList<>((dList) object);
Collections.sort(sortable, new NaturalOrderComparator());
return new dList(sortable).getObjectAttribute(attribute.fulfill(1));
}
@@ -1321,7 +1319,7 @@ public dObject run(Attribute attribute, dObject object) {
registerTag("alphabetical", new TagRunnable.ObjectForm() {
@Override
public dObject run(Attribute attribute, dObject object) {
ArrayList<String> sortable = new ArrayList<String>((dList) object);
ArrayList<String> sortable = new ArrayList<>((dList) object);
Collections.sort(sortable, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
@@ -1412,7 +1410,7 @@ public dObject run(Attribute attribute, dObject object) {
attribute = attribute.fulfill(1);
}
final dList context_send = context;
List<String> list = new ArrayList<String>(obj);
List<String> list = new ArrayList<>(obj);
try {
Collections.sort(list, new Comparator<String>() {
@Override
@@ -1807,7 +1805,7 @@ public dObject run(Attribute attribute, dObject object) {
if (attribute.hasContext(1)) {
int count = Integer.valueOf(attribute.getContext(1));
int times = 0;
ArrayList<dObject> available = new ArrayList<dObject>();
ArrayList<dObject> available = new ArrayList<>();
available.addAll(obj.objectForms);
dList toReturn = new dList();
while (!available.isEmpty() && times < count) {
@@ -1901,7 +1899,7 @@ public dObject run(Attribute attribute, dObject object) {

//public static HashMap<String, TagRunnable> registeredTags = new HashMap<String, TagRunnable>();

public static HashMap<String, TagRunnable.ObjectForm> registeredObjectTags = new HashMap<String, TagRunnable.ObjectForm>();
public static HashMap<String, TagRunnable.ObjectForm> registeredObjectTags = new HashMap<>();

public static void registerTag(String name, TagRunnable.ObjectForm runnable) {
if (runnable.name == null) {
@@ -2010,12 +2008,10 @@ public dObject getObjectAttribute(Attribute attribute) {
return new dList(this).getObjectAttribute(attribute.fulfill(1));
}

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

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

// If this is a flag, return the last element (this is how it has always worked...)
@@ -1,8 +1,6 @@
package net.aufdemrand.denizencore.objects;

import net.aufdemrand.denizencore.DenizenCore;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.scripts.queues.ScriptQueue;
@@ -541,7 +539,7 @@ public String run(Attribute attribute, dObject object) {
});
}

public static HashMap<String, TagRunnable> registeredTags = new HashMap<String, TagRunnable>();
public static HashMap<String, TagRunnable> registeredTags = new HashMap<>();

public static void registerTag(String name, TagRunnable runnable) {
if (runnable.name == null) {
@@ -566,12 +564,9 @@ public String getAttribute(Attribute attribute) {
return tr.run(attribute, this);
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this, attrLow)) {
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);

0 comments on commit e9a265d

Please sign in to comment.
You can’t perform that action at this time.