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();
}
use of com.skelril.skree.service.WorldService in project Skree by Skelril.
the class WildernessMetaCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
PaginationService pagination = Sponge.getServiceManager().provideUnchecked(PaginationService.class);
WildernessWorldWrapper wrapper = service.getEffectWrapper(WildernessWorldWrapper.class).get();
List<Text> result = wrapper.getMetaInformation().stream().sorted(Comparator.comparing(a -> a.getKey().getName())).map(this::createLine).collect(Collectors.toList());
pagination.builder().contents(result).title(Text.of(TextColors.GOLD, "Meta Info List")).padding(Text.of(" ")).sendTo(src);
return CommandResult.success();
}
use of com.skelril.skree.service.WorldService in project Skree by Skelril.
the class WildernessTeleportCommand 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();
}
if (!src.hasPermission("skree.world.wilderness.teleport")) {
src.sendMessage(Text.of(TextColors.RED, "You do not have permission to access worlds of this type."));
return CommandResult.empty();
}
WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
WildernessWorldWrapper wrapper = service.getEffectWrapper(WildernessWorldWrapper.class).get();
int targetLevel = args.<Integer>getOne("target level").get();
if (targetLevel < 1) {
src.sendMessage(Text.of("The target level must be at least 1."));
return CommandResult.empty();
}
Optional<World> optWorld = Sponge.getServer().getWorld(args.<String>getOne("world type").get());
if (!optWorld.isPresent()) {
src.sendMessage(Text.of("That world is not currently accessible."));
return CommandResult.empty();
}
World world = optWorld.get();
int variance = (int) (Math.sqrt(targetLevel) * 2);
int negative = Probability.getChance(3) ? -1 : 1;
targetLevel += Probability.getRandom(variance) * negative;
Player player = (Player) src;
for (int i = 0; i < 2; ++i) {
tf(player).hurtResistantTime = 0;
player.damage(wrapper.getDamageMod(targetLevel) * 3, DamageSource.builder().type(DAMAGE_TYPE).build());
}
if (player.get(Keys.HEALTH).orElse(0D) > 0) {
int unit = wrapper.getLevelUnit(world);
Location<World> dest;
do {
int x = getLevelCoord(targetLevel, unit);
int z = getLevelCoord(targetLevel, unit);
dest = SafeTeleportHelper.getSafeDest(new Location<>(world, x, 60, z)).orElse(null);
} while (dest == null);
player.setLocation(dest);
}
return CommandResult.success();
}
use of com.skelril.skree.service.WorldService 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 com.skelril.skree.service.WorldService in project Skree by Skelril.
the class MarketImplUtil method canBuyOrSell.
public static boolean canBuyOrSell(Player player) {
Optional<WorldService> optService = Sponge.getServiceManager().provide(WorldService.class);
if (optService.isPresent()) {
WorldService service = optService.get();
Collection<World> okayWorlds = new HashSet<>();
okayWorlds.addAll(service.getEffectWrapper(MainWorldWrapper.class).get().getWorlds());
okayWorlds.addAll(service.getEffectWrapper(BuildWorldWrapper.class).get().getWorlds());
return okayWorlds.contains(player.getWorld());
}
return true;
}
Aggregations