3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-19 17:30:08 +01:00

Merge branch 'main' into feat/improved-entity-operations

Dieser Commit ist enthalten in:
dordsor21 2024-06-14 19:36:51 +01:00
Commit a9414a11b4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
145 geänderte Dateien mit 1066 neuen und 672 gelöschten Zeilen

Datei anzeigen

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Label conflicting PRs - name: Label conflicting PRs
uses: eps1lon/actions-label-merge-conflict@v3.0.1 uses: eps1lon/actions-label-merge-conflict@v3.0.2
with: with:
dirtyLabel: "unresolved-merge-conflict" dirtyLabel: "unresolved-merge-conflict"
repoToken: "${{ secrets.GITHUB_TOKEN }}" repoToken: "${{ secrets.GITHUB_TOKEN }}"

Datei anzeigen

@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT"
griefprevention = "17.0.0" griefprevention = "17.0.0"
griefdefender = "2.1.0-SNAPSHOT" griefdefender = "2.1.0-SNAPSHOT"
residence = "4.5._13.1" residence = "4.5._13.1"
towny = "0.100.2.11" towny = "0.100.2.14"
plotsquared = "7.3.8" plotsquared = "7.3.8"
# Third party # Third party
@ -22,7 +22,7 @@ bstats = "3.0.2"
sparsebitset = "1.3" sparsebitset = "1.3"
parallelgzip = "1.0.5" parallelgzip = "1.0.5"
adventure = "4.17.0" adventure = "4.17.0"
adventure-bukkit = "4.3.2" adventure-bukkit = "4.3.3"
checkerqual = "3.43.0" checkerqual = "3.43.0"
truezip = "6.8.4" truezip = "6.8.4"
auto-value = "1.10.4" auto-value = "1.10.4"

Datei anzeigen

@ -283,11 +283,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));

Datei anzeigen

@ -480,7 +480,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -547,7 +547,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

Datei anzeigen

@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -262,7 +262,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

Datei anzeigen

@ -806,7 +806,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -902,9 +902,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -318,7 +319,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -339,26 +340,30 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
packet = new ClientboundLevelChunkWithLightPacket( synchronized (chunk) {
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null, null,
true, null,
false // last false is to not bother with x-ray true,
); false // last false is to not bother with x-ray
);
}
} else { } else {
// deprecated on paper - deprecation suppressed synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( // deprecated on paper - deprecation suppressed
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null, null,
true null,
); true
);
}
} }
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });

Datei anzeigen

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

Datei anzeigen

@ -284,11 +284,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -480,7 +480,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));

Datei anzeigen

@ -480,7 +480,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -547,7 +547,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

Datei anzeigen

@ -247,7 +247,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -263,7 +263,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

Datei anzeigen

@ -804,7 +804,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -900,9 +900,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -342,7 +343,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -363,24 +364,28 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
packet = new ClientboundLevelChunkWithLightPacket( synchronized (chunk) {
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
// last false is to not bother with x-ray null,
); false // last false is to not bother with x-ray
);
}
} else { } else {
// deprecated on paper - deprecation suppressed synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( // deprecated on paper - deprecation suppressed
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
); null
);
}
} }
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });

Datei anzeigen

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

Datei anzeigen

@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));

Datei anzeigen

@ -483,7 +483,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -550,7 +550,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

Datei anzeigen

@ -247,7 +247,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -263,7 +263,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

Datei anzeigen

@ -790,7 +790,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -886,9 +886,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -333,7 +334,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -354,24 +355,28 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
packet = new ClientboundLevelChunkWithLightPacket( synchronized (chunk) {
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
// last false is to not bother with x-ray null,
); false // last false is to not bother with x-ray
);
}
} else { } else {
// deprecated on paper - deprecation suppressed synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( // deprecated on paper - deprecation suppressed
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
); null
);
}
} }
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });

Datei anzeigen

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

Datei anzeigen

@ -12,6 +12,6 @@ repositories {
dependencies { dependencies {
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240424.165410-174") the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240528.102248-175")
compileOnly(libs.paperlib) compileOnly(libs.paperlib)
} }

Datei anzeigen

@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));

Datei anzeigen

@ -483,7 +483,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -550,7 +550,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

Datei anzeigen

@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -262,7 +262,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

Datei anzeigen

@ -89,7 +89,6 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
private final Registry<Biome> biomeRegistry; private final Registry<Biome> biomeRegistry;
private final IdMap<Holder<Biome>> biomeHolderIdMap; private final IdMap<Holder<Biome>> biomeHolderIdMap;
private final ConcurrentHashMap<Integer, PaperweightGetBlocks_Copy> copies = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Integer, PaperweightGetBlocks_Copy> copies = new ConcurrentHashMap<>();
private final Object sendLock = new Object();
private LevelChunkSection[] sections; private LevelChunkSection[] sections;
private LevelChunk levelChunk; private LevelChunk levelChunk;
private DataLayer[] blockLight; private DataLayer[] blockLight;
@ -790,7 +789,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -886,10 +885,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting);
}
} }
/** /**

Datei anzeigen

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -332,7 +333,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -353,24 +354,28 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
packet = new ClientboundLevelChunkWithLightPacket( synchronized (chunk) {
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
// last false is to not bother with x-ray null,
); false // last false is to not bother with x-ray
);
}
} else { } else {
// deprecated on paper - deprecation suppressed synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( // deprecated on paper - deprecation suppressed
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
); null
);
}
} }
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });

Datei anzeigen

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

Datei anzeigen

@ -12,6 +12,6 @@ repositories {
dependencies { dependencies {
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240526.222003-87") the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240604.210637-112")
compileOnly(libs.paperlib) compileOnly(libs.paperlib)
} }

Datei anzeigen

@ -291,12 +291,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse( return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(
blockType.getId())); blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse( return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(
itemType.getId())); itemType.id()));
} }
@Override @Override
@ -470,7 +470,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()); final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData());

Datei anzeigen

@ -492,7 +492,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().getId())), registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()); final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData());
@ -572,7 +572,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

Datei anzeigen

@ -247,7 +247,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -263,7 +263,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

Datei anzeigen

@ -790,7 +790,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -886,9 +886,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -332,7 +333,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -351,24 +352,28 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
packet = new ClientboundLevelChunkWithLightPacket( synchronized (chunk) {
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
// last false is to not bother with x-ray null,
); false // last false is to not bother with x-ray
);
}
} else { } else {
// deprecated on paper - deprecation suppressed synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( // deprecated on paper - deprecation suppressed
levelChunk, packet = new ClientboundLevelChunkWithLightPacket(
nmsWorld.getChunkSource().getLightEngine(), levelChunk,
null, nmsWorld.getChunkSource().getLightEngine(),
null null,
); null
);
}
} }
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });

Datei anzeigen

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

Datei anzeigen

@ -2,6 +2,6 @@ package com.fastasyncworldedit.bukkit.adapter;
public interface BukkitGetBlocks { public interface BukkitGetBlocks {
void send(int mask, boolean lighting); void send();
} }

Datei anzeigen

@ -166,10 +166,10 @@ public interface IBukkitAdapter {
*/ */
default Material adapt(ItemType itemType) { default Material adapt(ItemType itemType) {
checkNotNull(itemType); checkNotNull(itemType);
if (!itemType.getId().startsWith("minecraft:")) { if (!itemType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft items"); throw new IllegalArgumentException("Bukkit only supports Minecraft items");
} }
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT)); return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
} }
/** /**
@ -180,10 +180,10 @@ public interface IBukkitAdapter {
*/ */
default Material adapt(BlockType blockType) { default Material adapt(BlockType blockType) {
checkNotNull(blockType); checkNotNull(blockType);
if (!blockType.getId().startsWith("minecraft:")) { if (!blockType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks"); throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
} }
String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT); String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
return Material.getMaterial(id); return Material.getMaterial(id);
} }
@ -293,11 +293,11 @@ public interface IBukkitAdapter {
} }
default Biome adapt(BiomeType biomeType) { default Biome adapt(BiomeType biomeType) {
if (!biomeType.getId().startsWith("minecraft:")) { if (!biomeType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla biomes"); throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
} }
try { try {
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT)); return Biome.valueOf(biomeType.id().substring(10).toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return null; return null;
} }

Datei anzeigen

@ -137,7 +137,7 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
if (!(chunk instanceof BukkitGetBlocks)) { if (!(chunk instanceof BukkitGetBlocks)) {
throw new IllegalArgumentException("(IChunkGet) chunk not of type BukkitGetBlocks"); throw new IllegalArgumentException("(IChunkGet) chunk not of type BukkitGetBlocks");
} }
((BukkitGetBlocks) chunk).send(mask, lighting); ((BukkitGetBlocks) chunk).send();
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.fastasyncworldedit.bukkit.regions.plotsquared; package com.fastasyncworldedit.bukkit.regions.plotsquared;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.regions.FaweMask; import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.FaweMaskManager; import com.fastasyncworldedit.core.regions.FaweMaskManager;
@ -174,22 +173,21 @@ public class PlotSquaredFeature extends FaweMaskManager {
return null; return null;
} }
final World world = player.getWorld();
int min = area != null ? area.getMinBuildHeight() : world.getMinY();
// PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1
int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY();
Region maskedRegion; Region maskedRegion;
if (regions.size() == 1) { if (regions.size() == 1) {
final World world = player.getWorld();
int min = area != null ? area.getMinBuildHeight() : world.getMinY();
// PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1
int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY();
final CuboidRegion region = regions.iterator().next(); final CuboidRegion region = regions.iterator().next();
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ()); final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ()); final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
maskedRegion = new CuboidRegion(pos1, pos2); maskedRegion = new CuboidRegion(pos1, pos2);
} else { } else {
World world = FaweAPI.getWorld(area.getWorldName());
List<Region> weRegions = regions.stream().map( List<Region> weRegions = regions.stream().map(
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), min, r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()) BlockVector3.at(r.getMaximumX(), max, r.getMaximumZ())
)).collect(Collectors.toList()); )).collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions); maskedRegion = new RegionIntersection(world, weRegions);
} }

Datei anzeigen

@ -40,7 +40,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
@Override @Override
public Component getRichName(BiomeType biomeType) { public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of( return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId()) TranslationManager.makeTranslationKey("biome", biomeType.id())
); );
} }

Datei anzeigen

@ -162,7 +162,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
final PlayerInventory inv = player.getInventory(); final PlayerInventory inv = player.getInventory();
ItemStack newItem = BukkitAdapter.adapt(itemStack); ItemStack newItem = BukkitAdapter.adapt(itemStack);
TaskManager.taskManager().sync(() -> { TaskManager.taskManager().sync(() -> {
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) { if (itemStack.getType().id().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
inv.remove(newItem); inv.remove(newItem);
} }
final ItemStack item = player.getInventory().getItemInMainHand(); final ItemStack item = player.getInventory().getItemInMainHand();
@ -267,7 +267,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public void setGameMode(GameMode gameMode) { public void setGameMode(GameMode gameMode) {
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT))); player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.id().toUpperCase(Locale.ROOT)));
} }
@Override @Override

Datei anzeigen

@ -192,6 +192,9 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
@Override @Override
public BaseItem getItem(int slot) { public BaseItem getItem(int slot) {
loadInventory(); loadInventory();
if (items[slot] == null) {
return null;
}
return BukkitAdapter.adapt(items[slot]); return BukkitAdapter.adapt(items[slot]);
} }

Datei anzeigen

@ -230,7 +230,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
//FAWE start //FAWE start
@Override @Override
public String getId() { public String id() {
return "intellectualsites:bukkit"; return "intellectualsites:bukkit";
} }
//FAWE end //FAWE end

Datei anzeigen

@ -224,7 +224,7 @@ public class BukkitWorld extends AbstractWorld {
//FAWE end //FAWE end
@Override @Override
public String getId() { public String id() {
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT); return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
} }

Datei anzeigen

@ -137,6 +137,10 @@ public class WorldEditPlugin extends JavaPlugin {
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
getDataFolder().mkdirs(); getDataFolder().mkdirs();
//FAWE start - Migrate from config-legacy to worldedit-config
migrateLegacyConfig();
//FAWE end
//FAWE start - Modify WorldEdit config name //FAWE start - Modify WorldEdit config name
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this); config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this);
// Load config before we say we've loaded platforms as it is used in listeners of the event // Load config before we say we've loaded platforms as it is used in listeners of the event
@ -151,10 +155,6 @@ public class WorldEditPlugin extends JavaPlugin {
platform = new BukkitServerInterface(this, getServer()); platform = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(platform); worldEdit.getPlatformManager().register(platform);
//FAWE start - Migrate from config-legacy to worldedit-config
migrateLegacyConfig();
//FAWE end
//FAWE start - Setup permission attachments //FAWE start - Setup permission attachments
permissionAttachmentManager = new BukkitPermissionAttachmentManager(this); permissionAttachmentManager = new BukkitPermissionAttachmentManager(this);
//FAWE end //FAWE end

Datei anzeigen

@ -68,7 +68,7 @@ public class CLIBlockRegistry extends BundledBlockRegistry {
@Override @Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) { public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, FileRegistries.BlockProperty> properties = Map<String, FileRegistries.BlockProperty> properties =
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties; CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.id()).properties;
Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform = Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform =
(key, value) -> createProperty(value.type, key, value.values); (key, value) -> createProperty(value.type, key, value.values);
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform)); return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));

Datei anzeigen

@ -115,7 +115,7 @@ class CLIPlatform extends AbstractPlatform {
@Override @Override
public World matchWorld(World world) { public World matchWorld(World world) {
return this.worlds.stream() return this.worlds.stream()
.filter(w -> w.getId().equals(world.getId())) .filter(w -> w.id().equals(world.id()))
.findAny() .findAny()
.orElse(null); .orElse(null);
} }

Datei anzeigen

@ -85,7 +85,7 @@ public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld
//FAWE end //FAWE end
@Override @Override
public String getId() { public String id() {
return getName().replace(" ", "_").toLowerCase(Locale.ROOT); return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
} }

Datei anzeigen

@ -100,6 +100,9 @@ public class Config {
} }
public boolean load(File file) { public boolean load(File file) {
if (!file.exists()) {
return false;
}
existingMigrateNodes = new ArrayList<>(); existingMigrateNodes = new ArrayList<>();
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
for (String key : yml.getKeys(true)) { for (String key : yml.getKeys(true)) {

Datei anzeigen

@ -68,6 +68,7 @@ public class YamlConfiguration extends FileConfiguration {
LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex); LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex);
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
ex.printStackTrace();
} }
} }

Datei anzeigen

