dziwakkolega 29 Opublikowano 29 czerwca 2021 Udostępnij Opublikowano 29 czerwca 2021 Cześć, dorobił by mi ktoś cooldown do tej classy? @EventHandler public void onPlayerInteract(final PlayerInteractEvent event) { final Player player = event.getPlayer(); final Action action = event.getAction(); player.getItemInHand(); if (player.getItemInHand().getType() == Material.ENDER_PEARL && (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) && player.hasPermission("goodplay.enderpearl.ride")) { event.setCancelled(true); final EnderPearl pearl = player.launchProjectile((Class<? extends EnderPearl>) EnderPearl.class); pearl.setVelocity(player.getLocation().getDirection()); pearl.setPassenger(player); final int pearlSlot = Main.config.getInt("PearlSlot"); if (pearlSlot >= 0 && pearlSlot <= 8) { player.getInventory().setItem(pearlSlot, onJoin.custompearl); } else { player.getInventory().setItem(0, onJoin.custompearl); } final boolean throwSound = Main.config.getBoolean("ThrowSound"); if (throwSound) { player.playSound(player.getLocation(), Sound.valueOf(Main.config.getString("Sound")), 1.0f, 1.0f); } final String throwMessage = Main.config.getString("ThrowMessage"); assert throwMessage != null; if (!throwMessage.equals("")) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', throwMessage)); player.sendTitle("TEST", "TEST", 1, 20, 1); } } } @EventHandler public void onPlayerTeleport(final PlayerTeleportEvent event) { if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { event.setCancelled(true); } } } Przywracam treść. Odnośnik do komentarza https://skript.pl/temat/49318-temat-do-usuni%C4%99cia/ Udostępnij na innych stronach Więcej opcji udostępniania...
Glicz 246 Opublikowano 29 czerwca 2021 Udostępnij Opublikowano 29 czerwca 2021 Ten temat został przeniesiony. Odnośnik do komentarza https://skript.pl/temat/49318-temat-do-usuni%C4%99cia/#findComment-306297 Udostępnij na innych stronach Więcej opcji udostępniania...
LeviBoyPL 161 Opublikowano 29 czerwca 2021 Udostępnij Opublikowano 29 czerwca 2021 private Map<Player, Long> cooldowns = new HashMap<>(); Stwórz sobie mapkę zawierającą plajera i long if(cooldowns.containsKey(player)) Sprawdź czy ktoś jest w mapce cooldowns.put(player, System.currentMillis() + 5*60*1000L); Jeżeli nie ma go to dodaj go do mapki if(cooldowns.get(player) < System.currentMillis()) Jeżeli jest to sprawdź czy czas zapisany w mapce jest mniejszy niż aktualny czas, jeżeli jest to pozwól mu rzucić perełką, jeżeli nie ma to nie pozwalaj Do cooldownów polecam zrobić Ci osobny storage, bo musisz pamiętać, żeby usuwać ludzi z mapki, którzy wyszli z serwera. Btw czemu mam wrażenie, że inspirowałeś się kokscraftem? xd Odnośnik do komentarza https://skript.pl/temat/49318-temat-do-usuni%C4%99cia/#findComment-306308 Udostępnij na innych stronach Więcej opcji udostępniania...
dziwakkolega 29 Opublikowano 30 czerwca 2021 Autor Udostępnij Opublikowano 30 czerwca 2021 Tak masz racje, inspirowałem się kokscraftem, a czy mógłbyś mi pokazać mniej więcej jak ma wyglądać **ta** classa po dodaniu cooldownu? Przywracam treść. Odnośnik do komentarza https://skript.pl/temat/49318-temat-do-usuni%C4%99cia/#findComment-306344 Udostępnij na innych stronach Więcej opcji udostępniania...
Gość Usunięty#25876 Opublikowano 2 lipca 2021 Udostępnij Opublikowano 2 lipca 2021 Ten temat został przeniesiony do kosza! Odnośnik do komentarza https://skript.pl/temat/49318-temat-do-usuni%C4%99cia/#findComment-306431 Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi