mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +01:00
Add block-banned-player-chat to block chat from banned players matching IPs known to go with player
This commit is contained in:
parent
4a80b71a12
commit
6cfeee152c
@ -14,6 +14,7 @@ public class InternalClientUpdateComponent extends ClientUpdateComponent {
|
|||||||
final boolean hidewebchatip = configuration.getBoolean("hidewebchatip", false);
|
final boolean hidewebchatip = configuration.getBoolean("hidewebchatip", false);
|
||||||
final boolean trust_client_name = configuration.getBoolean("trustclientname", false);
|
final boolean trust_client_name = configuration.getBoolean("trustclientname", false);
|
||||||
final boolean useplayerloginip = configuration.getBoolean("use-player-login-ip", true);
|
final boolean useplayerloginip = configuration.getBoolean("use-player-login-ip", true);
|
||||||
|
final boolean checkuserban = configuration.getBoolean("block-banned-player-chat", true);
|
||||||
final boolean requireplayerloginip = configuration.getBoolean("require-player-login-ip", false);
|
final boolean requireplayerloginip = configuration.getBoolean("require-player-login-ip", false);
|
||||||
final float webchatInterval = configuration.getFloat("webchat-interval", 1);
|
final float webchatInterval = configuration.getFloat("webchat-interval", 1);
|
||||||
final String spammessage = plugin.configuration.getString("spammessage", "You may only chat once every %interval% seconds.");
|
final String spammessage = plugin.configuration.getString("spammessage", "You may only chat once every %interval% seconds.");
|
||||||
@ -37,6 +38,7 @@ public class InternalClientUpdateComponent extends ClientUpdateComponent {
|
|||||||
this.trustclientname = trust_client_name;
|
this.trustclientname = trust_client_name;
|
||||||
this.use_player_login_ip = useplayerloginip;
|
this.use_player_login_ip = useplayerloginip;
|
||||||
this.require_player_login_ip = requireplayerloginip;
|
this.require_player_login_ip = requireplayerloginip;
|
||||||
|
this.check_user_ban = checkuserban;
|
||||||
onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
|
onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
|
||||||
@Override
|
@Override
|
||||||
public void triggered(Message t) {
|
public void triggered(Message t) {
|
||||||
|
@ -13,7 +13,9 @@ import java.util.List;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.dynmap.web.HttpStatus;
|
||||||
import org.dynmap.web.Json;
|
import org.dynmap.web.Json;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
@ -31,6 +33,7 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
|||||||
private boolean useplayerloginip;
|
private boolean useplayerloginip;
|
||||||
private boolean requireplayerloginip;
|
private boolean requireplayerloginip;
|
||||||
private boolean trust_client_name;
|
private boolean trust_client_name;
|
||||||
|
private boolean checkuserban;
|
||||||
|
|
||||||
private HashMap<String,String> useralias = new HashMap<String,String>();
|
private HashMap<String,String> useralias = new HashMap<String,String>();
|
||||||
private int aliasindex = 1;
|
private int aliasindex = 1;
|
||||||
@ -45,6 +48,7 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
|||||||
useplayerloginip = configuration.getBoolean("use-player-login-ip", true);
|
useplayerloginip = configuration.getBoolean("use-player-login-ip", true);
|
||||||
requireplayerloginip = configuration.getBoolean("require-player-login-ip", false);
|
requireplayerloginip = configuration.getBoolean("require-player-login-ip", false);
|
||||||
trust_client_name = configuration.getBoolean("trustclientname", false);
|
trust_client_name = configuration.getBoolean("trustclientname", false);
|
||||||
|
checkuserban = configuration.getBoolean("block-banned-player-chat", true);
|
||||||
|
|
||||||
MapManager.scheduleDelayedJob(new Runnable() {
|
MapManager.scheduleDelayedJob(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -230,6 +234,13 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
|||||||
if(ids != null) {
|
if(ids != null) {
|
||||||
name = ids.get(0);
|
name = ids.get(0);
|
||||||
isip = false;
|
isip = false;
|
||||||
|
if(checkuserban) {
|
||||||
|
OfflinePlayer p = plugin.getServer().getOfflinePlayer(name);
|
||||||
|
if((p != null) && p.isBanned()) {
|
||||||
|
Log.info("Ignore message from '" + ip + "' - banned player (" + name + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(requireplayerloginip) {
|
else if(requireplayerloginip) {
|
||||||
Log.info("Ignore message from '" + name + "' - no matching player login recorded");
|
Log.info("Ignore message from '" + name + "' - no matching player login recorded");
|
||||||
|
@ -7,6 +7,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.dynmap.DynmapPlugin;
|
import org.dynmap.DynmapPlugin;
|
||||||
import org.dynmap.Event;
|
import org.dynmap.Event;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
@ -30,6 +31,7 @@ public class SendMessageHandler implements HttpHandler {
|
|||||||
public boolean trustclientname = false;
|
public boolean trustclientname = false;
|
||||||
public boolean use_player_login_ip = false;
|
public boolean use_player_login_ip = false;
|
||||||
public boolean require_player_login_ip = false;
|
public boolean require_player_login_ip = false;
|
||||||
|
public boolean check_user_ban = false;
|
||||||
public DynmapPlugin plug_in;
|
public DynmapPlugin plug_in;
|
||||||
public String spamMessage = "\"You may only chat once every %interval% seconds.\"";
|
public String spamMessage = "\"You may only chat once every %interval% seconds.\"";
|
||||||
private HashMap<String, WebUser> disallowedUsers = new HashMap<String, WebUser>();
|
private HashMap<String, WebUser> disallowedUsers = new HashMap<String, WebUser>();
|
||||||
@ -69,6 +71,17 @@ public class SendMessageHandler implements HttpHandler {
|
|||||||
if(use_player_login_ip) {
|
if(use_player_login_ip) {
|
||||||
List<String> ids = plug_in.getIDsForIP(message.name);
|
List<String> ids = plug_in.getIDsForIP(message.name);
|
||||||
if(ids != null) {
|
if(ids != null) {
|
||||||
|
String id = ids.get(0);
|
||||||
|
if(check_user_ban) {
|
||||||
|
OfflinePlayer p = plug_in.getServer().getOfflinePlayer(id);
|
||||||
|
if((p != null) && p.isBanned()) {
|
||||||
|
Log.info("Ignore message from '" + message.name + "' - banned player (" + id + ")");
|
||||||
|
response.fields.put("Content-Length", "0");
|
||||||
|
response.status = HttpStatus.Forbidden;
|
||||||
|
response.getBody();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
message.name = ids.get(0);
|
message.name = ids.get(0);
|
||||||
isip = false;
|
isip = false;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ components:
|
|||||||
use-player-login-ip: true
|
use-player-login-ip: true
|
||||||
# (optional) if use-player-login-ip is true, setting this to true will cause chat messages not matching a known player IP to be ignored
|
# (optional) if use-player-login-ip is true, setting this to true will cause chat messages not matching a known player IP to be ignored
|
||||||
require-player-login-ip: false
|
require-player-login-ip: false
|
||||||
|
# (optional) block player login IDs that are banned from chatting
|
||||||
|
block-banned-player-chat: true
|
||||||
# # Optional - make players hidden when they are inside/underground/in shadows (#=light level: 0=full shadow,15=sky)
|
# # Optional - make players hidden when they are inside/underground/in shadows (#=light level: 0=full shadow,15=sky)
|
||||||
# hideifshadow: 4
|
# hideifshadow: 4
|
||||||
# # Optional - make player hidden when they are under cover (#=sky light level,0=underground,15=open to sky)
|
# # Optional - make player hidden when they are under cover (#=sky light level,0=underground,15=open to sky)
|
||||||
@ -47,6 +49,7 @@ components:
|
|||||||
# includehiddenplayers: false
|
# includehiddenplayers: false
|
||||||
# use-player-login-ip: false
|
# use-player-login-ip: false
|
||||||
# require-player-login-ip: false
|
# require-player-login-ip: false
|
||||||
|
# block-banned-player-chat: true
|
||||||
# hideifshadow: 0
|
# hideifshadow: 0
|
||||||
# hideifundercover: 0
|
# hideifundercover: 0
|
||||||
# hideifsneaking: false
|
# hideifsneaking: false
|
||||||
|
Loading…
Reference in New Issue
Block a user