Revert "start reimplementing entities"

This reverts commit aac02ceea1.
This commit is contained in:
Aurora 2020-07-01 14:54:11 +02:00
parent 6fc68da2ce
commit 9fc2387f11
No known key found for this signature in database
GPG Key ID: 89839F67B53656AD
10 changed files with 67 additions and 100 deletions

View File

@ -89,7 +89,7 @@ public class BukkitEntity implements Entity {
@Override @Override
public com.sk89q.worldedit.world.entity.EntityType getType() { public com.sk89q.worldedit.world.entity.EntityType getType() {
return EntityTypes.get(type.getName().toLowerCase(Locale.ROOT)); return EntityTypes.get(type.getName().toUpperCase(Locale.ROOT));
} }
@Override @Override

View File

@ -99,6 +99,7 @@ public class BukkitWorld extends AbstractWorld {
@Override @Override
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) { public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
World world = getWorld(); World world = getWorld();
List<Entity> ents = world.getEntities(); List<Entity> ents = world.getEntities();
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>(); List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
for (Entity ent : ents) { for (Entity ent : ents) {

View File

@ -63,9 +63,4 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
return hasBiomes; return hasBiomes;
} }
@Override
public List<? extends Entity> getEntities(Region region) {
return getExtent().getEntities(region);
}
} }

View File

@ -46,8 +46,6 @@ import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.MaskTraverser;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -3056,20 +3054,4 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
} }
return false; return false;
} }
@Override
public List<? extends Entity> getEntities(Region region) {
return world.getEntities(region);
}
@Override
public List<? extends Entity> getEntities() {
System.out.println("editsession");
return world.getEntities();
}
@Override
public Entity createEntity(Location location, BaseEntity entity) {
return world.createEntity(location, entity);
}
} }

View File

@ -132,7 +132,6 @@ public interface Extent extends InputExtent, OutputExtent {
* @return a list of entities * @return a list of entities
*/ */
default List<? extends Entity> getEntities() { default List<? extends Entity> getEntities() {
System.out.println("el");
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -195,19 +195,11 @@ public class BlockArrayClipboard implements Clipboard {
@Override @Override
public List<? extends Entity> getEntities(Region region) { public List<? extends Entity> getEntities(Region region) {
System.out.println("blockarrayclipboard");
region = region.clone(); region = region.clone();
region.shift(BlockVector3.ZERO.subtract(origin)); region.shift(BlockVector3.ZERO.subtract(origin));
return getParent().getEntities(region); return getParent().getEntities(region);
} }
@Override
public List<? extends Entity> getEntities() {
System.out.println("blockarrayall");
return getParent().getEntities();
}
@Override @Override
@Nullable @Nullable
public Entity createEntity(Location location, BaseEntity entity) { public Entity createEntity(Location location, BaseEntity entity) {

View File

@ -397,7 +397,7 @@ public class ForwardExtentCopy implements Operation {
Operations.completeBlindly(blockCopy); Operations.completeBlindly(blockCopy);
if (!entities.isEmpty()) { if (!entities.isEmpty()) {
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), finalDest, to.toVector3(), currentTransform); ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform);
entityCopy.setRemoving(removingEntities); entityCopy.setRemoving(removingEntities);
List<? extends Entity> entities2 = Lists.newArrayList(source.getEntities(region)); List<? extends Entity> entities2 = Lists.newArrayList(source.getEntities(region));
entities2.removeIf(entity -> { entities2.removeIf(entity -> {
@ -406,7 +406,6 @@ public class ForwardExtentCopy implements Operation {
}); });
EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy); EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy);
Operations.completeBlindly(entityVisitor); Operations.completeBlindly(entityVisitor);
affectedEntities += entityVisitor.getAffected();
} }
if (transExt != null) { if (transExt != null) {
@ -428,8 +427,8 @@ public class ForwardExtentCopy implements Operation {
return ImmutableList.of( return ImmutableList.of(
TranslatableComponent.of("worldedit.operation.affected.block", TranslatableComponent.of("worldedit.operation.affected.block",
TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE), TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE),
//TranslatableComponent.of("worldedit.operation.affected.biome", TranslatableComponent.of("worldedit.operation.affected.biome",
// TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE), TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE),
TranslatableComponent.of("worldedit.operation.affected.entity", TranslatableComponent.of("worldedit.operation.affected.entity",
TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE) TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE)
); );

View File

@ -18,16 +18,16 @@
*/ */
package com.sk89q.worldedit.util.io.file; package com.sk89q.worldedit.util.io.file;
import java.io.Closeable; import java.io.Closeable;
import java.nio.file.Path; import java.nio.file.Path;
/** /**
* Represents an archive opened as a directory. This must be closed after work on the Path is * Represents an archive opened as a directory. This must be closed after work on the Path is
* done. * done.
*/ */
public interface ArchiveDir extends Closeable { public interface ArchiveDir extends Closeable {
Path getPath(); Path getPath();
} }

View File

@ -18,52 +18,52 @@
*/ */
package com.sk89q.worldedit.util.io.file; package com.sk89q.worldedit.util.io.file;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public class SafeFiles { public class SafeFiles {
/** /**
* A version of {@link Files#list(Path)} that won't leak resources. * A version of {@link Files#list(Path)} that won't leak resources.
* *
* <p> * <p>
* Instead, it immediately consumes the entire listing into a {@link List} and * Instead, it immediately consumes the entire listing into a {@link List} and
* calls {@link List#stream()}. * calls {@link List#stream()}.
* </p> * </p>
* *
* @param dir the directory to list * @param dir the directory to list
* @return an I/O-resource-free stream of the files in the directory * @return an I/O-resource-free stream of the files in the directory
* @throws IOException if an I/O error occurs * @throws IOException if an I/O error occurs
*/ */
public static Stream<Path> noLeakFileList(Path dir) throws IOException { public static Stream<Path> noLeakFileList(Path dir) throws IOException {
try (Stream<Path> stream = Files.list(dir)) { try (Stream<Path> stream = Files.list(dir)) {
return stream.collect(Collectors.toList()).stream(); return stream.collect(Collectors.toList()).stream();
} }
} }
/** /**
* {@link Path#getFileName()} includes a slash sometimes for some reason. * {@link Path#getFileName()} includes a slash sometimes for some reason.
* This will get rid of it. * This will get rid of it.
* *
* @param path the path to get the file name for * @param path the path to get the file name for
* @return the file name of the given path * @return the file name of the given path
*/ */
public static String canonicalFileName(Path path) { public static String canonicalFileName(Path path) {
return dropSlash(path.getFileName().toString()); return dropSlash(path.getFileName().toString());
} }
private static String dropSlash(String name) { private static String dropSlash(String name) {
if (name.isEmpty() || name.codePointBefore(name.length()) != '/') { if (name.isEmpty() || name.codePointBefore(name.length()) != '/') {
return name; return name;
} }
return name.substring(0, name.length() - 1); return name.substring(0, name.length() - 1);
} }
private SafeFiles() { private SafeFiles() {
} }
} }

View File

@ -192,7 +192,6 @@ public class NullWorld extends AbstractWorld {
@Override @Override
public List<Entity> getEntities(Region region) { public List<Entity> getEntities(Region region) {
System.out.println("nullworld");
return Collections.emptyList(); return Collections.emptyList();
} }