mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 03:05:17 +01:00
commit
0a9cadc2e2
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.cache.limbo;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -83,6 +84,10 @@ public class LimboPlayer {
|
||||
}
|
||||
|
||||
public void setTimeoutTaskId(BukkitTask i) {
|
||||
if (this.timeoutTaskId != null) {
|
||||
if (Bukkit.getScheduler().isCurrentlyRunning(this.timeoutTaskId.getTaskId()) || Bukkit.getScheduler().isQueued(this.timeoutTaskId.getTaskId()))
|
||||
Bukkit.getScheduler().cancelTask(this.timeoutTaskId.getTaskId());
|
||||
}
|
||||
this.timeoutTaskId = i;
|
||||
}
|
||||
|
||||
@ -91,6 +96,10 @@ public class LimboPlayer {
|
||||
}
|
||||
|
||||
public void setMessageTaskId(BukkitTask messageTaskId) {
|
||||
if (this.messageTaskId != null) {
|
||||
if (Bukkit.getScheduler().isCurrentlyRunning(this.messageTaskId.getTaskId()) || Bukkit.getScheduler().isQueued(this.messageTaskId.getTaskId()))
|
||||
Bukkit.getScheduler().cancelTask(this.messageTaskId.getTaskId());
|
||||
}
|
||||
this.messageTaskId = messageTaskId;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,8 @@ public class AdminCommand implements CommandExecutor {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("register") || args[0].equalsIgnoreCase("reg")) {
|
||||
} else
|
||||
if (args[0].equalsIgnoreCase("register") || args[0].equalsIgnoreCase("reg")) {
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage("Usage: /authme register playername password");
|
||||
return true;
|
||||
@ -394,7 +395,8 @@ public class AdminCommand implements CommandExecutor {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
|
||||
} else
|
||||
if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage("Usage: /authme changepassword playername newpassword");
|
||||
return true;
|
||||
@ -460,10 +462,10 @@ public class AdminCommand implements CommandExecutor {
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = sender.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTask(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));
|
||||
if (Settings.applyBlindEffect)
|
||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||
m.send(target, "unregistered");
|
||||
|
@ -2,8 +2,6 @@ package fr.xephi.authme.commands;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -29,6 +27,7 @@ import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
public class UnregisterCommand implements CommandExecutor {
|
||||
|
||||
@ -93,10 +92,10 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = sender.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTask(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));
|
||||
m.send(player, "unregistered");
|
||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
||||
if (plugin.notifications != null) {
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -86,7 +85,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
|
||||
String msg = event.getMessage();
|
||||
// WorldEdit GUI Shit
|
||||
if (msg.equalsIgnoreCase("/worldedit cui"))
|
||||
return;
|
||||
|
||||
@ -403,7 +401,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
final String name = player.getName().toLowerCase();
|
||||
@ -447,18 +445,31 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Settings.isSessionsEnabled)
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
if (!Settings.sessionExpireOnIpChange)
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
});
|
||||
|
||||
// Check if forceSingleSession is set to true, so kick player that has
|
||||
// joined with same nick of online player
|
||||
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
event.setKickMessage(m.send("same_nick")[0]);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
utils.addNormal(player, limbo.getGroup());
|
||||
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
Utils.getInstance().addNormal(player, limbo.getGroup());
|
||||
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -569,27 +580,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void placePlayerSafely(Player player, Location spawnLoc) {
|
||||
if (!Settings.noTeleport)
|
||||
return;
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||
return;
|
||||
Block b = player.getLocation().getBlock();
|
||||
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) {
|
||||
m.send(player, "unsafe_spawn");
|
||||
if (spawnLoc.getWorld() != null)
|
||||
player.teleport(spawnLoc);
|
||||
return;
|
||||
}
|
||||
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
|
||||
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) {
|
||||
m.send(player, "unsafe_spawn");
|
||||
if (spawnLoc.getWorld() != null)
|
||||
player.teleport(spawnLoc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer() == null) {
|
||||
@ -616,7 +606,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if ((Settings.isForceSingleSessionEnabled) && (event.getReason().contains("You logged in from another location"))) {
|
||||
if ((!Settings.isForceSingleSessionEnabled) && (event.getReason().contains("You logged in from another location"))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ public class AsyncronousJoin {
|
||||
int time = Settings.getRegistrationTimeout * 20;
|
||||
int msgInterval = Settings.getWarnMessageInterval;
|
||||
if (time != 0) {
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), time);
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), time);
|
||||
if (!LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
@ -302,11 +302,12 @@ public class AsyncronousJoin {
|
||||
}
|
||||
|
||||
});
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
}
|
||||
|
||||
private void placePlayerSafely(final Player player, final Location spawnLoc) {
|
||||
private void placePlayerSafely(final Player player,
|
||||
final Location spawnLoc) {
|
||||
Location loc = null;
|
||||
if (spawnLoc == null)
|
||||
return;
|
||||
|
@ -3,8 +3,6 @@ package fr.xephi.authme.process.login;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -21,6 +19,7 @@ import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
public class AsyncronousLogin {
|
||||
|
||||
@ -64,7 +63,8 @@ public class AsyncronousLogin {
|
||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
|
||||
}
|
||||
return true;
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
} else
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
try {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.cap.remove(name);
|
||||
@ -87,14 +87,14 @@ public class AsyncronousLogin {
|
||||
if (!database.isAuthAvailable(name)) {
|
||||
m.send(player, "user_unknown");
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId().cancel();
|
||||
LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId().cancel();
|
||||
String[] msg;
|
||||
if (Settings.emailRegistration) {
|
||||
msg = m.send("reg_email_msg");
|
||||
} else {
|
||||
msg = m.send("reg_msg");
|
||||
}
|
||||
BukkitTask msgT = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
|
||||
BukkitTask msgT = Bukkit.getScheduler().runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
}
|
||||
return null;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package fr.xephi.authme.process.logout;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -17,6 +15,7 @@ import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
|
||||
@ -37,10 +36,10 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = player.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
try {
|
||||
if (player.isInsideVehicle())
|
||||
|
@ -1,7 +1,5 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -14,6 +12,7 @@ import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
public class ProcessSyncronousEmailRegister implements Runnable {
|
||||
|
||||
@ -37,13 +36,13 @@ public class ProcessSyncronousEmailRegister implements Runnable {
|
||||
int time = Settings.getRegistrationTimeout * 20;
|
||||
int msgInterval = Settings.getWarnMessageInterval;
|
||||
if (time != 0) {
|
||||
LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId().cancel();
|
||||
BukkitTask id = Bukkit.getScheduler().runTaskLater(plugin, new TimeoutTask(plugin, name), time);
|
||||
LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId().cancel();
|
||||
BukkitTask id = Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), time);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
|
||||
LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId().cancel();
|
||||
BukkitTask nwMsg = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, m.send("login_msg"), msgInterval));
|
||||
BukkitTask nwMsg = Bukkit.getScheduler().runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
|
||||
player.saveData();
|
||||
if (!Settings.noConsoleSpam)
|
||||
|
@ -1,7 +1,5 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -22,6 +20,7 @@ import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
|
||||
@ -67,10 +66,10 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
try {
|
||||
plugin.pllog.removePlayer(name);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package fr.xephi.authme.task;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
@ -33,11 +32,11 @@ public class MessageTask implements Runnable {
|
||||
for (String ms : msg) {
|
||||
player.sendMessage(ms);
|
||||
}
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
BukkitTask late = sched.runTaskLater(plugin, this, interval * 20);
|
||||
BukkitTask late = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, interval * 20);
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.task;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -34,7 +35,7 @@ public class TimeoutTask implements Runnable {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (final Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@ -44,14 +45,27 @@ public class TimeoutTask implements Runnable {
|
||||
playerCache.removeCache(player);
|
||||
}
|
||||
}
|
||||
GameMode gm = AuthMePlayerListener.gameMode.get(name);
|
||||
if (gm != null)
|
||||
{
|
||||
player.setGameMode(gm);
|
||||
ConsoleLogger.info("Set " + player.getName() + " to gamemode: " + gm.name());
|
||||
final GameMode gm = AuthMePlayerListener.gameMode.get(name);
|
||||
if (gm != null) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.setGameMode(gm);
|
||||
}
|
||||
|
||||
});
|
||||
ConsoleLogger.info("Set " + player.getName() + " to gamemode: " + gm.name());
|
||||
}
|
||||
player.kickPlayer(m.send("timeout")[0]);
|
||||
break;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.isOnline())
|
||||
player.kickPlayer(m.send("timeout")[0]);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user