Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with use-virtual-thread-for-async-sheduler #214

Open
3 of 4 tasks
sh2kcs opened this issue Feb 7, 2025 · 5 comments
Open
3 of 4 tasks

Bug with use-virtual-thread-for-async-sheduler #214

sh2kcs opened this issue Feb 7, 2025 · 5 comments
Labels
bug Something isn't working More information needed Waiting response and provide more information

Comments

@sh2kcs
Copy link

sh2kcs commented Feb 7, 2025

Checklist

What behaviour is observed?

Spam messages from plugin

Expected behaviour

Send 1 message to chat

To Reproduce

  1. Write your own plugin and use the Bukkit#runTaskAsynchronously chat method in it
  2. Use the command and you will see spam in the chat

Spark profiler link

https://spark.lucko.me/C8fKJoDG9U

Error log (if applicable)

No response

@sh2kcs sh2kcs added the bug Something isn't working label Feb 7, 2025
@NoltoxGit
Copy link

Hello @sh2kcs,
Your Spark profile link doesn't work. Please try sending a new one!

@Dreeam-qwq
Copy link
Member

Can't replicate

@Override
    public void execute(CommandSender sender, String[] args, Plugin plugin) {
        if (args.length > 0) {
            switch (args[0]) {
                case "test": {
                    Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
                        sender.sendMessage("test first message");
                    });
                    break;
                }
            }
        } else {
            sendErrorMessage();
        }

spark: https://spark.lucko.me/v67v4T5ASD

Can you provide your code for replication? and also spark profiler.

@Dreeam-qwq Dreeam-qwq added the More information needed Waiting response and provide more information label Feb 7, 2025
@sh2kcs
Copy link
Author

sh2kcs commented Feb 7, 2025

Can't replicate

@Override
    public void execute(CommandSender sender, String[] args, Plugin plugin) {
        if (args.length > 0) {
            switch (args[0]) {
                case "test": {
                    Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
                        sender.sendMessage("test first message");
                    });
                    break;
                }
            }
        } else {
            sendErrorMessage();
        }

spark: https://spark.lucko.me/v67v4T5ASD

Can you provide your code for replication? and also spark profiler.

if (!module.getRequestSet().contains(player) && !module.getApprovedSet().contains(player)) {
                player.sendMessage(MiniMessage.miniMessage().deserialize("<yellow>⚠ <reset><white>Отправка запроса..."));
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        if (!module.getWaitingSet().contains(player)) {
                            module.getWaitingSet().add(player);
                            module.getRequestSet().add(player);
                            player.sendMessage(MiniMessage.miniMessage().deserialize("<yellow>⚠ <reset><white>Запрос на получение информации об IP-адресе был отправлен Руководству"));
                            player.sendMessage(MiniMessage.miniMessage().deserialize("<white>После его одобрения, используйте <yellow>/ip-check <white>ещё раз"));

                            Bukkit.getOnlinePlayers().forEach(pl -> {
                                if (pl.hasPermission("ssc.admin")) {
                                    player.sendMessage(MiniMessage.miniMessage().deserialize("<yellow>⚠ <reset><white>Запрос на получение информации об IP-адресе от игрока <yellow>" + player.getName()));
                                    player.sendMessage(MiniMessage.miniMessage().deserialize("<white>Чтобы принять запрос, используйте <yellow>/approve " + player.getName()));
                                    player.sendMessage(MiniMessage.miniMessage().deserialize("<white>Чтобы отклонить запрос, просто игнорируйте его"));
                                }
                            });
                        }
                    }
                }.runTaskLaterAsynchronously(LoggerModule.getInstance(), 30L);

try this pls

@Dreeam-qwq
Copy link
Member

Still can't (

Image

@Override
    public void execute(CommandSender sender, String[] args, Plugin plugin) {
        if (args.length > 0) {
            switch (args[0]) {
                 case "test": {
                    new BukkitRunnable() {
                        @Override
                        public void run() {
                            sender.sendMessage("Message 1");

                            Bukkit.getOnlinePlayers().forEach($ -> {
                                sender.sendMessage("Message 2");
                            });
                        }
                    }.runTaskLaterAsynchronously(plugin, 30L);

                    break;
                }
           }
        } else {
            sendErrorMessage();
        }

@sh2kcs
Copy link
Author

sh2kcs commented Feb 8, 2025

Still can't (

Image

@Override
    public void execute(CommandSender sender, String[] args, Plugin plugin) {
        if (args.length > 0) {
            switch (args[0]) {
                 case "test": {
                    new BukkitRunnable() {
                        @Override
                        public void run() {
                            sender.sendMessage("Message 1");

                            Bukkit.getOnlinePlayers().forEach($ -> {
                                sender.sendMessage("Message 2");
                            });
                        }
                    }.runTaskLaterAsynchronously(plugin, 30L);

                    break;
                }
           }
        } else {
            sendErrorMessage();
        }

Perhaps this only occurs when there is a lot of online activity.
But please try this piece of code too:

@EventHandler
    private void handle(PlayerInteractEntityEvent event){
        Entity rightClicked = event.getRightClicked();
        Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
            Bukkit.getOnlinePlayers().forEach(player -> {
                player.sendMessage("Entity:" + rightClicked.getType().name());
            });
        });
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working More information needed Waiting response and provide more information
Projects
None yet
Development

No branches or pull requests

3 participants