Search in sources :

Example 11 with WorldService

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

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

the class WorldCommand 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);
    Optional<WorldProperties> optProperties = args.getOne("world");
    if (!optProperties.isPresent()) {
        src.sendMessage(Text.of(TextColors.YELLOW, "You are in: " + ((Player) src).getWorld().getName() + "."));
        return CommandResult.empty();
    }
    Optional<World> optWorld = Sponge.getServer().getWorld(optProperties.get().getWorldName());
    if (!optWorld.isPresent()) {
        src.sendMessage(Text.of(TextColors.RED, "No loaded world by that name found."));
        return CommandResult.empty();
    }
    World world = optWorld.get();
    if (!WorldEntryPermissionCheck.checkDestination((Player) src, world)) {
        src.sendMessage(Text.of(TextColors.RED, "You do not have permission to access worlds of this type."));
        return CommandResult.empty();
    }
    Optional<Location<World>> optLoc = SafeTeleportHelper.teleport((Entity) src, optWorld.get().getSpawnLocation());
    if (optLoc.isPresent()) {
        src.sendMessage(Text.of(TextColors.YELLOW, "Entered world: " + world.getName() + " successfully!"));
    } else if (args.hasAny("f")) {
        ((Player) src).setLocation(optWorld.get().getSpawnLocation());
        src.sendMessage(Text.of(TextColors.YELLOW, "Force entered world: " + world.getName() + " successfully!"));
    } else {
        src.sendMessage(Text.of(TextColors.YELLOW, "Failed to enter " + world.getName() + " please report this!"));
    }
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) World(org.spongepowered.api.world.World) WorldService(com.skelril.skree.service.WorldService) WorldProperties(org.spongepowered.api.world.storage.WorldProperties) Location(org.spongepowered.api.world.Location)

Example 13 with WorldService

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

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

Example 15 with WorldService

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

the class ZoneSystem method init.

@NModuleTrigger(trigger = "SERVER_STARTED", dependencies = { "World System" })
public void init() {
    Optional<WorldService> optService = Sponge.getServiceManager().provide(WorldService.class);
    World world = optService.get().getEffectWrapper(InstanceWorldWrapper.class).get().getWorlds().iterator().next();
    Task.builder().execute(() -> {
        WorldResolver instWorldResolver = new WorldResolver(world, WorldEdit.getInstance());
        service = new ZoneServiceImpl(new CacheBasedAllocator(Decorators.ZONE_PRIMARY_DECORATOR, instWorldResolver));
        service.registerManager(new CursedMineManager());
        service.registerManager(new TempleOfFateManager());
        service.registerManager(new TheForgeManager());
        service.registerManager(new CatacombsManager());
        service.registerManager(new FreakyFourManager());
        service.registerManager(new GoldRushManager());
        service.registerManager(new JungleRaidManager());
        service.registerManager(new PatientXManager());
        service.registerManager(new ShnugglesPrimeManager());
        service.registerManager(new SkyWarsManager());
        Sponge.getServiceManager().setProvider(SkreePlugin.inst(), ZoneService.class, service);
        Sponge.getCommandManager().register(SkreePlugin.inst(), ZoneMeCommand.aquireSpec(), "zoneme");
    }).delayTicks(1).submit(SkreePlugin.inst());
}
Also used : CacheBasedAllocator(com.skelril.skree.service.internal.zone.allocator.CacheBasedAllocator) JungleRaidManager(com.skelril.skree.content.zone.group.jungleraid.JungleRaidManager) WorldResolver(com.skelril.skree.service.internal.zone.WorldResolver) TempleOfFateManager(com.skelril.skree.content.zone.global.templeoffate.TempleOfFateManager) ShnugglesPrimeManager(com.skelril.skree.content.zone.group.shnugglesprime.ShnugglesPrimeManager) TheForgeManager(com.skelril.skree.content.zone.global.theforge.TheForgeManager) World(org.spongepowered.api.world.World) ZoneServiceImpl(com.skelril.skree.service.internal.zone.ZoneServiceImpl) WorldService(com.skelril.skree.service.WorldService) GoldRushManager(com.skelril.skree.content.zone.group.goldrush.GoldRushManager) PatientXManager(com.skelril.skree.content.zone.group.patientx.PatientXManager) SkyWarsManager(com.skelril.skree.content.zone.group.skywars.SkyWarsManager) CatacombsManager(com.skelril.skree.content.zone.group.catacombs.CatacombsManager) FreakyFourManager(com.skelril.skree.content.zone.group.freakyfour.FreakyFourManager) CursedMineManager(com.skelril.skree.content.zone.global.cursedmine.CursedMineManager) NModuleTrigger(com.skelril.nitro.module.NModuleTrigger)

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