fix blindness when timeout = 0

This commit is contained in:
Gabriele C 2015-12-23 11:51:06 +01:00
parent f785d9d357
commit 8bfb56f34e
3 changed files with 42 additions and 16 deletions

View File

@ -29,7 +29,7 @@ public class RegisterCommand extends ExecutableCommand {
// Make sure the command arguments are valid // Make sure the command arguments are valid
final Player player = (Player) sender; final Player player = (Player) sender;
if (arguments.isEmpty() || (Settings.getEnablePasswordVerifier && arguments.size() < 2)) { if (arguments.isEmpty() || (Settings.enablePasswordConfirmation && arguments.size() < 2)) {
m.send(player, MessageKey.USAGE_REGISTER); m.send(player, MessageKey.USAGE_REGISTER);
return; return;
} }
@ -49,7 +49,7 @@ public class RegisterCommand extends ExecutableCommand {
management.performRegister(player, thePass, email); management.performRegister(player, thePass, email);
return; return;
} }
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) { if (arguments.size() > 1 && Settings.enablePasswordConfirmation) {
if (!arguments.get(0).equals(arguments.get(1))) { if (!arguments.get(0).equals(arguments.get(1))) {
m.send(player, MessageKey.PASSWORD_MATCH_ERROR); m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
return; return;

View File

@ -107,7 +107,8 @@ public class AsynchronousJoin {
}); });
} }
if (!Settings.noTeleport)
if (!Settings.noTeleport) {
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -117,26 +118,32 @@ public class AsynchronousJoin {
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) { if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) { if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null) if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo()); player.teleport(tpEvent.getTo());
}
} }
} }
} }
}); });
} }
}
placePlayerSafely(player, spawnLoc); placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player); LimboCache.getInstance().updateLimboPlayer(player);
// protect inventory // protect inventory
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) { if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
ProtectInventoryEvent ev = new ProtectInventoryEvent(player); ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
plugin.getServer().getPluginManager().callEvent(ev); plugin.getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) { if (ev.isCancelled()) {
plugin.inventoryProtector.sendInventoryPacket(player); plugin.inventoryProtector.sendInventoryPacket(player);
if (!Settings.noConsoleSpam) if (!Settings.noConsoleSpam) {
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
}
} }
} }
} else { } else {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) { if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -155,7 +162,8 @@ public class AsynchronousJoin {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
if (!Settings.noTeleport)
if (!Settings.noTeleport) {
if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -165,29 +173,26 @@ public class AsynchronousJoin {
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) { if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) { if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null) if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo()); player.teleport(tpEvent.getTo());
}
} }
} }
} }
}); });
} }
}
} }
if (!LimboCache.getInstance().hasLimboPlayer(name)) { if (!LimboCache.getInstance().hasLimboPlayer(name)) {
LimboCache.getInstance().addLimboPlayer(player); LimboCache.getInstance().addLimboPlayer(player);
} }
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
final int timeOut = Settings.getRegistrationTimeout * 20; final int timeOut = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (timeOut > 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -205,11 +210,24 @@ public class AsynchronousJoin {
player.performCommand("motd"); player.performCommand("motd");
} }
if (Settings.applyBlindEffect) { if (Settings.applyBlindEffect) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2)); int blindTimeOut;
// Allow infinite blindness effect
if(timeOut < 0) {
blindTimeOut = 99999;
} else {
blindTimeOut = timeOut;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2));
} }
} }
}); });
int msgInterval = Settings.getWarnMessageInterval;
if (timeOut > 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) { if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) {
if (plugin.sessions.containsKey(name)) { if (plugin.sessions.containsKey(name)) {

View File

@ -67,7 +67,7 @@ public final class Settings {
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled, isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
isSaveQuitLocationEnabled, isForceSurvivalModeEnabled, isSaveQuitLocationEnabled, isForceSurvivalModeEnabled,
isResetInventoryIfCreative, isCachingEnabled, isResetInventoryIfCreative, isCachingEnabled,
isKickOnWrongPasswordEnabled, getEnablePasswordVerifier, isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
protectInventoryBeforeLogInEnabled, isBackupActivated, protectInventoryBeforeLogInEnabled, isBackupActivated,
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport, isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
@ -202,7 +202,7 @@ public final class Settings {
} }
getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", ""); getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true); enablePasswordConfirmation = configFile.getBoolean("settings.restrictions.enablePasswordConfirmation", true);
protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true); protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
plugin.checkProtocolLib(); plugin.checkProtocolLib();
@ -581,6 +581,14 @@ public final class Settings {
set("settings.useWelcomeMessage", true); set("settings.useWelcomeMessage", true);
changes = true; changes = true;
} }
if (!contains("settings.restrictions.enablePasswordConfirmation")) {
set("settings.restrictions.enablePasswordConfirmation", true);
changes = true;
}
if (contains("settings.restrictions.enablePasswordVerifier")) {
set("settings.restrictions.enablePasswordVerifier", null);
changes = true;
}
if (!contains("settings.security.unsafePasswords")) { if (!contains("settings.security.unsafePasswords")) {
List<String> str = new ArrayList<>(); List<String> str = new ArrayList<>();
str.add("123456"); str.add("123456");