Search in sources :

Example 1 with BuildWorldWrapper

use of com.skelril.skree.content.world.build.BuildWorldWrapper in project Skree by Skelril.

the class RespawnServiceImpl method getDefault.

@Override
public Location<World> getDefault(Player target) {
    WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
    Optional<Map<UUID, RespawnLocation>> optRespawnLocations = target.get(Keys.RESPAWN_LOCATIONS);
    if (optRespawnLocations.isPresent()) {
        BuildWorldWrapper buildWrapper = service.getEffectWrapper(BuildWorldWrapper.class).get();
        UUID buildWorldId = buildWrapper.getPrimaryWorld().getUniqueId();
        RespawnLocation targetLocation = optRespawnLocations.get().get(buildWorldId);
        if (targetLocation != null) {
            Optional<Location<World>> optLocation = targetLocation.asLocation();
            if (optLocation.isPresent()) {
                return optLocation.get();
            }
        }
    }
    return service.getEffectWrapper(MainWorldWrapper.class).get().getPrimaryWorld().getSpawnLocation();
}
Also used : MainWorldWrapper(com.skelril.skree.content.world.main.MainWorldWrapper) RespawnLocation(org.spongepowered.api.util.RespawnLocation) BuildWorldWrapper(com.skelril.skree.content.world.build.BuildWorldWrapper) WorldService(com.skelril.skree.service.WorldService) Location(org.spongepowered.api.world.Location) RespawnLocation(org.spongepowered.api.util.RespawnLocation)

Example 2 with BuildWorldWrapper

use of com.skelril.skree.content.world.build.BuildWorldWrapper in project Skree by Skelril.

the class WorldSystem method initWrappers.

private void initWrappers() throws IOException {
    List<WorldEffectWrapper> wrappers = Lists.newArrayList(new MainWorldWrapper(), new BuildWorldWrapper(), new InstanceWorldWrapper(), new WildernessWorldWrapper(ConfigLoader.loadConfig("wilderness.json", WildernessConfig.class)));
    for (WorldEffectWrapper wrapper : wrappers) {
        this.wrappers.put(wrapper.getName(), wrapper);
        Sponge.getEventManager().registerListeners(SkreePlugin.inst(), wrapper);
        service.registerEffectWrapper(wrapper);
    }
}
Also used : MainWorldWrapper(com.skelril.skree.content.world.main.MainWorldWrapper) InstanceWorldWrapper(com.skelril.skree.content.world.instance.InstanceWorldWrapper) WorldEffectWrapper(com.skelril.skree.service.internal.world.WorldEffectWrapper) BuildWorldWrapper(com.skelril.skree.content.world.build.BuildWorldWrapper)

Aggregations

BuildWorldWrapper (com.skelril.skree.content.world.build.BuildWorldWrapper)2 MainWorldWrapper (com.skelril.skree.content.world.main.MainWorldWrapper)2 InstanceWorldWrapper (com.skelril.skree.content.world.instance.InstanceWorldWrapper)1 WorldService (com.skelril.skree.service.WorldService)1 WorldEffectWrapper (com.skelril.skree.service.internal.world.WorldEffectWrapper)1 RespawnLocation (org.spongepowered.api.util.RespawnLocation)1 Location (org.spongepowered.api.world.Location)1