Search in sources :

Example 6 with ModifierService

use of com.skelril.skree.service.ModifierService in project Skree by Skelril.

the class ModifierNotifier method onPlayerJoin.

@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
    Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
    if (!optService.isPresent()) {
        return;
    }
    ModifierService service = optService.get();
    List<String> messages = new ArrayList<>();
    for (Map.Entry<String, Long> entry : service.getActiveModifiers().entrySet()) {
        String friendlyName = StringUtils.capitalize(entry.getKey().replace("_", " ").toLowerCase());
        String friendlyTime = PrettyText.date(entry.getValue());
        messages.add(" - " + friendlyName + " till " + friendlyTime);
    }
    if (messages.isEmpty())
        return;
    messages.sort(String.CASE_INSENSITIVE_ORDER);
    messages.add(0, "\n\nThe following donation perks are enabled:");
    Player player = event.getTargetEntity();
    Task.builder().execute(() -> {
        for (String message : messages) {
            player.sendMessage(Text.of(TextColors.GOLD, message));
        }
    }).delay(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) ArrayList(java.util.ArrayList) ModifierService(com.skelril.skree.service.ModifierService) Map(java.util.Map) Listener(org.spongepowered.api.event.Listener)

Example 7 with ModifierService

use of com.skelril.skree.service.ModifierService in project Skree by Skelril.

the class ArrowFishingHandler method onProjectileTickEvent.

@Listener
public void onProjectileTickEvent(ProjectileTickEvent event) {
    Projectile projectile = event.getTargetEntity();
    if (!(projectile instanceof Arrow) || Probability.getChance(3)) {
        return;
    }
    Location<World> loc = projectile.getLocation();
    if (MultiTypeRegistry.isWater(loc.getBlockType()) && checkVelocity(projectile.getVelocity())) {
        ProjectileSource source = projectile.getShooter();
        double modifier = 1;
        if (source instanceof Living) {
            modifier = 50;
        }
        Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
        int rolls = 1;
        if (optService.isPresent() && optService.get().isActive(UBER_ARROW_FISHING)) {
            if (source instanceof Living) {
                rolls = 15;
            } else {
                rolls = 5;
            }
        }
        new ItemDropper(loc).dropStacks(dropTable.getDrops(rolls, modifier), SpawnTypes.DROPPED_ITEM);
    }
}
Also used : Arrow(org.spongepowered.api.entity.projectile.arrow.Arrow) ItemDropper(com.skelril.nitro.item.ItemDropper) Living(org.spongepowered.api.entity.living.Living) ProjectileSource(org.spongepowered.api.entity.projectile.source.ProjectileSource) ModifierService(com.skelril.skree.service.ModifierService) World(org.spongepowered.api.world.World) Projectile(org.spongepowered.api.entity.projectile.Projectile) Listener(org.spongepowered.api.event.Listener)

Aggregations

ModifierService (com.skelril.skree.service.ModifierService)7 Listener (org.spongepowered.api.event.Listener)4 Player (org.spongepowered.api.entity.living.player.Player)3 World (org.spongepowered.api.world.World)3 ItemDropper (com.skelril.nitro.item.ItemDropper)2 ItemStack (org.spongepowered.api.item.inventory.ItemStack)2 DropTable (com.skelril.nitro.droptable.DropTable)1 MasterDropTable (com.skelril.nitro.droptable.MasterDropTable)1 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)1 WanderingBoss (com.skelril.skree.content.world.wilderness.wanderer.WanderingBoss)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)1 ItemEnchantment (org.spongepowered.api.data.meta.ItemEnchantment)1 Entity (org.spongepowered.api.entity.Entity)1 Item (org.spongepowered.api.entity.Item)1 Living (org.spongepowered.api.entity.living.Living)1 Boss (org.spongepowered.api.entity.living.monster.Boss)1 Monster (org.spongepowered.api.entity.living.monster.Monster)1