Merge remote-tracking branch 'kilandor/master'

This commit is contained in:
FrozenCow 2011-03-10 12:03:56 +01:00
commit 4ae5707505
20 changed files with 290 additions and 201 deletions

View file

@ -1,175 +1,175 @@
Stone Stone
1 119 104 84 255 104 95 80 255 96 87 72 255 77 68 53 255 1 119 104 84 255 104 95 80 255 96 87 72 255 77 68 53 255
Grass Grass
2 75 156 43 255 56 117 32 255 35 104 10 255 32 82 0 255 2 75 156 43 255 56 117 32 255 35 104 10 255 32 82 0 255
Dirt Dirt
3 134 96 67 255 107 76 53 255 67 48 33 255 68 49 33 255 3 134 96 67 255 107 76 53 255 67 48 33 255 68 49 33 255
Cobblestone Cobblestone
4 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255 4 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
Wooden Plank Wooden Plank
5 157 128 79 255 125 102 63 255 78 64 39 255 62 51 31 255 5 157 128 79 255 125 102 63 255 78 64 39 255 62 51 31 255
Sappling Sappling
6 120 120 120 0 96 96 96 0 60 60 60 0 48 48 48 0 6 120 120 120 0 96 96 96 0 60 60 60 0 48 48 48 0
Bedrock Bedrock
7 84 84 84 255 67 67 67 255 42 42 42 255 33 33 33 255 7 84 84 84 255 67 67 67 255 42 42 42 255 33 33 33 255
Water Water
8 21 88 125 80 7 70 117 80 6 68 115 80 5 53 90 80 8 21 88 125 80 7 70 117 80 6 68 115 80 5 53 90 80
Stationary Water Stationary Water
9 21 88 125 80 7 70 117 80 6 68 115 80 5 53 90 80 9 21 88 125 80 7 70 117 80 6 68 115 80 5 53 90 80
Lava Lava
10 255 90 0 255 204 72 0 255 127 45 0 255 102 36 0 255 10 255 90 0 255 204 72 0 255 127 45 0 255 102 36 0 255
Stationary Lava Stationary Lava
11 255 90 0 255 204 72 0 255 127 45 0 255 102 36 0 255 11 255 90 0 255 204 72 0 255 127 45 0 255 102 36 0 255
Sand Sand
12 214 182 111 255 203 171 100 255 186 154 83 255 173 141 70 255 12 214 182 111 255 203 171 100 255 186 154 83 255 173 141 70 255
Gravel Gravel
13 136 126 126 255 108 100 100 255 68 63 63 255 54 50 50 255 13 136 126 126 255 108 100 100 255 68 63 63 255 54 50 50 255
Gold Ore Gold Ore
14 143 140 125 255 114 112 100 255 71 70 62 255 57 56 50 255 14 143 140 125 255 114 112 100 255 71 70 62 255 57 56 50 255
Iron Ore Iron Ore
15 136 130 127 255 108 104 101 255 68 65 63 255 54 52 50 255 15 136 130 127 255 108 104 101 255 68 65 63 255 54 52 50 255
Coal Ore Coal Ore
16 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255 16 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
Wood Wood
17 102 81 51 255 81 64 40 255 51 40 25 255 40 32 20 255 17 102 81 51 255 81 64 40 255 51 40 25 255 40 32 20 255
Leaves Leaves
18 23 68 6 100 12 56 0 100 6 52 0 100 0 42 0 100 18 23 68 6 100 12 56 0 100 6 52 0 100 0 42 0 100
Sponge Sponge
19 193 193 65 255 174 174 47 255 97 97 5 255 76 76 20 255 19 193 193 65 255 174 174 47 255 97 97 5 255 76 76 20 255
Glass Glass
20 255 255 255 64 204 204 204 64 127 127 127 64 102 102 102 64 20 255 255 255 64 204 204 204 64 127 127 127 64 102 102 102 64
Lapis Lazuli Ore Lapis Lazuli Ore
21 23 68 196 255 18 56 158 255 14 43 122 255 14 43 78 255 21 23 68 196 255 18 56 158 255 14 43 122 255 14 43 78 255
Lapis Lazuli Block Lapis Lazuli Block
22 23 68 196 255 18 56 158 255 14 43 122 255 14 43 78 255 22 23 68 196 255 18 56 158 255 14 43 122 255 14 43 78 255
Dispenser Dispenser
23 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255 23 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255
Sandstone Sandstone
24 214 182 111 255 203 171 100 255 186 154 83 255 173 141 70 255 24 214 182 111 255 203 171 100 255 186 154 83 255 173 141 70 255
Note Block Note Block
25 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255 25 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255
Aqua Green Cloth Aqua Green Cloth
26 43 192 117 255 38 168 101 255 34 150 90 255 29 130 78 255 26 43 192 117 255 38 168 101 255 34 150 90 255 29 130 78 255
Cyan Cloth Cyan Cloth
27 43 192 192 255 36 185 185 255 29 130 130 255 22 99 99 255 27 43 192 192 255 36 185 185 255 29 130 130 255 22 99 99 255
Blue Cloth Blue Cloth
28 0 0 255 255 0 0 204 255 0 0 127 255 0 0 102 255 28 0 0 255 255 0 0 204 255 0 0 127 255 0 0 102 255
Purple Cloth Purple Cloth
29 101 101 188 255 95 95 175 255 86 86 160 255 78 78 145 255 29 101 101 188 255 95 95 175 255 86 86 160 255 78 78 145 255
Indigo Cloth Indigo Cloth
30 113 41 186 255 99 38 165 255 85 32 142 255 72 27 119 255 30 113 41 186 255 99 38 165 255 85 32 142 255 72 27 119 255
Violet Cloth Violet Cloth
31 156 65 198 255 132 55 168 255 112 47 142 255 84 35 107 255 31 156 65 198 255 132 55 168 255 112 47 142 255 84 35 107 255
Magenta Cloth Magenta Cloth
32 187 42 187 255 160 36 160 255 135 31 135 255 112 25 112 255 32 187 42 187 255 160 36 160 255 135 31 135 255 112 25 112 255
Pink Cloth Pink Cloth
33 192 43 117 255 168 38 103 255 142 32 87 255 127 29 78 255 33 192 43 117 255 168 38 103 255 142 32 87 255 127 29 78 255
Black Cloth Black Cloth
34 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255 34 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255
Wool Wool
35 222 222 222 255 177 177 177 255 111 111 111 255 88 88 88 255 35 222 222 222 255 177 177 177 255 111 111 111 255 88 88 88 255
Gray Cloth Gray Cloth
36 125 125 125 255 114 114 114 255 104 104 104 255 86 86 86 255 36 125 125 125 255 114 114 114 255 104 104 104 255 86 86 86 255
Yellow Flower Yellow Flower
37 255 255 0 255 204 204 0 255 127 127 0 255 102 102 0 255 37 255 255 0 255 204 204 0 255 127 127 0 255 102 102 0 255
Red Rose Red Rose
38 255 0 0 255 204 0 0 255 127 0 0 255 102 0 0 255 38 255 0 0 255 204 0 0 255 127 0 0 255 102 0 0 255
Brown Mushroom Brown Mushroom
39 204 153 120 32 145 109 85 32 114 86 67 32 73 64 58 32 39 204 153 120 32 145 109 85 32 114 86 67 32 73 64 58 32
Red Mushroom Red Mushroom
40 255 43 43 32 196 29 38 32 186 105 109 32 124 64 64 32 40 255 43 43 32 196 29 38 32 186 105 109 32 124 64 64 32
Gold Block Gold Block
41 232 245 46 255 185 196 36 255 116 122 23 255 92 98 18 255 41 232 245 46 255 185 196 36 255 116 122 23 255 92 98 18 255
Iron Block Iron Block
42 191 191 191 255 152 152 152 255 95 95 95 255 76 76 76 255 42 191 191 191 255 152 152 152 255 95 95 95 255 76 76 76 255
Double Stone Slab Double Stone Slab
43 200 200 200 255 160 160 160 255 100 100 100 255 80 80 80 255 43 200 200 200 255 160 160 160 255 100 100 100 255 80 80 80 255
Stone Slab Stone Slab
44 200 200 200 255 160 160 160 255 100 100 100 255 80 80 80 255 44 200 200 200 255 160 160 160 255 100 100 100 255 80 80 80 255
Brick Brick
45 170 86 62 255 136 68 49 255 85 43 31 255 68 34 24 255 45 170 86 62 255 136 68 49 255 85 43 31 255 68 34 24 255
TNT TNT
46 160 83 65 255 128 66 52 255 80 41 32 255 64 33 26 255 46 160 83 65 255 128 66 52 255 80 41 32 255 64 33 26 255
Bookshelf Bookshelf
54 125 91 38 192 100 72 30 192 62 45 19 192 50 36 15 192 54 125 91 38 192 100 72 30 192 62 45 19 192 50 36 15 192
Moss Stone Moss Stone
48 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255 48 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
Obsidian Obsidian
49 26 11 43 255 20 8 34 255 13 5 21 255 10 4 17 255 49 26 11 43 255 20 8 34 255 13 5 21 255 10 4 17 255
Torch Torch
50 159 127 80 255 98 88 20 0 245 220 50 255 196 176 40 0 50 159 127 80 255 98 88 20 0 245 220 50 255 196 176 40 0
Fire Fire
51 255 170 30 200 204 136 24 200 127 85 15 200 102 68 12 200 51 255 170 30 200 204 136 24 200 127 85 15 200 102 68 12 200
Monster Spawner Monster Spawner
52 0 150 110 196 0 150 130 196 0 150 110 196 0 150 130 196 52 0 150 110 196 0 150 130 196 0 150 110 196 0 150 130 196
Wooden Stair Wooden Stair
53 157 128 79 255 125 102 63 255 78 64 39 255 62 51 31 255 53 157 128 79 255 125 102 63 255 78 64 39 255 62 51 31 255
Chest Chest
54 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255 54 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255
Diamond Ore Diamond Ore
56 129 140 143 255 103 112 114 255 64 70 71 255 51 56 57 255 56 129 140 143 255 103 112 114 255 64 70 71 255 51 56 57 255
Diamond Block Diamond Block
57 45 166 152 255 36 132 121 255 22 83 76 255 18 66 60 255 57 45 166 152 255 36 132 121 255 22 83 76 255 18 66 60 255
Workbench Workbench
58 114 88 56 255 91 70 44 255 57 44 28 255 45 35 22 255 58 114 88 56 255 91 70 44 255 57 44 28 255 45 35 22 255
Crops Crops
59 146 192 0 255 116 153 0 255 73 96 0 255 58 76 0 255 59 146 192 0 255 116 153 0 255 73 96 0 255 58 76 0 255
Farmland Farmland
60 95 58 30 255 76 46 24 255 47 29 15 255 38 23 12 255 60 95 58 30 255 76 46 24 255 47 29 15 255 38 23 12 255
Furnace Furnace
61 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255 61 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255
Burning Furnace Burning Furnace
62 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255 62 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255
Sign Post Sign Post
63 111 91 54 255 88 72 43 255 55 45 27 255 44 36 21 255 63 111 91 54 255 88 72 43 255 55 45 27 255 44 36 21 255
Wooden Door Wooden Door
64 136 109 67 255 108 87 53 255 68 54 33 255 54 43 26 255 64 136 109 67 255 108 87 53 255 68 54 33 255 54 43 26 255
Ladder Ladder
65 181 140 64 32 144 112 51 32 90 70 32 32 72 56 25 32 65 181 140 64 32 144 112 51 32 90 70 32 32 72 56 25 32
Minecart Tracks Minecart Tracks
66 150 134 102 180 120 107 81 180 75 67 51 180 60 53 40 180 66 150 134 102 180 120 107 81 180 75 67 51 180 60 53 40 180
Cobblestone Stairs Cobblestone Stairs
67 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255 67 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
Iron Door Iron Door
71 191 191 191 255 152 152 152 255 95 95 95 255 76 76 76 255 71 191 191 191 255 152 152 152 255 95 95 95 255 76 76 76 255
Redstone Ore Redstone Ore
73 131 107 107 255 104 85 85 255 65 53 53 255 52 42 42 255 73 131 107 107 255 104 85 85 255 65 53 53 255 52 42 42 255
Glowing Redstone Ore Glowing Redstone Ore
74 131 107 107 255 104 85 85 255 65 53 53 255 52 42 42 255 74 131 107 107 255 104 85 85 255 65 53 53 255 52 42 42 255
Redstone Torch off Redstone Torch off
75 159 127 80 255 72 56 25 0 181 140 64 255 144 112 51 0 75 159 127 80 255 72 56 25 0 181 140 64 255 144 112 51 0
Redstone Torch on Redstone Torch on
76 159 127 80 255 102 0 0 0 255 0 0 255 204 0 0 0 76 159 127 80 255 102 0 0 0 255 0 0 255 204 0 0 0
Snow Snow
78 255 255 255 255 204 204 204 255 127 127 127 255 102 102 102 255 78 255 255 255 255 204 204 204 255 127 127 127 255 102 102 102 255
Ice Ice
79 83 113 163 51 66 90 130 51 41 56 81 51 33 45 65 51 79 83 113 163 51 66 90 130 51 41 56 81 51 33 45 65 51
Snow Block Snow Block
80 250 250 250 255 200 200 200 255 125 125 125 255 100 100 100 255 80 250 250 250 255 200 200 200 255 125 125 125 255 100 100 100 255
Cactus Cactus
81 25 120 25 255 20 96 20 255 12 60 12 255 10 48 10 255 81 25 120 25 255 20 96 20 255 12 60 12 255 10 48 10 255
Clay Clay
82 151 157 169 255 120 125 135 255 75 78 84 255 60 62 67 255 82 151 157 169 255 120 125 135 255 75 78 84 255 60 62 67 255
Sugar Cane Sugar Cane
83 193 234 150 255 154 187 120 255 96 117 75 255 77 93 60 255 83 193 234 150 255 154 187 120 255 96 117 75 255 77 93 60 255
Jukebox Jukebox
84 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255 84 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255
Fence Fence
85 127 98 49 96 95 72 33 96 48 34 9 96 32 21 21 96 85 127 98 49 96 95 72 33 96 48 34 9 96 32 21 21 96
Pumpkin Pumpkin
86 255 115 0 200 204 92 0 200 126 57 0 200 102 46 0 200 86 255 115 0 200 204 92 0 200 126 57 0 200 102 46 0 200
Netherrack Netherrack
87 166 89 89 255 141 80 62 255 135 15 15 255 96 6 6 255 87 166 89 89 255 141 80 62 255 135 15 15 255 96 6 6 255
Soulsand Soulsand
88 133 109 94 255 121 97 82 255 90 70 57 255 79 59 46 255 88 133 109 94 255 121 97 82 255 90 70 57 255 79 59 46 255
Glowstone Glowstone
89 249 212 156 255 255 188 94 255 192 143 70 255 122 91 44 255 89 249 212 156 255 255 188 94 255 192 143 70 255 122 91 44 255
Portal Portal
90 140 0 196 128 120 0 196 128 140 0 196 128 120 0 196 128 90 140 0 196 128 120 0 196 128 140 0 196 128 120 0 196 128
Jack-o-lantern Jack-o-lantern
91 255 115 0 255 204 92 0 255 126 57 0 255 102 46 0 255 91 255 115 0 255 204 92 0 255 126 57 0 255 102 46 0 255
Cake Block Cake Block
92 234 234 234 255 210 210 210 255 203 203 203 255 190 190 190 255 92 234 234 234 255 210 210 210 255 203 203 203 255 190 190 190 255

View file

@ -134,9 +134,7 @@ public class DynmapPlugin extends JavaPlugin {
messageHandler.onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() { messageHandler.onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
@Override @Override
public void triggered(Message t) { public void triggered(Message t) {
mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message)); webChat(t.name, t.message);
log.info("[WEB]" + t.name + ": " + t.message);
getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
} }
}); });
webServer.handlers.put("/up/sendmessage", messageHandler); webServer.handlers.put("/up/sendmessage", messageHandler);
@ -345,7 +343,7 @@ public class DynmapPlugin extends JavaPlugin {
private void jsonConfig() { private void jsonConfig() {
File outputFile; File outputFile;
Map<?, ?> clientConfig = (Map<?, ?>) configuration.getProperty("web"); Map<?, ?> clientConfig = (Map<?, ?>) configuration.getProperty("web");
File webpath = new File(configuration.getString("webpath", "web"), "dynmap_config.json"); File webpath = new File(configuration.getString("webpath", "web"), "standalone/dynmap_config.json");
if (webpath.isAbsolute()) if (webpath.isAbsolute())
outputFile = webpath; outputFile = webpath;
else else
@ -361,4 +359,11 @@ public class DynmapPlugin extends JavaPlugin {
log.log(Level.SEVERE, "Exception while writing JSON-configuration-file.", ioe); log.log(Level.SEVERE, "Exception while writing JSON-configuration-file.", ioe);
} }
} }
public void webChat(String name, String message)
{
mapManager.pushUpdate(new Client.WebChatMessage(name, message));
log.info("[WEB]" + name + ": " + message);
getServer().broadcastMessage("[WEB]" + name + ": " + message);
}
} }