@ -0,0 +1,72 @@
package com.fastasyncworldedit.core.extension.factory.parser.common;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public abstract class HotbarParser<T> extends SimpleInputParser<T> {
private final List<String> aliases = ImmutableList.of("#hotbar");
protected HotbarParser(final WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public List<String> getMatchedAliases() {
return aliases;
}
protected List<BlockType> getBlockTypes(ParserContext context) {
Player player = context.requirePlayer();
BlockBag bag = player.getInventoryBlockBag();
if (!(bag instanceof final SlottableBlockBag slottable)) {
// Matches DefaultBlockParser
throw new InputParseException(Caption.of("fawe.error.unsupported"));
}
List<BlockType> types = new ArrayList<>();
FaweLimit limit = player.getLimit();
boolean anyBlock = player.hasPermission("worldedit.anyblock");
for (int slot = 0; slot < 9; slot++) {
BaseItem item = slottable.getItem(slot);
if (item != null && item.getType().hasBlockType()) {
BlockType type = item.getType().getBlockType();
if (!anyBlock && worldEdit.getConfiguration().disallowedBlocks.contains(type.id().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of(
"worldedit.error.disallowed-block",
TextComponent.of(type.getId())
));
}
if (!limit.isUnlimited()) {
if (limit.DISALLOWED_BLOCKS.contains(type.id().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of(
"fawe.error.limit.disallowed-block",
TextComponent.of(type.getId())
));
}
}
types.add(type);
}
}
if (types.isEmpty()) {
throw new InputParseException(Caption.of("fawe.error.no-valid-on-hotbar"));
}
return types;
}
}

Datei anzeigen

@ -0,0 +1,20 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.common.HotbarParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
public class HotbarMaskParser extends HotbarParser<Mask> {
public HotbarMaskParser(WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new BlockTypeMask(context.getExtent(), getBlockTypes(context));
}
}

Datei anzeigen

@ -0,0 +1,26 @@
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
import com.fastasyncworldedit.core.extension.factory.parser.common.HotbarParser;
import com.fastasyncworldedit.core.math.random.TrueRandom;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.world.block.BlockType;
public class HotbarPatternParser extends HotbarParser<Pattern> {
public HotbarPatternParser(WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public Pattern parseFromSimpleInput(String input, ParserContext context) {
RandomPattern random = new RandomPattern(new TrueRandom());
for (BlockType type : getBlockTypes(context)) {
random.add(type, 1);
}
return random;
}
}

Datei anzeigen

@ -101,7 +101,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <B extends BlockStateHolder<B>> B checkBlock(B block) { private <B extends BlockStateHolder<B>> B checkBlock(B block) {
if (blockedBlocks != null) { if (blockedBlocks != null) {
if (blockedBlocks.contains(block.getBlockType().getId())) { if (blockedBlocks.contains(block.getBlockType().id())) {
return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty
} }
} }
@ -140,7 +140,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
} }
BlockState state = BlockTypesCache.states[block]; BlockState state = BlockTypesCache.states[block];
if (blockedBlocks != null) { if (blockedBlocks != null) {
if (blockedBlocks.contains(state.getBlockType().getId())) { if (blockedBlocks.contains(state.getBlockType().id())) {
blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__; blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
continue; continue;
} }

Datei anzeigen

@ -110,7 +110,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBiome(BlockVector3 position, BiomeType newBiome) { public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
BiomeType oldBiome = this.getBiome(position); BiomeType oldBiome = this.getBiome(position);
if (!oldBiome.getId().equals(newBiome.getId())) { if (!oldBiome.id().equals(newBiome.id())) {
this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome); this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome);
return getExtent().setBiome(position, newBiome); return getExtent().setBiome(position, newBiome);
} else { } else {
@ -121,7 +121,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBiome(int x, int y, int z, BiomeType newBiome) { public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z)); BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
if (!oldBiome.getId().equals(newBiome.getId())) { if (!oldBiome.id().equals(newBiome.id())) {
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome); this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
return getExtent().setBiome(x, y, z, newBiome); return getExtent().setBiome(x, y, z, newBiome);
} else { } else {

Datei anzeigen

@ -237,7 +237,7 @@ public class FastSchematicWriter implements ClipboardWriter {
if (!brokenEntities) { if (!brokenEntities) {
loc = loc.setPosition(loc.add(min.toVector3())); loc = loc.setPosition(loc.add(min.toVector3()));
} }
values.put("Id", new StringTag(state.getType().getId())); values.put("Id", new StringTag(state.getType().id()));
values.put("Pos", writeVector(loc)); values.put("Pos", writeVector(loc));
values.put("Rotation", writeRotation(entity.getLocation())); values.put("Rotation", writeRotation(entity.getLocation()));
@ -297,7 +297,7 @@ public class FastSchematicWriter implements ClipboardWriter {
for (int i = 0; i < paletteList.size(); i++) { for (int i = 0; i < paletteList.size(); i++) {
int ordinal = paletteList.get(i); int ordinal = paletteList.get(i);
BiomeType state = BiomeTypes.get(ordinal); BiomeType state = BiomeTypes.get(ordinal);
out12.writeNamedTag(state.getId(), i); out12.writeNamedTag(state.id(), i);
} }
}); });

Datei anzeigen

@ -183,7 +183,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
indexes.put(combined, (Integer) palette.size()); indexes.put(combined, (Integer) palette.size());
HashMap<String, Object> paletteEntry = new HashMap<>(); HashMap<String, Object> paletteEntry = new HashMap<>();
paletteEntry.put("Name", type.getId()); paletteEntry.put("Name", type.id());
if (block.getInternalId() != type.getInternalId()) { if (block.getInternalId() != type.getInternalId()) {
Map<String, Object> properties = null; Map<String, Object> properties = null;
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) { for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
@ -236,11 +236,11 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
BaseEntity state = entity.getState(); BaseEntity state = entity.getState();
if (state != null) { if (state != null) {
CompoundTag nbt = state.getNbtData(); CompoundTag nbt = state.getNbtData();
Map<String, Tag> nbtMap = nbt.getValue(); Map<String, Tag> nbtMap = new HashMap<>(nbt.getValue());
// Replace rotation data // Replace rotation data
nbtMap.put("Rotation", writeRotation(entity.getLocation())); nbtMap.put("Rotation", writeRotation(entity.getLocation()));
nbtMap.put("id", new StringTag(state.getType().getId())); nbtMap.put("id", new StringTag(state.getType().id()));
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", new CompoundTag(nbtMap));
entities.add(entityMap); entities.add(entityMap);
} }
} }

Datei anzeigen

@ -346,7 +346,7 @@ public class NMSRelighter implements Relighter {
} }
int lightLevel = iChunk.getEmittedLight(node.x() & 15, node.y(), node.z() & 15); int lightLevel = iChunk.getEmittedLight(node.x() & 15, node.y(), node.z() & 15);
BlockState state = this.queue.getBlock(node.x(), node.y(), node.z()); BlockState state = this.queue.getBlock(node.x(), node.y(), node.z());
String id = state.getBlockType().getId().toLowerCase(Locale.ROOT); String id = state.getBlockType().id().toLowerCase(Locale.ROOT);
if (lightLevel <= 1) { if (lightLevel <= 1) {
continue; continue;
} }
@ -396,7 +396,7 @@ public class NMSRelighter implements Relighter {
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) { if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
break east; break east;
} }
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited); this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited);
break east; break east;
} }
@ -449,7 +449,7 @@ public class NMSRelighter implements Relighter {
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) { if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
break west; break west;
} }
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited); this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited);
break west; break west;
} }
@ -502,7 +502,7 @@ public class NMSRelighter implements Relighter {
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) { if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
break south; break south;
} }
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited); this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited);
break south; break south;
} }
@ -555,7 +555,7 @@ public class NMSRelighter implements Relighter {
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) { if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
break north; break north;
} }
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited); this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited);
break north; break north;
} }
@ -707,7 +707,7 @@ public class NMSRelighter implements Relighter {
} }
private boolean checkStairNorth(BlockState state) { private boolean checkStairNorth(BlockState state) {
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
return true; return true;
} }
Direction direction = getStairDir(state); Direction direction = getStairDir(state);
@ -725,7 +725,7 @@ public class NMSRelighter implements Relighter {
} }
private boolean checkStairSouth(BlockState state) { private boolean checkStairSouth(BlockState state) {
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
return true; return true;
} }
Direction direction = getStairDir(state); Direction direction = getStairDir(state);
@ -743,7 +743,7 @@ public class NMSRelighter implements Relighter {
} }
private boolean checkStairEast(BlockState state) { private boolean checkStairEast(BlockState state) {
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
return true; return true;
} }
Direction direction = getStairDir(state); Direction direction = getStairDir(state);
@ -761,7 +761,7 @@ public class NMSRelighter implements Relighter {
} }
private boolean checkStairWest(BlockState state) { private boolean checkStairWest(BlockState state) {
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) { if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
return true; return true;
} }
Direction direction = getStairDir(state); Direction direction = getStairDir(state);
@ -787,11 +787,11 @@ public class NMSRelighter implements Relighter {
} }
private boolean isStairOrTrueTop(BlockState state, boolean top) { private boolean isStairOrTrueTop(BlockState state, boolean top) {
return !state.getBlockType().getId().contains("stair") || state.getState(stairHalf).equals("top") == top; return !state.getBlockType().id().contains("stair") || state.getState(stairHalf).equals("top") == top;
} }
private boolean isSlabOrTrueValue(BlockState state, String value) { private boolean isSlabOrTrueValue(BlockState state, String value) {
return !state.getBlockType().getId().contains("slab") || state.getState(slabHalf).equals(value); return !state.getBlockType().id().contains("slab") || state.getState(slabHalf).equals(value);
} }
private void computeRemoveBlockLight( private void computeRemoveBlockLight(

Datei anzeigen

@ -236,7 +236,7 @@ public class CavesGen extends GenBase {
BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z); BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
BlockState materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z); BlockState materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
BlockType blockType = material.getBlockType(); BlockType blockType = material.getBlockType();
switch (blockType.getId()) { switch (blockType.id()) {
case "minecraft:mycelium", "minecraft:grass_block" -> grassFound = true; case "minecraft:mycelium", "minecraft:grass_block" -> grassFound = true;
} }
if (this.isSuitableBlock(material, materialAbove)) { if (this.isSuitableBlock(material, materialAbove)) {
@ -277,7 +277,7 @@ public class CavesGen extends GenBase {
} }
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) { protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
return switch (material.getBlockType().getId()) { return switch (material.getBlockType().id()) {
case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false; case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false;
default -> true; default -> true;
}; };

Datei anzeigen

@ -40,7 +40,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
List<BlockState> all = type.getAllStates(); List<BlockState> all = type.getAllStates();
hasAll = all.stream().map(this::test).reduce(true, (a, b) -> a && b); hasAll = all.stream().map(this::test).reduce(true, (a, b) -> a && b);
if (hasAll) { if (hasAll) {
strings.add(type.getId()); strings.add(type.id());
} else { } else {
for (BlockState state : all) { for (BlockState state : all) {
if (test(state)) { if (test(state)) {

Datei anzeigen

@ -183,7 +183,7 @@ public class BlockMaskBuilder {
builders = new ArrayList<>(); builders = new ArrayList<>();
Pattern pattern = Pattern.compile("(minecraft:)?" + regex); Pattern pattern = Pattern.compile("(minecraft:)?" + regex);
for (BlockType type : BlockTypesCache.values) { for (BlockType type : BlockTypesCache.values) {
if (pattern.matcher(type.getId()).find()) { if (pattern.matcher(type.id()).find()) {
blockTypeList.add(type); blockTypeList.add(type);
builders.add(new FuzzyStateAllowingBuilder(type)); builders.add(new FuzzyStateAllowingBuilder(type));
add(type); add(type);
@ -284,7 +284,7 @@ public class BlockMaskBuilder {
} else { } else {
boolean success = false; boolean success = false;
for (BlockType myType : BlockTypesCache.values) { for (BlockType myType : BlockTypesCache.values) {
if (myType.getId().matches("(minecraft:)?" + input)) { if (myType.id().matches("(minecraft:)?" + input)) {
add(myType); add(myType);
success = true; success = true;
} }
@ -571,7 +571,7 @@ public class BlockMaskBuilder {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"Property %s cannot be applied to block type %s", "Property %s cannot be applied to block type %s",
property.getName(), property.getName(),
type.getId() type.id()
)); ));
} }
masked.computeIfAbsent(property, k -> new ArrayList<>()).add(index); masked.computeIfAbsent(property, k -> new ArrayList<>()).add(index);

Datei anzeigen

@ -79,7 +79,7 @@ public class TypeSwapPattern extends AbstractExtentPattern {
} }
private BlockState getNewBlock(BlockState existing) { private BlockState getNewBlock(BlockState existing) {
String oldId = existing.getBlockType().getId(); String oldId = existing.getBlockType().id();
String newId = oldId; String newId = oldId;
if (inputPattern != null) { if (inputPattern != null) {
newId = inputPattern.matcher(oldId).replaceAll(outputString); newId = inputPattern.matcher(oldId).replaceAll(outputString);

Datei anzeigen

@ -297,7 +297,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
public void add(BlockChange change) { public void add(BlockChange change) {
try { try {
BlockVector3 loc = change.getPosition(); BlockVector3 loc = change.getPosition();
BaseBlock from = change.getPrevious(); BaseBlock from = change.previous();
BaseBlock to = change.getCurrent(); BaseBlock to = change.getCurrent();
add(loc, from, to); add(loc, from, to);
} catch (Exception e) { } catch (Exception e) {

Datei anzeigen

@ -69,7 +69,7 @@ public interface IBatchProcessor {
/** /**
* Utility method to trim a chunk based on min and max Y (inclusive). * Utility method to trim a chunk based on min and max Y (inclusive).
* *
* @param keepInsideRange if all blocks inside the range (inclusive) should be kept (default) * @param keepInsideRange if all blocks inside the range (inclusive) should be kept (default), or removed
* @return false if chunk is empty of blocks * @return false if chunk is empty of blocks
*/ */
default boolean trimY(IChunkSet set, int minY, int maxY, final boolean keepInsideRange) { default boolean trimY(IChunkSet set, int minY, int maxY, final boolean keepInsideRange) {
@ -85,16 +85,14 @@ public interface IBatchProcessor {
for (int i = 0; i < index; i++) { for (int i = 0; i < index; i++) {
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__; arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
} }
} else { set.setBlocks(layer, arr);
arr = new char[4096];
} }
set.setBlocks(layer, arr);
} else { } else {
set.setBlocks(layer, null); set.setBlocks(layer, null);
} }
} }
} }
for (int layer = maxLayer; layer < set.getMaxSectionPosition(); layer++) { for (int layer = maxLayer; layer <= set.getMaxSectionPosition(); layer++) {
if (set.hasSection(layer)) { if (set.hasSection(layer)) {
if (layer == maxLayer) { if (layer == maxLayer) {
char[] arr = set.loadIfPresent(layer); char[] arr = set.loadIfPresent(layer);
@ -103,10 +101,8 @@ public interface IBatchProcessor {
for (int i = index; i < arr.length; i++) { for (int i = index; i < arr.length; i++) {
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__; arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
} }
} else { set.setBlocks(layer, arr);
arr = new char[4096];
} }
set.setBlocks(layer, arr);
} else { } else {
set.setBlocks(layer, null); set.setBlocks(layer, null);
} }

Datei anzeigen

@ -238,7 +238,7 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks {
} }
public void set(int x, int y, int z, char value) { public void set(int x, int y, int z, char value) {
final int layer = y >> 4; final int layer = (y >> 4) - minSectionPosition;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
try { try {
blocks[layer][index] = value; blocks[layer][index] = value;

Datei anzeigen

@ -444,7 +444,7 @@ public class MainUtil {
@Nonnull @Nonnull
public static CompoundTag setEntityInfo(@Nonnull CompoundTag tag, @Nonnull Entity entity) { public static CompoundTag setEntityInfo(@Nonnull CompoundTag tag, @Nonnull Entity entity) {
Map<String, Tag> map = new HashMap<>(tag.getValue()); Map<String, Tag> map = new HashMap<>(tag.getValue());
map.put("Id", new StringTag(entity.getState().getType().getId())); map.put("Id", new StringTag(entity.getState().getType().id()));
ListTag pos = (ListTag) map.get("Pos"); ListTag pos = (ListTag) map.get("Pos");
if (pos != null) { if (pos != null) {
Location loc = entity.getLocation(); Location loc = entity.getLocation();

Datei anzeigen

@ -929,10 +929,10 @@ public class TextureUtil implements TextureHolder {
}.getType(); }.getType();
for (BlockType blockType : BlockTypesCache.values) { for (BlockType blockType : BlockTypesCache.values) {
if (!blockType.getMaterial().isFullCube() || blockType.getId().toLowerCase().contains("shulker")) { if (!blockType.getMaterial().isFullCube() || blockType.id().toLowerCase().contains("shulker")) {
continue; continue;
} }
switch (blockType.getId().toLowerCase(Locale.ROOT)) { switch (blockType.id().toLowerCase(Locale.ROOT)) {
case "slime_block": case "slime_block":
case "honey_block": case "honey_block":
case "mob_spawner": case "mob_spawner":
@ -940,7 +940,7 @@ public class TextureUtil implements TextureHolder {
continue; continue;
} }
int combined = blockType.getInternalId(); int combined = blockType.getInternalId();
String id = blockType.getId(); String id = blockType.id();
String[] split = id.split(":", 2); String[] split = id.split(":", 2);
String name = split.length == 1 ? id : split[1]; String name = split.length == 1 ? id : split[1];
String nameSpace = split.length == 1 ? "" : split[0]; String nameSpace = split.length == 1 ? "" : split[0];

Datei anzeigen

@ -0,0 +1,61 @@
package com.fastasyncworldedit.core.util.gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.nbt.TagStringIO;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import java.io.IOException;
import java.lang.reflect.Type;
public final class BaseItemAdapter implements JsonDeserializer<BaseItem>, JsonSerializer<BaseItem> {
@Override
public BaseItem deserialize(JsonElement json, Type type, JsonDeserializationContext cont) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
JsonElement id = jsonObject.get("id");
if (id != null) {
ItemType itemType = ItemTypes.get(id.getAsString());
if (itemType == null) {
throw new JsonParseException("Could not parse item type `" + id + "`");
}
return new BaseItem(itemType);
}
ItemType itemType = cont.deserialize(jsonObject.get("itemType").getAsJsonObject(), ItemType.class);
JsonElement nbt = jsonObject.get("nbt");
if (nbt == null) {
return new BaseItem(itemType);
}
try {
return new BaseItem(itemType, LazyReference.computed(TagStringIO.get().asCompound(nbt.getAsString())));
} catch (IOException e) {
throw new JsonParseException("Could not deserialize BaseItem", e);
}
}
@Override
public JsonElement serialize(
final BaseItem baseItem,
final Type type,
final JsonSerializationContext jsonSerializationContext
) {
JsonObject obj = new JsonObject();
obj.add("itemType", jsonSerializationContext.serialize(baseItem.getType()));
try {
obj.add("nbt", baseItem.getNbt() == null ? null : new JsonPrimitive(TagStringIO.get().asString(baseItem.getNbt())));
return obj;
} catch (IOException e) {
throw new JsonParseException("Could not deserialize BaseItem", e);
}
}
}

Datei anzeigen

@ -3082,8 +3082,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
) <= 0) { ) <= 0) {
return null; return null;
} }
int newType = (int) typeVariable.getValue(); int newType = (int) typeVariable.value();
int newData = (int) dataVariable.getValue(); int newData = (int) dataVariable.value();
if (newType != typeVar || newData != dataVar) { if (newType != typeVar || newData != dataVar) {
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(newType, newData); BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(newType, newData);
return state == null ? defaultMaterial : state.toBaseBlock(); return state == null ? defaultMaterial : state.toBaseBlock();
@ -3181,9 +3181,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
// transform // transform
expression.evaluate(new double[]{scaled.x(), scaled.y(), scaled.z()}, timeout); expression.evaluate(new double[]{scaled.x(), scaled.y(), scaled.z()}, timeout);
int xv = (int) Math.floor(x.getValue() * unit.x() + zero2.x()); int xv = (int) Math.floor(x.value() * unit.x() + zero2.x());
int yv = (int) Math.floor(y.getValue() * unit.y() + zero2.y()); int yv = (int) Math.floor(y.value() * unit.y() + zero2.y());
int zv = (int) Math.floor(z.getValue() * unit.z() + zero2.z()); int zv = (int) Math.floor(z.value() * unit.z() + zero2.z());
BlockState get; BlockState get;
if (yv >= minY && yv <= maxY) { if (yv >= minY && yv <= maxY) {

Datei anzeigen

@ -196,7 +196,7 @@ public abstract class LocalConfiguration {
BlockTypes.BEDROCK BlockTypes.BEDROCK
FAWE end*/ FAWE end*/
); );
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new); return blockTypes.stream().filter(Objects::nonNull).map(BlockType::id).toArray(String[]::new);
} }
/** /**
@ -277,7 +277,7 @@ public abstract class LocalConfiguration {
id = Integer.parseInt(splitter[0]); id = Integer.parseInt(splitter[0]);
data = Byte.parseByte(splitter[1]); data = Byte.parseByte(splitter[1]);
} }
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId(); item = LegacyMapper.getInstance().getItemFromLegacy(id, data).id();
} catch (Throwable ignored) { } catch (Throwable ignored) {
} }

Datei anzeigen

@ -52,6 +52,7 @@ import com.sk89q.worldedit.command.tool.SelectionWand;
import com.sk89q.worldedit.command.tool.SinglePickaxe; import com.sk89q.worldedit.command.tool.SinglePickaxe;
import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.Tool;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.extent.NullExtent;
@ -80,7 +81,6 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.snapshot.experimental.Snapshot; import com.sk89q.worldedit.world.snapshot.experimental.Snapshot;
import com.zaxxer.sparsebits.SparseBitSet; import com.zaxxer.sparsebits.SparseBitSet;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@ -182,8 +182,10 @@ public class LocalSession implements TextureHolder {
private String lastScript; private String lastScript;
private RegionSelectorType defaultSelector; private RegionSelectorType defaultSelector;
private boolean useServerCUI = false; // Save this to not annoy players. private boolean useServerCUI = false; // Save this to not annoy players.
private ItemType wandItem; //FAWE start - allow NBT
private ItemType navWandItem; private BaseItem wandItem;
private BaseItem navWandItem;
//FAWE end
/** /**
* Construct the object. * Construct the object.
@ -1199,7 +1201,7 @@ public class LocalSession implements TextureHolder {
tool = tools.get(item.getInternalId()); tool = tools.get(item.getInternalId());
} }
if (tool == SelectionWand.INSTANCE && !SelectionWand.INSTANCE.canUse(player)) { if (tool == SelectionWand.INSTANCE && !SelectionWand.INSTANCE.canUse(player)) {
tools.remove(wandItem.getInternalId()); tools.remove(wandItem.getType().getInternalId());
loadDefaults(player, true); // Permissions have changed so redo the player's current tools. loadDefaults(player, true); // Permissions have changed so redo the player's current tools.
return null; return null;
} }
@ -1253,18 +1255,20 @@ public class LocalSession implements TextureHolder {
if (loadDefaults || force) { if (loadDefaults || force) {
loadDefaults = false; loadDefaults = false;
LocalConfiguration config = WorldEdit.getInstance().getConfiguration(); LocalConfiguration config = WorldEdit.getInstance().getConfiguration();
ParserContext context = new ParserContext();
context.setActor(actor);
if (wandItem == null) { if (wandItem == null) {
wandItem = ItemTypes.parse(config.wandItem); wandItem = WorldEdit.getInstance().getItemFactory().parseFromInput(config.wandItem, context);
} }
if (navWandItem == null) { if (navWandItem == null) {
navWandItem = ItemTypes.parse(config.navigationWand); navWandItem = WorldEdit.getInstance().getItemFactory().parseFromInput(config.navigationWand, context);
} }
synchronized (this.tools) { synchronized (this.tools) {
if (tools.get(navWandItem.getInternalId()) == null && NavigationWand.INSTANCE.canUse(actor)) { if (tools.get(navWandItem.getType().getInternalId()) == null && NavigationWand.INSTANCE.canUse(actor)) {
tools.put(navWandItem.getInternalId(), NavigationWand.INSTANCE); tools.put(navWandItem.getType().getInternalId(), NavigationWand.INSTANCE);
} }
if (tools.get(wandItem.getInternalId()) == null && SelectionWand.INSTANCE.canUse(actor)) { if (tools.get(wandItem.getType().getInternalId()) == null && SelectionWand.INSTANCE.canUse(actor)) {
tools.put(wandItem.getInternalId(), SelectionWand.INSTANCE); tools.put(wandItem.getType().getInternalId(), SelectionWand.INSTANCE);
} }
} }
} }
@ -1334,10 +1338,24 @@ public class LocalSession implements TextureHolder {
* @param item the item type * @param item the item type
* @param tool the tool to set, which can be {@code null} * @param tool the tool to set, which can be {@code null}
* @throws InvalidToolBindException if the item can't be bound to that item * @throws InvalidToolBindException if the item can't be bound to that item
* @deprecated use {@link #setTool(BaseItem, Tool)}
*/ */
@Deprecated
public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException { public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException {
if (item.hasBlockType()) { setTool(new BaseItem(item), tool);
throw new InvalidToolBindException(item, Caption.of("worldedit.error.blocks-cant-be-used")); }
/**
* Set the tool.
*
* @param item the item type
* @param tool the tool to set, which can be {@code null}
* @throws InvalidToolBindException if the item can't be bound to that item
* @since TODO
*/
public void setTool(BaseItem item, @Nullable Tool tool) throws InvalidToolBindException {
if (item.getType().hasBlockType()) {
throw new InvalidToolBindException(item.getType(), Caption.of("worldedit.error.blocks-cant-be-used"));
} }
if (tool instanceof SelectionWand) { if (tool instanceof SelectionWand) {
changeTool(this.wandItem, this.wandItem = item, tool); changeTool(this.wandItem, this.wandItem = item, tool);
@ -1348,7 +1366,7 @@ public class LocalSession implements TextureHolder {
setDirty(); setDirty();
return; return;
} }
setTool(item.getDefaultState(), tool, null); setTool(item, tool, null);
} }
public void setTool(Player player, @Nullable Tool tool) throws InvalidToolBindException { public void setTool(Player player, @Nullable Tool tool) throws InvalidToolBindException {
@ -1356,17 +1374,17 @@ public class LocalSession implements TextureHolder {
setTool(item, tool, player); setTool(item, tool, player);
} }
private void changeTool(ItemType oldType, ItemType newType, Tool newTool) { private void changeTool(BaseItem oldItem, BaseItem newItem, Tool newTool) {
if (oldType != null) { if (oldItem != null) {
synchronized (this.tools) { synchronized (this.tools) {
this.tools.remove(oldType.getInternalId()); this.tools.remove(oldItem.getType().getInternalId());
} }
} }
synchronized (this.tools) { synchronized (this.tools) {
if (newTool == null) { if (newTool == null) {
this.tools.remove(newType.getInternalId()); this.tools.remove(newItem.getType().getInternalId());
} else { } else {
this.tools.put(newType.getInternalId(), newTool); this.tools.put(newItem.getType().getInternalId(), newTool);
} }
} }
} }
@ -1376,11 +1394,11 @@ public class LocalSession implements TextureHolder {
if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) { if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) {
throw new InvalidToolBindException(type, Caption.of("worldedit.error.blocks-cant-be-used")); throw new InvalidToolBindException(type, Caption.of("worldedit.error.blocks-cant-be-used"));
} else if (tool instanceof SelectionWand) { } else if (tool instanceof SelectionWand) {
changeTool(this.wandItem, this.wandItem = item.getType(), tool); changeTool(this.wandItem, this.wandItem = item, tool);
setDirty(); setDirty();
return; return;
} else if (tool instanceof NavigationWand) { } else if (tool instanceof NavigationWand) {
changeTool(this.navWandItem, this.navWandItem = item.getType(), tool); changeTool(this.navWandItem, this.navWandItem = item, tool);
setDirty(); setDirty();
return; return;
} }
@ -1877,20 +1895,46 @@ public class LocalSession implements TextureHolder {
* Get the preferred wand item for this user, or {@code null} to use the default * Get the preferred wand item for this user, or {@code null} to use the default
* *
* @return item id of wand item, or {@code null} * @return item id of wand item, or {@code null}
* @deprecated use {@link #getWandBaseItem()}
*/ */
@Deprecated
public String getWandItem() { public String getWandItem() {
return wandItem.getId(); return wandItem.getType().id();
} }
/** /**
* Get the preferred navigation wand item for this user, or {@code null} to use the default * Get the preferred navigation wand item for this user, or {@code null} to use the default
* *
* @return item id of nav wand item, or {@code null} * @return item id of nav wand item, or {@code null}
* @deprecated use {@link #getNavWandBaseItem()}
*/ */
@Deprecated
public String getNavWandItem() { public String getNavWandItem() {
return navWandItem.getId(); return navWandItem.getType().id();
} }
//FAWE start
/**
* Get the preferred wand item for this user, or {@code null} to use the default
*
* @return item id of wand item, or {@code null}
* @since TODO
*/
public BaseItem getWandBaseItem() {
return wandItem == null ? null : new BaseItem(wandItem.getType(), wandItem.getNbtReference());
}
/**
* Get the preferred navigation wand item for this user, or {@code null} to use the default
*
* @return item id of nav wand item, or {@code null}
* @since TODO
*/
public BaseItem getNavWandBaseItem() {
return navWandItem == null ? null : new BaseItem(navWandItem.getType(), navWandItem.getNbtReference());
}
//FAWE end
/** /**
* Get the last block distribution stored in this session. * Get the last block distribution stored in this session.
* *

Datei anzeigen

@ -71,6 +71,7 @@ public class BaseItem implements NbtValued {
* @param itemType The type to set * @param itemType The type to set
*/ */
public void setType(ItemType itemType) { public void setType(ItemType itemType) {
checkNotNull(itemType);
this.itemType = itemType; this.itemType = itemType;
} }
@ -128,7 +129,7 @@ public class BaseItem implements NbtValued {
} }
} }
return getType().getId() + nbtString; return getType().id() + nbtString;
} }
//FAWE end //FAWE end
} }

Datei anzeigen

@ -98,7 +98,7 @@ public class BiomeCommands {
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%", PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
BiomeType.REGISTRY.values().stream() BiomeType.REGISTRY.values().stream()
.map(biomeType -> TextComponent.builder() .map(biomeType -> TextComponent.builder()
.append(biomeType.getId()) .append(biomeType.id())
.append(" (") .append(" (")
.append(biomeRegistry.getRichName(biomeType)) .append(biomeRegistry.getRichName(biomeType))
.append(")") .append(")")
@ -166,7 +166,7 @@ public class BiomeCommands {
List<Component> components = biomes.stream().map(biome -> List<Component> components = biomes.stream().map(biome ->
biomeRegistry.getRichName(biome).hoverEvent( biomeRegistry.getRichName(biome).hoverEvent(
HoverEvent.showText(TextComponent.of(biome.getId())) HoverEvent.showText(TextComponent.of(biome.id()))
) )
).collect(Collectors.toList()); ).collect(Collectors.toList());
actor.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", ")))); actor.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));

Datei anzeigen

@ -349,7 +349,7 @@ public class GeneralCommands {
if (world == null) { if (world == null) {
actor.print(Caption.of("worldedit.world.remove")); actor.print(Caption.of("worldedit.world.remove"));
} else { } else {
actor.print(Caption.of("worldedit.world.set", TextComponent.of(world.getId()))); actor.print(Caption.of("worldedit.world.set", TextComponent.of(world.id())));
} }
} }
@ -641,7 +641,7 @@ public class GeneralCommands {
if (itemsOnly && searchType.hasBlockType()) { if (itemsOnly && searchType.hasBlockType()) {
continue; continue;
} }
final String id = searchType.getId(); final String id = searchType.id();
if (id.contains(idMatch)) { if (id.contains(idMatch)) {
Component name = searchType.getRichName(); Component name = searchType.getRichName();
results.put(id, TextComponent.builder() results.put(id, TextComponent.builder()

Datei anzeigen

@ -30,6 +30,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.command.argument.SelectorChoice; import com.sk89q.worldedit.command.argument.SelectorChoice;
import com.sk89q.worldedit.command.tool.NavigationWand; import com.sk89q.worldedit.command.tool.NavigationWand;
@ -38,6 +39,8 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
@ -76,8 +79,6 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.ChunkStore;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
@ -325,22 +326,28 @@ public class SelectionCommands {
//FAWE start //FAWE start
session.loadDefaults(player, true); session.loadDefaults(player, true);
//FAWE end //FAWE end
String wandId = navWand ? session.getNavWandItem() : session.getWandItem(); BaseItem wand = navWand ? session.getNavWandBaseItem() : session.getWandBaseItem();
if (wandId == null) { if (wand == null) {
wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem; String wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem;
//FAWE start - allow item NBT
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setSession(session);
try {
wand = WorldEdit.getInstance().getItemFactory().parseFromInput(wandId, parserContext);
} catch (InputParseException e) {
player.print(Caption.of("worldedit.wand.invalid"));
return;
}
} }
ItemType itemType = ItemTypes.parse(wandId); player.giveItem(new BaseItemStack(wand.getType(), wand.getNbtReference(), 1));
if (itemType == null) { //FAWE end
player.print(Caption.of("worldedit.wand.invalid"));
return;
}
player.giveItem(new BaseItemStack(itemType, 1));
//FAWE start - instance-iate session //FAWE start - instance-iate session
if (navWand) { if (navWand) {
session.setTool(itemType, NavigationWand.INSTANCE); session.setTool(wand, NavigationWand.INSTANCE);
player.print(Caption.of("worldedit.wand.navwand.info")); player.print(Caption.of("worldedit.wand.navwand.info"));
} else { } else {
session.setTool(itemType, SelectionWand.INSTANCE); session.setTool(wand, SelectionWand.INSTANCE);
player.print(Caption.of("worldedit.wand.selwand.info")); player.print(Caption.of("worldedit.wand.selwand.info"));
//FAWE end //FAWE end
} }
@ -832,7 +839,7 @@ public class SelectionCommands {
toolTip = TextComponent.of(state.getAsString()); toolTip = TextComponent.of(state.getAsString());
blockName = blockName.append(TextComponent.of("*")); blockName = blockName.append(TextComponent.of("*"));
} else { } else {
toolTip = TextComponent.of(blockType.getId()); toolTip = TextComponent.of(blockType.id());
} }
blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip)); blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip));
line.append(blockName); line.append(blockName);

Datei anzeigen

@ -149,7 +149,7 @@ public class ToolCommands {
throws InvalidToolBindException { throws InvalidToolBindException {
//FAWE start //FAWE start
isBrush = session.getTool(player) instanceof BrushTool; isBrush = session.getTool(player) instanceof BrushTool;
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null); session.setTool(player.getItemInHand(HandSide.MAIN_HAND), null);
//FAWE end //FAWE end
player.print(Caption.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip")); player.print(Caption.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip"));
} }
@ -163,7 +163,7 @@ public class ToolCommands {
String translationKey String translationKey
) throws InvalidToolBindException { ) throws InvalidToolBindException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(itemStack.getType(), tool); session.setTool(itemStack, tool);
player.print(Caption.of(translationKey, itemStack.getRichName())); player.print(Caption.of(translationKey, itemStack.getRichName()));
sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT); sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
} }

Datei anzeigen

@ -65,7 +65,7 @@ public class WorldConverter implements ArgumentConverter<World> {
@Override @Override
public List<String> getSuggestions(String input, InjectedValueAccess context) { public List<String> getSuggestions(String input, InjectedValueAccess context) {
return getWorlds() return getWorlds()
.map(World::getId) .map(World::id)
.filter(world -> world.startsWith(input)) .filter(world -> world.startsWith(input))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@ -73,7 +73,7 @@ public class WorldConverter implements ArgumentConverter<World> {
@Override @Override
public ConversionResult<World> convert(String s, InjectedValueAccess injectedValueAccess) { public ConversionResult<World> convert(String s, InjectedValueAccess injectedValueAccess) {
World result = getWorlds() World result = getWorlds()
.filter(world -> world.getId().equals(s)) .filter(world -> world.id().equals(s))
.findAny().orElse(null); .findAny().orElse(null);
return result == null return result == null
? FailedConversion.from(new IllegalArgumentException( ? FailedConversion.from(new IllegalArgumentException(

Datei anzeigen

@ -66,7 +66,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
if (!config.allowedDataCycleBlocks.isEmpty() if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler") && !player.hasPermission("worldedit.override.data-cycler")
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) { && !config.allowedDataCycleBlocks.contains(block.getBlockType().id())) {
player.print(Caption.of("worldedit.tool.data-cycler.block-not-permitted")); player.print(Caption.of("worldedit.tool.data-cycler.block-not-permitted"));
return true; return true;
} }

Datei anzeigen

@ -25,6 +25,7 @@ import com.fastasyncworldedit.core.extension.factory.parser.mask.AngleMaskParser
import com.fastasyncworldedit.core.extension.factory.parser.mask.BesideMaskParser; import com.fastasyncworldedit.core.extension.factory.parser.mask.BesideMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ExtremaMaskParser; import com.fastasyncworldedit.core.extension.factory.parser.mask.ExtremaMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.FalseMaskParser; import com.fastasyncworldedit.core.extension.factory.parser.mask.FalseMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.HotbarMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.LiquidMaskParser; import com.fastasyncworldedit.core.extension.factory.parser.mask.LiquidMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ROCAngleMaskParser; import com.fastasyncworldedit.core.extension.factory.parser.mask.ROCAngleMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.RadiusMaskParser; import com.fastasyncworldedit.core.extension.factory.parser.mask.RadiusMaskParser;
@ -110,6 +111,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
register(new BesideMaskParser(worldEdit)); register(new BesideMaskParser(worldEdit));
register(new ExtremaMaskParser(worldEdit)); register(new ExtremaMaskParser(worldEdit));
register(new FalseMaskParser(worldEdit)); register(new FalseMaskParser(worldEdit));
register(new HotbarMaskParser(worldEdit));
register(new LiquidMaskParser(worldEdit)); register(new LiquidMaskParser(worldEdit));
register(new RadiusMaskParser(worldEdit)); register(new RadiusMaskParser(worldEdit));
register(new RichOffsetMaskParser(worldEdit)); register(new RichOffsetMaskParser(worldEdit));

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.extension.factory; package com.sk89q.worldedit.extension.factory;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.mask.HotbarMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.AngleColorPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.AngleColorPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.AverageColorPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.AverageColorPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.BiomePatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.BiomePatternParser;
@ -30,6 +31,7 @@ import com.fastasyncworldedit.core.extension.factory.parser.pattern.DarkenPatter
import com.fastasyncworldedit.core.extension.factory.parser.pattern.DesaturatePatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.DesaturatePatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExistingPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExistingPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExpressionPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExpressionPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.HotbarPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.LightenPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.LightenPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear2DPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear2DPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear3DPatternParser; import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear3DPatternParser;
@ -116,6 +118,7 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
register(new DesaturatePatternParser(worldEdit)); register(new DesaturatePatternParser(worldEdit));
register(new ExistingPatternParser(worldEdit)); register(new ExistingPatternParser(worldEdit));
register(new ExpressionPatternParser(worldEdit)); register(new ExpressionPatternParser(worldEdit));
register(new HotbarPatternParser(worldEdit));
register(new LightenPatternParser(worldEdit)); register(new LightenPatternParser(worldEdit));
register(new Linear2DPatternParser(worldEdit)); register(new Linear2DPatternParser(worldEdit));
register(new Linear3DPatternParser(worldEdit)); register(new Linear3DPatternParser(worldEdit));

Datei anzeigen

@ -135,42 +135,42 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
private String woolMapper(String string) { private String woolMapper(String string) {
switch (string.toLowerCase(Locale.ROOT)) { switch (string.toLowerCase(Locale.ROOT)) {
case "white": case "white":
return BlockTypes.WHITE_WOOL.getId(); return BlockTypes.WHITE_WOOL.id();
case "black": case "black":
return BlockTypes.BLACK_WOOL.getId(); return BlockTypes.BLACK_WOOL.id();
case "blue": case "blue":
return BlockTypes.BLUE_WOOL.getId(); return BlockTypes.BLUE_WOOL.id();
case "brown": case "brown":
return BlockTypes.BROWN_WOOL.getId(); return BlockTypes.BROWN_WOOL.id();
case "cyan": case "cyan":
return BlockTypes.CYAN_WOOL.getId(); return BlockTypes.CYAN_WOOL.id();
case "gray": case "gray":
case "grey": case "grey":
return BlockTypes.GRAY_WOOL.getId(); return BlockTypes.GRAY_WOOL.id();
case "green": case "green":
return BlockTypes.GREEN_WOOL.getId(); return BlockTypes.GREEN_WOOL.id();
case "light_blue": case "light_blue":
case "lightblue": case "lightblue":
return BlockTypes.LIGHT_BLUE_WOOL.getId(); return BlockTypes.LIGHT_BLUE_WOOL.id();
case "light_gray": case "light_gray":
case "light_grey": case "light_grey":
case "lightgray": case "lightgray":
case "lightgrey": case "lightgrey":
return BlockTypes.LIGHT_GRAY_WOOL.getId(); return BlockTypes.LIGHT_GRAY_WOOL.id();
case "lime": case "lime":
return BlockTypes.LIME_WOOL.getId(); return BlockTypes.LIME_WOOL.id();
case "magenta": case "magenta":
return BlockTypes.MAGENTA_WOOL.getId(); return BlockTypes.MAGENTA_WOOL.id();
case "orange": case "orange":
return BlockTypes.ORANGE_WOOL.getId(); return BlockTypes.ORANGE_WOOL.id();
case "pink": case "pink":
return BlockTypes.PINK_WOOL.getId(); return BlockTypes.PINK_WOOL.id();
case "purple": case "purple":
return BlockTypes.PURPLE_WOOL.getId(); return BlockTypes.PURPLE_WOOL.id();
case "yellow": case "yellow":
return BlockTypes.YELLOW_WOOL.getId(); return BlockTypes.YELLOW_WOOL.id();
case "red": case "red":
return BlockTypes.RED_WOOL.getId(); return BlockTypes.RED_WOOL.id();
default: default:
return string; return string;
} }
@ -194,7 +194,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (input.indexOf('[') == -1 && input.indexOf(']') == -1) { if (input.indexOf('[') == -1 && input.indexOf(']') == -1) {
continue; continue;
} }
if (!type.getId().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) { if (!type.id().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) {
continue; continue;
} }
String[] properties = input.substring(input.indexOf('[') + 1, input.indexOf(']')).split(","); String[] properties = input.substring(input.indexOf('[') + 1, input.indexOf(']')).split(",");
@ -249,10 +249,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
throw new NoMatchException(Caption.of( throw new NoMatchException(Caption.of(
"worldedit.error.parser.unknown-property", "worldedit.error.parser.unknown-property",
TextComponent.of(parts[0]), TextComponent.of(parts[0]),
TextComponent.of(type.getId()) TextComponent.of(type.id())
)); ));
} else { } else {
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId()); WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.id());
} }
return Maps.newHashMap(); return Maps.newHashMap();
} }
@ -516,20 +516,20 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
//FAWE start - per-limit disallowed blocks //FAWE start - per-limit disallowed blocks
if (actor != null) { if (actor != null) {
if (!actor.hasPermission("worldedit.anyblock") if (!actor.hasPermission("worldedit.anyblock")
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId().toLowerCase(Locale.ROOT))) { && worldEdit.getConfiguration().disallowedBlocks.contains(blockType.id().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of( throw new DisallowedUsageException(Caption.of(
"worldedit.error.disallowed-block", "worldedit.error.disallowed-block",
TextComponent.of(blockType.getId()) TextComponent.of(blockType.id())
)); ));
} }
FaweLimit limit = actor.getLimit(); FaweLimit limit = actor.getLimit();
if (!limit.isUnlimited()) { if (!limit.isUnlimited()) {
// No need to account for blocked states/properties as it will simply return false in the equality check // No need to account for blocked states/properties as it will simply return false in the equality check
// during contains. // during contains.
if (limit.DISALLOWED_BLOCKS.contains(blockType.getId().toLowerCase(Locale.ROOT))) { if (limit.DISALLOWED_BLOCKS.contains(blockType.id().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of( throw new DisallowedUsageException(Caption.of(
"fawe.error.limit.disallowed-block", "fawe.error.limit.disallowed-block",
TextComponent.of(blockType.getId()) TextComponent.of(blockType.id())
)); ));
} }
} }
@ -559,14 +559,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (ent == null) { if (ent == null) {
throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName))); throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
} }
mobName = ent.getId(); mobName = ent.id();
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) { if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName))); throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
} }
return validate(context, new MobSpawnerBlock(state, mobName)); return validate(context, new MobSpawnerBlock(state, mobName));
} else { } else {
//noinspection ConstantConditions //noinspection ConstantConditions
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId())); return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.id()));
} }
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) { } else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
// allow setting type/player/rotation // allow setting type/player/rotation

Datei anzeigen

@ -71,7 +71,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> implements
Set<BlockType> blocks = category.getAll(); Set<BlockType> blocks = category.getAll();
if (blocks.isEmpty()) { if (blocks.isEmpty()) {
throw new InputParseException(Caption.of("worldedit.error.empty-tag", TextComponent.of(category.getId()))); throw new InputParseException(Caption.of("worldedit.error.empty-tag", TextComponent.of(category.id())));
} }
if (anyState) { if (anyState) {

Datei anzeigen

@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.configuration.Caption;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.factory.MaskFactory; import com.sk89q.worldedit.extension.factory.MaskFactory;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
@ -217,6 +218,20 @@ public class ParserContext {
return actor; return actor;
} }
/**
* Get the {@link Player} set on this context.
*
* @return a player
* @throws InputParseException thrown if no {@link Actor} is set
*/
public Player requirePlayer() throws InputParseException {
Actor actor = getActor();
if (!(actor instanceof Player player)) {
throw new InputParseException(Caption.of("worldedit.error.missing-player"));
}
return player;
}
/** /**
* Returns whether there should be restrictions (as a result of * Returns whether there should be restrictions (as a result of
* limits or permissions) considered when parsing the input. * limits or permissions) considered when parsing the input.

Datei anzeigen

@ -233,7 +233,7 @@ public interface Platform extends Keyed {
*/ */
@NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {}) @NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {})
@Override @Override
default String getId() { default String id() {
return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_"); return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_");
} }

Datei anzeigen

@ -425,7 +425,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
if (pasteEntities) { if (pasteEntities) {
for (Entity entity : this.getEntities()) { for (Entity entity : this.getEntities()) {
// skip players on pasting schematic // skip players on pasting schematic
if (entity.getState() != null && entity.getState().getType().getId() if (entity.getState() != null && entity.getState().getType().id()
.equals("minecraft:player")) { .equals("minecraft:player")) {
continue; continue;
} }

Datei anzeigen

@ -223,7 +223,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
BlockVector3 pt = BlockVector3.at(x0, min.y(), z0); BlockVector3 pt = BlockVector3.at(x0, min.y(), z0);
BiomeType biome = clipboard.getBiome(pt); BiomeType biome = clipboard.getBiome(pt);
String biomeKey = biome.getId(); String biomeKey = biome.id();
int biomeId; int biomeId;
if (palette.containsKey(biomeKey)) { if (palette.containsKey(biomeKey)) {
biomeId = palette.get(biomeKey); biomeId = palette.get(biomeKey);
@ -262,7 +262,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
values.putAll(rawData.getValue()); values.putAll(rawData.getValue());
} }
values.remove("id"); values.remove("id");
values.put("Id", new StringTag(state.getType().getId())); values.put("Id", new StringTag(state.getType().id()));
final Location location = e.getLocation(); final Location location = e.getLocation();
values.put("Pos", writeVector(location.toVector())); values.put("Pos", writeVector(location.toVector()));
values.put("Rotation", writeRotation(location)); values.put("Rotation", writeRotation(location));

Datei anzeigen

@ -84,7 +84,7 @@ public class FlowerPotCompatibilityHandler implements NBTCompatibilityHandler {
} else { } else {
BlockState plantedWithData = LegacyMapper.getInstance().getBlockFromLegacy(newId, data); BlockState plantedWithData = LegacyMapper.getInstance().getBlockFromLegacy(newId, data);
if (plantedWithData != null) { if (plantedWithData != null) {
plantedName = plantedWithData.getBlockType().getId().substring(10); // remove "minecraft:" plantedName = plantedWithData.getBlockType().id().substring(10); // remove "minecraft:"
} }
} }
if (plantedName != null) { if (plantedName != null) {

Datei anzeigen

@ -29,7 +29,7 @@ public class Pre13HangingCompatibilityHandler implements EntityNBTCompatibilityH
@Override @Override
public boolean isAffectedEntity(EntityType type, CompoundTag tag) { public boolean isAffectedEntity(EntityType type, CompoundTag tag) {
if (!type.getId().startsWith("minecraft:")) { if (!type.id().startsWith("minecraft:")) {
return false; return false;
} }
boolean hasLegacyDirection = tag.containsKey("Dir") || tag.containsKey("Direction"); boolean hasLegacyDirection = tag.containsKey("Dir") || tag.containsKey("Direction");

Datei anzeigen

@ -23,27 +23,10 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
/** /**
* Items of metadata about shared clipboards. * Items of metadata about shared clipboards.
*
* @param format the format of the clipboard
* @param name the name of the clipboard
* @param author the author of the clipboard
*/ */
public class ClipboardShareMetadata { public record ClipboardShareMetadata(ClipboardFormat format, String name, String author) {
private final ClipboardFormat format;
private final String name;
private final String author;
public ClipboardShareMetadata(ClipboardFormat format, String name, String author) {
this.format = format;
this.name = name;
this.author = author;
}
public ClipboardFormat format() {
return this.format;
}
public String name() {
return this.name;
}
public String author() {
return this.author;
}
} }

Datei anzeigen

@ -441,7 +441,7 @@ public class BlockTransformExtent extends ResettableExtent {
if (Settings.settings().ENABLED_COMPONENTS.DEBUG) { if (Settings.settings().ENABLED_COMPONENTS.DEBUG) {
LOGGER.warn(String.format( LOGGER.warn(String.format(
"Index outside direction array length found for block:{%s} property:{%s}", "Index outside direction array length found for block:{%s} property:{%s}",
state.getBlockType().getId(), state.getBlockType().id(),
property.getName() property.getName()
)); ));
} }

Datei anzeigen

@ -116,7 +116,7 @@ public class SnowSimulator implements LayerFunction {
if (!above.getBlockType().getMaterial().isAir() && (!stack || above.getBlockType() != BlockTypes.SNOW)) { if (!above.getBlockType().getMaterial().isAir() && (!stack || above.getBlockType() != BlockTypes.SNOW)) {
return false; return false;
//FAWE start //FAWE start
} else if (!block.getBlockType().getId().toLowerCase(Locale.ROOT).contains("ice") && this.extent.getEmittedLight( } else if (!block.getBlockType().id().toLowerCase(Locale.ROOT).contains("ice") && this.extent.getEmittedLight(
abovePosition) > 10) { abovePosition) > 10) {
return false; return false;
} else if (!block.getBlockType().getMaterial().isFullCube()) { } else if (!block.getBlockType().getMaterial().isFullCube()) {
@ -132,7 +132,7 @@ public class SnowSimulator implements LayerFunction {
return false; return false;
} }
//FAWE end //FAWE end
} else if (!block.getBlockType().getId().toLowerCase(Locale.ROOT).contains("ice") && block } else if (!block.getBlockType().id().toLowerCase(Locale.ROOT).contains("ice") && block
.getBlockType() .getBlockType()
.getMaterial() .getMaterial()
.isTranslucent()) { .isTranslucent()) {

Datei anzeigen

@ -167,24 +167,14 @@ public class Deform implements Contextual<Operation> {
); );
} }
private static final class DeformOperation implements Operation { private record DeformOperation(
Extent destination,
private final Extent destination; Region region,
private final Region region; Vector3 zero,
private final Vector3 zero; Vector3 unit,
private final Vector3 unit; String expression, //FAWE: Expression -> String
private final String expression; int timeout
private final int timeout; ) implements Operation {
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression, int timeout) {
this.destination = destination;
this.region = region;
this.zero = zero;
this.unit = unit;
this.expression = expression;
this.timeout = timeout;
}
@Override @Override
public Operation resume(RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
try { try {

Datei anzeigen

@ -87,7 +87,7 @@ public interface Mask {
} else if (this instanceof Masks.AlwaysFalse) { } else if (this instanceof Masks.AlwaysFalse) {
return Masks.ALWAYS_TRUE; return Masks.ALWAYS_TRUE;
} else if (this instanceof Masks.NegatedMask) { } else if (this instanceof Masks.NegatedMask) {
return ((Masks.NegatedMask) this).mask; return ((Masks.NegatedMask) this).mask();
} }
return new InverseMask(this); return new InverseMask(this);
} }

Datei anzeigen

@ -211,15 +211,7 @@ public final class Masks {
} }
//FAWE start - protected > private protected record NegatedMask(Mask mask) implements Mask {
protected static class NegatedMask implements Mask {
//FAWE end
protected final Mask mask;
private NegatedMask(Mask mask) {
this.mask = mask;
}
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(BlockVector3 vector) {
@ -245,13 +237,7 @@ public final class Masks {
} }
private static class NegatedMask2D implements Mask2D { private record NegatedMask2D(Mask2D mask) implements Mask2D {
private final Mask2D mask;
private NegatedMask2D(Mask2D mask) {
this.mask = mask;
}
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(BlockVector2 vector) {

Datei anzeigen

@ -33,34 +33,30 @@ import static com.google.common.base.Preconditions.checkNotNull;
* <p>This biome change does not have an {@link Extent} assigned to it because * <p>This biome change does not have an {@link Extent} assigned to it because
* one will be taken from the passed {@link UndoContext}. If the context * one will be taken from the passed {@link UndoContext}. If the context
* does not have an extent (it is null), cryptic errors may occur.</p> * does not have an extent (it is null), cryptic errors may occur.</p>
*
* @param position the position
* @param previous the previous biome
* @param current the current biome
*/ */
public class BiomeChange3D implements Change { public record BiomeChange3D(BlockVector3 position, BiomeType previous, BiomeType current) implements Change {
private final BlockVector3 position;
private final BiomeType previous;
private final BiomeType current;
/** /**
* Create a new biome change. * Create a new biome change.
* *
* @param position the position
* @param previous the previous biome
* @param current the current biome
*/ */
public BiomeChange3D(BlockVector3 position, BiomeType previous, BiomeType current) { public BiomeChange3D {
checkNotNull(position); checkNotNull(position);
checkNotNull(previous); checkNotNull(previous);
checkNotNull(current); checkNotNull(current);
this.position = position;
this.previous = previous;
this.current = current;
} }
/** /**
* Get the position. * Get the position.
* *
* @return the position * @return the position
* @deprecated Use {@link #position()}.
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public BlockVector3 getPosition() { public BlockVector3 getPosition() {
return position; return position;
} }
@ -69,7 +65,9 @@ public class BiomeChange3D implements Change {
* Get the previous biome. * Get the previous biome.
* *
* @return the previous biome * @return the previous biome
* @deprecated Use {@link #previous()}.
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public BiomeType getPrevious() { public BiomeType getPrevious() {
return previous; return previous;
} }
@ -78,7 +76,9 @@ public class BiomeChange3D implements Change {
* Get the current biome. * Get the current biome.
* *
* @return the current biome * @return the current biome
* @deprecated Use {@link #current()}.
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public BiomeType getCurrent() { public BiomeType getCurrent() {
return current; return current;
} }

Datei anzeigen

@ -34,12 +34,21 @@ import static com.google.common.base.Preconditions.checkNotNull;
* <p>This block change does not have an {@link Extent} assigned to it because * <p>This block change does not have an {@link Extent} assigned to it because
* one will be taken from the passed {@link UndoContext}. If the context * one will be taken from the passed {@link UndoContext}. If the context
* does not have an extent (it is null), cryptic errors may occur.</p> * does not have an extent (it is null), cryptic errors may occur.</p>
*
* @param position the position
* @param previous the previous block
* @param current the current block
*/ */
public class BlockChange implements Change { public record BlockChange(BlockVector3 position, BaseBlock previous, BaseBlock current) implements Change {
private final BlockVector3 position; /**
private final BaseBlock previous; * Create a new block change.
private final BaseBlock current; */
public BlockChange {
checkNotNull(position);
checkNotNull(previous);
checkNotNull(current);
}
/** /**
* Create a new block change. * Create a new block change.
@ -53,19 +62,16 @@ public class BlockChange implements Change {
BP previous, BP previous,
BC current BC current
) { ) {
checkNotNull(position); this(position, previous.toBaseBlock(), current.toBaseBlock());
checkNotNull(previous);
checkNotNull(current);
this.position = position;
this.previous = previous.toBaseBlock();
this.current = current.toBaseBlock();
} }
/** /**
* Get the position. * Get the position.
* *
* @return the position * @return the position
* @deprecated use {@link #position()}
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public BlockVector3 getPosition() { public BlockVector3 getPosition() {
return position; return position;
} }
@ -74,7 +80,9 @@ public class BlockChange implements Change {
* Get the previous block. * Get the previous block.
* *
* @return the previous block * @return the previous block
* @deprecated use {@link #previous()}
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public BaseBlock getPrevious() { public BaseBlock getPrevious() {
return previous; return previous;
} }
@ -83,7 +91,9 @@ public class BlockChange implements Change {
* Get the current block. * Get the current block.
* *
* @return the current block * @return the current block
* @deprecated use {@link #current()}
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public BaseBlock getCurrent() { public BaseBlock getCurrent() {
return current; return current;
} }

Datei anzeigen

@ -56,7 +56,7 @@ public class BlockOptimizedHistory extends ArrayListHistory {
BlockChange blockChange = (BlockChange) change; BlockChange blockChange = (BlockChange) change;
BlockVector3 position = blockChange.getPosition(); BlockVector3 position = blockChange.getPosition();
if (!previous.containsLocation(position)) { if (!previous.containsLocation(position)) {
previous.add(position, blockChange.getPrevious()); previous.add(position, blockChange.previous());
} }
current.add(position, blockChange.getCurrent()); current.add(position, blockChange.getCurrent());
} else { } else {

Datei anzeigen

@ -87,16 +87,10 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
} }
} }
private static class ExceptionHandler implements Comparable<ExceptionHandler> { private record ExceptionHandler(
Class<? extends Throwable> cls,
final Class<? extends Throwable> cls; Method method
final Method method; ) implements Comparable<ExceptionHandler> {
private ExceptionHandler(Class<? extends Throwable> cls, Method method) {
this.cls = cls;
this.method = method;
}
@Override @Override
public int compareTo(ExceptionHandler o) { public int compareTo(ExceptionHandler o) {
if (cls.equals(o.cls)) { if (cls.equals(o.cls)) {

Datei anzeigen

@ -165,7 +165,7 @@ public class ServerCUIHandler {
structureTag.putString("mode", "SAVE"); structureTag.putString("mode", "SAVE");
structureTag.putByte("ignoreEntities", (byte) 1); structureTag.putByte("ignoreEntities", (byte) 1);
structureTag.putByte("showboundingbox", (byte) 1); structureTag.putByte("showboundingbox", (byte) 1);
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.getId()); structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.id());
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build()); return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build());
//FAWE end //FAWE end

Datei anzeigen

@ -57,13 +57,6 @@ public class InteractionDebouncer {
return Optional.empty(); return Optional.empty();
} }
private static class Interaction { private record Interaction(long tick, boolean result) {
public final long tick;
public final boolean result;
public Interaction(long tick, boolean result) {
this.tick = tick;
this.result = result;
}
} }
} }

Datei anzeigen

@ -23,36 +23,23 @@ import java.time.Instant;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
public class ExecutionData { public record ExecutionData(SlotTable slots, Functions functions, Instant deadline) {
/** /**
* Special execution context for evaluating constant values. As long as no variables are used, * Special execution context for evaluating constant values. As long as no variables are used, it can be considered
* it can be considered constant. * constant.
*/ */
public static final ExecutionData CONSTANT_EVALUATOR = new ExecutionData(null, null, Instant.MAX); public static final ExecutionData CONSTANT_EVALUATOR = new ExecutionData(null, null, Instant.MAX);
private final SlotTable slots; @Override
private final Functions functions; public SlotTable slots() {
private final Instant deadline;
public ExecutionData(SlotTable slots, Functions functions, Instant deadline) {
this.slots = slots;
this.functions = functions;
this.deadline = deadline;
}
public SlotTable getSlots() {
return requireNonNull(slots, "Cannot use variables in a constant"); return requireNonNull(slots, "Cannot use variables in a constant");
} }
public Functions getFunctions() { @Override
public Functions functions() {
return requireNonNull(functions, "Cannot use functions in a constant"); return requireNonNull(functions, "Cannot use functions in a constant");
} }
public Instant getDeadline() {
return deadline;
}
public void checkDeadline() { public void checkDeadline() {
if (Instant.now().isAfter(deadline)) { if (Instant.now().isAfter(deadline)) {
throw new ExpressionTimeoutException("Calculations exceeded time limit."); throw new ExpressionTimeoutException("Calculations exceeded time limit.");

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen