Player move one red sand

Discussion in 'Plugin Development' started by samsung0104, Nov 4, 2021.

  1. Offline


    Hi! Iam try to learn minecraft plugin writing. I need help, becouse i dont find any working code.
    If player walk sand , kill player and write chat, you are death.
    Somebody help me code?
  2. Offline


    YouTube tutorials are the best place to start.
  3. Offline


    Since what you want to do is extremely simple I would advice you to start watching some basic tutorials first (e.g. on YouTube), before you ask on a forum. But regardless, you need to make a PlayerMoveEvent and check if the block below the player is sand. If it is sand, then you kill the player and send a chat message. Like I said it's extremely simple, so please learn the basics.

    It would look like this:

    public void onPlayerMove(PlayerMoveEvent e) {
    Player p = e#getPlayer()
    Block block = p#getLocation()#getBlock()#getRelative(BlockFace#DOWN)

    if(block#getType() == Material#SAND) {
    p#sendMessage(ChatColor#RED + "!Please don't just blindly copy and paste this. Make sure you understand the code first!")
  4. Offline


    Thanks, i understand, why you type this code. Iam learning c# and php. i changed "#" to "." , and after the line get ";".
    I try, but nothing happend.
    I post pastebin, and help me please whats worng?
  5. Offline


    The code I sent you was a listener, so you need to put "@EventHandler" above the function like this:

    public void onPlayerMove(PlayerMoveEvent e) {...

    And you also need to register the listener by putting this code in "onEnable()":

    PluginManager pM = Bukkit.getPluginManager();
    pM.registerEvents(this, this);

    You can also put "System.out.println("Test")" in your onPlayerMove, that way you can check if the code inside the method is being ran.

    Let me know if that helps :)
  6. Offline


    Tankh you for helping me! Its fine working!

Share This Page