From c930eb677e8f0f286a0d8169bb01ea20cb3350e2 Mon Sep 17 00:00:00 2001 From: Trever Fischer Date: Mon, 27 Feb 2012 19:27:13 -0500 Subject: [PATCH] Send MOTD on join, not login --- src/main/java/us/camin/JoinListener.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/us/camin/JoinListener.java b/src/main/java/us/camin/JoinListener.java index 9108a7d..596d05b 100644 --- a/src/main/java/us/camin/JoinListener.java +++ b/src/main/java/us/camin/JoinListener.java @@ -31,6 +31,7 @@ import java.util.Scanner; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.json.JSONArray; import org.json.JSONObject; @@ -68,19 +69,23 @@ public class JoinListener extends PlayerListener { } catch (IOException e) { event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Camin.us auth server seems down."); } + } + + public void onPlayerJoin(PlayerJoinEvent event) { + Player p = event.getPlayer(); String[] motd = null; try { motd = fetchMOTD(p.getName()); } catch (MalformedURLException e) { - p.chat("Could not fetch MOTD: Bad URL"); + p.sendMessage("Could not fetch MOTD: Bad URL"); } catch (IOException e) { - p.chat("Could not fetch MOTD: Communication error"); + p.sendMessage("Could not fetch MOTD: Communication error"); } catch (JSONException e) { - p.chat("Could not fetch MOTD: Bad JSON"); + p.sendMessage("Could not fetch MOTD: Bad JSON"); } if (motd != null) { for(String msg : motd) { - p.chat(msg); + p.sendMessage(msg); } } }