Skip to content

Commit 4f114a6

Browse files
authored
Revert "chore: cherry-pick appropriate changes from upstream" (#3158)
Revert "chore: cherry-pick appropriate changes from upstream (#3137)" This reverts commit ccc82bd.
1 parent ccc82bd commit 4f114a6

47 files changed

Lines changed: 147 additions & 998 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ target
1616
forge-download
1717
out
1818
run
19-
.jqwik-database
2019

2120
/dependency-reduced-pom.xml
2221
*-private.sh

buildSrc/src/main/kotlin/CommonJavaConfig.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean
3636
}
3737

3838
tasks.withType<Test>().configureEach {
39-
useJUnitPlatform {
40-
includeEngines("junit-jupiter", "jqwik")
41-
}
39+
useJUnitPlatform()
4240
}
4341

4442
dependencies {
4543
"compileOnly"("com.google.code.findbugs:jsr305:3.0.2")
4644
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.11.1")
4745
"testImplementation"("org.junit.jupiter:junit-jupiter-params:5.11.1")
48-
"testImplementation"("net.jqwik:jqwik:1.9.0")
4946
"testImplementation"("org.mockito:mockito-core:5.14.0")
5047
"testImplementation"("org.mockito:mockito-junit-jupiter:5.14.0")
5148
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.11.1")

buildSrc/src/main/kotlin/PlatformConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fun Project.applyShadowConfiguration() {
151151

152152
val CLASSPATH = listOf("truezip", "truevfs", "js")
153153
.map { "$it.jar" }
154-
.flatMap { listOf(it, "FastAsyncWorldEdit/$it", "../$it", "../FastAsyncWorldEdit/$it") }
154+
.flatMap { listOf(it, "FastAsyncWorldEdit/$it") }
155155
.joinToString(separator = " ")
156156

157157
sealed class WorldEditKind(

worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightServerLevelDelegateProxy.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
103103
if (tileEntity == null) {
104104
return null;
105105
}
106-
tileEntity.loadWithComponents(
106+
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
107+
newEntity.loadWithComponents(
107108
(CompoundTag) adapter.fromNativeLin(this.editSession.getFullBlock(
108109
blockPos.getX(),
109110
blockPos.getY(),
@@ -112,7 +113,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
112113
this.serverLevel.registryAccess()
113114
);
114115

115-
return tileEntity;
116+
return newEntity;
116117
}
117118

118119
private BlockState getBlockState(BlockPos blockPos) {

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightServerLevelDelegateProxy.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
103103
if (tileEntity == null) {
104104
return null;
105105
}
106-
tileEntity.loadWithComponents(
106+
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
107+
newEntity.loadWithComponents(
107108
(CompoundTag) adapter.fromNativeLin(this.editSession.getFullBlock(
108109
blockPos.getX(),
109110
blockPos.getY(),
@@ -112,7 +113,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
112113
this.serverLevel.registryAccess()
113114
);
114115

115-
return tileEntity;
116+
return newEntity;
116117
}
117118

118119
private BlockState getBlockState(BlockPos blockPos) {

worldedit-bukkit/adapters/adapter-1_21_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_4/PaperweightServerLevelDelegateProxy.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
103103
if (tileEntity == null) {
104104
return null;
105105
}
106-
tileEntity.loadWithComponents(
106+
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
107+
newEntity.loadWithComponents(
107108
(CompoundTag) adapter.fromNativeLin(this.editSession.getFullBlock(
108109
blockPos.getX(),
109110
blockPos.getY(),
@@ -112,7 +113,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
112113
this.serverLevel.registryAccess()
113114
);
114115

115-
return tileEntity;
116+
return newEntity;
116117
}
117118

118119
private BlockState getBlockState(BlockPos blockPos) {

worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ default Entity adapt(org.bukkit.entity.Entity entity) {
166166
*/
167167
default Material adapt(ItemType itemType) {
168168
checkNotNull(itemType);
169-
NamespacedKey key = checkNotNull(NamespacedKey.fromString(itemType.id()), "Item type key is invalid");
170-
return Registry.MATERIAL.get(key);
169+
if (!itemType.id().startsWith("minecraft:")) {
170+
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
171+
}
172+
return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
171173
}
172174

173175
/**
@@ -178,8 +180,11 @@ default Material adapt(ItemType itemType) {
178180
*/
179181
default Material adapt(BlockType blockType) {
180182
checkNotNull(blockType);
181-
NamespacedKey key = checkNotNull(NamespacedKey.fromString(blockType.id()), "Block type key is invalid");
182-
return Registry.MATERIAL.get(key);
183+
if (!blockType.id().startsWith("minecraft:")) {
184+
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
185+
}
186+
String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
187+
return Material.getMaterial(id);
183188
}
184189

185190
default org.bukkit.entity.EntityType adapt(EntityType entityType) {

worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252

5353
import javax.annotation.Nonnull;
5454
import javax.annotation.Nullable;
55+
import java.util.EnumMap;
5556
import java.util.HashMap;
5657
import java.util.Map;
5758
import java.util.Objects;
58-
import java.util.concurrent.ConcurrentHashMap;
5959

6060
import static com.google.common.base.Preconditions.checkNotNull;
6161

@@ -83,7 +83,6 @@ private static IBukkitAdapter getAdapter() {
8383

8484
static {
8585
TO_BLOCK_CONTEXT.setRestricted(false);
86-
TO_BLOCK_CONTEXT.setTryLegacy(false);
8786
}
8887

8988
/**
@@ -367,9 +366,6 @@ public static GameMode adapt(org.bukkit.GameMode gameMode) {
367366
//FAWE end
368367
}
369368

370-
private static final Map<Biome, BiomeType> biomeBiomeTypeCache = new ConcurrentHashMap<>();
371-
private static final Map<BiomeType, Biome> biomeTypeBiomeCache = new ConcurrentHashMap<>();
372-
373369
/**
374370
* Create a WorldEdit BiomeType from a Bukkit one.
375371
*
@@ -406,8 +402,8 @@ public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
406402
//FAWE end
407403
}
408404

409-
private static final Map<Material, BlockType> materialBlockTypeCache = new ConcurrentHashMap<>();
410-
private static final Map<Material, ItemType> materialItemTypeCache = new ConcurrentHashMap<>();
405+
private static final EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
406+
private static final EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
411407

412408
/**
413409
* Converts a Material to a BlockType.

worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
2929
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
3030
import org.bukkit.Material;
31+
import org.bukkit.block.data.BlockData;
32+
3133
import javax.annotation.Nullable;
34+
import java.util.ArrayList;
3235
import java.util.Collection;
3336
import java.util.List;
3437
import java.util.Map;

worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,9 @@ private void initializeRegistries() {
312312
/*
313313
314314
// Block & Item
315-
Registry.MATERIAL.forEach(material -> {
316-
String key = material.getKey().toString();
317-
if (material.isBlock()) {
318-
BlockType.REGISTRY.register(key, new BlockType(key, blockState -> {
315+
for (Material material : Material.values()) {
316+
if (material.isBlock() && !material.isLegacy()) {
317+
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
319318
// TODO Use something way less hacky than this.
320319
ParserContext context = new ParserContext();
321320
context.setPreferringWildcard(true);
@@ -332,13 +331,13 @@ private void initializeRegistries() {
332331
}
333332
return defaultState;
334333
} catch (InputParseException e) {
335-
LOGGER.warn("Error loading block state for " + key, e);
334+
LOGGER.warn("Error loading block state for " + material.getKey(), e);
336335
return blockState;
337336
}
338337
}));
339338
}
340-
if (material.isItem()) {
341-
ItemType.REGISTRY.register(key, new ItemType(key));
339+
if (material.isItem() && !material.isLegacy()) {
340+
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
342341
}
343342
}
344343
*/
@@ -360,12 +359,10 @@ private void setupTags() {
360359
// Tags
361360
try {
362361
for (Tag<Material> blockTag : Bukkit.getTags(Tag.REGISTRY_BLOCKS, Material.class)) {
363-
String key = blockTag.getKey().toString();
364-
BlockCategory.REGISTRY.register(key, new BlockCategory(blockTag.getKey().toString()));
362+
BlockCategory.REGISTRY.register(blockTag.getKey().toString(), new BlockCategory(blockTag.getKey().toString()));
365363
}
366364
for (Tag<Material> itemTag : Bukkit.getTags(Tag.REGISTRY_ITEMS, Material.class)) {
367-
String key = itemTag.getKey().toString();
368-
ItemCategory.REGISTRY.register(key, new ItemCategory(itemTag.getKey().toString()));
365+
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
369366
}
370367
} catch (NoSuchMethodError ignored) {
371368
LOGGER.warn(

0 commit comments

Comments
 (0)