Made ECR diffs more preview-friendly in future commits

This commit is contained in:
LAX1DUDE
2022-12-29 22:10:05 -08:00
parent 3d6bbb672c
commit 67a922d528
701 changed files with 3835 additions and 3747 deletions

View File

@ -7,9 +7,9 @@
> DELETE 2 @ 2 : 14
> DELETE 3 @ 15 : 23
> DELETE 1 @ 13 : 21
> INSERT 4 : 11 @ 24
> INSERT 1 : 8 @ 9
+ import org.json.JSONArray;
+ import org.json.JSONException;
@ -19,11 +19,11 @@
+ import net.lax1dude.eaglercraft.v1_8.json.JSONTypeProvider;
+
> CHANGE 30 : 31 @ 43 : 45
> CHANGE 26 : 27 @ 19 : 21
~ public static class Serializer implements JSONTypeCodec<IChatComponent, Object> {
> CHANGE 32 : 38 @ 46 : 53
> CHANGE 2 : 8 @ 3 : 10
~ public IChatComponent deserialize(Object parJsonElement) throws JSONException {
~ if (parJsonElement instanceof String) {
@ -32,138 +32,138 @@
~ if (parJsonElement instanceof JSONArray) {
~ JSONArray jsonarray1 = (JSONArray) parJsonElement;
> CHANGE 40 : 42 @ 55 : 58
> CHANGE 8 : 10 @ 9 : 12
~ for (Object jsonelement : jsonarray1) {
~ IChatComponent ichatcomponent1 = this.deserialize(jsonelement);
> CHANGE 51 : 53 @ 67 : 69
> CHANGE 11 : 13 @ 12 : 14
~ throw new JSONException("Don\'t know how to turn " + parJsonElement.getClass().getSimpleName()
~ + " into a Component");
> CHANGE 55 : 56 @ 71 : 72
> CHANGE 4 : 5 @ 4 : 5
~ JSONObject jsonobject = (JSONObject) parJsonElement;
> CHANGE 58 : 59 @ 74 : 75
> CHANGE 3 : 4 @ 3 : 4
~ object = new ChatComponentText(jsonobject.getString("text"));
> CHANGE 60 : 61 @ 76 : 77
> CHANGE 2 : 3 @ 2 : 3
~ String s = jsonobject.getString("translate");
> CHANGE 62 : 64 @ 78 : 80
> CHANGE 2 : 4 @ 2 : 4
~ JSONArray jsonarray = jsonobject.getJSONArray("with");
~ Object[] aobject = new Object[jsonarray.length()];
> CHANGE 66 : 67 @ 82 : 83
> CHANGE 4 : 5 @ 4 : 5
~ aobject[i] = this.deserialize(jsonarray.get(i));
> CHANGE 81 : 82 @ 97 : 98
> CHANGE 15 : 16 @ 15 : 16
~ JSONObject jsonobject1 = jsonobject.getJSONObject("score");
> CHANGE 83 : 84 @ 99 : 100
> CHANGE 2 : 3 @ 2 : 3
~ throw new JSONException("A score component needs a least a name and an objective");
> CHANGE 86 : 87 @ 102 : 104
> CHANGE 3 : 4 @ 3 : 5
~ object = new ChatComponentScore(jsonobject1.getString("name"), jsonobject1.getString("objective"));
> CHANGE 88 : 89 @ 105 : 106
> CHANGE 2 : 3 @ 3 : 4
~ ((ChatComponentScore) object).setValue(jsonobject1.getString("value"));
> CHANGE 92 : 93 @ 109 : 110
> CHANGE 4 : 5 @ 4 : 5
~ throw new JSONException(
> CHANGE 96 : 97 @ 113 : 114
> CHANGE 4 : 5 @ 4 : 5
~ object = new ChatComponentSelector(jsonobject.getString("selector"));
> CHANGE 100 : 103 @ 117 : 120
> CHANGE 4 : 7 @ 4 : 7
~ JSONArray jsonarray2 = jsonobject.getJSONArray("extra");
~ if (jsonarray2.length() <= 0) {
~ throw new JSONException("Unexpected empty array of components");
> CHANGE 105 : 107 @ 122 : 125
> CHANGE 5 : 7 @ 5 : 8
~ for (int j = 0; j < jsonarray2.length(); ++j) {
~ ((IChatComponent) object).appendSibling(this.deserialize(jsonarray2.get(j)));
> CHANGE 110 : 111 @ 128 : 130
> CHANGE 5 : 6 @ 6 : 8
~ ((IChatComponent) object).setChatStyle(JSONTypeProvider.deserialize(parJsonElement, ChatStyle.class));
> CHANGE 115 : 119 @ 134 : 142
> CHANGE 5 : 9 @ 6 : 14
~ private void serializeChatStyle(ChatStyle style, JSONObject object) {
~ JSONObject jsonelement = JSONTypeProvider.serialize(style);
~ for (String entry : jsonelement.keySet()) {
~ object.put(entry, jsonelement.get(entry));
> DELETE 120 @ 143 : 144
> DELETE 5 @ 9 : 10
> CHANGE 122 : 123 @ 146 : 148
> CHANGE 2 : 3 @ 3 : 5
~ public Object serialize(IChatComponent ichatcomponent) {
> CHANGE 125 : 126 @ 150 : 151
> CHANGE 3 : 4 @ 4 : 5
~ return ((ChatComponentText) ichatcomponent).getChatComponentText_TextValue();
> CHANGE 127 : 128 @ 152 : 153
> CHANGE 2 : 3 @ 2 : 3
~ JSONObject jsonobject = new JSONObject();
> CHANGE 129 : 130 @ 154 : 155
> CHANGE 2 : 3 @ 2 : 3
~ this.serializeChatStyle(ichatcomponent.getChatStyle(), jsonobject);
> CHANGE 133 : 134 @ 158 : 159
> CHANGE 4 : 5 @ 4 : 5
~ JSONArray jsonarray = new JSONArray();
> CHANGE 136 : 137 @ 161 : 163
> CHANGE 3 : 4 @ 3 : 5
~ jsonarray.put(this.serialize(ichatcomponent1));
> CHANGE 139 : 140 @ 165 : 166
> CHANGE 3 : 4 @ 4 : 5
~ jsonobject.put("extra", jsonarray);
> CHANGE 143 : 144 @ 169 : 171
> CHANGE 4 : 5 @ 4 : 6
~ jsonobject.put("text", ((ChatComponentText) ichatcomponent).getChatComponentText_TextValue());
> CHANGE 146 : 147 @ 173 : 174
> CHANGE 3 : 4 @ 4 : 5
~ jsonobject.put("translate", chatcomponenttranslation.getKey());
> CHANGE 149 : 150 @ 176 : 177
> CHANGE 3 : 4 @ 3 : 4
~ JSONArray jsonarray1 = new JSONArray();
> CHANGE 153 : 154 @ 180 : 182
> CHANGE 4 : 5 @ 4 : 6
~ jsonarray1.put(this.serialize((IChatComponent) object));
> CHANGE 155 : 156 @ 183 : 184
> CHANGE 2 : 3 @ 3 : 4
~ jsonarray1.put(String.valueOf(object));
> CHANGE 159 : 160 @ 187 : 188
> CHANGE 4 : 5 @ 4 : 5
~ jsonobject.put("with", jsonarray1);
> CHANGE 163 : 168 @ 191 : 196
> CHANGE 4 : 9 @ 4 : 9
~ JSONObject jsonobject1 = new JSONObject();
~ jsonobject1.put("name", chatcomponentscore.getName());
@ -171,17 +171,17 @@
~ jsonobject1.put("value", chatcomponentscore.getUnformattedTextForChat());
~ jsonobject.put("score", jsonobject1);
> CHANGE 175 : 176 @ 203 : 204
> CHANGE 12 : 13 @ 12 : 13
~ jsonobject.put("selector", chatcomponentselector.getSelector());
> INSERT 182 : 185 @ 210
> INSERT 7 : 10 @ 7
+ /**
+ * So sorry for this implementation
+ */
> CHANGE 186 : 192 @ 211 : 212
> CHANGE 4 : 10 @ 1 : 2
~ if (component instanceof ChatComponentText) {
~ String escaped = new JSONObject().put("E", component.getUnformattedTextForChat()).toString();
@ -190,15 +190,15 @@
~ return JSONTypeProvider.serialize(component).toString();
~ }
> CHANGE 195 : 196 @ 215 : 216
> CHANGE 9 : 10 @ 4 : 5
~ return (IChatComponent) JSONTypeProvider.deserialize(json, IChatComponent.class);
> INSERT 197 : 198 @ 217
> INSERT 2 : 3 @ 2
+ }
> CHANGE 199 : 212 @ 218 : 224
> CHANGE 2 : 15 @ 1 : 7
~ public static IChatComponent join(List<IChatComponent> components) {
~ ChatComponentText chatcomponenttext = new ChatComponentText("");
@ -214,7 +214,7 @@
~
~ chatcomponenttext.appendSibling((IChatComponent) components.get(i));
> INSERT 213 : 215 @ 225
> INSERT 14 : 16 @ 7
+
+ return chatcomponenttext;