View file

@ -3,7 +3,9 @@ package org.dynmap;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -13,7 +15,12 @@ import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.config.Configuration; import org.bukkit.util.config.Configuration;
import org.dynmap.Event;
import org.dynmap.web.Json; import org.dynmap.web.Json;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
class JsonTimerTask extends TimerTask { class JsonTimerTask extends TimerTask {
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
@ -22,6 +29,8 @@ class JsonTimerTask extends TimerTask {
private Server server; private Server server;
private MapManager mapManager; private MapManager mapManager;
private Configuration configuration; private Configuration configuration;
private static final JSONParser parser = new JSONParser();
private long lastTimestamp = 0;
public JsonTimerTask(DynmapPlugin instance, Configuration config) { public JsonTimerTask(DynmapPlugin instance, Configuration config) {
this.plugin = instance; this.plugin = instance;
@ -31,8 +40,48 @@ class JsonTimerTask extends TimerTask {
} }
public void run() { public void run() {
long jsonInterval = configuration.getInt("jsonfile-interval", 1) * 1000;
long current = System.currentTimeMillis();
File outputFile;
//Handles Reading WebChat
if(configuration.getNode("web").getBoolean("allowwebchat", false))
{
File webChatPath = new File(this.configuration.getString("webpath", "web"), "standalone/dynmap_webchat.json");
if (webChatPath.isAbsolute())
outputFile = webChatPath;
else {
outputFile = new File(plugin.getDataFolder(), webChatPath.toString());
}
if(webChatPath.exists() && lastTimestamp != 0)
{
JSONArray jsonMsgs = null;
try {
FileReader inputFileReader = new FileReader(webChatPath);
jsonMsgs = (JSONArray) parser.parse(inputFileReader);
inputFileReader.close();
} catch(IOException ex){
log.log(Level.SEVERE, "Exception while reading JSON-file.", ex);
} catch(ParseException ex) {
log.log(Level.SEVERE, "Exception while parsing JSON-file.", ex);
}
if(jsonMsgs != null) {
Iterator iter = jsonMsgs.iterator();
while(iter.hasNext()) {
JSONObject o = (JSONObject)iter.next();
if(Long.parseLong(String.valueOf(o.get("timestamp"))) >= (lastTimestamp))
{
plugin.webChat(String.valueOf(o.get("name")), String.valueOf(o.get("message")));
}
}
}
}
}
//Handles Updates
for (World world : this.server.getWorlds()) { for (World world : this.server.getWorlds()) {
long current = System.currentTimeMillis(); current = System.currentTimeMillis();
Client.Update update = new Client.Update(); Client.Update update = new Client.Update();
@ -47,14 +96,13 @@ class JsonTimerTask extends TimerTask {
update.players[i] = new Client.Player(p.getName(), pl.getWorld().getName(), pl.getX(), pl.getY(), pl.getZ()); update.players[i] = new Client.Player(p.getName(), pl.getWorld().getName(), pl.getX(), pl.getY(), pl.getZ());
} }
update.updates = mapManager.getWorldUpdates(world.getName(), current - (configuration.getInt("jsonfile-interval", 1) + 10000)); update.updates = mapManager.getWorldUpdates(world.getName(), current - (jsonInterval + 10000));
File webpath = new File(this.configuration.getString("webpath", "web"), "dynmap_" + world.getName() + ".json"); File webWorldPath = new File(this.configuration.getString("webpath", "web"), "standalone/dynmap_" + world.getName() + ".json");
File outputFile; if (webWorldPath.isAbsolute())
if (webpath.isAbsolute()) outputFile = webWorldPath;
outputFile = webpath;
else { else {
outputFile = new File(plugin.getDataFolder(), webpath.toString()); outputFile = new File(plugin.getDataFolder(), webWorldPath.toString());
} }
try { try {
FileOutputStream fos = new FileOutputStream(outputFile); FileOutputStream fos = new FileOutputStream(outputFile);
@ -66,5 +114,6 @@ class JsonTimerTask extends TimerTask {
log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe); log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe);
} }
} }
lastTimestamp = System.currentTimeMillis();
} }
} }

