Skip to content

Commit

Permalink
Verbosify some things, fix some things
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 14, 2015
1 parent e2cf57d commit f68304f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ public static <T extends dObject> T getObjectFrom(Class<T> dClass, String value,
T gotten = (T) valueof.get(dClass).invoke(null, matched ? matches.get(0): value, context);
if (gotten != null && matched) {
for (int i = 1; i < matches.size(); i++) {
Object[] data = CoreUtilities.split(matches.get(i), '=', 2).toArray();
if (data.length != 2) {
List<String> data = CoreUtilities.split(matches.get(i), '=', 2);
if (data.size() != 2) {
dB.echoError("Invalid property string '" + matches.get(i) + "'!");
continue;
}
((Adjustable) gotten).applyProperty(new Mechanism(new Element((String)data[0]),
new Element(((String)data[1]).replace((char)0x2011, ';'))));
((Adjustable) gotten).applyProperty(new Mechanism(new Element(data.get(0)),
new Element((data.get(1)).replace((char)0x2011, ';'))));
}
}
return gotten;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/aufdemrand/denizencore/objects/aH.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ public Argument(String string) {
}
else {
has_prefix = true;
Object[] split = CoreUtilities.split(string, ':', 2).toArray();
prefix = (String)split[0];
List<String> split = CoreUtilities.split(string, ':', 2);
prefix = split.get(0);
lower_prefix = CoreUtilities.toLowerCase(prefix);
if (split.length == 2)
value = (String)split[1];
if (split.size() == 2)
value = split.get(1);
else
value = "";
lower_value = CoreUtilities.toLowerCase(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.aufdemrand.denizencore.utilities;

import net.aufdemrand.denizencore.utilities.debugging.dB;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
Expand Down Expand Up @@ -64,16 +66,31 @@ public static List<String> split(String str, char c) {
return strings;
}

public static String concat(List<String> str, String split) {
StringBuilder sb = new StringBuilder();
if (str.size() > 0) {
sb.append(str.get(0));
}
for (int i = 1; i < str.size(); i++) {
sb.append(split).append(str.get(i));
}
return sb.toString();
}

public static List<String> split(String str, char c, int max) {
List<String> strings = new ArrayList<String>();
int start = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == c) {
strings.add(str.substring(start, i));
start = i + 1;
if (strings.size() + 1 == max) {
break;
}
}
}
strings.add(str.substring(start, str.length()));
if (dB.verbose) dB.log("Splitting " + str + " around " + c + " limited to " + max + " returns " + concat(strings, ":::"));
return strings;
}

Expand Down

0 comments on commit f68304f

Please sign in to comment.