Search in sources :

Example 21 with Player

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

the class PvPCommand 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!"));
        return CommandResult.empty();
    }
    Optional<PvPService> optService = Sponge.getServiceManager().provide(PvPService.class);
    if (!optService.isPresent()) {
        src.sendMessage(Text.of(TextColors.DARK_RED, "The PvP service is not currently running."));
        return CommandResult.empty();
    }
    PvPService service = optService.get();
    Player player = (Player) src;
    Optional<PvPState> stateArg = args.getOne("status");
    PvPState state = stateArg.orElse(service.getPvPState(player));
    service.setPvPState(player, state);
    player.sendMessage(Text.of(TextColors.BLUE, "Your Opt-in PvP Settings", (stateArg.isPresent() ? " Changed!" : "")));
    player.sendMessage(Text.of(TextColors.YELLOW, "  Currently: ", getColor(state), state.toString()));
    PvPState defaultState = service.getDefaultState(player);
    player.sendMessage(Text.of(TextColors.YELLOW, "  Upon disconnect: ", getColor(defaultState), defaultState.toString()));
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PvPService(com.skelril.skree.service.PvPService) PvPState(com.skelril.skree.service.internal.pvp.PvPState)

Example 22 with Player

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

the class RegionRemMemberCommand 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<Region> optRef = service.getSelectedRegion(player);
    if (!optRef.isPresent()) {
        player.sendMessage(Text.of(TextColors.RED, "You do not currently have a region selected."));
        return CommandResult.empty();
    }
    Region ref = optRef.get();
    if (!ref.getMembers().contains(player.getUniqueId())) {
        player.sendMessage(Text.of(TextColors.RED, "You must be a member of the region to modify it!"));
        return CommandResult.empty();
    }
    List<UUID> oldMembers = args.<User>getAll("player").stream().map(Identifiable::getUniqueId).filter(a -> ref.getMembers().contains(a)).collect(Collectors.toList());
    ref.remMember(oldMembers);
    player.sendMessage(Text.of(TextColors.YELLOW, "Removed ", oldMembers.size(), " players from the region."));
    return CommandResult.success();
}
Also used : CommandResult(org.spongepowered.api.command.CommandResult) GenericArguments.allOf(org.spongepowered.api.command.args.GenericArguments.allOf) User(org.spongepowered.api.entity.living.player.User) CommandSource(org.spongepowered.api.command.CommandSource) Sponge(org.spongepowered.api.Sponge) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) RegionService(com.skelril.skree.service.RegionService) CommandSpec(org.spongepowered.api.command.spec.CommandSpec) CommandException(org.spongepowered.api.command.CommandException) List(java.util.List) CommandContext(org.spongepowered.api.command.args.CommandContext) Text(org.spongepowered.api.text.Text) CommandExecutor(org.spongepowered.api.command.spec.CommandExecutor) Region(com.skelril.skree.service.internal.region.Region) Optional(java.util.Optional) GenericArguments.user(org.spongepowered.api.command.args.GenericArguments.user) Player(org.spongepowered.api.entity.living.player.Player) TextColors(org.spongepowered.api.text.format.TextColors) Identifiable(org.spongepowered.api.util.Identifiable) Player(org.spongepowered.api.entity.living.player.Player) User(org.spongepowered.api.entity.living.player.User) Region(com.skelril.skree.service.internal.region.Region) RegionService(com.skelril.skree.service.RegionService) UUID(java.util.UUID) Identifiable(org.spongepowered.api.util.Identifiable)

Example 23 with Player

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

