#658 Add hide_chat setting
This commit is contained in:
parent
6c9297a667
commit
4040cd9ba6
@ -382,7 +382,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Register event listeners
|
// Register event listeners
|
||||||
pluginManager.registerEvents(new AuthMePlayerListener(
|
pluginManager.registerEvents(new AuthMePlayerListener(
|
||||||
this, messages, dataSource, antiBot, management, bukkitService), this);
|
this, newSettings, messages, dataSource, antiBot, management, bukkitService), this);
|
||||||
pluginManager.registerEvents(new AuthMeBlockListener(), this);
|
pluginManager.registerEvents(new AuthMeBlockListener(), this);
|
||||||
pluginManager.registerEvents(new AuthMeEntityListener(), this);
|
pluginManager.registerEvents(new AuthMeEntityListener(), this);
|
||||||
pluginManager.registerEvents(new AuthMeServerListener(this, messages, pluginHooks, spawnLoader), this);
|
pluginManager.registerEvents(new AuthMeServerListener(this, messages, pluginHooks, spawnLoader), this);
|
||||||
|
|||||||
@ -16,7 +16,11 @@ import fr.xephi.authme.output.Messages;
|
|||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import fr.xephi.authme.util.GeoLiteAPI;
|
import fr.xephi.authme.util.GeoLiteAPI;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -61,15 +65,17 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
|
private final NewSetting settings;
|
||||||
private final Messages m;
|
private final Messages m;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final AntiBot antiBot;
|
private final AntiBot antiBot;
|
||||||
private final Management management;
|
private final Management management;
|
||||||
private final BukkitService bukkitService;
|
private final BukkitService bukkitService;
|
||||||
|
|
||||||
public AuthMePlayerListener(AuthMe plugin, Messages messages, DataSource dataSource, AntiBot antiBot,
|
public AuthMePlayerListener(AuthMe plugin, NewSetting settings, Messages messages, DataSource dataSource, AntiBot antiBot,
|
||||||
Management management, BukkitService bukkitService) {
|
Management management, BukkitService bukkitService) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.settings = settings;
|
||||||
this.m = messages;
|
this.m = messages;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.antiBot = antiBot;
|
this.antiBot = antiBot;
|
||||||
@ -78,15 +84,18 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleChat(AsyncPlayerChatEvent event) {
|
private void handleChat(AsyncPlayerChatEvent event) {
|
||||||
if (Settings.isChatAllowed) {
|
if (settings.getProperty(RestrictionSettings.ALLOW_CHAT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (Utils.checkAuth(player)) {
|
if (Utils.checkAuth(player)) {
|
||||||
for (Player p : Utils.getOnlinePlayers()) {
|
for (Player p : Utils.getOnlinePlayers()) {
|
||||||
|
if(!settings.getProperty(RestrictionSettings.HIDE_CHAT)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
|
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
|
||||||
event.getRecipients().remove(p); // TODO: it should be configurable
|
event.getRecipients().remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -103,7 +112,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (dataSource.isAuthAvailable(player.getName().toLowerCase())) {
|
if (dataSource.isAuthAvailable(player.getName().toLowerCase())) {
|
||||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
if (Settings.emailRegistration) {
|
if (settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)) {
|
||||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
m.send(player, MessageKey.REGISTER_MESSAGE);
|
m.send(player, MessageKey.REGISTER_MESSAGE);
|
||||||
@ -116,7 +125,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
String cmd = event.getMessage().split(" ")[0].toLowerCase();
|
String cmd = event.getMessage().split(" ")[0].toLowerCase();
|
||||||
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
|
if (settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD) && cmd.equals("/motd")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
|
if (!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public final class Settings {
|
|||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||||
removeJoinMessage, removeLeaveMessage, delayJoinMessage,
|
removeJoinMessage, removeLeaveMessage, delayJoinMessage,
|
||||||
noTeleport, allowAllCommandsIfRegIsOptional,
|
noTeleport, allowAllCommandsIfRegIsOptional,
|
||||||
isRemoveSpeedEnabled, preventOtherCase;
|
isRemoveSpeedEnabled, preventOtherCase, hideChat;
|
||||||
public static String getNickRegex, getUnloggedinGroup,
|
public static String getNickRegex, getUnloggedinGroup,
|
||||||
unRegisteredGroup, backupWindowsPath, getRegisteredGroup,
|
unRegisteredGroup, backupWindowsPath, getRegisteredGroup,
|
||||||
rakamakUsers, rakamakUsersIp, defaultWorld,
|
rakamakUsers, rakamakUsersIp, defaultWorld,
|
||||||
@ -154,6 +154,7 @@ public final class Settings {
|
|||||||
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
|
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
|
||||||
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
||||||
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
||||||
|
hideChat = load(RestrictionSettings.HIDE_CHAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -12,12 +12,16 @@ import static fr.xephi.authme.settings.domain.Property.newProperty;
|
|||||||
public class RestrictionSettings implements SettingsClass {
|
public class RestrictionSettings implements SettingsClass {
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Can not authenticated players chat and see the chat log?",
|
"Can not authenticated players chat?",
|
||||||
"Keep in mind that this feature also blocks all commands not",
|
"Keep in mind that this feature also blocks all commands not",
|
||||||
"listed in the list below."})
|
"listed in the list below."})
|
||||||
public static final Property<Boolean> ALLOW_CHAT =
|
public static final Property<Boolean> ALLOW_CHAT =
|
||||||
newProperty("settings.restrictions.allowChat", false);
|
newProperty("settings.restrictions.allowChat", false);
|
||||||
|
|
||||||
|
@Comment("Can not authenticated players see the chat log?")
|
||||||
|
public static final Property<Boolean> HIDE_CHAT =
|
||||||
|
newProperty("settings.restrictions.hideChat", false);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Allow unlogged users to use all the commands if registration is not forced!",
|
"Allow unlogged users to use all the commands if registration is not forced!",
|
||||||
"WARNING: use this only if you need it!)"})
|
"WARNING: use this only if you need it!)"})
|
||||||
@ -29,8 +33,9 @@ public class RestrictionSettings implements SettingsClass {
|
|||||||
newListProperty("settings.restrictions.allowCommands",
|
newListProperty("settings.restrictions.allowCommands",
|
||||||
"login", "register", "l", "reg", "email", "captcha");
|
"login", "register", "l", "reg", "email", "captcha");
|
||||||
|
|
||||||
@Comment("Max number of allowed registrations per IP")
|
@Comment({
|
||||||
// TODO ljacqu 20160109: If 0 == unlimited, add this fact to the comment
|
"Max number of allowed registrations per IP",
|
||||||
|
"The value 0 means an unlimited number of registrations!"})
|
||||||
public static final Property<Integer> MAX_REGISTRATION_PER_IP =
|
public static final Property<Integer> MAX_REGISTRATION_PER_IP =
|
||||||
newProperty("settings.restrictions.maxRegPerIp", 1);
|
newProperty("settings.restrictions.maxRegPerIp", 1);
|
||||||
|
|
||||||
|
|||||||
@ -67,6 +67,8 @@ settings:
|
|||||||
# Care that this feature blocks also all the commands not
|
# Care that this feature blocks also all the commands not
|
||||||
# listed in the list below.
|
# listed in the list below.
|
||||||
allowChat: false
|
allowChat: false
|
||||||
|
# Can not authenticated players see the chat log?
|
||||||
|
hideChat: false
|
||||||
# WARNING: use this only if you need it!
|
# WARNING: use this only if you need it!
|
||||||
# Allow unlogged users to use all the commands if registration is not forced!
|
# Allow unlogged users to use all the commands if registration is not forced!
|
||||||
allowAllCommandsIfRegistrationIsOptional: false
|
allowAllCommandsIfRegistrationIsOptional: false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user