Skip to content

Commit

Permalink
fix(tsl): EITHER action omitting displaying message
Browse files Browse the repository at this point in the history
Closes #21
  • Loading branch information
iGoodie committed Jan 1, 2020
1 parent 93514f4 commit 07a2763
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false

mod_id=twitchspawn
mod_group=net.programmer.igoodie
mod_version=0.4.9
mod_version=0.4.10

minecraft_version=1.12.2
forge_version=14.23.3.2655
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package net.programmer.igoodie.twitchspawn.configuration.validation;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import java.util.Map;

public class JSONValidator {

private JsonObject actualJson;
private JsonObject expectedJson;
private JsonObject builtJson;

public JSONValidator(String actualScript, String defaultScript) {
Gson gson = new Gson();
this.actualJson = gson.fromJson(actualScript, JsonObject.class);
this.expectedJson = gson.fromJson(actualScript, JsonObject.class);
this.builtJson = new JsonObject();
}

public boolean isValid() {
return false; // TODO
}

public JsonObject validate() {


return builtJson;
}

private JsonObject validate(JsonObject actualJson, JsonObject expectedJson) {
JsonObject validated = new JsonObject();

// Traverse each key-value pair in Expected JSON
for (Map.Entry<String, JsonElement> property : expectedJson.entrySet()) {
String key = property.getKey();
JsonElement expectedValue = property.getValue();

// Value in the Expected JSON is a primitive
// if (expectedValue.isJsonPrimitive()) {
// validated.add(key, actualJson.has(key) && actualJson.get(key).getClass()
// ? actualJson.get(key)
// : expectedValue);
// }

// Value in the Expected JSON is an array
if(expectedValue.isJsonArray()) {

}
}

return validated;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ protected void performAction(EntityPlayerMP player, EventArguments args) {

selectedAction.performAction(player, args); // No need to include notification
selectedAction = actions.randomItem();
message = selectedAction.message;
}

@Override
Expand Down

0 comments on commit 07a2763

Please sign in to comment.