Search in sources :

Example 1 with SoundButton

use of gg.projecteden.nexus.features.events.y2020.halloween20.models.SoundButton in project Nexus by ProjectEdenGG.

the class Halloween20 method onButtonClick.

@EventHandler
public void onButtonClick(PlayerInteractEvent event) {
    if (!ActionGroup.CLICK_BLOCK.applies(event))
        return;
    if (event.getHand() != EquipmentSlot.HAND)
        return;
    SoundButton button = SoundButton.getByLocation(event.getClickedBlock().getLocation());
    if (button == null)
        return;
    new SoundBuilder(button.getSound()).receiver(event.getPlayer()).play();
    Halloween20Service service = new Halloween20Service();
    Halloween20User user = service.get(event.getPlayer());
    if (user.getFoundButtons().contains(button)) {
        if (new CooldownService().check(event.getPlayer(), "halloween20-button-alreadyfound", TickTime.SECOND.x(10)))
            user.sendMessage(PREFIX + "You've already found this button!");
        return;
    }
    user.getFoundButtons().add(button);
    service.save(user);
    user.sendMessage(PREFIX + "You have found a spooky button! &e(" + user.getFoundButtons().size() + "/" + SoundButton.values().length + ")");
    if (user.getFoundButtons().size() != SoundButton.values().length)
        return;
    PermissionChange.set().player(event.getPlayer()).permissions("powder.powder.spookyscaryskeletons").runAsync();
    user.sendMessage(PREFIX + "You have unlocked the Spooky Scary Skeletons song! &c/songs");
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Halloween20User(gg.projecteden.nexus.models.halloween20.Halloween20User) Halloween20Service(gg.projecteden.nexus.models.halloween20.Halloween20Service) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) SoundButton(gg.projecteden.nexus.features.events.y2020.halloween20.models.SoundButton) EventHandler(org.bukkit.event.EventHandler)

Aggregations

SoundButton (gg.projecteden.nexus.features.events.y2020.halloween20.models.SoundButton)1 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)1 Halloween20Service (gg.projecteden.nexus.models.halloween20.Halloween20Service)1 Halloween20User (gg.projecteden.nexus.models.halloween20.Halloween20User)1 SoundBuilder (gg.projecteden.nexus.utils.SoundBuilder)1 EventHandler (org.bukkit.event.EventHandler)1