geforkt von Mirrors/FastAsyncWorldEdit
chore: Update upstream
c515eb5 Cache properties to reduce startup memory (2103)
Dieser Commit ist enthalten in:
Ursprung
0b33fa8757
Commit
9b3608aada
@ -155,6 +155,7 @@ import java.util.Objects;
|
|||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.OptionalLong;
|
import java.util.OptionalLong;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
@ -485,42 +486,34 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
|
private static final LoadingCache<net.minecraft.world.level.block.state.properties.Property, Property<?>> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<net.minecraft.world.level.block.state.properties.Property, Property<?>>() {
|
||||||
|
@Override
|
||||||
|
public Property<?> load(net.minecraft.world.level.block.state.properties.Property state) throws Exception {
|
||||||
|
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
|
||||||
|
return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
||||||
|
} else if (state instanceof DirectionProperty) {
|
||||||
|
return new DirectionalProperty(state.getName(),
|
||||||
|
(List<Direction>) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).collect(Collectors.toList()));
|
||||||
|
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
|
||||||
|
return new EnumProperty(state.getName(),
|
||||||
|
(List<String>) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).collect(Collectors.toList()));
|
||||||
|
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
|
||||||
|
return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("FastAsyncWorldEdit needs an update to support " + state.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@SuppressWarnings({ "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
Map<String, Property<?>> properties = Maps.newTreeMap(String::compareTo);
|
Map<String, Property<?>> properties = new TreeMap<>();
|
||||||
Block block = getBlockFromType(blockType);
|
Block block = getBlockFromType(blockType);
|
||||||
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
|
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
|
||||||
block.getStateDefinition();
|
block.getStateDefinition();
|
||||||
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
|
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
|
||||||
Property property;
|
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
|
||||||
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
|
|
||||||
property = new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
|
||||||
} else if (state instanceof DirectionProperty) {
|
|
||||||
property = new DirectionalProperty(
|
|
||||||
state.getName(),
|
|
||||||
(List<Direction>) state
|
|
||||||
.getPossibleValues()
|
|
||||||
.stream()
|
|
||||||
.map(e -> Direction.valueOf(((StringRepresentable) e)
|
|
||||||
.getSerializedName()
|
|
||||||
.toUpperCase(Locale.ROOT)))
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
|
|
||||||
property = new EnumProperty(
|
|
||||||
state.getName(),
|
|
||||||
(List<String>) state
|
|
||||||
.getPossibleValues()
|
|
||||||
.stream()
|
|
||||||
.map(e -> ((StringRepresentable) e).getSerializedName())
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
|
|
||||||
property = new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("FastAsyncWorldEdit needs an update to support " + state.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
properties.put(property.getName(), property);
|
properties.put(property.getName(), property);
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
|
@ -154,6 +154,7 @@ import java.util.Objects;
|
|||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.OptionalLong;
|
import java.util.OptionalLong;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
@ -475,42 +476,34 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
|
private static final LoadingCache<net.minecraft.world.level.block.state.properties.Property, Property<?>> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<net.minecraft.world.level.block.state.properties.Property, Property<?>>() {
|
||||||
|
@Override
|
||||||
|
public Property<?> load(net.minecraft.world.level.block.state.properties.Property state) throws Exception {
|
||||||
|
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
|
||||||
|
return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
||||||
|
} else if (state instanceof DirectionProperty) {
|
||||||
|
return new DirectionalProperty(state.getName(),
|
||||||
|
(List<Direction>) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).collect(Collectors.toList()));
|
||||||
|
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
|
||||||
|
return new EnumProperty(state.getName(),
|
||||||
|
(List<String>) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).collect(Collectors.toList()));
|
||||||
|
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
|
||||||
|
return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("WorldEdit needs an update to support " + state.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@SuppressWarnings({ "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
Map<String, Property<?>> properties = Maps.newTreeMap(String::compareTo);
|
Map<String, Property<?>> properties = new TreeMap<>();
|
||||||
Block block = getBlockFromType(blockType);
|
Block block = getBlockFromType(blockType);
|
||||||
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
|
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
|
||||||
block.getStateDefinition();
|
block.getStateDefinition();
|
||||||
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
|
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
|
||||||
Property property;
|
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
|
||||||
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
|
|
||||||
property = new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
|
||||||
} else if (state instanceof DirectionProperty) {
|
|
||||||
property = new DirectionalProperty(
|
|
||||||
state.getName(),
|
|
||||||
(List<Direction>) state
|
|
||||||
.getPossibleValues()
|
|
||||||
.stream()
|
|
||||||
.map(e -> Direction.valueOf(((StringRepresentable) e)
|
|
||||||
.getSerializedName()
|
|
||||||
.toUpperCase(Locale.ROOT)))
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
|
|
||||||
property = new EnumProperty(
|
|
||||||
state.getName(),
|
|
||||||
(List<String>) state
|
|
||||||
.getPossibleValues()
|
|
||||||
.stream()
|
|
||||||
.map(e -> ((StringRepresentable) e).getSerializedName())
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
|
|
||||||
property = new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("FastAsyncWorldEdit needs an update to support " + state.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
properties.put(property.getName(), property);
|
properties.put(property.getName(), property);
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
|
@ -151,6 +151,7 @@ import java.util.Objects;
|
|||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.OptionalLong;
|
import java.util.OptionalLong;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
@ -483,42 +484,34 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
|
private static final LoadingCache<net.minecraft.world.level.block.state.properties.Property, Property<?>> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<net.minecraft.world.level.block.state.properties.Property, Property<?>>() {
|
||||||
|
@Override
|
||||||
|
public Property<?> load(net.minecraft.world.level.block.state.properties.Property state) throws Exception {
|
||||||
|
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
|
||||||
|
return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
||||||
|
} else if (state instanceof DirectionProperty) {
|
||||||
|
return new DirectionalProperty(state.getName(),
|
||||||
|
(List<Direction>) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).collect(Collectors.toList()));
|
||||||
|
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
|
||||||
|
return new EnumProperty(state.getName(),
|
||||||
|
(List<String>) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).collect(Collectors.toList()));
|
||||||
|
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
|
||||||
|
return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("FastAsyncWorldEdit needs an update to support " + state.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@SuppressWarnings({ "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
Map<String, Property<?>> properties = Maps.newTreeMap(String::compareTo);
|
Map<String, Property<?>> properties = new TreeMap<>();
|
||||||
Block block = getBlockFromType(blockType);
|
Block block = getBlockFromType(blockType);
|
||||||
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
|
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
|
||||||
block.getStateDefinition();
|
block.getStateDefinition();
|
||||||
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
|
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
|
||||||
Property property;
|
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
|
||||||
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
|
|
||||||
property = new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
|
||||||
} else if (state instanceof DirectionProperty) {
|
|
||||||
property = new DirectionalProperty(
|
|
||||||
state.getName(),
|
|
||||||
(List<Direction>) state
|
|
||||||
.getPossibleValues()
|
|
||||||
.stream()
|
|
||||||
.map(e -> Direction.valueOf(((StringRepresentable) e)
|
|
||||||
.getSerializedName()
|
|
||||||
.toUpperCase(Locale.ROOT)))
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
|
|
||||||
property = new EnumProperty(
|
|
||||||
state.getName(),
|
|
||||||
(List<String>) state
|
|
||||||
.getPossibleValues()
|
|
||||||
.stream()
|
|
||||||
.map(e -> ((StringRepresentable) e).getSerializedName())
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
|
|
||||||
property = new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("FastAsyncWorldEdit needs an update to support " + state.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
properties.put(property.getName(), property);
|
properties.put(property.getName(), property);
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren