Solved Help With code

Discussion in 'Plugin Development' started by jolbol1, Nov 8, 2013.

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

    jolbol1

    Hey Guys, i am having trouble with a teleport plugin. I do not want people to spawn above water or lava, however the code i tried has not seemed to work. Here it Is
    Code:java
    1. if(loc.getBlock().isLiquid()){
    2. Bukkit.getServer().dispatchCommand(player, "rc");
    3. }
    4. if(!loc.getBlock().isLiquid())
    5. {
    6. player.teleport(loc);
    7. player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("Whoooshh.....").toString());
    8. }

    Maybe this is not a problem with the code, it may be the fact that they seem to spawn ontop of the water.
     
  2. Offline

    sd5

    jolbol1 Try to use something like this:
    Code:java
    1. if(player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()) {
    2. ...
    3. }

    Because you have to check the block below the player not the block the player's feet are in
     
  3. Offline

    jolbol1

    Well the player is not there yet, im checking wether the variable Loc is liquid.
     
  4. Offline

    NinjaWAffles

    How is there no player? Aren't you checking if the player spawns above a liquid? Wouldn't that be PlayerMoveEvent or something similar?
     
  5. Offline

    jolbol1

    i just applied these to the loc int and it is fixed, thanks for your help.

    IM Checking if were im about to send the player if there is a liquid.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  6. Offline

    AoH_Ruthless


    Please set your thread to solved so people like me don't read the entire thread only to find the issue is fixed. Seems petty on my part, but thank you anyways.
     
Thread Status:
Not open for further replies.

Share This Page