mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 05:05:16 +01:00
Cleaned up join/quit messages (not being send as chat messages)
This commit is contained in:
parent
e1e13df4b2
commit
b47bbee4e8
@ -29,23 +29,30 @@ public class Client {
|
||||
|
||||
public static class ChatMessage extends Stamped {
|
||||
public String type = "chat";
|
||||
public String source;
|
||||
public String playerName;
|
||||
public String message;
|
||||
|
||||
public ChatMessage(String playerName, String message) {
|
||||
public ChatMessage(String source, String playerName, String message) {
|
||||
this.source = source;
|
||||
this.playerName = playerName;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WebChatMessage extends Stamped {
|
||||
public String type = "webchat";
|
||||
public static class PlayerJoinMessage extends Stamped {
|
||||
public String type = "playerjoin";
|
||||
public String playerName;
|
||||
public String message;
|
||||
|
||||
public WebChatMessage(String playerName, String message) {
|
||||
public PlayerJoinMessage(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerQuitMessage extends Stamped {
|
||||
public String type = "playerquit";
|
||||
public String playerName;
|
||||
public PlayerQuitMessage(String playerName) {
|
||||
this.playerName = playerName;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,21 +15,17 @@ public class DynmapPlayerChatListener extends PlayerListener {
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage(event.getPlayer().getName(), event.getMessage()));
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("player", event.getPlayer().getName(), event.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
String joinMessage = plugin.configuration.getNode("web").getString("joinmessage", "%playername% joined");
|
||||
joinMessage = joinMessage.replaceAll("%playername%", event.getPlayer().getName());
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("Server", joinMessage));
|
||||
plugin.mapManager.pushUpdate(new Client.PlayerJoinMessage(event.getPlayer().getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
String quitMessage = plugin.configuration.getNode("web").getString("quitmessage", "%playername% quit");
|
||||
quitMessage = quitMessage.replaceAll("%playername%", event.getPlayer().getName());
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("Server", quitMessage));
|
||||
plugin.mapManager.pushUpdate(new Client.PlayerQuitMessage(event.getPlayer().getName()));
|
||||
}
|
||||
|
||||
}
|
@ -382,7 +382,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void webChat(String name, String message) {
|
||||
mapManager.pushUpdate(new Client.WebChatMessage(name, message));
|
||||
mapManager.pushUpdate(new Client.ChatMessage("web", name, message));
|
||||
log.info("[WEB]" + name + ": " + message);
|
||||
getServer().broadcastMessage("[WEB]" + name + ": " + message);
|
||||
}
|
||||
|
@ -12,10 +12,7 @@ componentconstructors['chat'] = function(dynmap, configuration) {
|
||||
$(dynmap).bind('worldupdate', function(event, update) {
|
||||
swtch(update.type, {
|
||||
chat: function() {
|
||||
$(dynmap).trigger('chat', [{source: 'player', name: update.playerName, text: update.message}]);
|
||||
},
|
||||
webchat: function() {
|
||||
$(dynmap).trigger('chat', [{source: 'web', name: update.playerName, text: update.message}]);
|
||||
$(dynmap).trigger('chat', [{source: update.source, name: update.playerName, text: update.message}]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -27,6 +27,27 @@ componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||
.appendTo(chat);
|
||||
}
|
||||
|
||||
var addrow = function(row) {
|
||||
setTimeout(function() { row.remove(); }, (configuration.messagettl * 1000));
|
||||
messagelist.append(row);
|
||||
messagelist.show();
|
||||
messagelist.scrollTop(messagelist.scrollHeight());
|
||||
};
|
||||
|
||||
$(dynmap).bind('playerjoin', function(event, playername) {
|
||||
addrow($('<div/>')
|
||||
.addClass('messagerow')
|
||||
.text(dynmap.options.joinmessage.replace('%playername%', playername))
|
||||
);
|
||||
});
|
||||
|
||||
$(dynmap).bind('playerquit', function(event, playername) {
|
||||
addrow($('<div/>')
|
||||
.addClass('messagerow')
|
||||
.text(dynmap.options.quitmessage.replace('%playername%', playername))
|
||||
);
|
||||
});
|
||||
|
||||
$(dynmap).bind('chat', function(event, message) {
|
||||
var playerName = message.name;
|
||||
var messageRow = $('<div/>')
|
||||
@ -59,12 +80,6 @@ componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||
.text(message.text);
|
||||
|
||||
messageRow.append(playerIconContainer,playerNameContainer,playerMessageContainer);
|
||||
//messageRow.append(playerIconContainer,playerWorldContainer,playerGroupContainer,playerNameContainer,playerMessageContainer);
|
||||
setTimeout(function() { messageRow.remove(); }, (configuration.messagettl * 1000));
|
||||
messagelist.append(messageRow);
|
||||
|
||||
messagelist.show();
|
||||
//var scrollHeight = jQuery(me.messagelist).attr('scrollHeight');
|
||||
messagelist.scrollTop(messagelist.scrollHeight());
|
||||
addrow(messageRow);
|
||||
});
|
||||
};
|
@ -375,6 +375,12 @@ DynMap.prototype = {
|
||||
swtch(update.type, {
|
||||
tile: function() {
|
||||
me.onTileUpdated(update.name);
|
||||
},
|
||||
playerjoin: function() {
|
||||
$(me).trigger('playerjoin', [ update.playerName ]);
|
||||
},
|
||||
playerquit: function() {
|
||||
$(me).trigger('playerquit', [ update.playerName ]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user