Solved Is It Possible To Get Tall Grass 31:1 As Of 1.8?

Discussion in 'Plugin Development' started by YoYoNoYo555, Dec 30, 2015.

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

    YoYoNoYo555

    Code:
    
    
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class InvisibleGrass implements Listener{
       
        main configGetter;
       
        public InvisibleGrass(main plugin){
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
                    configGetter= plugin;
        }
       
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e){
            Player player = e.getPlayer();
            Location location = player.getLocation();
            Location location2 = new Location(location.getWorld(), location.getX(), location.getBlockY()+1, location.getZ());
           
            if(location2.getBlock().getType() == Material.LONG_GRASS && location2.getBlock().getData() == (byte) 1){
                player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1, 24000));
                player.hidePlayer(player);
            }else{
                player.removePotionEffect(PotionEffectType.INVISIBILITY);
                player.showPlayer(player);
            }
           
           
           
        }
       
       
    
    }
    
    
    Here Is My Current Code. I wanted to know if it was possible to turn a player invisible if they walk through tall grass or long grass. All the old methods I tried are deprecated and do not work. I have been looking on Bukkit forums and all of Google for that past week looking on how to get the material long_grass. The current one I am using now is getData(), but that does not work anymore since it is deprecated. It would be nice for any response.
    Remember, this is not an item stack so I cannot do (byte) 1; which I have tried and does not work.
    Thank You!
     
  2. Offline

    Zombie_Striker

    I don't think you have a full understanding of what "deprecated" means. "Deprected" means to avoid due to the ability to be remove, but will still work.

    If "main" is your main class, keep these things in mind:
    • Classes should start with an uppercase.
    • You should name your main class either the name of your plugin or "Plugin".
     
  3. Offline

    567legodude

    @YoYoNoYo555 I made a small plugin to test this. Here is what I found:
    Take this image for example:[​IMG]
    I made the plugin send me a message when they were clicked, here is what I got:
    Left Block - Type: DEAD_BUSH Data: 0
    Middle Block - Type: LONG_GRASS Data: 1
    Right Block - (Bottom Half) Type: DOUBLE_PLANT Data: 2
    Right Block - (Top Half) Type: DOUBLE_PLANT Data: 10

    Hopefully those values can help you in some way.
     
    teej107 likes this.
  4. Offline

    YoYoNoYo555

    Thank You For The Help!
     
  5. Offline

    mcdorli

    Deprected doesn't always means it's going to be removed. In case of getPlayer(String name), setTypeId(byte id), and getData()/setData(byte data) it just warns the programmer, that he should use UUID-s, and that minecraft gets further and further from using ids.
     
Thread Status:
Not open for further replies.

Share This Page