MoveEvent

Discussion in 'Spigot Plugin Development' started by wantsome909, May 14, 2017.

  1. How can i get a custom block that if they move on they teleport

    i made a custom block and got .getItemMeta();
    but when i try to do getTo().getBlock().getType()

    but i cant do .getItemMeta() i dont wnat getType i want a custom block
     
  2. Try getTo().getBlock().getData() to get data value, which I assume is what you want.
     
  3. here let me show u what i got
    Code (Text):
        @EventHandler
        public void playerMove(PlayerMoveEvent event) {

    if (event.getTo().getBlock().getRelative(BlockFace.DOWN).getType().getData().equals(blocks.getManager().block25.getData())) {
        Player player = event.getPlayer();
        Vector velo = new Vector(0,2.5,0);
        player.setVelocity(velo);
    }
                Player player = event.getPlayer();
                Vector velo = new Vector(0,2.5,0);
                player.setVelocity(velo);
            }
    }

    i want a custom item instead
     
  4. Can you define 'custom item'? Also, .equals() should be '==', because you are comparing enums.
     
  5. Code (Text):
        public static blocks instance = new blocks();

        public static blocks getManager(){
            return instance;
        }

        public ItemStack block25;

        public ItemStack block15;

        public ItemStack block1;

        public void registerBlocks(){
            block25 = setData(new ItemStack(Material.SLIME_BLOCK), "§eVelo 2.5", Arrays.asList("§c§lJumpPad"));
            block15 = setData(new ItemStack(Material.SLIME_BLOCK), "§eVelo 1.5", Arrays.asList("§c§lJumpPad"));
            block1 = setData(new ItemStack(Material.SLIME_BLOCK), "§eVelo 1", Arrays.asList("§c§lJumpPad"));
        }

        public ItemStack setData(ItemStack item, String name, List<String> lore){
            ItemMeta lam = item.getItemMeta();
            lam.setDisplayName(name);
            lam.setLore(lore);
            item.setItemMeta(lam);
            return item;
        }
     
     
  6. So are you trying to see if the block the player is on during a tp is one of thoes blocks? ItemStacks and Blocks are different, you can't place an item stack, and a block has no lore or anything. Try setting custom NBT data on the block (I think you can do that)
     
  7. how would i do nbt data?