Enhance join/leave message delay

This commit is contained in:
Gabriele C 2015-11-01 13:23:47 +01:00
parent b2bd3b0ab7
commit d478973fa5
4 changed files with 32 additions and 28 deletions

View File

@ -4,6 +4,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.settings.Messages;

View File

@ -52,10 +52,11 @@ import fr.xephi.authme.settings.Settings;
public class AuthMePlayerListener implements Listener {
public AuthMe plugin;
private Messages m = Messages.getInstance();
public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
private Messages m = Messages.getInstance();
public AuthMe plugin;
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
private List<String> antibot = new ArrayList<>();
@ -67,9 +68,16 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
if (!Utils.checkAuth(player)) {
String cmd = event.getMessage().split(" ")[0];
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
event.setCancelled(true);
if (cmd.startsWith("/")) {
if (Settings.allowCommands.contains(cmd)) {
return;
}
} else {
if (Settings.isChatAllowed) {
return;
}
}
if (plugin.database.isAuthAvailable(player.getName().toLowerCase())) {
m.send(player, "login_msg");
} else {
@ -84,22 +92,14 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String msg = event.getMessage();
if (msg.equalsIgnoreCase("/worldedit cui"))
return;
String cmd = msg.split(" ")[0];
if (cmd.equalsIgnoreCase("/login") || cmd.equalsIgnoreCase("/register") || cmd.equalsIgnoreCase("/l") || cmd.equalsIgnoreCase("/reg") || cmd.equalsIgnoreCase("/email") || cmd.equalsIgnoreCase("/captcha"))
return;
String cmd = event.getMessage().split(" ")[0];
if (Settings.useEssentialsMotd && cmd.equalsIgnoreCase("/motd"))
return;
if (Settings.allowCommands.contains(cmd))
return;
if (!Utils.checkAuth(event.getPlayer())) {
event.setMessage("/notloggedin");
event.setCancelled(true);
}
if (Utils.checkAuth(event.getPlayer()))
return;
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
@ -216,7 +216,7 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performJoin(player);
// Remove the join message while the player isn't logging in
if (Settings.delayJoinMessage && event.getJoinMessage() != null) {
if (Settings.delayJoinLeaveMessages && event.getJoinMessage() != null) {
joinMessage.put(name, event.getJoinMessage());
event.setJoinMessage(null);
}
@ -372,13 +372,12 @@ public class AuthMePlayerListener implements Listener {
}
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
if (!Utils.checkAuth(player) && Settings.delayJoinLeaveMessages) {
event.setQuitMessage(null);
}
plugin.management.performQuit(player, false);
// TODO: rename delayjoinmessage setting
if (!PlayerCache.getInstance().isAuthenticated(name) && Settings.delayJoinMessages)
event.setQuitMessage(null);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)

View File

@ -76,7 +76,7 @@ public final class Settings extends YamlConfiguration {
purgeLimitedCreative, purgeAntiXray, purgePermissions,
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
@ -273,7 +273,7 @@ public final class Settings extends YamlConfiguration {
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
delayJoinLeaveMessages = configFile.getBoolean("settings.delayJoinLeaveMessage", false);
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*");
@ -402,8 +402,12 @@ public final class Settings extends YamlConfiguration {
set("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
changes = true;
}
if (!contains("settings.delayJoinMessage")) {
set("settings.delayJoinMessage", false);
if (contains("settings.delayJoinMessage")) {
set("settings.delayJoinMessage", null);
changes = true;
}
if (!contains("settings.delayJoinLeaveMessages")) {
set("settings.delayJoinLeaveMessages", true);
changes = true;
}
if (!contains("settings.restrictions.noTeleport")) {

View File

@ -253,8 +253,8 @@ settings:
useWelcomeMessage: true
# Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player
broadcastWelcomeMessage: false
# Do we need to delay the X has joined the game after /login ?
delayJoinMessage: false
# Do we need to delay the join/leave message to be displayed only when the player is authenticated ?
delayJoinLeaveMessages: true
# Do we need to add potion effect Blinding before login/register ?
applyBlindEffect: false
ExternalBoardOptions: