Search in sources :

Example 1 with WildernessWorldWrapper

use of com.skelril.skree.content.world.wilderness.WildernessWorldWrapper 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)

Aggregations

ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)1 WildernessWorldWrapper (com.skelril.skree.content.world.wilderness.WildernessWorldWrapper)1 WorldService (com.skelril.skree.service.WorldService)1 DecimalFormat (java.text.DecimalFormat)1 Listener (org.spongepowered.api.event.Listener)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 World (org.spongepowered.api.world.World)1