View file

@ -10,22 +10,22 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="icon" href="images/dynmap.ico" type="image/ico" /> <link rel="icon" href="images/dynmap.ico" type="image/ico" />
<!--<link rel="stylesheet" type="text/css" href="/map/embedded.css" media="screen" />--> <!--<link rel="stylesheet" type="text/css" href="css/embedded.css" media="screen" />-->
<link rel="stylesheet" type="text/css" href="standalone.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/standalone.css" media="screen" />
<link rel="stylesheet" type="text/css" href="dynmap_style.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/dynmap_style.css" media="screen" />
<!-- <link rel="stylesheet" type="text/css" href="override.css" media="screen" /> --> <!-- <link rel="stylesheet" type="text/css" href="css/override.css" media="screen" /> -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.json.js"></script> <script type="text/javascript" src="js/jquery.json.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="custommarker.js"></script> <script type="text/javascript" src="js/custommarker.js"></script>
<script type="text/javascript" src="minecraft.js"></script> <script type="text/javascript" src="js/minecraft.js"></script>
<script type="text/javascript" src="map.js"></script> <script type="text/javascript" src="js/map.js"></script>
<script type="text/javascript" src="kzedmaps.js"></script> <script type="text/javascript" src="js/kzedmaps.js"></script>
<script type="text/javascript" src="flatmap.js"></script> <script type="text/javascript" src="js/flatmap.js"></script>
<script type="text/javascript" src="clock.timeofday.js"></script> <script type="text/javascript" src="js/clock.timeofday.js"></script>
<script type="text/javascript" src="clock.digital.js"></script> <script type="text/javascript" src="js/clock.digital.js"></script>
<script type="text/javascript" src="chat.js"></script> <script type="text/javascript" src="js/chat.js"></script>
<script type="text/javascript" src="config.js"></script> <script type="text/javascript" src="config.js"></script>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -1,4 +1,4 @@
function sendChat(message) { function sendChat(me, message) {
var ip; var ip;
$.ajax({ $.ajax({
type: "GET", type: "GET",
@ -13,6 +13,8 @@ function sendChat(message) {
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
//handle response //handle response
if(response)
me.onPlayerChat('', response);
} }
}); });
} }

