Solved Stop player getting advancement in specific world

Discussion in 'Spigot Plugin Development' started by Tajam, Mar 14, 2019.

  1. PlayerAdvancementDoneEvent does not have setCancel function. Any other way to block this event?
     
  2. The closest I found is ANNOUNCE_ADVANCEMENTS - Toggles the announcing of advancements.
    However, it doesn't stop player from achieving advancement. It just mute the announcement, doesn't it?
     
    • Agree Agree x 1
  3. get the event of achievement and check if the player is in a specified world...

    Sent from my Android using Tapatalk
     
  4. ItsSchatten

    ItsSchatten Previously _ItsShadow_

  5. md_5

    Administrator Developer

    Because cancelling an advancement doesn't make sense if they have all the criterion. Maybe look at that event instead.
     
  6. Why would we do something as smart as that? Obviously there must be some other way /s
     
  7. If you are trying to remove the message of "ExamplePlayer has just earned the achievement [Opening Inventory]" just set the "announce-player-achivements" to false in the server.properties file.

    upload_2019-3-15_1-3-52.png

    (sorry for bad english)
     
  8. try this:
    Code (Text):

    @EventHandler
    public void achievement(PlayerAchievementAwardedEvent e) {
           Player player = e.getPlayer();
           if (player.getWorld().getName().equalsIgnoreCase("yourworld")) {
                e.setCancelled(true);
           }
    }
     
     
  9. I think that he wants to disable getting achievements that is already unlocked in other worlds. If not, correct me :p
     
  10. The PlayerAchievementAwardedEvent is deprecated.
    To quote:
     
  11. But if he is trying to make a plugin for his server with version for example 1.8.8 it is fine

    Otherwise i don't know.
     
  12. And what do you recommend?

    Sent from my Android using Tapatalk
     
  13. We may should add a boolean displayed :
    event.setDisplayed: the avancement TAB in the top-right of the screen
    event setMessage: the chat message. Invisible if null
     
    • Winner Winner x 1
  14. Code (Java):
    @EventHandler(priority=EventPriority.NORMAL)
    public void blockAdvancement(final PlayerAdvancementDoneEvent event) {
        Player p = event.getPlayer();
        String world = p.getWorld().getName();
        if (world.equals("world_creative")) {
            Advancement advancement = event.getAdvancement();
            for(String c: advancement.getCriteria()) {
                p.getAdvancementProgress(advancement).revokeCriteria(c);
            }
        }
    }
    This is how I do it but I am missing the final piece from the puzzle. I can't block the client-side message of getting advancement (top-right side of the screen). Is there anyway to stop that?

    Edit: make code look nicer
     
  15. You will need to block the packet.
     
    • Useful Useful x 1
  16. Oh wow thanks, I learn something new here. I didn't know you can block packet.
    Ok, this is solved.
     
    • Friendly Friendly x 1

Share This Page