Send MOTD on join, not login
This commit is contained in:
parent
731aa96648
commit
c930eb677e
@ -31,6 +31,7 @@ import java.util.Scanner;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -68,19 +69,23 @@ public class JoinListener extends PlayerListener {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Camin.us auth server seems down.");
|
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Camin.us auth server seems down.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player p = event.getPlayer();
|
||||||
String[] motd = null;
|
String[] motd = null;
|
||||||
try {
|
try {
|
||||||
motd = fetchMOTD(p.getName());
|
motd = fetchMOTD(p.getName());
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
p.chat("Could not fetch MOTD: Bad URL");
|
p.sendMessage("Could not fetch MOTD: Bad URL");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
p.chat("Could not fetch MOTD: Communication error");
|
p.sendMessage("Could not fetch MOTD: Communication error");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
p.chat("Could not fetch MOTD: Bad JSON");
|
p.sendMessage("Could not fetch MOTD: Bad JSON");
|
||||||
}
|
}
|
||||||
if (motd != null) {
|
if (motd != null) {
|
||||||
for(String msg : motd) {
|
for(String msg : motd) {
|
||||||
p.chat(msg);
|
p.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user