added join and quit messages to chat

This commit is contained in:
Arthur Mayer 2011-02-18 05:30:49 +01:00
parent 00485ddcc2
commit 7c917b729e
3 changed files with 22 additions and 1 deletions

View File

@ -40,6 +40,8 @@ web:
showplayerfacesonmap: true
showplayerfacesinmenu: true
focuschatballoons: false
joinmessage: %playername% joined
quitmessage: %playername% quit
# The clock that is shown alongside the map.
clock: timeofday

View File

@ -2,6 +2,7 @@ package org.dynmap;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.util.config.ConfigurationNode;
@ -69,4 +70,19 @@ public class DynmapPlayerListener extends PlayerListener {
public void onPlayerChat(PlayerChatEvent event) {
mgr.pushUpdate(new Client.ChatMessage(event.getPlayer().getName(), event.getMessage()));
}
/**
* Called when a player joins or quits the server
*/
public void onPlayerJoin(PlayerEvent event) {
String joinMessage = configuration.getString("joinmessage", "%playername% joined");
joinMessage = joinMessage.replaceAll("%playername%", event.getPlayer().getName());
mgr.pushUpdate(new Client.ChatMessage("Server", joinMessage));
}
public void onPlayerQuit(PlayerEvent event) {
String quitMessage = configuration.getString("quitmessage", "%playername% quit");
quitMessage = quitMessage.replaceAll("%playername%", event.getPlayer().getName());
mgr.pushUpdate(new Client.ChatMessage("Server", quitMessage));
}
}

View File

@ -64,7 +64,7 @@ public class DynmapPlugin extends JavaPlugin {
tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles"));
tilesDirectory.mkdirs();
playerList = new PlayerList(getServer());
playerList.load();
@ -127,6 +127,9 @@ public class DynmapPlugin extends JavaPlugin {
PlayerListener playerListener = new DynmapPlayerListener(mapManager, playerList, configuration);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
}
private static File combinePaths(File parent, String path) {