Solved Phone plugin not working!

Discussion in 'Spigot Plugin Development' started by Leftdark, Jun 3, 2017.

  1. So I am trying to create a phone plugin,
    basically everyone gets a phone number and you can call people with a gui and
    I'm working on sending a message to the player that is getting called by typing his/her phone number in the
    chat, but it doesn't seem to work for some reason!! :(

    Anyway, if anyone could help, then that would we awesome :)


    Config File :
    Code (Text):
    players:
      <uuid>:
        typingnumber: true
        phonenumber: '735'
    phonenumbers:
      '735': <uuid>
     











    Code :
    Code (Text):
    @EventHandler
        public void Chat(PlayerChatEvent e){
            Player p = e.getPlayer();
            if(getConfig().getBoolean("players."+p.getUniqueId().toString()+".typingnumber") == true){
                if(getConfig().contains("phonenumbers."+e.getMessage())){
                    for(Player pl : Bukkit.getOnlinePlayers() ){
                        if(getConfig().get("players."+pl.getUniqueId().toString()+".phonenumber").toString() == e.getMessage()){
                            pl.sendMessage(prefix + p.getName() + " is calling you!");
                       
                       
                       
                        }
                   
                    }
               
                 
               
               
                } else p.sendMessage(prefix + "This phone number doesn't exist!");
           
           
            }
       
       
       
        }
     
    #1 Leftdark, Jun 3, 2017
    Last edited: Jun 3, 2017
  2. Instead of using #get() try using #getString(path.to.number);
     
  3. Thank you, I will try that! :)
     
  4. It doesn't work :(
     
  5. I think your problem is here:
    Code (Text):
    if(getConfig().get("players."+pl.getUniqueId().toString()+".phonenumber").toString() == e.getMessage()){
    You should use .equals() instead of ==.
    Code (Text):
    if(getConfig().getString("players."+pl.getUniqueId().toString()+".phonenumber").equals(e.getMessage())){
     
  6. The weird thing is, it does know when the phone number exists or not.
     
  7. I am assuming the number is stored as a String correct?
     
  8. Whoops totally forgot about .equals() xD
     
  9. Thank you guys!!! It works now!
     
  10. Mark thread as solved. :)