Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix case handling issues, fix to_json
  • Loading branch information
mcmonkey4eva committed Nov 24, 2019
1 parent 9e05e35 commit 2225740
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Expand Up @@ -445,7 +445,7 @@ public static void registerTags() {

registerTag("to_json", (attribute, object) -> {
JSONObject jsobj = new JSONObject(YamlConfiguration.reverse(object.container.getContents().getMap(), true));
jsobj.remove("TYPE");
jsobj.remove("type");
return new ElementTag(jsobj.toString());
});

Expand Down
Expand Up @@ -57,8 +57,13 @@ public class ScriptContainer implements Debuggable {
public ScriptContainer(YamlConfiguration configurationSection, String scriptContainerName) {
if (configurationSection == null) {
Debug.echoError("Null configuration section while generating a ScriptContainer?!");
throw new RuntimeException("Null configuration section while generating a ScriptContainer");
}
contents = configurationSection;
configurationSection.forceLoweredRootKey("type");
configurationSection.forceLoweredRootKey("debug");
configurationSection.forceLoweredRootKey("script");
configurationSection.forceLoweredRootKey("speed");
this.name = scriptContainerName.toUpperCase();
}

Expand Down Expand Up @@ -177,8 +182,8 @@ public ScriptTag getAsScriptArg() {
* @return the type of container
*/
public String getContainerType() {
return contents.contains("TYPE")
? contents.getString("TYPE").toUpperCase()
return contents.contains("type")
? contents.getString("type").toUpperCase()
: null;
}

Expand Down
Expand Up @@ -83,6 +83,15 @@ else if (patchLines && obj.getValue() instanceof List) {
return map;
}

public void forceLoweredRootKey(String keyName) {
StringHolder key = new StringHolder(CoreUtilities.toLowerCase(keyName));
Object obj = contents.get(key);
if (obj != null) {
contents.remove(key);
contents.put(key, obj);
}
}

public static List<String> patchListNonsense(List<Object> objs) {
List<String> list = new ArrayList<>();
for (Object o : objs) {
Expand Down

0 comments on commit 2225740

Please sign in to comment.