the class MarketTrackItemCommand 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!"));
        return CommandResult.empty();
    }
    Optional<MarketService> optService = Sponge.getServiceManager().provide(MarketService.class);
    if (!optService.isPresent()) {
        src.sendMessage(Text.of(TextColors.DARK_RED, "The market service is not currently running."));
        return CommandResult.empty();
    }
    MarketService service = optService.get();
    Optional<ItemStack> held = ((Player) src).getItemInHand(HandTypes.MAIN_HAND);
    if (!held.isPresent()) {
        src.sendMessage(Text.of(TextColors.RED, "You are not holding an item."));
        return CommandResult.empty();
    }
    ItemStack item = held.get();
    if (service.addItem(item)) {
        src.sendMessage(Text.of(TextColors.YELLOW, "Your held item is now being tracked."));
    } else {
        src.sendMessage(Text.of(TextColors.RED, "Your held item is already tracked."));
        return CommandResult.empty();
    }
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) ItemStack(org.spongepowered.api.item.inventory.ItemStack) MarketService(com.skelril.skree.service.MarketService)

Example 24 with Player

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

the class RegionInfoCommand 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<Region> optRef = service.getSelectedRegion(player);
    if (!optRef.isPresent()) {
        player.sendMessage(Text.of(TextColors.RED, "You do not currently have a region selected."));
        return CommandResult.empty();
    }
    DecimalFormat countFormat = new DecimalFormat("#,###");
    Region ref = optRef.get();
    player.sendMessage(Text.of(TextColors.GOLD, "Region information for: ", (ref.isActive() ? TextColors.BLUE : TextColors.RED), ref.getName().toUpperCase()));
    player.sendMessage(Text.of(countFormat.format(ref.getPowerLevel()), TextColors.YELLOW, " power cores"));
    player.sendMessage(Text.of(countFormat.format(ref.getArea()), TextColors.YELLOW, " block area"));
    player.sendMessage(Text.of(countFormat.format(ref.getMaximumArea()), TextColors.YELLOW, " block maximum area"));
    player.sendMessage(Text.of(TextActions.runCommand("/region listmembers"), TextActions.showText(Text.of("List the region's members")), countFormat.format(ref.getMembers().size()), TextColors.YELLOW, " members"));
    player.sendMessage(Text.of(TextActions.runCommand("/region listmarkers"), TextActions.showText(Text.of("List the region's marker block positions")), countFormat.format(ref.getPoints().size()), TextColors.YELLOW, " active markers"));
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) DecimalFormat(java.text.DecimalFormat) Region(com.skelril.skree.service.internal.region.Region) RegionService(com.skelril.skree.service.RegionService)

Example 25 with Player

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

the class PatientXManager method setupBossManager.

