Skip to content

Commit

Permalink
Fixed multiple actions not saving correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
ImCodist committed Jun 27, 2023
1 parent b923a4d commit 0cb2a8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/main/java/xyz/imcodist/data/ActionData.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import xyz.imcodist.data.command_actions.CommandActionData;

import java.util.ArrayList;
import java.util.HashMap;

public class ActionData {
public String name;
Expand All @@ -18,9 +17,15 @@ public ActionDataJSON toJSON() {
ActionDataJSON jsonData = new ActionDataJSON();

jsonData.name = name;
jsonData.actions = new HashMap<>();
jsonData.actions = new ArrayList<>();

actions.forEach((action) -> jsonData.actions.put(action.getJsonType(), action.getJsonValue()));
actions.forEach((action) -> {
ArrayList<String> actionArray = new ArrayList<>();
actionArray.add(action.getJsonType());
actionArray.add(action.getJsonValue());

jsonData.actions.add(actionArray);
});

if (icon != null) jsonData.icon = icon.getRegistryEntry().value().toString();

Expand All @@ -33,8 +38,8 @@ public static ActionData fromJSON(ActionDataJSON json) {
data.name = json.name;
data.actions = new ArrayList<>();

json.actions.forEach((k, v) -> {
BaseActionData actionData = getActionDataType(k, v);
json.actions.forEach((actionArray) -> {
BaseActionData actionData = getActionDataType(actionArray.get(0), actionArray.get(1));
data.actions.add(actionData);
});

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xyz/imcodist/data/ActionDataJSON.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package xyz.imcodist.data;

import java.util.Map;
import java.util.ArrayList;

public class ActionDataJSON {
public String name;
public Map<String, String> actions;
public ArrayList<ArrayList<String>> actions;
public String icon;
}

0 comments on commit 0cb2a8b

Please sign in to comment.