feature/d01-component-system #5

Merged
NotEvil merged 20 commits from feature/d01-component-system into develop 2026-04-14 00:54:17 +00:00
4 changed files with 74 additions and 0 deletions
Showing only changes of commit b8a0d839f5 - Show all commits

View File

@@ -0,0 +1,38 @@
package com.tiedup.remake.v2.bondage.component;
import com.google.gson.JsonObject;
import java.util.function.Function;
import org.jetbrains.annotations.Nullable;
public enum ComponentType {
LOCKABLE("lockable", LockableComponent::fromJson),
RESISTANCE("resistance", ResistanceComponent::fromJson),
GAGGING("gagging", GaggingComponent::fromJson);
private final String jsonKey;
private final Function<JsonObject, IItemComponent> factory;
ComponentType(
String jsonKey,
Function<JsonObject, IItemComponent> factory
) {
this.jsonKey = jsonKey;
this.factory = factory;
}
public String getJsonKey() {
return jsonKey;
}
public IItemComponent create(JsonObject config) {
return factory.apply(config);
}
@Nullable
public static ComponentType fromKey(String key) {
for (ComponentType type : values()) {
if (type.jsonKey.equals(key)) return type;
}
return null;
}
}

View File

@@ -0,0 +1,12 @@
package com.tiedup.remake.v2.bondage.component;
import com.google.gson.JsonObject;
public class GaggingComponent implements IItemComponent {
private GaggingComponent() {}
public static IItemComponent fromJson(JsonObject config) {
return new GaggingComponent();
}
}

View File

@@ -0,0 +1,12 @@
package com.tiedup.remake.v2.bondage.component;
import com.google.gson.JsonObject;
public class LockableComponent implements IItemComponent {
private LockableComponent() {}
public static IItemComponent fromJson(JsonObject config) {
return new LockableComponent();
}
}

View File

@@ -0,0 +1,12 @@
package com.tiedup.remake.v2.bondage.component;
import com.google.gson.JsonObject;
public class ResistanceComponent implements IItemComponent {
private ResistanceComponent() {}
public static IItemComponent fromJson(JsonObject config) {
return new ResistanceComponent();
}
}