Dieser Commit ist enthalten in:
Ursprung
5558d9ccf7
Commit
96b73f2d28
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.inventory;
|
package de.steamwar.inventory;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
@ -374,6 +377,16 @@ public class SchematicSelector {
|
|||||||
|
|
||||||
if (!filterCache.containsKey(player)) {
|
if (!filterCache.containsKey(player)) {
|
||||||
filterCache.put(player, new SelectorFilter[9]);
|
filterCache.put(player, new SelectorFilter[9]);
|
||||||
|
|
||||||
|
String cfg = UserConfig.getConfig(user.getId(), "selector:filters");
|
||||||
|
|
||||||
|
if (cfg != null) {
|
||||||
|
JsonArray array = JsonParser.parseString(cfg).getAsJsonArray();
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JsonObject object = array.get(i).getAsJsonObject();
|
||||||
|
filterCache.get(player)[i] = new SelectorFilter(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectorFilter[] filters = filterCache.get(player);
|
SelectorFilter[] filters = filterCache.get(player);
|
||||||
@ -381,7 +394,7 @@ public class SchematicSelector {
|
|||||||
for (int i = 0; i < filters.length; i++) {
|
for (int i = 0; i < filters.length; i++) {
|
||||||
SelectorFilter filterCached = filters[i];
|
SelectorFilter filterCached = filters[i];
|
||||||
if (filterCached == null) {
|
if (filterCached == null) {
|
||||||
inv.setItem(i + 9, new SWItem(Material.BARRIER, "SCHEM_SELECTOR_FILTER_EMPTY", click -> {}));
|
inv.setItem(i + 9, new SWItem(Material.BARRIER, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_EMPTY", player), click -> {}));
|
||||||
} else {
|
} else {
|
||||||
SWItem item = filterCached.toItemStack(player);
|
SWItem item = filterCached.toItemStack(player);
|
||||||
item.setEnchanted(filterCached.equals(filter));
|
item.setEnchanted(filterCached.equals(filter));
|
||||||
@ -413,6 +426,14 @@ public class SchematicSelector {
|
|||||||
filters[0] = filter;
|
filters[0] = filter;
|
||||||
|
|
||||||
filterCache.put(player, filters);
|
filterCache.put(player, filters);
|
||||||
|
JsonArray array = new JsonArray();
|
||||||
|
for (SelectorFilter f : filters) {
|
||||||
|
if (f != null) {
|
||||||
|
array.add(f.toJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UserConfig.updatePlayerConfig(user.getId(), "selector:filters", array.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
injectable.onFilterApply(this);
|
injectable.onFilterApply(this);
|
||||||
@ -526,6 +547,13 @@ public class SchematicSelector {
|
|||||||
private final SchematicType type;
|
private final SchematicType type;
|
||||||
private final Material item;
|
private final Material item;
|
||||||
|
|
||||||
|
public SelectorFilter(JsonObject object) {
|
||||||
|
this.name = object.get("name").isJsonNull() ? null : object.get("name").getAsString();
|
||||||
|
this.owner = object.get("owner").isJsonNull() ? null : object.get("owner").getAsInt();
|
||||||
|
this.type = object.get("type").isJsonNull() ? null : SchematicType.fromDB(object.get("type").getAsString());
|
||||||
|
this.item = object.get("item").isJsonNull() ? null : Material.valueOf(object.get("item").getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean matches(SchematicNode node) {
|
public boolean matches(SchematicNode node) {
|
||||||
boolean matches = name == null || node.getName().contains(name);
|
boolean matches = name == null || node.getName().contains(name);
|
||||||
|
|
||||||
@ -594,6 +622,16 @@ public class SchematicSelector {
|
|||||||
return new SWItem(Material.BARRIER, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TITLE_EMPTY", player), Collections.emptyList(), false, click -> {});
|
return new SWItem(Material.BARRIER, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TITLE_EMPTY", player), Collections.emptyList(), false, click -> {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonObject toJson() {
|
||||||
|
JsonObject object = new JsonObject();
|
||||||
|
object.addProperty("name", name);
|
||||||
|
object.addProperty("owner", owner);
|
||||||
|
object.addProperty("type", type == null?null:type.toDB());
|
||||||
|
object.addProperty("item", item == null?null:item.name());
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PublicMode {
|
public enum PublicMode {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren