1.12.2 Just need some quick help

Discussion in 'Spigot Plugin Development' started by ServerProxy, Aug 2, 2020 at 7:24 PM.

  1. I'm trying to make a plugin that checks the config for a certain ID, so like 351:4 and if the player has that, they can't put it in their offhand.

    I'm trying to figure out how to convert the ID to the Material
     
  2. Don’t use IDs. They’re effectively gone. Use names.
     
    • Agree Agree x 2
  3. Strahan

    Benefactor

    Yea, get away from relying on IDs. Yea, they still work, but it's building a castle on the sand. It may all fall to pieces some day heh.

    I'd just check in PlayerSwapHandItemsEvent for Material.INK_SACK and durability 4:

    Code (Text):
    @EventHandler
    public void ooo(PlayerSwapHandItemsEvent e) {
      if (e.getOffHandItem().getType() != Material.INK_SACK) return;
      if (e.getOffHandItem().getDurability() != (short)4) return;

      e.setCancelled(true);
    }[code]