Upload files to "src/openonyx/history/internal"
This commit is contained in:
1 parent
8d3ce6856e
commit
77493827f8
5 files changed
+950
No files matched your search
@@ -0,0 +1,171 @@
|
||||
package openonyx.history.internal;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import openonyx.history.SettingValue;
|
||||
import openonyx.utilities.ItemSpec;
|
||||
|
||||
public class ItemListSetting extends SettingValue<List<ItemSpec>> {
|
||||
public ItemListSetting describe(String string) {
|
||||
super.describe(string);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void D(ItemSpec itemSpec) {
|
||||
if (this.L(itemSpec)) {
|
||||
this.L(itemSpec);
|
||||
} else {
|
||||
this.d(itemSpec);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemListSetting visibleWhen(SettingValue<Boolean> settingValue) {
|
||||
super.visibleWhen(settingValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemListSetting(String string, String... strings) {
|
||||
super(string, L(strings));
|
||||
}
|
||||
|
||||
public boolean L(ItemStack itemStack) {
|
||||
ItemListSetting itemListSetting1 = this;
|
||||
Iterator iterator = itemListSetting1.getValue().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
if (((ItemSpec)iterator.next()).L(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void d(ItemSpec itemSpec) {
|
||||
if (itemSpec != null && !this.L(itemSpec)) {
|
||||
ArrayList arrayList;
|
||||
(arrayList = new ArrayList<>(this.getValue())).add(itemSpec);
|
||||
this.setValue(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ItemSpec> L(String... strings) {
|
||||
String[] strings1 = strings;
|
||||
ArrayList arrayList = new ArrayList();
|
||||
String[] strings2 = strings1;
|
||||
int j = strings1.length;
|
||||
|
||||
int i;
|
||||
for (int k = i = 0; k < j; k = ++i) {
|
||||
ItemSpec itemSpec;
|
||||
if ((itemSpec = ItemSpec.d(strings2[i])) != null && !arrayList.contains(itemSpec)) {
|
||||
arrayList.add(itemSpec);
|
||||
}
|
||||
}
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public ItemListSetting visibleWhen(BooleanSupplier booleanSupplier) {
|
||||
super.visibleWhen(booleanSupplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemListSetting onChange(Consumer<List<ItemSpec>> consumer) {
|
||||
super.onChange(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
ItemListSetting itemListSetting1 = this;
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
Iterator iterator;
|
||||
Iterator iterator1 = iterator = itemListSetting1.getValue().iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
ItemSpec itemSpec = (ItemSpec)iterator.next();
|
||||
iterator1 = iterator;
|
||||
jsonArray.add(new JsonPrimitive(itemSpec.L()));
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
protected List<ItemSpec> L(List<ItemSpec> list) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (list == null) {
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ItemSpec itemSpec;
|
||||
if ((itemSpec = (ItemSpec)iterator.next()) != null && !arrayList.contains(itemSpec)) {
|
||||
arrayList.add(itemSpec);
|
||||
}
|
||||
}
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public <O> ItemListSetting visibleWhen(SettingValue<O> settingValue, Predicate<O> predicate) {
|
||||
super.visibleWhen(settingValue, predicate);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJson(JsonElement jsonElement) {
|
||||
ItemListSetting itemListSetting1 = this;
|
||||
if (jsonElement.isJsonArray()) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator iterator = jsonElement.getAsJsonArray().iterator();
|
||||
|
||||
label31:
|
||||
while (true) {
|
||||
for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) {
|
||||
JsonElement jsonElement1;
|
||||
if (!(jsonElement1 = (JsonElement)iterator.next()).isJsonPrimitive()) {
|
||||
continue label31;
|
||||
}
|
||||
|
||||
if (jsonElement1.getAsJsonPrimitive().isString()) {
|
||||
ItemSpec itemSpec;
|
||||
if ((itemSpec = ItemSpec.d(jsonElement1.getAsString())) != null && !arrayList.contains(itemSpec)) {
|
||||
arrayList.add(itemSpec);
|
||||
}
|
||||
continue label31;
|
||||
}
|
||||
}
|
||||
|
||||
itemListSetting1.setValue(arrayList);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void L(ItemSpec itemSpec) {
|
||||
if (itemSpec != null && this.L(itemSpec)) {
|
||||
ArrayList arrayList;
|
||||
(arrayList = new ArrayList<>(this.getValue())).remove(itemSpec);
|
||||
this.setValue(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean L(ItemSpec itemSpec) {
|
||||
return this.getValue().contains(itemSpec);
|
||||
}
|
||||
|
||||
public void D() {
|
||||
this.setValue(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user