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();
}
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();
}
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();
}
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();
}
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();
});
});
}
Aggregations