2014-07-16 02:47:47 +00:00
|
|
|
/*
|
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2014-07-16 02:47:47 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-07-16 02:47:47 +00:00
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2014-07-16 02:47:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package com.sk89q.worldedit.bukkit;
|
|
|
|
|
2018-07-19 12:41:26 +00:00
|
|
|
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
2021-02-15 11:24:33 +00:00
|
|
|
import org.bukkit.entity.AbstractVillager;
|
2014-07-16 02:47:47 +00:00
|
|
|
import org.bukkit.entity.Ambient;
|
|
|
|
import org.bukkit.entity.Animals;
|
2018-08-23 10:15:31 +00:00
|
|
|
import org.bukkit.entity.ArmorStand;
|
2014-07-16 02:47:47 +00:00
|
|
|
import org.bukkit.entity.Boat;
|
2018-01-02 10:49:36 +00:00
|
|
|
import org.bukkit.entity.ComplexEntityPart;
|
2014-07-16 02:47:47 +00:00
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.ExperienceOrb;
|
|
|
|
import org.bukkit.entity.FallingBlock;
|
|
|
|
import org.bukkit.entity.Golem;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
import org.bukkit.entity.Item;
|
|
|
|
import org.bukkit.entity.ItemFrame;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Minecart;
|
|
|
|
import org.bukkit.entity.Painting;
|
2018-01-02 10:49:36 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2014-07-16 02:47:47 +00:00
|
|
|
import org.bukkit.entity.Projectile;
|
|
|
|
import org.bukkit.entity.TNTPrimed;
|
|
|
|
import org.bukkit.entity.Tameable;
|
|
|
|
import org.bukkit.entity.Villager;
|
2020-11-13 20:46:11 +00:00
|
|
|
import org.bukkit.entity.WaterMob;
|
2015-01-22 20:48:45 +00:00
|
|
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
2014-07-16 02:47:47 +00:00
|
|
|
|
2020-10-05 17:41:41 +00:00
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
|
|
|
|
2018-07-19 12:41:26 +00:00
|
|
|
class BukkitEntityProperties implements EntityProperties {
|
2014-07-16 02:47:47 +00:00
|
|
|
|
2021-02-15 11:24:33 +00:00
|
|
|
private static final boolean HAS_ABSTRACT_VILLAGER;
|
|
|
|
|
|
|
|
static {
|
|
|
|
boolean temp;
|
|
|
|
try {
|
|
|
|
Class.forName("org.bukkit.entity.AbstractVillager");
|
|
|
|
temp = true;
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
temp = false;
|
|
|
|
}
|
|
|
|
HAS_ABSTRACT_VILLAGER = temp;
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:47:47 +00:00
|
|
|
private final Entity entity;
|
|
|
|
|
2018-07-19 12:41:26 +00:00
|
|
|
BukkitEntityProperties(Entity entity) {
|
2014-07-16 02:47:47 +00:00
|
|
|
checkNotNull(entity);
|
|
|
|
this.entity = entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPlayerDerived() {
|
|
|
|
return entity instanceof HumanEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isProjectile() {
|
|
|
|
return entity instanceof Projectile;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isItem() {
|
|
|
|
return entity instanceof Item;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFallingBlock() {
|
|
|
|
return entity instanceof FallingBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPainting() {
|
|
|
|
return entity instanceof Painting;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isItemFrame() {
|
|
|
|
return entity instanceof ItemFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBoat() {
|
|
|
|
return entity instanceof Boat;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isMinecart() {
|
|
|
|
return entity instanceof Minecart;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isTNT() {
|
2015-01-22 20:48:45 +00:00
|
|
|
return entity instanceof TNTPrimed || entity instanceof ExplosiveMinecart;
|
2014-07-16 02:47:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isExperienceOrb() {
|
|
|
|
return entity instanceof ExperienceOrb;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isLiving() {
|
|
|
|
return entity instanceof LivingEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isAnimal() {
|
|
|
|
return entity instanceof Animals;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isAmbient() {
|
|
|
|
return entity instanceof Ambient;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isNPC() {
|
2021-02-15 11:24:33 +00:00
|
|
|
if (HAS_ABSTRACT_VILLAGER) {
|
|
|
|
return entity instanceof AbstractVillager;
|
|
|
|
}
|
2014-07-16 02:47:47 +00:00
|
|
|
return entity instanceof Villager;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isGolem() {
|
|
|
|
return entity instanceof Golem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isTamed() {
|
|
|
|
return entity instanceof Tameable && ((Tameable) entity).isTamed();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isTagged() {
|
2018-07-12 12:23:03 +00:00
|
|
|
return entity instanceof LivingEntity && entity.getCustomName() != null;
|
2014-07-16 02:47:47 +00:00
|
|
|
}
|
2015-01-22 20:48:45 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isArmorStand() {
|
2018-08-23 10:15:31 +00:00
|
|
|
return entity instanceof ArmorStand;
|
2015-01-22 20:48:45 +00:00
|
|
|
}
|
2018-01-02 10:49:36 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPasteable() {
|
|
|
|
return !(entity instanceof Player || entity instanceof ComplexEntityPart);
|
|
|
|
}
|
2020-11-13 20:46:11 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isWaterCreature() {
|
|
|
|
return entity instanceof WaterMob;
|
|
|
|
}
|
2021-07-24 15:34:05 +00:00
|
|
|
|
2014-07-16 02:47:47 +00:00
|
|
|
}
|