Welcome Messages

Discussion in 'Plugin Development' started by IIxUnderWorldxII, Apr 29, 2014.

Thread Status:
Not open for further replies.
  1. I have been trying to do this for 1-2 days and its bugging me. I am trying to figure out how I can make a custom message when they join for the first time and the message is customizable via config.
     
  2. Offline

    Flybelette

    Code:java
    1. @EventHandler
    2. public void onPlayerjoin(PlayerJoinEvent e){
    3.  
    4. Player player = e.getPlayer()
    5. if(!player.hasPlayedBefore()){
    6. File file = new File(getDataFolder(), "config.yml");
    7. FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    8. e.setJoinMessage(config.getString("Welcome_Message"));
    9. }
    10.  
    11. }
     
  3. Offline

    MineStein

    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent event) {
    3. Player p = event.getPlayer();
    4. p.sendMessage(ChatColor.GREEN + getConfig().getString("message"));
    5. p.setHealth(20.0);
    6. p.setFoodLevel(20);


    You will want to use this code as an EventHandler that registers the event "PlayerJoinEvent". Change the chat color to whatever you want.

    As for customizing the join message in game, create a file named "config.yml" and add this line:

    Code:
    message: <Your Message Here>
     
Thread Status:
Not open for further replies.

Share This Page