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);
}
}
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();
}
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();
}
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());
}
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();
}
Aggregations