mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 05:05:16 +01:00
Added ability to disable commands in configuration.
This commit is contained in:
parent
421b91058a
commit
553eb7952d
@ -19,6 +19,10 @@ webserver-bindaddress: 0.0.0.0
|
|||||||
# The TCP-port the webserver will listen on.
|
# The TCP-port the webserver will listen on.
|
||||||
webserver-port: 8123
|
webserver-port: 8123
|
||||||
|
|
||||||
|
disabledcommands:
|
||||||
|
- fullrender
|
||||||
|
- fullrenderasync
|
||||||
|
|
||||||
# The maptypes Dynmap will use to render.
|
# The maptypes Dynmap will use to render.
|
||||||
maps:
|
maps:
|
||||||
- class: org.dynmap.kzedmap.KzedMap
|
- class: org.dynmap.kzedmap.KzedMap
|
||||||
|
@ -3,14 +3,17 @@ package org.dynmap;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.util.config.ConfigurationNode;
|
||||||
|
|
||||||
public class DynmapPlayerListener extends PlayerListener {
|
public class DynmapPlayerListener extends PlayerListener {
|
||||||
private MapManager mgr;
|
private MapManager mgr;
|
||||||
private PlayerList playerList;
|
private PlayerList playerList;
|
||||||
|
private ConfigurationNode configuration;
|
||||||
|
|
||||||
public DynmapPlayerListener(MapManager mgr, PlayerList playerList) {
|
public DynmapPlayerListener(MapManager mgr, PlayerList playerList, ConfigurationNode configuration) {
|
||||||
this.mgr = mgr;
|
this.mgr = mgr;
|
||||||
this.playerList = playerList;
|
this.playerList = playerList;
|
||||||
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -18,6 +21,12 @@ public class DynmapPlayerListener extends PlayerListener {
|
|||||||
String[] split = event.getMessage().split(" ");
|
String[] split = event.getMessage().split(" ");
|
||||||
if (split[0].equalsIgnoreCase("/dynmap")) {
|
if (split[0].equalsIgnoreCase("/dynmap")) {
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
for(String s : (Iterable<String>)configuration.getProperty("disabledcommands")) {
|
||||||
|
if (split[1].equals(s)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (split[1].equals("render")) {
|
if (split[1].equals("render")) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
mgr.touch(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
|
mgr.touch(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoader;
|
import org.bukkit.plugin.PluginLoader;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -29,6 +30,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
private HttpServer webServer = null;
|
private HttpServer webServer = null;
|
||||||
private MapManager mapManager = null;
|
private MapManager mapManager = null;
|
||||||
private PlayerList playerList;
|
private PlayerList playerList;
|
||||||
|
private Configuration configuration;
|
||||||
|
|
||||||
private BukkitPlayerDebugger debugger = new BukkitPlayerDebugger(this);
|
private BukkitPlayerDebugger debugger = new BukkitPlayerDebugger(this);
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Configuration configuration = new Configuration(new File(this.getDataFolder(), "configuration.txt"));
|
configuration = new Configuration(new File(this.getDataFolder(), "configuration.txt"));
|
||||||
configuration.load();
|
configuration.load();
|
||||||
|
|
||||||
debugger.enable();
|
debugger.enable();
|
||||||
@ -105,7 +107,8 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, new DynmapPlayerListener(mapManager, playerList), Priority.Normal, this);
|
PlayerListener playerListener = new DynmapPlayerListener(mapManager, playerList, configuration);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, new DynmapPlayerListener(mapManager, playerList), Priority.Normal, this);
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user