How do I block item crafting?

Discussion in 'Plugin Development' started by rfsantos1996, Feb 18, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    rfsantos1996

    (full source)

    Code:java
    1. @EventHandler(ignoreCancelled = false, priority = EventPriority.HIGHEST)
    2. public void onCrafting(CraftItemEvent e) {
    3. if (e.getInventory().getHolder() instanceof Player) {
    4. Player p = (Player) e.getInventory().getHolder();
    5. if (pl.ingame.containsKey(p)) {
    6. if (e.getRecipe().getResult() != null && pl.ingame.get(p).getMatch().getBlockedCrafting().contains(e.getRecipe().getResult().getType())) {
    7. e.setCancelled(true);
    8. }
    9. }
    10. }
    11. pl.getLogger().log(Level.INFO, "current type: " + e.getCurrentItem().getType().name());
    12. pl.getLogger().log(Level.INFO, "cursor type: " + e.getCursor().getType());
    13. pl.getLogger().log(Level.INFO, "result recipe type: " + e.getRecipe().getResult().getType());
    14. }


    Yeah, I registered events, yeah, I already tested without the "/* */", I'm not dumb ( not too dumb )

    I'm trying to block some items from being crafted (2x2 and 3x3 craftings) but even my debug things dont show D:

    Can someone help me?
     
  2. Offline

    Mathias Eklund

    Cancel the click in the crafting window. I think the results are client sided. If I am wrong, please tell me.
     
  3. Offline

    rfsantos1996

    I think its the only way, and I think since 1.6 its server sided because I belive you can create recipes
     
  4. Offline

    desht

    rfsantos1996 likes this.
  5. Offline

    rfsantos1996

    Will try that later

    Thanks, it helped/worked (;

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page