mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Remove all raw usages of BSH, improve API generics
This commit is contained in:
@ -135,7 +135,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof BaseBlock)) {
|
||||
if (!hasNbtData() && o instanceof BlockStateHolder) {
|
||||
return Objects.equals(toImmutableState(), ((BlockStateHolder) o).toImmutableState());
|
||||
return Objects.equals(toImmutableState(), ((BlockStateHolder<?>) o).toImmutableState());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
public boolean equalsFuzzy(BlockStateHolder o) {
|
||||
public boolean equalsFuzzy(BlockStateHolder<?> o) {
|
||||
return this.toImmutableState().equalsFuzzy(o);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class BlockCategory extends Category<BlockType> {
|
||||
* @param blockStateHolder The blockstateholder
|
||||
* @return If it's a part of this category
|
||||
*/
|
||||
public boolean contains(BlockStateHolder blockStateHolder) {
|
||||
public <B extends BlockStateHolder<B>> boolean contains(B blockStateHolder) {
|
||||
return this.getAll().contains(blockStateHolder.getBlockType());
|
||||
}
|
||||
}
|
||||
|
@ -74,11 +74,11 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
||||
|
||||
static Map<Map<Property<?>, Object>, BlockState> generateStateMap(BlockType blockType) {
|
||||
Map<Map<Property<?>, Object>, BlockState> stateMap = new LinkedHashMap<>();
|
||||
List<? extends Property> properties = blockType.getProperties();
|
||||
List<? extends Property<?>> properties = blockType.getProperties();
|
||||
|
||||
if (!properties.isEmpty()) {
|
||||
List<List<Object>> separatedValues = Lists.newArrayList();
|
||||
for (Property prop : properties) {
|
||||
for (Property<?> prop : properties) {
|
||||
List<Object> vals = Lists.newArrayList();
|
||||
vals.addAll(prop.getValues());
|
||||
separatedValues.add(vals);
|
||||
@ -113,7 +113,7 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
||||
final Table<Property<?>, Object, BlockState> states = HashBasedTable.create();
|
||||
|
||||
for(final Map.Entry<Property<?>, Object> entry : this.values.entrySet()) {
|
||||
final Property property = entry.getKey();
|
||||
final Property<Object> property = (Property<Object>) entry.getKey();
|
||||
|
||||
property.getValues().forEach(value -> {
|
||||
if(value != entry.getValue()) {
|
||||
@ -167,7 +167,7 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsFuzzy(BlockStateHolder o) {
|
||||
public boolean equalsFuzzy(BlockStateHolder<?> o) {
|
||||
if (this == o) {
|
||||
// Added a reference equality check for
|
||||
return true;
|
||||
@ -176,19 +176,19 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<Property> differingProperties = new HashSet<>();
|
||||
Set<Property<?>> differingProperties = new HashSet<>();
|
||||
for (Object state : o.getStates().keySet()) {
|
||||
if (getState((Property) state) == null) {
|
||||
differingProperties.add((Property) state);
|
||||
if (getState((Property<?>) state) == null) {
|
||||
differingProperties.add((Property<?>) state);
|
||||
}
|
||||
}
|
||||
for (Property property : getStates().keySet()) {
|
||||
for (Property<?> property : getStates().keySet()) {
|
||||
if (o.getState(property) == null) {
|
||||
differingProperties.add(property);
|
||||
}
|
||||
}
|
||||
|
||||
for (Property property : getStates().keySet()) {
|
||||
for (Property<?> property : getStates().keySet()) {
|
||||
if (differingProperties.contains(property)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.sk89q.worldedit.registry.state.Property;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface BlockStateHolder<T extends BlockStateHolder> {
|
||||
public interface BlockStateHolder<B extends BlockStateHolder<B>> {
|
||||
|
||||
/**
|
||||
* Get the block type
|
||||
@ -41,7 +41,7 @@ public interface BlockStateHolder<T extends BlockStateHolder> {
|
||||
* @param value The value
|
||||
* @return The modified state, or same if could not be applied
|
||||
*/
|
||||
<V> T with(final Property<V> property, final V value);
|
||||
<V> B with(final Property<V> property, final V value);
|
||||
|
||||
/**
|
||||
* Gets the value at the given state
|
||||
@ -64,7 +64,7 @@ public interface BlockStateHolder<T extends BlockStateHolder> {
|
||||
* @param o other block
|
||||
* @return true if equal
|
||||
*/
|
||||
boolean equalsFuzzy(BlockStateHolder o);
|
||||
boolean equalsFuzzy(BlockStateHolder<?> o);
|
||||
|
||||
/**
|
||||
* Returns an immutable {@link BlockState} from this BlockStateHolder.
|
||||
|
@ -30,7 +30,6 @@ import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -49,7 +48,7 @@ public class BlockType {
|
||||
private final String id;
|
||||
private final Function<BlockState, BlockState> values;
|
||||
private final AtomicReference<BlockState> defaultState = new AtomicReference<>();
|
||||
private final AtomicReference<Map<String, ? extends Property>> properties = new AtomicReference<>();
|
||||
private final AtomicReference<Map<String, ? extends Property<?>>> properties = new AtomicReference<>();
|
||||
private final AtomicReference<BlockMaterial> blockMaterial = new AtomicReference<>();
|
||||
private final AtomicReference<Map<Map<Property<?>, Object>, BlockState>> blockStatesMap = new AtomicReference<>();
|
||||
|
||||
@ -114,7 +113,7 @@ public class BlockType {
|
||||
*
|
||||
* @return The properties map
|
||||
*/
|
||||
public Map<String, ? extends Property> getPropertyMap() {
|
||||
public Map<String, ? extends Property<?>> getPropertyMap() {
|
||||
return updateField(properties, () -> ImmutableMap.copyOf(WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getProperties(this)));
|
||||
}
|
||||
@ -124,7 +123,7 @@ public class BlockType {
|
||||
*
|
||||
* @return the properties
|
||||
*/
|
||||
public List<? extends Property> getProperties() {
|
||||
public List<? extends Property<?>> getProperties() {
|
||||
return ImmutableList.copyOf(this.getPropertyMap().values());
|
||||
}
|
||||
|
||||
@ -135,7 +134,9 @@ public class BlockType {
|
||||
* @return The property
|
||||
*/
|
||||
public <V> Property<V> getProperty(String name) {
|
||||
Property<V> property = getPropertyMap().get(name);
|
||||
// Assume it works, CCE later at runtime if not.
|
||||
@SuppressWarnings("unchecked")
|
||||
Property<V> property = (Property<V>) getPropertyMap().get(name);
|
||||
checkArgument(property != null, "%s has no property named %s", this, name);
|
||||
return property;
|
||||
}
|
||||
|
Reference in New Issue
Block a user