3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-20 01:40:06 +01:00

Prevent players and complex parts being pasted in schematics.

Dieser Commit ist enthalten in:
Matthew Miller 2018-01-02 20:49:36 +10:00
Ursprung 6fc1449837
Commit 50f60da69f
5 geänderte Dateien mit 39 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,7 @@ import com.sk89q.worldedit.util.Enums;
import org.bukkit.entity.Ambient;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Boat;
import org.bukkit.entity.ComplexEntityPart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.FallingBlock;
@ -34,6 +35,7 @@ import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
@ -143,4 +145,9 @@ class BukkitEntityType implements EntityType {
public boolean isArmorStand() {
return entity.getType() == armorStandType;
}
@Override
public boolean isPasteable() {
return !(entity instanceof Player || entity instanceof ComplexEntityPart);
}
}

Datei anzeigen

@ -154,4 +154,11 @@ public interface EntityType {
* @return true if an armor stand
*/
boolean isArmorStand();
/**
* Test whether this entity can be pasted.
*
* @return true if pasteable
*/
boolean isPasteable();
}

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.operation;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.metadata.EntityType;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.CombinedRegionFunction;
import com.sk89q.worldedit.function.RegionFunction;
@ -36,6 +37,7 @@ import com.sk89q.worldedit.math.transform.Identity;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
@ -255,6 +257,15 @@ public class ForwardExtentCopy implements Operation {
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform);
entityCopy.setRemoving(removingEntities);
List<? extends Entity> entities = source.getEntities(region);
// Switch to entities.removeIf after Java 8 cutoff.
Iterator<? extends Entity> entityIterator = entities.iterator();
while (entityIterator.hasNext()) {
EntityType type = entityIterator.next().getFacet(EntityType.class);
if (type != null && !type.isPasteable()) {
entityIterator.remove();
}
}
EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy);
return new DelegateOperation(this, new OperationQueue(blockVisitor, entityVisitor));
} else {

Datei anzeigen

@ -25,6 +25,7 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.IMerchant;
import net.minecraft.entity.INpc;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.MultiPartEntityPart;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderEye;
@ -40,6 +41,7 @@ import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import static com.google.common.base.Preconditions.checkNotNull;
@ -141,4 +143,9 @@ public class ForgeEntityType implements EntityType {
public boolean isArmorStand() {
return entity instanceof EntityArmorStand;
}
@Override
public boolean isPasteable() {
return !(entity instanceof EntityPlayerMP || entity instanceof MultiPartEntityPart);
}
}

Datei anzeigen

@ -30,7 +30,9 @@ import org.spongepowered.api.entity.hanging.ItemFrame;
import org.spongepowered.api.entity.hanging.Painting;
import org.spongepowered.api.entity.living.*;
import org.spongepowered.api.entity.living.animal.Animal;
import org.spongepowered.api.entity.living.complex.ComplexLivingPart;
import org.spongepowered.api.entity.living.golem.Golem;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.projectile.Projectile;
import org.spongepowered.api.entity.vehicle.Boat;
import org.spongepowered.api.entity.vehicle.minecart.Minecart;
@ -139,4 +141,9 @@ public class SpongeEntityType implements EntityType {
public boolean isArmorStand() {
return entity instanceof ArmorStand;
}
@Override
public boolean isPasteable() {
return !(entity instanceof Player || entity instanceof ComplexLivingPart);
}
}