Run non-thread-safe addPotionEffect sync on unregister (Fixes #828)

This commit is contained in:
games647 2016-07-07 11:02:09 +02:00
parent 42ef99cf15
commit 6be58ee2e2
2 changed files with 17 additions and 6 deletions

View File

@ -14,7 +14,9 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -37,6 +39,9 @@ public class AsynchronousUnregister implements AsynchronousProcess {
@Inject
private PlayerCache playerCache;
@Inject
private BukkitService bukktiService;
@Inject
private LimboCache limboCache;
@ -49,7 +54,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
AsynchronousUnregister() { }
public void unregister(Player player, String password, boolean force) {
public void unregister(final Player player, String password, boolean force) {
final String name = player.getName().toLowerCase();
PlayerAuth cachedAuth = playerCache.getAuth(name);
if (force || passwordSecurity.comparePassword(password, cachedAuth.getPassword(), player.getName())) {
@ -80,10 +85,16 @@ public class AsynchronousUnregister implements AsynchronousProcess {
playerCache.removePlayer(name);
// Apply blind effect
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
}
final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
bukktiService.runTask(new Runnable() {
@Override
public void run() {
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
}
}
});
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
ConsoleLogger.info(player.getName() + " unregistered himself");
} else {

View File

@ -12,7 +12,7 @@ login: '&aConnexion effectuée !'
vb_nonActiv: '&fCe compte n''est pas actif, consultez vos emails !'
user_regged: '&cCe nom est déjà utilisé.'
usage_reg: '&cUtilisez la commande /register motdepasse confirmermotdepasse'
# TODO max_reg: Missing tag %reg_count
# TODO max_reg: Missing tag %reg_count
max_reg: '&cVous ne pouvez pas enregistrer plus de %max_acc compte(s). &o(Compte(s): %reg_names)'
no_perm: '&cVous n''avez pas la permission.'
password_error_nick: '&fTu ne peux pas utiliser ton pseudo comme mot de passe.'