Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 17:30:08 +01:00
Address comments
Dieser Commit ist enthalten in:
Ursprung
4df7961c88
Commit
936f5b7690
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2;
|
||||
|
||||
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;
|
||||
@ -366,91 +367,20 @@ 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 CompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = getTag.getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
PaperweightPlatformAdapter.readEntityIntoTag(input, tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<com.sk89q.worldedit.entity.Entity> getFullEntities() {
|
||||
getSections(true);
|
||||
getChunk();
|
||||
List<Entity> entities = PaperweightPlatformAdapter.getEntities(ensureLoaded(serverLevel, chunkX, chunkZ));
|
||||
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_18_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;
|
||||
@ -357,44 +358,11 @@ 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 CompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = getTag.getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
PaperweightPlatformAdapter.readEntityIntoTag(input, tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -403,43 +371,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_19_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;
|
||||
@ -360,44 +361,11 @@ 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 CompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = getTag.getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
PaperweightPlatformAdapter.readEntityIntoTag(input, tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -406,43 +374,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_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;
|
||||
@ -359,44 +360,11 @@ 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 CompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = getTag.getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
PaperweightPlatformAdapter.readEntityIntoTag(input, tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -405,43 +373,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_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;
|
||||
@ -341,49 +342,15 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
|
||||
@Override
|
||||
public Set<CompoundTag> getEntities() {
|
||||
ensureLoaded(serverLevel, chunkX, chunkZ);
|
||||
List<Entity> entities = PaperweightPlatformAdapter.getEntities(getChunk());
|
||||
List<Entity> entities = PaperweightPlatformAdapter.getEntities(ensureLoaded(serverLevel, chunkX, chunkZ));
|
||||
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 CompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = getTag.getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
input.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -392,43 +359,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;
|
||||
@ -341,49 +342,15 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
|
||||
@Override
|
||||
public Set<CompoundTag> getEntities() {
|
||||
ensureLoaded(serverLevel, chunkX, chunkZ);
|
||||
List<Entity> entities = PaperweightPlatformAdapter.getEntities(getChunk());
|
||||
List<Entity> entities = PaperweightPlatformAdapter.getEntities(ensureLoaded(serverLevel, chunkX, chunkZ));
|
||||
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 CompoundTag getTag)) {
|
||||
return false;
|
||||
}
|
||||
UUID getUUID = getTag.getUUID();
|
||||
for (Entity entity : entities) {
|
||||
UUID uuid = entity.getUUID();
|
||||
if (uuid.equals(getUUID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = entities.stream().map(input -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
input.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||
e.save(tag);
|
||||
return (CompoundTag) adapter.toNative(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -392,43 +359,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