Java Code Examples for org.bukkit.entity.EntityType#isAlive()

The following examples show how to use org.bukkit.entity.EntityType#isAlive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameCreator.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String changeStoreEntityType(Location loc, String type) {
    type = type.toUpperCase();

    String location = loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ();
    if (villagerstores.containsKey(location)) {
        EntityType t = null;
        try {
            t = EntityType.valueOf(type);
            if (!t.isAlive()) {
                t = null;
            }
        } catch (Exception e) {
        }

        if (t == null) {
            return i18n("admin_command_wrong_living_entity_type");
        }

        villagerstores.get(location).setEntityType(t);

        return i18n("admin_command_store_living_entity_type_set").replace("%type%", t.toString());
    }

    return i18n("admin_command_store_not_exists");
}
 
Example 2
Source File: GameCreator.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String changeStoreEntityType(Location loc, String type) {
    type = type.toUpperCase();

    String location = loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ();
    if (villagerstores.containsKey(location)) {
        EntityType t = null;
        try {
            t = EntityType.valueOf(type);
            if (!t.isAlive()) {
                t = null;
            }
        } catch (Exception e) {
        }

        if (t == null) {
            return i18n("admin_command_wrong_living_entity_type");
        }

        villagerstores.get(location).setEntityType(t);

        return i18n("admin_command_store_living_entity_type_set").replace("%type%", t.toString());
    }

    return i18n("admin_command_store_not_exists");
}
 
Example 3
Source File: GameStore.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param loc
 * @param shop
 * @param useParent
 * @param type
 * @param shopName
 * @param enableCustomName
 * @param isBaby
 */
public GameStore(Location loc, String shop, boolean useParent, EntityType type, String shopName, boolean enableCustomName, boolean isBaby) {
    if (type == null || !type.isAlive()) {
        type = EntityType.VILLAGER;
    }
    this.loc = loc;
    this.shop = shop;
    this.useParent = useParent;
    this.type = type;
    this.shopName = shopName;
    this.enableCustomName = enableCustomName;
    this.isBaby = isBaby;
}
 
Example 4
Source File: GameStore.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param loc
 * @param shop
 * @param useParent
 * @param type
 * @param shopName
 * @param enableCustomName
 * @param isBaby
 */
public GameStore(Location loc, String shop, boolean useParent, EntityType type, String shopName, boolean enableCustomName, boolean isBaby) {
    if (type == null || !type.isAlive()) {
        type = EntityType.VILLAGER;
    }
    this.loc = loc;
    this.shop = shop;
    this.useParent = useParent;
    this.type = type;
    this.shopName = shopName;
    this.enableCustomName = enableCustomName;
    this.isBaby = isBaby;
}
 
Example 5
Source File: CommandCloudServer.java    From CloudNet with Apache License 2.0 5 votes vote down vote up
private boolean mobList(CommandSender commandSender) {
    if (checkMobSelectorActive(commandSender)) {
        return true;
    }

    for (EntityType entityType : EntityType.values()) {
        if (entityType.isAlive() && entityType.isSpawnable()) {
            commandSender.sendMessage("- " + entityType.name());
        }
    }
    return false;
}
 
Example 6
Source File: SpawnEggNBT.java    From CratesPlus with GNU General Public License v3.0 5 votes vote down vote up
public static SpawnEggNBT fromItemStack(ItemStack itemStack) {
    if (itemStack == null || itemStack.getType() != LegacyMaterial.MONSTER_EGG.getMaterial())
        return null;
    try {
        Class craftItemStack = ReflectionUtil.getCBClass("inventory.CraftItemStack");
        Method asNMSCopyMethod = craftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class);
        Object nmsItemStack = asNMSCopyMethod.invoke(null, itemStack);
        Class nmsItemStackClass = ReflectionUtil.getNMSClass("ItemStack");
        Object nbtTagCompound = nmsItemStackClass.getDeclaredMethod("getTag").invoke(nmsItemStack);
        Class nbtTagCompoundClass = ReflectionUtil.getNMSClass("NBTTagCompound");
        if (nbtTagCompound != null) {
            Method getCompoundMethod = nbtTagCompoundClass.getDeclaredMethod("getCompound", String.class);
            Object entityTagCompount = getCompoundMethod.invoke(nbtTagCompound, "EntityTag");
            Method getStringMethod = nbtTagCompoundClass.getDeclaredMethod("getString", String.class);
            String type = (String) getStringMethod.invoke(entityTagCompount, "id");
            type = type.replaceFirst("minecraft:", "");
            switch (type) {
                case "CAVESPIDER":
                    type = "CAVE_SPIDER";
                    break;
            }
            EntityType entityType = EntityType.fromName(type);
            if (entityType == null || !entityType.isAlive())
                return null;
            return new SpawnEggNBT(entityType);
        } else if (itemStack.getData() instanceof SpawnEgg) {
            return new SpawnEggNBT(((SpawnEgg) itemStack.getData()).getSpawnedType());
        }
    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 7
Source File: GameStore.java    From BedWars with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param type
 */
public void setEntityType(EntityType type) {
    if (type != null && type.isAlive()) {
        this.type = type;
    }
}
 
Example 8
Source File: GameStore.java    From BedWars with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param type
 */
public void setEntityType(EntityType type) {
    if (type != null && type.isAlive()) {
        this.type = type;
    }
}
 
Example 9
Source File: SpawnEgg1_9.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set the type of entity this egg will spawn.
 *
 * @param type The entity type.
 */
public void setSpawnedType(EntityType type) {
  if (type.isAlive()) {
    this.type = type;
  }
}
 
Example 10
Source File: SpawnEgg1_9.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set the type of entity this egg will spawn.
 *
 * @param type The entity type.
 */
public void setSpawnedType(EntityType type) {
  if (type.isAlive()) {
    this.type = type;
  }
}
 
Example 11
Source File: SpawnEgg1_11.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set the type of entity this egg will spawn.
 *
 * @param type The entity type.
 */
public void setSpawnedType(EntityType type) {
  if (type.isAlive()) {
    this.type = type;
  }
}
 
Example 12
Source File: SpawnEgg1_12.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set the type of entity this egg will spawn.
 *
 * @param type The entity type.
 */
public void setSpawnedType(EntityType type) {
  if (type.isAlive()) {
    this.type = type;
  }
}
 
Example 13
Source File: SpawnEgg1_10.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set the type of entity this egg will spawn.
 *
 * @param type The entity type.
 */
public void setSpawnedType(EntityType type) {
  if (type.isAlive()) {
    this.type = type;
  }
}
 
Example 14
Source File: SpawnEggNBT.java    From CratesPlus with GNU General Public License v3.0 4 votes vote down vote up
public void setSpawnedType(EntityType type) {
    if (type.isAlive()) {
        this.type = type;
    }
}