use of org.spongepowered.api.world.World in project Skree by Skelril.
the class LegacyZoneBase method remove.
@Override
public Clause<Player, ZoneStatus> remove(Player player) {
RespawnService respawnService = Sponge.getServiceManager().provideUnchecked(RespawnService.class);
Location<World> newLocation = respawnService.pop(player).orElse(respawnService.getDefault(player));
player.setLocation(newLocation);
return new Clause<>(player, ZoneStatus.REMOVED);
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class ZoneRelativePositionListener method onBlockInteract.
@Listener
public void onBlockInteract(InteractBlockEvent.Secondary event, @First Player player) {
Optional<Location<World>> optLocation = event.getTargetBlock().getLocation();
if (!optLocation.isPresent()) {
return;
}
Location<World> location = optLocation.get();
Optional<T> optInst = getApplicable(location);
if (!optInst.isPresent()) {
return;
}
T inst = optInst.get();
Vector3i minPoint = inst.getRegion().getMinimumPoint();
Vector3i clickedPoint = location.getBlockPosition();
Vector3i offset = clickedPoint.sub(minPoint);
player.sendMessage(Text.of("Offset: ", offset));
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class InstanceWorldWrapper method onLogin.
@Listener
public void onLogin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
if (!isApplicable(player)) {
return;
}
Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
if (!optWorldService.isPresent()) {
return;
}
WorldService worldService = optWorldService.get();
Collection<World> worlds = worldService.getEffectWrapper(MainWorldWrapper.class).get().getWorlds();
player.setLocation(worlds.iterator().next().getSpawnLocation());
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class MainWorldWrapper method run.
@Override
public void run() {
PotionEffect speedEffect = PotionEffect.builder().duration(3 * 20).amplifier(5).particles(false).potionType(PotionEffectTypes.SPEED).build();
for (World world : getWorlds()) {
for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
continue;
}
List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(speedEffect);
entity.offer(Keys.POTION_EFFECTS, potionEffects);
}
}
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class DropClearCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Optional<DropClearService> optService = Sponge.getServiceManager().provide(DropClearService.class);
if (!optService.isPresent()) {
src.sendMessage(Text.of(TextColors.DARK_RED, "The drop clear service is not currently running."));
return CommandResult.empty();
}
DropClearService service = optService.get();
// World resolution
Optional<WorldProperties> optWorldProps = args.getOne("world");
Optional<World> optWorld;
if (!optWorldProps.isPresent()) {
if (!(src instanceof Player)) {
src.sendMessage(Text.of(TextColors.RED, "You are not a player and need to specify a world!"));
return CommandResult.empty();
}
optWorld = Optional.of(((Player) src).getWorld());
} else {
optWorld = Sponge.getServer().getWorld(optWorldProps.get().getUniqueId());
}
// Handled by command spec, so always provided
int seconds = args.<Integer>getOne("seconds").get();
World world = optWorld.get();
if (!world.isLoaded()) {
src.sendMessage(Text.of(TextColors.RED, "The specified world was not loaded!"));
return CommandResult.empty();
}
service.cleanup(world, Math.max(0, Math.min(seconds, maxDelay)));
return CommandResult.success();
}
Aggregations