Skip to content

Commit

Permalink
Format code [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 4, 2023
1 parent 6080297 commit 22e953b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import emu.grasscutter.data.common.DynamicFloat;
import emu.grasscutter.game.props.ElementType;
import emu.grasscutter.utils.objects.DropType;
import lombok.ToString;

import java.io.Serializable;
import lombok.ToString;

public class AbilityModifier implements Serializable {
private static final long serialVersionUID = -2001232313615923575L;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/emu/grasscutter/utils/JsonAdapters.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import emu.grasscutter.utils.objects.DropType;
import it.unimi.dsi.fastutil.floats.FloatArrayList;
import it.unimi.dsi.fastutil.ints.*;
import lombok.val;

import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
import lombok.val;

public interface JsonAdapters {
class DynamicFloatAdapter extends TypeAdapter<DynamicFloat> {
Expand Down Expand Up @@ -56,8 +55,7 @@ public void write(JsonWriter writer, DynamicFloat f) {}
class DropTypeAdapter extends TypeAdapter<DropType> {
@Override
public void write(JsonWriter out, DropType value) throws IOException {
if (value.isString())
out.value(value.getAsString());
if (value.isString()) out.value(value.getAsString());
else out.value(value.getAsInt());
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/emu/grasscutter/utils/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import emu.grasscutter.utils.JsonAdapters.*;
import emu.grasscutter.utils.objects.*;
import it.unimi.dsi.fastutil.ints.IntList;

import java.io.*;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/emu/grasscutter/utils/objects/DropType.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public DropType(int value) {

public DropType(String value) {
this.raw = value;
this.value = switch (value) {
default -> Integer.parseInt(value);
case "ForceDrop" -> 2;
};
this.value =
switch (value) {
default -> Integer.parseInt(value);
case "ForceDrop" -> 2;
};
}

/**
Expand All @@ -31,17 +32,15 @@ public boolean isString() {
* @return The drop type value as a string.
*/
public String getAsString() {
if (this.raw instanceof String)
return (String) this.raw;
if (this.raw instanceof String) return (String) this.raw;
throw new UnsupportedOperationException();
}

/**
* @return The drop type value as an integer.
*/
public int getAsInt() {
if (this.raw instanceof Integer)
return (int) this.raw;
if (this.raw instanceof Integer) return (int) this.raw;
throw new UnsupportedOperationException();
}
}

0 comments on commit 22e953b

Please sign in to comment.