Sending a message with an int in it.

Discussion in 'Plugin Development' started by ZaneBaney, Feb 27, 2015.

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

    ZaneBaney

    Hey, I need to send a message to a player, however 'player.sendMessage("")' only allows for string to be entered. I need an int to be sent, as I am trying to send the player some coordinates that are saved in the config.

    Here is the code: (Main class)
    Show Spoiler

    Code:
     
    
         if (cmd.getName().equalsIgnoreCase("whatis") && sender instanceof Player) {
           Player player = (Player) sender;
           
           player.sendMessage(xyz.getX() + xyz.getY() + xyz.getZ());
         }
    
    
    
    


    Here is the XYZ class, which is where the code gets the ints from:
    Show Spoiler

    Code:
    
    
    public class XYZ {
       Main configGetter;
    
       public XYZ(Main main2) {
         configGetter = main2;
       }
    
       public void setX(String[] args) {
         configGetter.getConfig().set("X", args[0]);
       }
    
       public void setY(String[] args) {
         configGetter.getConfig().set("Y", args[0]);
       }
    
       public void setZ(String[] args) {
         configGetter.getConfig().set("z", args[0]);
       }
    
       public int getX() {
         return configGetter.getConfig().getInt("X");
       }
       public int getY() {
         return configGetter.getConfig().getInt("Y");
       }
       public int getZ() {
         return configGetter.getConfig().getInt("Z");
       }
    }
    
    
     
  2. Offline

    uksspy

    @ZaneBaney
    To add on to what @DJSkepter was saying: You can also concatenate ints to make them part of a larger string using a '+' sign. For example: player.sendMessage("The coords are " + coords);
     
Thread Status:
Not open for further replies.

Share This Page