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