Spigot PortableCrafting 1.1.1

Right click a workbench to open it!

  1. EnderTweaks submitted a new resource:

    PortableCrafting - Right click a workbench to open it!

    Read more about this resource...
     
  2. Your discord link is invalid and you aren't accepting DMs on discord, so I'll post it here:

    Version 1.0.0
    Paper 111
    Still seems to work though.
     
  3. Tip: Instead of using this
    Code (Java):
        @EventHandler
        public void onInteract(PlayerInteractEvent event){
            if (event.getItem() == null) {return;}
            if (event.getItem().getType() == Material.CRAFTING_TABLE) {
                if(event.getPlayer().hasPermission("portablecrafting.use")) {
                  if (event.getAction() == Action.RIGHT_CLICK_AIR) {
                      event.getPlayer().openWorkbench(null, true);
                  }
                  else if (event.getAction() == Action.LEFT_CLICK_AIR) {
                      event.getPlayer().openWorkbench(null, true);
                  }
                  else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
                      event.getPlayer().openWorkbench(null, true);
                  }
                }
        }
        }
    you should avoid nesting if statements and do this instead:
    Code (Java):
    @EventHandler
        public void onInteract(PlayerInteractEvent event) {
            if (event.getItem() == null) return;
            if (event.getItem().getType() != Material.CRAFTING_TABLE) return;
            if (!event.getPlayer().hasPermission("portablecrafting.use")) return;
            switch(event.getAction()) {
                case RIGHT_CLICK_AIR:
                case LEFT_CLICK_AIR:
                case LEFT_CLICK_BLOCK:
                    event.getPlayer().openWorkbench(null, true);
            }
        }
    or even simpler, because there is only one Action you don't wanna listen to:
    Code (Java):
        @EventHandler
        public void onInteract(PlayerInteractEvent event) {
            if (event.getItem() == null) return;
            if (event.getItem().getType() != Material.CRAFTING_TABLE) return;
            if (!event.getPlayer().hasPermission("portablecrafting.use")) return;
            if(event.getAction()== Action.RIGHT_CLICK_BLOCK) return;
            event.getPlayer().openWorkbench(null, true);
        }
     
  4. Requesting furnace support! Even if the player has to leave it open to keep it burning, the ability to totally forbid block placement but still allow players to progress is pretty vital for me.

    Edit: Found PortableFurnace, but it doesn't work in 1.16
    Edit2: Got it covered elsewhere. It'd still be pretty cool to see here for others though.
     
    #7 Nytemare3701, Aug 3, 2020
    Last edited: Aug 9, 2020
    • Like Like x 1