Enhance join/leave message delay
This commit is contained in:
parent
b2bd3b0ab7
commit
d478973fa5
@ -4,6 +4,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
|
|||||||
@ -52,10 +52,11 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
|
|
||||||
public class AuthMePlayerListener implements Listener {
|
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, GameMode> gameMode = new ConcurrentHashMap<>();
|
||||||
public static ConcurrentHashMap<String, String> joinMessage = 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<>();
|
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||||
private List<String> antibot = new ArrayList<>();
|
private List<String> antibot = new ArrayList<>();
|
||||||
|
|
||||||
@ -67,9 +68,16 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!Utils.checkAuth(player)) {
|
if (!Utils.checkAuth(player)) {
|
||||||
String cmd = event.getMessage().split(" ")[0];
|
String cmd = event.getMessage().split(" ")[0];
|
||||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
if (cmd.startsWith("/")) {
|
||||||
event.setCancelled(true);
|
if (Settings.allowCommands.contains(cmd)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Settings.isChatAllowed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.database.isAuthAvailable(player.getName().toLowerCase())) {
|
if (plugin.database.isAuthAvailable(player.getName().toLowerCase())) {
|
||||||
m.send(player, "login_msg");
|
m.send(player, "login_msg");
|
||||||
} else {
|
} else {
|
||||||
@ -84,22 +92,14 @@ 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 msg = event.getMessage();
|
String cmd = event.getMessage().split(" ")[0];
|
||||||
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;
|
|
||||||
if (Settings.useEssentialsMotd && cmd.equalsIgnoreCase("/motd"))
|
if (Settings.useEssentialsMotd && cmd.equalsIgnoreCase("/motd"))
|
||||||
return;
|
return;
|
||||||
if (Settings.allowCommands.contains(cmd))
|
if (Settings.allowCommands.contains(cmd))
|
||||||
return;
|
return;
|
||||||
|
if (Utils.checkAuth(event.getPlayer()))
|
||||||
if (!Utils.checkAuth(event.getPlayer())) {
|
return;
|
||||||
event.setMessage("/notloggedin");
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
@ -216,7 +216,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.management.performJoin(player);
|
plugin.management.performJoin(player);
|
||||||
|
|
||||||
// Remove the join message while the player isn't logging in
|
// 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());
|
joinMessage.put(name, event.getJoinMessage());
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
}
|
}
|
||||||
@ -372,13 +372,12 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
|
||||||
|
if (!Utils.checkAuth(player) && Settings.delayJoinLeaveMessages) {
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
}
|
||||||
|
|
||||||
plugin.management.performQuit(player, false);
|
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)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
||||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||||
checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
|
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
||||||
customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
|
customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
|
||||||
|
|
||||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||||
@ -273,7 +273,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
||||||
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
||||||
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
|
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);
|
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
|
||||||
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
|
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
|
||||||
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*");
|
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_]*");
|
set("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
|
||||||
changes = true;
|
changes = true;
|
||||||
}
|
}
|
||||||
if (!contains("settings.delayJoinMessage")) {
|
if (contains("settings.delayJoinMessage")) {
|
||||||
set("settings.delayJoinMessage", false);
|
set("settings.delayJoinMessage", null);
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
if (!contains("settings.delayJoinLeaveMessages")) {
|
||||||
|
set("settings.delayJoinLeaveMessages", true);
|
||||||
changes = true;
|
changes = true;
|
||||||
}
|
}
|
||||||
if (!contains("settings.restrictions.noTeleport")) {
|
if (!contains("settings.restrictions.noTeleport")) {
|
||||||
|
|||||||
@ -253,8 +253,8 @@ settings:
|
|||||||
useWelcomeMessage: true
|
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
|
# 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
|
broadcastWelcomeMessage: false
|
||||||
# Do we need to delay the X has joined the game after /login ?
|
# Do we need to delay the join/leave message to be displayed only when the player is authenticated ?
|
||||||
delayJoinMessage: false
|
delayJoinLeaveMessages: true
|
||||||
# Do we need to add potion effect Blinding before login/register ?
|
# Do we need to add potion effect Blinding before login/register ?
|
||||||
applyBlindEffect: false
|
applyBlindEffect: false
|
||||||
ExternalBoardOptions:
|
ExternalBoardOptions:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user