Merge branch 'version/7.3.x'

This commit is contained in:
Octavia Togami 2024-07-20 10:21:25 -07:00
commit c9fdcc6ab4
No known key found for this signature in database
GPG Key ID: CC364524D1983C99
13 changed files with 52 additions and 22 deletions

View File

@ -1,5 +1,7 @@
7.3.4
- Added support for 1.21
- Fixed an issue where //drawsel can prevent using //world overrides in some situation
- Improved performance of repeatedly getting string representations of a block
7.3.3
- [Sponge] Re-add Sponge support

View File

@ -2,7 +2,7 @@
set -e
# For snapshots, please specify the full version (with date and time)
cdist_version="0.1.0-20210612.072458-9"
cdist_version="0.1.0-20240706.110724-10"
cdist_path_version="$cdist_version"
if [ -n "${cdist_version#*-}" ]; then

View File

@ -491,7 +491,7 @@ public static <B extends BlockStateHolder<B>> BlockData adapt(B block) {
if (cacheKey == BlockStateIdAccess.invalidId()) {
cacheKey = block.hashCode();
}
return blockDataCache.computeIfAbsent(cacheKey, input -> Bukkit.createBlockData(block.getAsString())).clone();
return blockDataCache.computeIfAbsent(cacheKey, input -> Bukkit.createBlockData(block.toImmutableState().getAsString())).clone();
}
/**

View File

@ -63,8 +63,8 @@
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.Tag;
import org.bukkit.block.Biome;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -208,14 +208,14 @@ private void setupWorldData() {
@SuppressWarnings({ "unchecked" })
private void initializeRegistries() {
// Biome
for (Biome biome : Biome.values()) {
Registry.BIOME.forEach(biome -> {
if (!biome.name().equals("CUSTOM")) {
String key = biome.getKey().toString();
BiomeType.REGISTRY.register(key, new BiomeType(key));
}
}
});
// Block & Item
for (Material material : Material.values()) {
Registry.MATERIAL.forEach(material -> {
if (material.isBlock()) {
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
// TODO Use something way less hacky than this.
@ -242,16 +242,13 @@ private void initializeRegistries() {
if (material.isItem()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
}
}
});
// Entity
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
if (entityType == org.bukkit.entity.EntityType.UNKNOWN) {
// This doesn't have a key - skip it
continue;
}
Registry.ENTITY_TYPE.forEach(entityType -> {
String key = entityType.getKey().toString();
EntityType.REGISTRY.register(key, new EntityType(key));
}
});
// ... :|
GameModes.get("");
WeatherTypes.get("");
@ -327,6 +324,7 @@ public void onDisable() {
config.unload();
}
this.getServer().getScheduler().cancelTasks(this);
worldEdit.getExecutorService().shutdown();
}
/**

View File

@ -213,6 +213,7 @@ public void onStopped() {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
worldEdit.getPlatformManager().unregister(platform);
WorldEdit.getInstance().getExecutorService().shutdown();
}
public FileRegistries getFileRegistries() {

View File

@ -2433,9 +2433,12 @@ public int deformRegion(final Region region, final Vector3 zero, final Vector3 u
final DoubleArrayList<BlockVector3, BaseBlock> queue = new DoubleArrayList<>(false);
for (BlockVector3 position : region) {
for (BlockVector3 targetBlockPosition : region) {
final Vector3 targetPosition = targetBlockPosition.toVector3();
environment.setCurrentBlock(targetPosition);
// offset, scale
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
final Vector3 scaled = targetPosition.subtract(zero).divide(unit);
// transform
expression.evaluate(new double[]{ scaled.x(), scaled.y(), scaled.z() }, timeout);
@ -2446,7 +2449,7 @@ public int deformRegion(final Region region, final Vector3 zero, final Vector3 u
final BaseBlock material = world.getFullBlock(sourcePosition);
// queue operation
queue.put(position, material);
queue.put(targetBlockPosition, material);
}
int affected = 0;

View File

@ -23,7 +23,6 @@
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.RegionSelector;
@ -47,10 +46,7 @@ private ServerCUIHandler() {
}
public static int getMaxServerCuiSize() {
int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion();
// 1.16 increased maxSize to 48.
return dataVersion >= 2566 ? 48 : 32;
return 48;
}
/**

View File

@ -192,8 +192,18 @@ public int hashCode() {
return ret;
}
/**
* Gets a string representation of this BaseBlock, in the format expected by WorldEdit's block parsers.
*
* <p>
* If NBT data is present, it will be included in the string. If you only want the underlying block state, call
* this method on the return value from {@link #toImmutableState()} instead.
* </p>
*
* @return The string representation
*/
@Override
public String toString() {
public String getAsString() {
String nbtString = "";
if (nbtData != null) {
nbtString = LinStringIO.writeToString(nbtData.getValue());
@ -202,4 +212,9 @@ public String toString() {
return blockState.getAsString() + nbtString;
}
@Override
public String toString() {
return getAsString();
}
}

View File

@ -66,6 +66,7 @@ public void setInternalId(BlockState blockState, int internalId) {
private final Map<Property<?>, Object> values;
private final BaseBlock emptyBaseBlock;
private final LazyReference<String> lazyStringRepresentation;
// Neighbouring state table.
private Table<Property<?>, Object, BlockState> states;
@ -79,6 +80,7 @@ public void setInternalId(BlockState blockState, int internalId) {
this.blockType = blockType;
this.values = new LinkedHashMap<>();
this.emptyBaseBlock = new BaseBlock(this);
this.lazyStringRepresentation = LazyReference.from(BlockStateHolder.super::getAsString);
}
/**
@ -270,6 +272,11 @@ BlockState setState(final Property<?> property, final Object value) {
return this;
}
@Override
public String getAsString() {
return lazyStringRepresentation.getValue();
}
@Override
public String toString() {
return getAsString();

View File

@ -133,6 +133,11 @@ default BaseBlock applyBlock(BlockVector3 position) {
return toBaseBlock();
}
/**
* Gets a String representation of this BlockStateHolder, in the format expected by WorldEdit's block parsers.
*
* @return a string representation
*/
default String getAsString() {
if (getStates().isEmpty()) {
return this.getBlockType().id();

View File

@ -299,6 +299,7 @@ private void onStopServer(MinecraftServer minecraftServer) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
}
private boolean skipEvents() {

View File

@ -257,6 +257,7 @@ public void serverStopping(ServerStoppingEvent event) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
}
@SubscribeEvent

View File

@ -244,6 +244,7 @@ public void serverStopping(StoppingEngineEvent<Server> event) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
}
@Listener