mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-26 18:47:40 +01:00
Add cyrillic-support option for cyrillic codepage hack
This commit is contained in:
parent
e696988e34
commit
bbb5db3524
@ -23,6 +23,7 @@ public class ClientConfigurationComponent extends Component {
|
||||
s(t, "defaultzoom", c.getInteger("defaultzoom", 0));
|
||||
s(t, "sidebaropened", c.getString("sidebaropened", "false"));
|
||||
s(t, "dynmapversion", plugin.getDescription().getVersion());
|
||||
s(t, "cyrillic", c.getBoolean("cyrillic-support", false));
|
||||
|
||||
DynmapWorld defaultWorld = null;
|
||||
String defmap = null;
|
||||
|
@ -369,6 +369,9 @@ defaultzoom: 0
|
||||
defaultworld: world
|
||||
defaultmap: flat
|
||||
|
||||
# Option to enable workaround for incorrectly encoded unicode in Cyrillic MC/Bukkit (not good for other code pages)
|
||||
#cyrillic-support: true
|
||||
|
||||
# NOTE: the 'templates' section is now found in the 'templates' directory
|
||||
# Templates CAN still be defined in configuration.txt, as before 0.20
|
||||
templates:
|
||||
|
@ -43,7 +43,7 @@ componentconstructors['chatballoon'] = function(dynmap, configuration) {
|
||||
}
|
||||
|
||||
// Add line to balloon.
|
||||
$('<div/>').addClass('balloonmessage').text(message.text).appendTo(popup.content);
|
||||
$('<div/>').addClass('balloonmessage').text(chat_encoder(message)).appendTo(popup.content);
|
||||
|
||||
// Remove older lines when too many messages are shown.
|
||||
var children = $(popup.content).children();
|
||||
|
@ -104,7 +104,7 @@ componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||
|
||||
var playerMessageContainer = $('<span/>')
|
||||
.addClass('messagetext')
|
||||
.text(message.text);
|
||||
.text(chat_encoder(message));
|
||||
|
||||
messageRow.append(playerIconContainer,playerChannelContainer,playerNameContainer,playerMessageContainer);
|
||||
addrow(messageRow);
|
||||
|
@ -31,3 +31,24 @@ function getMinecraftTime(servertime) {
|
||||
night: !day
|
||||
};
|
||||
}
|
||||
|
||||
function chat_encoder(message) {
|
||||
if (dynmap.options.cyrillic) {
|
||||
if(message.source === 'player') {
|
||||
var utftext = "";
|
||||
for (var n = 0; n < message.text.length; n++) {
|
||||
var c = message.text.charCodeAt(n);
|
||||
if (c >= 192) {
|
||||
var c = message.text.charCodeAt(n);
|
||||
utftext += String.fromCharCode(c+848);
|
||||
}
|
||||
else if (c == 184) { utftext += String.fromCharCode(1105); }
|
||||
else {
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
}
|
||||
return utftext
|
||||
}
|
||||
}
|
||||
return message.text;
|
||||
}
|
Loading…
Reference in New Issue
Block a user