#658 Add hide_chat setting

This commit is contained in:
Gabriele C 2016-04-15 21:50:32 +02:00
parent 6c9297a667
commit 4040cd9ba6
5 changed files with 27 additions and 10 deletions

View File

@ -382,7 +382,7 @@ public class AuthMe extends JavaPlugin {
// Register event listeners
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 AuthMeEntityListener(), this);
pluginManager.registerEvents(new AuthMeServerListener(this, messages, pluginHooks, spawnLoader), this);

View File

@ -16,7 +16,11 @@ import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.settings.NewSetting;
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.GeoLiteAPI;
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, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
private final AuthMe plugin;
private final NewSetting settings;
private final Messages m;
private final DataSource dataSource;
private final AntiBot antiBot;
private final Management management;
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) {
this.plugin = plugin;
this.settings = settings;
this.m = messages;
this.dataSource = dataSource;
this.antiBot = antiBot;
@ -78,15 +84,18 @@ public class AuthMePlayerListener implements Listener {
}
private void handleChat(AsyncPlayerChatEvent event) {
if (Settings.isChatAllowed) {
if (settings.getProperty(RestrictionSettings.ALLOW_CHAT)) {
return;
}
final Player player = event.getPlayer();
if (Utils.checkAuth(player)) {
for (Player p : Utils.getOnlinePlayers()) {
if(!settings.getProperty(RestrictionSettings.HIDE_CHAT)) {
break;
}
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
event.getRecipients().remove(p); // TODO: it should be configurable
event.getRecipients().remove(p);
}
}
return;
@ -103,7 +112,7 @@ public class AuthMePlayerListener implements Listener {
if (dataSource.isAuthAvailable(player.getName().toLowerCase())) {
m.send(player, MessageKey.LOGIN_MESSAGE);
} else {
if (Settings.emailRegistration) {
if (settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)) {
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
} else {
m.send(player, MessageKey.REGISTER_MESSAGE);
@ -116,7 +125,7 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage().split(" ")[0].toLowerCase();
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
if (settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD) && cmd.equals("/motd")) {
return;
}
if (!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {

View File

@ -47,7 +47,7 @@ public final class Settings {
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
removeJoinMessage, removeLeaveMessage, delayJoinMessage,
noTeleport, allowAllCommandsIfRegIsOptional,
isRemoveSpeedEnabled, preventOtherCase;
isRemoveSpeedEnabled, preventOtherCase, hideChat;
public static String getNickRegex, getUnloggedinGroup,
unRegisteredGroup, backupWindowsPath, getRegisteredGroup,
rakamakUsers, rakamakUsersIp, defaultWorld,
@ -154,6 +154,7 @@ public final class Settings {
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
hideChat = load(RestrictionSettings.HIDE_CHAT);
}
/**

View File

@ -12,12 +12,16 @@ import static fr.xephi.authme.settings.domain.Property.newProperty;
public class RestrictionSettings implements SettingsClass {
@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",
"listed in the list below."})
public static final Property<Boolean> ALLOW_CHAT =
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({
"Allow unlogged users to use all the commands if registration is not forced!",
"WARNING: use this only if you need it!)"})
@ -29,8 +33,9 @@ public class RestrictionSettings implements SettingsClass {
newListProperty("settings.restrictions.allowCommands",
"login", "register", "l", "reg", "email", "captcha");
@Comment("Max number of allowed registrations per IP")
// TODO ljacqu 20160109: If 0 == unlimited, add this fact to the comment
@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 =
newProperty("settings.restrictions.maxRegPerIp", 1);

View File

@ -67,6 +67,8 @@ settings:
# Care that this feature blocks also all the commands not
# listed in the list below.
allowChat: false
# Can not authenticated players see the chat log?
hideChat: false
# WARNING: use this only if you need it!
# Allow unlogged users to use all the commands if registration is not forced!
allowAllCommandsIfRegistrationIsOptional: false