PlayerCraftItemEvent

  • Unfortunately we won't get the item API ready in time :( It's a bit tricky to implement the communication between Java and native side (because inventory items don't have a unique global ID, which makes it difficult to identify the correct item instance on native side). Sorry :silenced:


    But it sounds like you don't want to detect regular items (like tools or weapons), instead you're apparently looking for a way to ban objects (like furniture etc)? Unfortunately the "item.getName()" method would just return "objectkit" in most cases then (because most objects are just represented by this generic item). The item has a separate attribute which then contains the actual object id. So that method wouldn't help in this case...


    Which issue did you experience with the permissions exactly? The main limitation is indeed that you can only ban items atm, no objects or construction elements... or did you experience any other issues with it?


    Being unable to ban objects (like furniture) or blocks is definitely a big issue... it requires some more extensive changes (unfortunately this won't make it into the hotfix either), but I'll put in on our priority list now, so this will be changed with the next update :)


    Sorry for not having a solution for this atm :/

  • I just figured the CraftItemEvent would return a string or an ID I could then use to cancel the event and send a notification to the player saying this item (or object) is locked, if the identifier was of a certain type. Or accomplish via runtime polymorphism...


    I mean, heh, you get players joining a medieval themed server and then building glass structures with glass doors and using metal yellow and black chevrons with purple incandescent lights. *roll eyes* because I guess that's just what some people do.


    Administrative controls are fine to a degree, but I'll always opt for the technical contol.


    But if it can't be done right now, it can't be done :)


    Doing a great job mate :thumbup:

  • A small update: The upcoming hotfix will change the PlayerCraftItemEvent, so it will now also give access to the recipe definition. This way you can easily check the recipe name (which is almost always the object/item name) :) Example:

    Java
    //Example: Prevent player from crafting the repeater item or paper press object
    @EventMethod
    public void onPlayerCraftItem(PlayerCraftItemEvent evt) {
    Crafting.Recipe recipe = evt.getRecipe();
    if (recipe.name.equals("repeater") || recipe.name.equals("paperpress")) {
    evt.setCancelled(true);
    }
    }

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!