Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-27 03:12:37 +01:00
Address comments
Dieser Commit ist enthalten in:
Ursprung
e1bd3e28c4
Commit
6f83adcff0
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks;
|
||||
import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore;
|
||||
import com.fastasyncworldedit.bukkit.adapter.NativeEntityFunctionSet;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
@ -377,44 +378,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractCollection<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = NbtUtils.uuid(getTag);
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<FaweCompoundTag> iterator() {
|
||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
input.save(tag);
|
||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
||||
})::iterator;
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -423,43 +391,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractSet<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof com.sk89q.worldedit.entity.Entity e)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = e.getState().getNbtData().getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<com.sk89q.worldedit.entity.Entity> iterator() {
|
||||
Iterable<com.sk89q.worldedit.entity.Entity> result = entities
|
||||
.stream()
|
||||
.map(input -> new BukkitEntity(input.getBukkitEntity()))
|
||||
.collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||
}
|
||||
|
||||
private void removeEntity(Entity entity) {
|
||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks;
|
||||
import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore;
|
||||
import com.fastasyncworldedit.bukkit.adapter.NativeEntityFunctionSet;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
@ -377,44 +378,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractCollection<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = NbtUtils.uuid(getTag);
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<FaweCompoundTag> iterator() {
|
||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
input.save(tag);
|
||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
||||
})::iterator;
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -423,43 +391,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractSet<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof com.sk89q.worldedit.entity.Entity e)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = e.getState().getNbtData().getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<com.sk89q.worldedit.entity.Entity> iterator() {
|
||||
Iterable<com.sk89q.worldedit.entity.Entity> result = entities
|
||||
.stream()
|
||||
.map(input -> new BukkitEntity(input.getBukkitEntity()))
|
||||
.collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||
}
|
||||
|
||||
private void removeEntity(Entity entity) {
|
||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks;
|
||||
import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore;
|
||||
import com.fastasyncworldedit.bukkit.adapter.NativeEntityFunctionSet;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
@ -378,44 +379,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractCollection<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = NbtUtils.uuid(getTag);
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<FaweCompoundTag> iterator() {
|
||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
input.save(tag);
|
||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
||||
})::iterator;
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -424,43 +392,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractSet<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof com.sk89q.worldedit.entity.Entity e)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = e.getState().getNbtData().getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<com.sk89q.worldedit.entity.Entity> iterator() {
|
||||
Iterable<com.sk89q.worldedit.entity.Entity> result = entities
|
||||
.stream()
|
||||
.map(input -> new BukkitEntity(input.getBukkitEntity()))
|
||||
.collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||
}
|
||||
|
||||
private void removeEntity(Entity entity) {
|
||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks;
|
||||
import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore;
|
||||
import com.fastasyncworldedit.bukkit.adapter.NativeEntityFunctionSet;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
@ -378,45 +379,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractCollection<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = NbtUtils.uuid(getTag);
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<FaweCompoundTag> iterator() {
|
||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
input.save(tag);
|
||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
||||
})::iterator;
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -427,43 +394,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (entities.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
int size = entities.size();
|
||||
return new AbstractSet<>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof com.sk89q.worldedit.entity.Entity e)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = e.getState().getNbtData().getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<com.sk89q.worldedit.entity.Entity> iterator() {
|
||||
Iterable<com.sk89q.worldedit.entity.Entity> result = entities
|
||||
.stream()
|
||||
.map(input -> new BukkitEntity(input.getBukkitEntity()))
|
||||
.collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||
}
|
||||
|
||||
private void removeEntity(Entity entity) {
|
||||
|
@ -0,0 +1,60 @@
|
||||
package com.fastasyncworldedit.bukkit.adapter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NativeEntityFunctionSet<NativeEntity, Result> extends AbstractSet<Result> {
|
||||
|
||||
private final List<NativeEntity> nativeEntities;
|
||||
private final Function<NativeEntity, UUID> uuidGetter;
|
||||
private final Function<NativeEntity, Result> resultFunction;
|
||||
|
||||
public NativeEntityFunctionSet(
|
||||
List<NativeEntity> nativeEntities,
|
||||
Function<NativeEntity, UUID> uuidGetter,
|
||||
Function<NativeEntity, Result> resultFunction
|
||||
) {
|
||||
this.nativeEntities = nativeEntities;
|
||||
this.uuidGetter = uuidGetter;
|
||||
this.resultFunction = resultFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return nativeEntities.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object get) {
|
||||
if (!(get instanceof com.sk89q.worldedit.entity.Entity e)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = e.getState().getNbtData().getUUID();
|
||||
for (NativeEntity entity : nativeEntities) {
|
||||
UUID uuid = uuidGetter.apply(entity);
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<Result> iterator() {
|
||||
return nativeEntities
|
||||
.stream()
|
||||
.map(resultFunction)
|
||||
.iterator();
|
||||
}
|
||||
|
||||
}
|
@ -32,7 +32,6 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
|
||||
private final IQueueExtent<IQueueChunk> queue;
|
||||
private Consumer<IChunkGet> task;
|
||||
private volatile long lastPair = Long.MAX_VALUE;
|
||||
private volatile boolean isProcessing;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -59,16 +58,12 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
|
||||
}
|
||||
lastPair = pair;
|
||||
synchronized (set) {
|
||||
if (!set.contains(chunkX, chunkZ)) {
|
||||
set.add(chunkX, chunkZ);
|
||||
return true;
|
||||
}
|
||||
return set.add(chunkX, chunkZ);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkAndRun(int chunkX, int chunkZ) {
|
||||
if (!isProcessing && shouldRun(chunkX, chunkZ)) {
|
||||
if (shouldRun(chunkX, chunkZ)) {
|
||||
task.accept(queue.getCachedGet(chunkX, chunkZ));
|
||||
}
|
||||
}
|
||||
@ -88,7 +83,6 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
|
||||
|
||||
@Override
|
||||
public IChunkGet processGet(final IChunkGet get) {
|
||||
isProcessing = true;
|
||||
if (shouldRun(get.getX(), get.getZ())) {
|
||||
task.accept(get);
|
||||
}
|
||||
|
@ -72,11 +72,11 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
|
||||
if (offsetX == Integer.MAX_VALUE) {
|
||||
return false;
|
||||
}
|
||||
short sx = (short) (x - offsetX);
|
||||
short sz = (short) (z - offsetZ);
|
||||
if (sx > 32767 || sx < -32767 || sz > 32767 || sz < -32767) {
|
||||
if (x > 32767 || x < -32769 || z > 32769 || z < -32767) {
|
||||
return false;
|
||||
}
|
||||
short sx = (short) (x - offsetX);
|
||||
short sz = (short) (z - offsetZ);
|
||||
try {
|
||||
return set.get(MathMan.pairSearchCoords(sx, sz));
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren