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

now working API, show me analog #105

Open
Alienn-Know opened this issue Jun 27, 2023 · 6 comments
Open

now working API, show me analog #105

Alienn-Know opened this issue Jun 27, 2023 · 6 comments
Labels
type: feature Request for a new Feature.

Comments

@Alienn-Know
Copy link

Alienn-Know commented Jun 27, 2023

Is your feature request related to a problem?

@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
    event.getPlayer().sendMessage(ChatColor.GREEN + "PlayerRespawnEvent executed");
}

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
    event.getPlayer().sendMessage(ChatColor.GREEN + "PlayerTeleportEvent executed");
}

Describe the solution you'd like.

I figured out how to get around this (PlayerRespawnEvent event)

Map<String, ScheduledTask> playerTasks = new HashMap<>();

@EventHandler
    public void onEntityDeath(EntityDeathEvent event) {
         if (event.getEntity().getType() == EntityType.PLAYER) {
           Player player = (Player) event.getEntity();
           String playerName = player.getName();

            ScheduledTask task = new FoliaTaskScheduler(plugin).runRepeating(player, () -> {
                if (player.getHealth() != 0) {
                    ////////////////////////////////////     Example     ////////////////////////////////////////
                   event.getPlayer().sendMessage(ChatColor.GREEN + "PlayerRespawnEvent executed");

                   /////////////////////////////////////////////////////////////////////////////////////////////
                    ScheduledTask playerTask = playerTasks.remove(player);
                    if (playerTask != null) {
                        playerTask.cancel();
                    }
                }
            }, 1, 10 * 1);
            playerTasks.put(playerName, task);
        }
    }

Describe alternatives you've considered.

I did not receive any message in the chat, following these steps, show me an analogue of this

Other

No response

@Alienn-Know Alienn-Know added status: needs triage type: feature Request for a new Feature. labels Jun 27, 2023
@RaphaelWoude
Copy link

Did you register the events?

@Alienn-Know
Copy link
Author

yes, I have other events, and they are in the 1st class, they work, but these do not

@sofianedjerbi
Copy link
Contributor

Those events aren't called by Folia, the API will be completed someday

@Alienn-Know
Copy link
Author

Alienn-Know commented Jun 27, 2023

Thank you

@Spottedleaf
Copy link
Member

The respawn and teleport APIs are very awkward since the target region for the respawn position or teleport location are not actually owned during the event invocation, which may make modifying the event outcome or even reading from it very challenging. It requires a different event system to properly facilitate this, which is not a priority currently.

@nyancat-hu
Copy link

The respawn and teleport APIs are very awkward since the target region for the respawn position or teleport location are not actually owned during the event invocation, which may make modifying the event outcome or even reading from it very challenging. It requires a different event system to properly facilitate this, which is not a priority currently.

EntityPortalEvent doesn't work either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Request for a new Feature.
Projects
None yet
Development

No branches or pull requests

5 participants