View file

@ -213,7 +213,7 @@ DynMap.prototype = {
.keydown(function(event) { .keydown(function(event) {
if (event.keyCode == '13') { if (event.keyCode == '13') {
event.preventDefault(); event.preventDefault();
sendChat(chatinput.val()); sendChat(me, chatinput.val());
chatinput.val(''); chatinput.val('');
} }
}) })
@ -329,6 +329,7 @@ DynMap.prototype = {
//var divs = $('div[rel]'); //var divs = $('div[rel]');
//divs.filter(function(i){return parseInt(divs[i].attr('rel')) > timestamp+me.options.messagettl;}).remove(); //divs.filter(function(i){return parseInt(divs[i].attr('rel')) > timestamp+me.options.messagettl;}).remove();
}); });
me.lasttimestamp = update.timestamp;
setTimeout(function() { me.update(); }, me.options.updaterate); setTimeout(function() { me.update(); }, me.options.updaterate);
}, function(status, statusText, request) { }, function(status, statusText, request) {
me.alertbox me.alertbox

View file

@ -0,0 +1,32 @@
<?php
$msginterval = 5; //In seconds - add this to dynmap web config??
session_start();
if($_SERVER['REQUEST_METHOD'] == 'POST' && $_SESSION['lastchat'] < time())
{
$config = json_decode(file_get_contents('dynmap_config.json'), true);
$micro = explode(' ', microtime());
$timestamp = $micro[1].round($micro[0]*1000);
$data = json_decode(trim(file_get_contents('php://input')));
$data->timestamp = $timestamp;
$old_messages = json_decode(file_get_contents('dynmap_webchat.json'), true);
if(!empty($old_messages))
{
foreach($old_messages as $message)
{
if(($timestamp - $config['updaterate'] - 10000) < $message['timestamp'])
$new_messages[] = $message;
}
}
$new_messages[] = $data;
file_put_contents('dynmap_webchat.json', json_encode($new_messages));
$_SESSION['lastchat'] = time()+$msginterval;
}
elseif($_SERVER['REQUEST_METHOD'] == 'POST' && $_SESSION['lastchat'] > time())
{
echo json_encode('You may only chat once every '.$msginterval.' seconds.');
}
?>