Search in sources :

Example 1 with WorldService

use of com.skelril.skree.service.WorldService in project Skree by Skelril.

the class SkullOfTheFallen method onRightClick.

@Listener
public void onRightClick(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
    Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
    if (!optHeldItem.isPresent()) {
        return;
    }
    if (this != optHeldItem.get().getItem()) {
        return;
    }
    Location<World> pLoc = player.getLocation();
    Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
    if (optWorldService.isPresent()) {
        WorldService worldService = optWorldService.get();
        WildernessWorldWrapper wrapper = worldService.getEffectWrapper(WildernessWorldWrapper.class).get();
        Optional<Integer> optLevel = wrapper.getLevel(pLoc);
        if (optLevel.isPresent()) {
            int level = optLevel.get();
            DecimalFormat df = new DecimalFormat("#,###.##");
            player.sendMessages(Text.of(TextColors.YELLOW, "Wilderness level: " + level), Text.of(TextColors.YELLOW, "PvP Enabled: " + (wrapper.allowsPvP(level) ? "Yes" : "No")), Text.of(TextColors.YELLOW, "Mob damage: +" + df.format(wrapper.getDamageMod(level))), Text.of(TextColors.YELLOW, "Mob health: x" + df.format(wrapper.getHealthMod(level))), Text.of(TextColors.YELLOW, "Ore modifier: x" + df.format(wrapper.getOreMod(wrapper.getDropTier(level)))), Text.of(TextColors.YELLOW, "Drop modifier: x" + df.format(level * wrapper.getDropMod(wrapper.getDropTier(level)))));
        } else {
            player.sendMessage(Text.of(TextColors.RED, "You're not in a Wilderness world!"));
        }
        event.setUseBlockResult(Tristate.FALSE);
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) WildernessWorldWrapper(com.skelril.skree.content.world.wilderness.WildernessWorldWrapper) ItemStack(org.spongepowered.api.item.inventory.ItemStack) ItemStackFactory.newItemStack(com.skelril.nitro.item.ItemStackFactory.newItemStack) World(org.spongepowered.api.world.World) WorldService(com.skelril.skree.service.WorldService) Listener(org.spongepowered.api.event.Listener)

Example 2 with WorldService

use of com.skelril.skree.service.WorldService 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 3 with WorldService

use of com.skelril.skree.service.WorldService in project Skree by Skelril.

the class LoadWorldCommand method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
    src.sendMessage(Text.of(TextColors.YELLOW, "Loading..."));
    Optional<World> optWorld = service.loadVanillaMapFromDisk(args.<String>getOne("world name").get());
    if (optWorld.isPresent()) {
        src.sendMessage(Text.of(TextColors.DARK_GREEN, "World loaded successfully."));
    } else {
        src.sendMessage(Text.of(TextColors.RED, "World failed to load."));
    }
    return CommandResult.success();
}
Also used : World(org.spongepowered.api.world.World) WorldService(com.skelril.skree.service.WorldService)

Example 4 with WorldService

use of com.skelril.skree.service.WorldService 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 5 with WorldService

use of com.skelril.skree.service.WorldService in project Skree by Skelril.

the class SummonWandererCommand method supportedWanderers.

private static Collection<String> supportedWanderers() {
    WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
    WildernessWorldWrapper wrapper = service.getEffectWrapper(WildernessWorldWrapper.class).get();
    return wrapper.getWanderingMobManager().getSupportedWanderers();
}
Also used : WorldService(com.skelril.skree.service.WorldService)

Aggregations

WorldService (com.skelril.skree.service.WorldService)16 World (org.spongepowered.api.world.World)10 WorldEffectWrapper (com.skelril.skree.service.internal.world.WorldEffectWrapper)5 Player (org.spongepowered.api.entity.living.player.Player)4 NModuleTrigger (com.skelril.nitro.module.NModuleTrigger)2 BuildWorldWrapper (com.skelril.skree.content.world.build.BuildWorldWrapper)2 InstanceWorldWrapper (com.skelril.skree.content.world.instance.InstanceWorldWrapper)2 MainWorldWrapper (com.skelril.skree.content.world.main.MainWorldWrapper)2 DecimalFormat (java.text.DecimalFormat)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Sponge (org.spongepowered.api.Sponge)2 CommandException (org.spongepowered.api.command.CommandException)2 CommandResult (org.spongepowered.api.command.CommandResult)2 CommandSource (org.spongepowered.api.command.CommandSource)2 CommandContext (org.spongepowered.api.command.args.CommandContext)2 CommandExecutor (org.spongepowered.api.command.spec.CommandExecutor)2 CommandSpec (org.spongepowered.api.command.spec.CommandSpec)2 Listener (org.spongepowered.api.event.Listener)2 Text (org.spongepowered.api.text.Text)2