mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
Add /dynmap sendtoweb command, and published API for sending web messages
This commit is contained in:
parent
804fa769a2
commit
23ba798951
32
src/main/java/org/dynmap/DynmapAPI.java
Normal file
32
src/main/java/org/dynmap/DynmapAPI.java
Normal file
@ -0,0 +1,32 @@
|
||||
package org.dynmap;
|
||||
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
|
||||
/**
|
||||
* This is the interface representing the published API for the Dynmap plugin. Public methods of the
|
||||
* DynmapPlugin class that are not defined in this interface are subject to change without notice, so
|
||||
* be careful with forming dependencies beyond these. Plugins accessing dynmap 0.24 or later should
|
||||
* do so by casting the Plugin to this interface.
|
||||
*
|
||||
*/
|
||||
public interface DynmapAPI {
|
||||
/**
|
||||
* This method can return null if the 'markers' component has not been configured -
|
||||
* a warning message will be issued to the server.log in this event.
|
||||
*
|
||||
* @return MarkerAPI, or null if not configured
|
||||
*/
|
||||
public MarkerAPI getMarkerAPI();
|
||||
/**
|
||||
* Test if the marker API has been initialized yet
|
||||
*
|
||||
* @return true if it has been initialized
|
||||
*/
|
||||
public boolean markerAPIInitialized();
|
||||
/**
|
||||
* Send generic message to all web users
|
||||
* @param sender - label for sender of message ("Message from <plugin>:") - if null, no from notice
|
||||
* @param msg - message to be sent
|
||||
*/
|
||||
public boolean sendBroadcastToWeb(String sender, String msg);
|
||||
}
|
@ -66,7 +66,7 @@ import org.dynmap.web.HttpServer;
|
||||
import org.dynmap.web.handlers.ClientConfigurationHandler;
|
||||
import org.dynmap.web.handlers.FilesystemHandler;
|
||||
|
||||
public class DynmapPlugin extends JavaPlugin {
|
||||
public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public HttpServer webServer = null;
|
||||
public MapManager mapManager = null;
|
||||
public PlayerList playerList;
|
||||
@ -723,7 +723,8 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
"radiusrender",
|
||||
"reload",
|
||||
"stats",
|
||||
"resetstats" }));
|
||||
"resetstats",
|
||||
"sendtoweb" }));
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
@ -859,6 +860,12 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
mapManager.resetStats(sender, null);
|
||||
else
|
||||
mapManager.resetStats(sender, args[1]);
|
||||
} else if (c.equals("sendtoweb") && checkPlayerPermission(sender, "sendtoweb")) {
|
||||
String msg = "";
|
||||
for(int i = 1; i < args.length; i++) {
|
||||
msg += args[i] + " ";
|
||||
}
|
||||
this.sendBroadcastToWeb("dynmap", msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1287,6 +1294,18 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
public boolean markerAPIInitialized() {
|
||||
return (markerapi != null);
|
||||
}
|
||||
/**
|
||||
* Send generic message to all web users
|
||||
* @param sender - label for sender of message ("[<sender>] nessage") - if null, no from notice
|
||||
* @param msg - message to be sent
|
||||
*/
|
||||
public boolean sendBroadcastToWeb(String sender, String msg) {
|
||||
if(mapManager != null) {
|
||||
mapManager.pushUpdate(new Client.ChatMessage("plugin", sender, "", msg, ""));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Register markers API - used by component to supply marker API to plugin
|
||||
*/
|
||||
|
@ -23,6 +23,8 @@ commands:
|
||||
/<command> stats world - Show render statistics for maps on world 'world'.
|
||||
/<command> resetstats - Reset render statistics.
|
||||
/<command> resetstats world - Reset render statistics for maps on world 'world'.
|
||||
/<command> sendtoweb msg - Send message to web users
|
||||
|
||||
dmarker:
|
||||
description: Manipulate map markers
|
||||
usage: |
|
||||
@ -74,6 +76,7 @@ permissions:
|
||||
dynmap.reload: true
|
||||
dynmap.stats: true
|
||||
dynmap.resetstats: true
|
||||
dynmap.sendtoweb: true
|
||||
dynmap.marker.add: true
|
||||
dynmap.marker.update: true
|
||||
dynmap.marker.movehere: true
|
||||
@ -125,6 +128,9 @@ permissions:
|
||||
dynmap.resetstats:
|
||||
description: Allows /dynmap resetstats or /dynmap resetstats <world>
|
||||
default: op
|
||||
dynmap.sendtoweb:
|
||||
description: Allows /dynmap sendtoweb
|
||||
default: op
|
||||
dynmap.marker.add:
|
||||
description: Allows /dmarker add
|
||||
default: op
|
||||
|
@ -97,10 +97,11 @@ componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||
.appendTo(messageRow);
|
||||
}
|
||||
|
||||
var playerNameContainer = $('<span/>')
|
||||
.addClass('messagetext')
|
||||
.text(' '+message.name+': ');
|
||||
|
||||
var playerNameContainer = '';
|
||||
if(message.name) {
|
||||
playerNameContainer = $('<span/>').addClass('messagetext').text(' '+message.name+': ');
|
||||
}
|
||||
|
||||
var playerMessageContainer = $('<span/>')
|
||||
.addClass('messagetext')
|
||||
.text(message.text);
|
||||
|
Loading…
Reference in New Issue
Block a user