Search in sources :

Example 1 with WorldEffectWrapper

use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.

the class WorldListCommand method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
    List<WorldEffectWrapper> worldEffectWrapperList = service.getEffectWrappers().stream().sorted((a, b) -> a.getName().compareToIgnoreCase(b.getName())).collect(Collectors.toList());
    for (WorldEffectWrapper wrapper : worldEffectWrapperList) {
        String worldType = wrapper.getName();
        if (!src.hasPermission("skree.world." + worldType.toLowerCase() + ".teleport")) {
            continue;
        }
        src.sendMessage(Text.of(TextColors.GOLD, "Available ", worldType, " worlds (click to teleport):"));
        for (World world : wrapper.getWorlds()) {
            String worldName = world.getName();
            String prettyName = worldName.replaceAll("_", " ");
            src.sendMessage(Text.of(TextColors.YELLOW, TextActions.runCommand("/world " + worldName), TextActions.showText(Text.of("Teleport to " + prettyName)), " - ", prettyName));
        }
    }
    return CommandResult.success();
}
Also used : WorldService(com.skelril.skree.service.WorldService) CommandResult(org.spongepowered.api.command.CommandResult) TextActions(org.spongepowered.api.text.action.TextActions) CommandSource(org.spongepowered.api.command.CommandSource) Sponge(org.spongepowered.api.Sponge) Collectors(java.util.stream.Collectors) CommandSpec(org.spongepowered.api.command.spec.CommandSpec) CommandException(org.spongepowered.api.command.CommandException) List(java.util.List) WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) CommandContext(org.spongepowered.api.command.args.CommandContext) Text(org.spongepowered.api.text.Text) CommandExecutor(org.spongepowered.api.command.spec.CommandExecutor) World(org.spongepowered.api.world.World) TextColors(org.spongepowered.api.text.format.TextColors) WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) World(org.spongepowered.api.world.World) WorldService(com.skelril.skree.service.WorldService)

Example 2 with WorldEffectWrapper

use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.

the class ZoneTransitionalOrb method isInInstanceWorld.

private boolean isInInstanceWorld(Player player) {
    Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
    if (!optWorldService.isPresent()) {
        return false;
    }
    WorldService worldService = optWorldService.get();
    WorldEffectWrapper wrapper = worldService.getEffectWrapper(InstanceWorldWrapper.class).get();
    return wrapper.getWorlds().contains(player.getLocation().getExtent());
}
Also used : InstanceWorldWrapper(com.skelril.skree.content.world.instance.InstanceWorldWrapper) WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) WorldService(com.skelril.skree.service.WorldService)

Example 3 with WorldEffectWrapper

use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.

the class ZoneMasterOrb method isInInstanceWorld.

private boolean isInInstanceWorld(Player player) {
    Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
    if (optWorldService.isPresent()) {
        WorldService worldService = optWorldService.get();
        WorldEffectWrapper wrapper = worldService.getEffectWrapper(InstanceWorldWrapper.class).get();
        if (wrapper.getWorlds().contains(player.getLocation().getExtent())) {
            return true;
        }
    }
    return false;
}
Also used : InstanceWorldWrapper(com.skelril.skree.content.world.instance.InstanceWorldWrapper) WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) WorldService(com.skelril.skree.service.WorldService)

Example 4 with WorldEffectWrapper

use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.

the class WorldEntryPermissionCheck method checkDestination.

public static boolean checkDestination(Player player, World world) {
    WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
    Optional<WorldEffectWrapper> optEffectWrapper = service.getEffectWrapperFor(world);
    String worldType = "misc";
    if (optEffectWrapper.isPresent()) {
        worldType = optEffectWrapper.get().getName();
    }
    return player.hasPermission("skree.world." + worldType.toLowerCase() + ".teleport");
}
Also used : WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) WorldService(com.skelril.skree.service.WorldService)

Example 5 with WorldEffectWrapper

use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.

the class SummonWandererCommand 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();
    }
    WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
    World world = ((Player) src).getWorld();
    Optional<WorldEffectWrapper> optWrapper = service.getEffectWrapperFor(world);
    if (!optWrapper.isPresent()) {
        src.sendMessage(Text.of("This command can only be used in the Wilderness."));
        return CommandResult.empty();
    }
    WorldEffectWrapper wrapper = optWrapper.get();
    if (!(wrapper instanceof WildernessWorldWrapper)) {
        src.sendMessage(Text.of("This command can only be used in the Wilderness."));
        return CommandResult.empty();
    }
    Location<World> targetLocation = ((Player) src).getLocation();
    int playerWildernessLevel = ((WildernessWorldWrapper) wrapper).getLevel(targetLocation).get();
    int targetLevel = args.<Integer>getOne("target level").orElse(playerWildernessLevel);
    if (targetLevel < 1) {
        src.sendMessage(Text.of("The target level must be at least 1."));
        return CommandResult.empty();
    }
    String wanderer = args.<String>getOne("wanderer").get();
    ((WildernessWorldWrapper) wrapper).getWanderingMobManager().summon(wanderer, targetLevel, targetLocation);
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) World(org.spongepowered.api.world.World) WorldService(com.skelril.skree.service.WorldService)

Aggregations

WorldEffectWrapper (com.skelril.skree.service.internal.world.WorldEffectWrapper)6 WorldService (com.skelril.skree.service.WorldService)5 InstanceWorldWrapper (com.skelril.skree.content.world.instance.InstanceWorldWrapper)3 World (org.spongepowered.api.world.World)2 BuildWorldWrapper (com.skelril.skree.content.world.build.BuildWorldWrapper)1 MainWorldWrapper (com.skelril.skree.content.world.main.MainWorldWrapper)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Sponge (org.spongepowered.api.Sponge)1 CommandException (org.spongepowered.api.command.CommandException)1 CommandResult (org.spongepowered.api.command.CommandResult)1 CommandSource (org.spongepowered.api.command.CommandSource)1 CommandContext (org.spongepowered.api.command.args.CommandContext)1 CommandExecutor (org.spongepowered.api.command.spec.CommandExecutor)1 CommandSpec (org.spongepowered.api.command.spec.CommandSpec)1 Player (org.spongepowered.api.entity.living.player.Player)1 Text (org.spongepowered.api.text.Text)1 TextActions (org.spongepowered.api.text.action.TextActions)1 TextColors (org.spongepowered.api.text.format.TextColors)1