Search in sources :

Example 11 with EntityType

use of org.bukkit.entity.EntityType in project MagicPlugin by elBukkit.

the class MagicMobCommandExecutor method onTabComplete.

@Override
public Collection<String> onTabComplete(CommandSender sender, String commandName, String[] args) {
    List<String> options = new ArrayList<>();
    if (!sender.hasPermission("Magic.commands.mmob"))
        return options;
    if (args.length == 1) {
        options.add("spawn");
        options.add("list");
        options.add("clear");
    } else if (args.length == 2 && (args[0].equalsIgnoreCase("spawn") || args[0].equalsIgnoreCase("clear"))) {
        options.addAll(api.getController().getMobKeys());
        for (EntityType entityType : EntityType.values()) {
            if (entityType.isAlive() && entityType.isSpawnable()) {
                options.add(entityType.name().toLowerCase());
            }
        }
    } else if (args.length == 3 && args[0].equalsIgnoreCase("clear")) {
        List<World> worlds = api.getPlugin().getServer().getWorlds();
        for (World world : worlds) {
            options.add(world.getName());
        }
    }
    return options;
}
Also used : EntityType(org.bukkit.entity.EntityType) ArrayList(java.util.ArrayList) World(org.bukkit.World)

Example 12 with EntityType

use of org.bukkit.entity.EntityType in project CommandHelper by EngineHub.

the class BukkitMCEntityType method build.

// This way we don't take up extra memory on non-bukkit implementations
public static void build() {
    vanilla = new HashMap<>();
    mappings = new HashMap<>();
    NULL = new BukkitMCEntityType(EntityType.UNKNOWN, MCVanillaEntityType.UNKNOWN);
    ArrayList<EntityType> counted = new ArrayList<>();
    for (MCVanillaEntityType v : MCVanillaEntityType.values()) {
        if (v.existsInCurrent()) {
            EntityType type = getBukkitType(v);
            if (type == null) {
                CHLog.GetLogger().e(CHLog.Tags.RUNTIME, "Could not find a matching entity type for " + v.name() + ". This is an error, please report this to the bug tracker.", Target.UNKNOWN);
                continue;
            }
            BukkitMCEntityType wrapper = new BukkitMCEntityType(type, v);
            wrapper.setWrapperClass();
            vanilla.put(v, wrapper);
            mappings.put(v.name(), wrapper);
            counted.add(type);
        }
    }
    for (EntityType b : EntityType.values()) {
        if (!counted.contains(b)) {
            mappings.put(b.name(), new BukkitMCEntityType(b, MCVanillaEntityType.UNKNOWN));
        }
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntityType(com.laytonsmith.abstraction.enums.MCEntityType) ArrayList(java.util.ArrayList)

Example 13 with EntityType

use of org.bukkit.entity.EntityType in project CommandHelper by EngineHub.

the class BukkitMCBlockProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile, Vector3D init) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Vector vector = new Vector(init.X(), init.Y(), init.Z());
    Projectile proj = bps.launchProjectile(c.asSubclass(Projectile.class), vector);
    MCEntity e = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (e instanceof MCProjectile) {
        return (MCProjectile) e;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Vector(org.bukkit.util.Vector) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Example 14 with EntityType

use of org.bukkit.entity.EntityType in project CommandHelper by EngineHub.

the class BukkitMCEntityProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile, Vector3D init) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Vector vector = new Vector(init.X(), init.Y(), init.Z());
    Projectile proj = eps.launchProjectile(c.asSubclass(Projectile.class), vector);
    MCEntity mcproj = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (mcproj instanceof MCProjectile) {
        return (MCProjectile) mcproj;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Vector(org.bukkit.util.Vector) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Example 15 with EntityType

use of org.bukkit.entity.EntityType in project CommandHelper by EngineHub.

the class BukkitMCEntityProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Projectile proj = eps.launchProjectile(c.asSubclass(Projectile.class));
    MCEntity mcproj = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (mcproj instanceof MCProjectile) {
        return (MCProjectile) mcproj;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Aggregations

EntityType (org.bukkit.entity.EntityType)109 ArrayList (java.util.ArrayList)29 ItemStack (org.bukkit.inventory.ItemStack)28 Material (org.bukkit.Material)23 Player (org.bukkit.entity.Player)23 Entity (org.bukkit.entity.Entity)19 Location (org.bukkit.Location)17 IOException (java.io.IOException)16 File (java.io.File)13 LivingEntity (org.bukkit.entity.LivingEntity)13 EventHandler (org.bukkit.event.EventHandler)12 PotionType (org.bukkit.potion.PotionType)12 HashMap (java.util.HashMap)10 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)9 Block (org.bukkit.block.Block)8 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)8 World (org.bukkit.World)7 SpawnEgg (org.bukkit.material.SpawnEgg)7 UUID (java.util.UUID)5 Biome (org.bukkit.block.Biome)5