private void setupBossManager() {
    Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Zombie.class));
    List<Instruction<BindCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> bindProcessor = bossManager.getBindProcessor();
    bindProcessor.add((condition, boss) -> {
        Optional<Zombie> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Zombie bossEnt = optBossEnt.get();
            bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Patient X"));
            setMaxHealth(bossEnt, config.bossHealth, true);
        }
        return Optional.empty();
    });
    bindProcessor.add((condition, boss) -> {
        Optional<Zombie> optBoss = boss.getTargetEntity();
        if (optBoss.isPresent()) {
            optBoss.get().offer(Keys.PERSISTS, true);
        }
        return Optional.empty();
    });
    bindProcessor.add((condition, boss) -> {
        boss.getDetail().getZone().getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.GOLD, "Ice to meet you again!"));
        return Optional.empty();
    });
    List<Instruction<UnbindCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> unbindProcessor = bossManager.getUnbindProcessor();
    unbindProcessor.add((condition, boss) -> {
        PatientXInstance inst = boss.getDetail().getZone();
        Location<World> target = inst.getCenter();
        for (Player player : inst.getPlayers(PlayerClassifier.PARTICIPANT)) {
            player.setLocation(target);
            boolean useX = Probability.getChance(2);
            int accel = Probability.getChance(2) ? 1 : -1;
            Vector3d v = new Vector3d(useX ? accel : 0, 0, !useX ? accel : 0);
            player.setVelocity(v);
        }
        inst.freezeBlocks(100, false);
        // Reset respawn mechanics
        inst.bossDied();
        return Optional.empty();
    });
    List<Instruction<DamageCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> damageProcessor = bossManager.getDamageProcessor();
    damageProcessor.add((condition, boss) -> {
        PatientXInstance inst = boss.getDetail().getZone();
        DamageEntityEvent event = condition.getEvent();
        // Nullify all modifiers
        for (Tuple<DamageModifier, Function<? super Double, Double>> modifier : event.getModifiers()) {
            event.setDamage(modifier.getFirst(), (a) -> a);
        }
        event.setBaseDamage(inst.getDifficulty() * config.baseBossHit);
        return Optional.empty();
    });
    List<Instruction<DamagedCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> damagedProcessor = bossManager.getDamagedProcessor();
    damagedProcessor.add((condition, boss) -> {
        DamageEntityEvent event = condition.getEvent();
        Optional<DamageSource> optDamageSource = condition.getDamageSource();
        if (optDamageSource.isPresent() && blockedDamage.contains(optDamageSource.get().getType())) {
            event.setCancelled(true);
            return Optional.empty();
        }
        return Optional.of((damagedCondition, zombieZoneBossDetailBoss) -> {
            PatientXInstance inst = boss.getDetail().getZone();
            if (optDamageSource.isPresent() && optDamageSource.get() instanceof EntityDamageSource) {
                if (optDamageSource.get() instanceof IndirectEntityDamageSource) {
                    Task.builder().execute(() -> {
                        VelocityEntitySpawner.sendRadial(EntityTypes.SNOWBALL, inst.getBoss().get(), Cause.source(SpawnCause.builder().type(SpawnTypes.PROJECTILE).build()).build());
                    }).delayTicks(1).submit(SkreePlugin.inst());
                } else {
                    Entity srcEntity = ((EntityDamageSource) optDamageSource.get()).getSource();
                    if (srcEntity instanceof Player) {
                        Optional<ItemStack> optHeld = ((Player) srcEntity).getItemInHand(HandTypes.MAIN_HAND);
                        if (optHeld.isPresent() && optHeld.get().getItem() == ItemTypes.BLAZE_ROD) {
                            inst.modifyDifficulty(2);
                        }
                    }
                }
            }
            inst.modifyDifficulty(.5);
            inst.teleportRandom(true);
            return Optional.empty();
        });
    });
}
Also used : Entity(org.spongepowered.api.entity.Entity) Instruction(com.skelril.openboss.Instruction) World(org.spongepowered.api.world.World) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) Function(java.util.function.Function) DamageModifier(org.spongepowered.api.event.cause.entity.damage.DamageModifier) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Player(org.spongepowered.api.entity.living.player.Player) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) Zombie(org.spongepowered.api.entity.living.monster.Zombie) Vector3d(com.flowpowered.math.vector.Vector3d) ItemStack(org.spongepowered.api.item.inventory.ItemStack)

Aggregations

Player (org.spongepowered.api.entity.living.player.Player)113 Listener (org.spongepowered.api.event.Listener)34 ItemStack (org.spongepowered.api.item.inventory.ItemStack)28 Entity (org.spongepowered.api.entity.Entity)25 World (org.spongepowered.api.world.World)19 BigDecimal (java.math.BigDecimal)16 Text (org.spongepowered.api.text.Text)13 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)12 Vector3d (com.flowpowered.math.vector.Vector3d)10 PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)10 Living (org.spongepowered.api.entity.living.Living)10 Location (org.spongepowered.api.world.Location)10 List (java.util.List)9 MarketService (com.skelril.skree.service.MarketService)8 Optional (java.util.Optional)8 ItemStack (net.minecraft.item.ItemStack)8 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)8 TextColors (org.spongepowered.api.text.format.TextColors)8 TEAccount (com.erigitic.config.TEAccount)7 ArrayList (java.util.ArrayList)7