Solved How to Fix onJoinEvent

Discussion in 'Plugin Development' started by TECGaming360, May 14, 2014.

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

    TECGaming360

    I'm Trying to fix this but i need some help everything works but the if statement! see if you spot anything???
    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent e) {
    3. Player p = e.getPlayer();
    4. e.setJoinMessage(ChatColor.YELLOW + "[" + ChatColor.AQUA + "KeepthatItem" + ChatColor.YELLOW + "]" + ChatColor.RED + " " + KeepthatItem.plugin.getConfig().getString("Join Message 1"));
    5. p.playSound(p.getLocation(), Sound.FIREWORK_TWINKLE, 10, 1); //plays noise on join..
    6. if (p.getInventory().getItemInHand().getType() == Material.getMaterial(KeepthatItem.plugin.getConfig().getString("Item 1").toUpperCase())); // Gives player set item at spawn..
    7. }


    Also how do i make it so when they re-spawn they receive the item again?
     
  2. Offline

    The Fancy Whale

    You should check what value
    Code:java
    1. KeepthatItem.plugin.getConfig().getString("Item 1").toUpperCase())

    is returning. Also, you would do the same thing on player respawn event.
    Finally, this is a simple java mistake with your if statement. Look it over again and check why you have a semi colon after an if statement. You NEED to learn java before jumping into making plugins.
     
  3. Offline

    TECGaming360

    Simple mistake but still getting error with semi colon removed.

    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent e) {
    3. Player p = e.getPlayer();
    4. e.setJoinMessage(ChatColor.YELLOW + "[" + ChatColor.AQUA + "KeepthatItem" + ChatColor.YELLOW + "]" + ChatColor.RED + " " + KeepthatItem.plugin.getConfig().getString("Join Message 1"));
    5. p.playSound(p.getLocation(), Sound.FIREWORK_TWINKLE, 10, 1); //plays noise on join..
    6. if (p.getInventory().getItemInHand().getType() == Material.getMaterial(KeepthatItem.plugin.getConfig().getString("Item 1").toUpperCase()))
    7. }
    I took out semi colon it says "Syntax error on token ")", Statement expected after this token"

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

    The Fancy Whale

    Hence why I said you NEED to learn java before trying to make plugins. You do not know how to use an if statement so I find it EXTREMELY hard to believe you know java.
    PLEASE PLEASE PLEASE Learn java before trying to make plugins.
     
  5. Offline

    TECGaming360

    Never mind i got it

    Yah, im learning java. It's better to practice with doing something other than watching youtube videos all the time.

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

    JBoss925

    TECGaming360 , The Fancy Whale is correct. You should at least know the basics of java. I suggest you watch some videos from TheNewBoston. Each video is 2-5 minutes long. I suggest doing 1-22 then skipping to 32-42. That's what I think you'll need for basic java that will be used in bukkit. Also check out PogoStick29 on his channel here. He does some java and bukkit coding and could help you learn much more easily.
     
    PogoStick29 likes this.
  7. Offline

    Ghosti

    My bad your question has been answered :p
     
Thread Status:
Not open for further replies.

Share This Page