Search in sources :

Example 66 with Player

use of org.spongepowered.api.entity.living.player.Player in project Skree by Skelril.

the class SoulReaper method apply.

@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
    CatacombsBossDetail detail = zombieCatacombsBossDetailBoss.getDetail();
    Entity attacked = damageCondition.getAttacked();
    if (attacked instanceof Player && activate(detail)) {
        Task.builder().execute(() -> {
            Optional<Zombie> optZombie = zombieCatacombsBossDetailBoss.getTargetEntity();
            if (optZombie.isPresent()) {
                Zombie boss = optZombie.get();
                double stolen = EntityHealthUtil.getHealth((Living) attacked) - 1;
                attacked.offer(Keys.HEALTH, 1D);
                EntityHealthUtil.heal(boss, stolen);
                ((Player) attacked).sendMessage(Text.of(TextColors.RED, "The necromancer reaps your soul."));
            }
        }).delayTicks(1).submit(SkreePlugin.inst());
    }
    return Optional.empty();
}
Also used : CatacombsBossDetail(com.skelril.skree.content.zone.group.catacombs.CatacombsBossDetail) Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) Zombie(org.spongepowered.api.entity.living.monster.Zombie) Living(org.spongepowered.api.entity.living.Living)

Example 67 with Player

use of org.spongepowered.api.entity.living.player.Player in project Skree by Skelril.

the class TheForgeListener method onPlayerCombat.

@Listener
public void onPlayerCombat(CollideEntityEvent.Impact event, @First Projectile projectile) {
    Optional<TheForgeInstance> optInst = manager.getApplicableZone(projectile);
    if (!optInst.isPresent()) {
        return;
    }
    new PlayerCombatParser() {

        @Override
        public void processMonsterAttack(Living attacker, Player defender) {
            if (!(event instanceof DamageEntityEvent)) {
                return;
            }
            DamageEntityEvent dEvent = (DamageEntityEvent) event;
            if (isFlying(defender)) {
                dEvent.setBaseDamage(dEvent.getBaseDamage() * 3);
            }
        }
    }.parse(event);
}
Also used : DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Player(org.spongepowered.api.entity.living.player.Player) Living(org.spongepowered.api.entity.living.Living) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser) Listener(org.spongepowered.api.event.Listener)

Example 68 with Player

use of org.spongepowered.api.entity.living.player.Player in project Skree by Skelril.

the class TempleOfFateInstance method feedPlayers.

private void feedPlayers() {
    for (Player player : getPlayers(PARTICIPANT)) {
        player.offer(Keys.FOOD_LEVEL, 20);
        player.offer(Keys.SATURATION, 5D);
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player)

Example 69 with Player

use of org.spongepowered.api.entity.living.player.Player in project Skree by Skelril.

the class CursedMineListener method onPlayerDeath.

@Listener
public void onPlayerDeath(DestructEntityEvent.Death event) {
    Entity entity = event.getTargetEntity();
    if (!(entity instanceof Player)) {
        return;
    }
    Player player = (Player) entity;
    Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
    HitList hitList = manager.getHitList();
    if (optInst.isPresent() || hitList.isOnHitList(player)) {
        if (!optInst.isPresent()) {
            optInst = manager.getActiveZone();
        }
        if (optInst.isPresent()) {
            optInst.get().revertPlayer(player);
            optInst.get().clearCurses(player);
        }
        if (hitList.isOnHitList(player)) {
            hitList.remPlayer(player);
        }
        String deathMessage;
        switch(Probability.getRandom(11)) {
            case 1:
                deathMessage = " was killed by Dave";
                break;
            case 2:
                deathMessage = " got on Dave's bad side";
                break;
            case 3:
                deathMessage = " was slain by an evil spirit";
                break;
            case 4:
                deathMessage = " needs to stay away from the cursed mine";
                break;
            case 5:
                deathMessage = " enjoys death a little too much";
                break;
            case 6:
                deathMessage = " seriously needs to stop mining";
                break;
            case 7:
                deathMessage = " angered an evil spirit";
                break;
            case 8:
                deathMessage = " doesn't get a cookie from COOKIE";
                break;
            case 9:
                deathMessage = " should stay away";
                break;
            case 10:
                deathMessage = " needs to consider retirement";
                break;
            default:
                deathMessage = "'s head is now on Dave's mantel";
                break;
        }
        event.setMessage(Text.of(player.getName(), deathMessage));
    // addSkull(player);
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) HitList(com.skelril.skree.content.zone.global.cursedmine.hitlist.HitList) Listener(org.spongepowered.api.event.Listener)

Example 70 with Player

use of org.spongepowered.api.entity.living.player.Player in project Skree by Skelril.

the class RegionSelectCommand method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (!(src instanceof Player)) {
        src.sendMessage(Text.of("You must be a player to use this command (for now ;) )!"));
        return CommandResult.empty();
    }
    Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
    if (!optService.isPresent()) {
        src.sendMessage(Text.of(TextColors.DARK_RED, "The region service is not currently running."));
        return CommandResult.empty();
    }
    RegionService service = optService.get();
    Player player = (Player) src;
    Optional<Player> optPlayer = args.getOne("player");
    Optional<Location<World>> optLocation = args.getOne("location");
    Optional<Region> optRegion;
    if (optPlayer.isPresent()) {
        Player targPlayer = optPlayer.get();
        optRegion = service.get(targPlayer.getLocation());
        player.sendMessage(Text.of(TextColors.YELLOW, "Searching for ", targPlayer.getName(), "'s local region..."));
    } else if (optLocation.isPresent()) {
        optRegion = service.get(optLocation.get());
        player.sendMessage(Text.of(TextColors.YELLOW, "Searching for a region at the given location..."));
    } else {
        optRegion = service.get(player.getLocation());
        player.sendMessage(Text.of(TextColors.YELLOW, "Searching for your local region..."));
    }
    service.setSelectedRegion(player, optRegion.orElse(null));
    if (optRegion.isPresent()) {
        player.sendMessage(Text.of(TextColors.YELLOW, "Region found! View information with ", Text.of(TextColors.GREEN, TextActions.runCommand("/region info"), "/region info")));
    } else {
        player.sendMessage(Text.of(TextColors.YELLOW, "No region found, your region selection has been cleared"));
    }
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) Region(com.skelril.skree.service.internal.region.Region) RegionService(com.skelril.skree.service.RegionService) Location(org.spongepowered.api.world.Location)

Aggregations

Player (org.spongepowered.api.entity.living.player.Player)125 Listener (org.spongepowered.api.event.Listener)40 ItemStack (org.spongepowered.api.item.inventory.ItemStack)28 Entity (org.spongepowered.api.entity.Entity)25 World (org.spongepowered.api.world.World)21 Text (org.spongepowered.api.text.Text)17 BigDecimal (java.math.BigDecimal)16 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)12 Vector3d (com.flowpowered.math.vector.Vector3d)10 PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)10 List (java.util.List)10 Optional (java.util.Optional)10 ItemStack (net.minecraft.item.ItemStack)10 Living (org.spongepowered.api.entity.living.Living)10 Task (org.spongepowered.api.scheduler.Task)10 Location (org.spongepowered.api.world.Location)10 MarketService (com.skelril.skree.service.MarketService)8 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)8 TextColors (org.spongepowered.api.text.format.TextColors)8