mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
Rewrote block parsing, and further switch to BlockState
This commit is contained in:
@ -196,7 +196,7 @@ public class BundledBlockData {
|
||||
private String unlocalizedName;
|
||||
public String localizedName;
|
||||
private List<String> aliases;
|
||||
private Map<String, SimpleState> states = new HashMap<>();
|
||||
public Map<String, SimpleState> states = new HashMap<>();
|
||||
private SimpleBlockMaterial material = new SimpleBlockMaterial();
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,9 @@ import com.sk89q.worldedit.world.registry.state.value.SimpleStateValue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SimpleState<T extends SimpleStateValue> implements State<T> {
|
||||
|
||||
@ -41,4 +44,10 @@ public class SimpleState<T extends SimpleStateValue> implements State<T> {
|
||||
public List<T> getValues() {
|
||||
return Collections.unmodifiableList(values);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public T getValueFor(String string) {
|
||||
return values.stream().filter(value -> Objects.equals(value.getData(), string)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import com.sk89q.worldedit.world.registry.state.value.SimpleStateValue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Describes a state property of a block.
|
||||
*
|
||||
@ -38,4 +40,12 @@ public interface State<T extends SimpleStateValue> {
|
||||
*/
|
||||
List<T> getValues();
|
||||
|
||||
/**
|
||||
* Gets the value for the given string, or null.
|
||||
*
|
||||
* @param string The string
|
||||
* @return The value, or null
|
||||
*/
|
||||
@Nullable
|
||||
T getValueFor(String string);
|
||||
}
|
||||
|
Reference in New Issue
Block a user