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

Chorus flower destroyed by arrow/trident #812

Closed
SurpricesGS opened this issue Jul 4, 2019 · 3 comments
Closed

Chorus flower destroyed by arrow/trident #812

SurpricesGS opened this issue Jul 4, 2019 · 3 comments
Assignees
Labels
1.14 Related to 1.14+ Status: Done This issue has been completed or answered. This pull request has been merged. Type: Bug
Milestone

Comments

@SurpricesGS
Copy link

Description

Is your feature request related to a problem?

In 1.14 and higher Chorus Flower can be destroyed with Arrow/Trident
(video: https://www.curseforge.com/minecraft/customization/arrowbreakchorusfruitflower)

Describe the solution you'd like us to implement.

People who aren't permitted wouldn't be able to break the chorus flower

@SurpricesGS SurpricesGS added Status: Pending Waiting for a developer to start working on this issue. Type: Enhancement Improvement or modification which is usually a new feature. labels Jul 4, 2019
@Poslovitch Poslovitch added the 1.14 Related to 1.14+ label Jul 4, 2019
@Poslovitch
Copy link
Member

Poslovitch commented Jul 4, 2019

Here are some code snippets found on SpigotMC.

//credits goes to @Reckfullers (Spigot user)
@EventHandler
private void onChorusBreak(ProjectileHitEvent event)
{
    if (event.getHitBlock() != null && event.getHitBlock().getType() == Material.CHORUS_FLOWER)
    {
        event.getEntity().remove();
        event.getHitBlock().setType(Material.AIR);

        Bukkit.getScheduler().runTask(plugin, () -> event.getHitBlock().setType(Material.CHORUS_FLOWER));
    }
}
//credits goes to @Ugleh (Spigot user)
@EventHandler
public void projectileHitEvent(ProjectileHitEvent event) {
    Block b = event.getHitBlock();
    if(b == null || !b.getType().equals(Material.CHORUS_FLOWER)) return;
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, (Runnable) () -> b.setType(Material.CHORUS_FLOWER), 1L);

}

@EventHandler
public void itemSpawnEvent(ItemSpawnEvent event) {
    if( event.getEntity().getItemStack().getType().equals(Material.CHORUS_FLOWER))
        event.setCancelled(true);
}

@Poslovitch Poslovitch added Status: In progress Working on the issue. Type: Bug and removed Status: Pending Waiting for a developer to start working on this issue. Type: Enhancement Improvement or modification which is usually a new feature. labels Dec 29, 2019
@Poslovitch Poslovitch self-assigned this Dec 29, 2019
@Poslovitch
Copy link
Member

Could confirm on a 1.14.4 server, using BentoBox 1.10.0 snapshots and BSkyBlock. The /bsb why debug doesn't even catch that event.

@Poslovitch Poslovitch added Status: Done This issue has been completed or answered. This pull request has been merged. and removed Status: In progress Working on the issue. labels Dec 29, 2019
@Poslovitch
Copy link
Member

Note it can cause the block to flicker or to turn into a ghost block. The Bukkit API does not provide a way to actually cancel the block breaking, therefore we need to resort to a delayed task.

@Poslovitch Poslovitch added this to the 1.10.0 milestone Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.14 Related to 1.14+ Status: Done This issue has been completed or answered. This pull request has been merged. Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants