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
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);
return;
}
@ -49,7 +49,7 @@ public class RegisterCommand extends ExecutableCommand {
management.performRegister(player, thePass, email);
return;
}
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) {
if (arguments.size() > 1 && Settings.enablePasswordConfirmation) {
if (!arguments.get(0).equals(arguments.get(1))) {
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
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()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -117,26 +118,32 @@ public class AsynchronousJoin {
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null)
if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
}
}
});
}
}
placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player);
// protect inventory
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
plugin.getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
plugin.inventoryProtector.sendInventoryPacket(player);
if (!Settings.noConsoleSpam)
if (!Settings.noConsoleSpam) {
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
}
}
}
} else {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -155,7 +162,8 @@ public class AsynchronousJoin {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
if (!Settings.noTeleport)
if (!Settings.noTeleport) {
if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -165,29 +173,26 @@ public class AsynchronousJoin {
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null)
if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
}
}
});
}
}
}
if (!LimboCache.getInstance().hasLimboPlayer(name)) {
LimboCache.getInstance().addLimboPlayer(player);
}
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
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() {
@Override
public void run() {
@ -205,11 +210,24 @@ public class AsynchronousJoin {
player.performCommand("motd");
}
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 (plugin.sessions.containsKey(name)) {

View File

@ -67,7 +67,7 @@ public final class Settings {
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
isSaveQuitLocationEnabled, isForceSurvivalModeEnabled,
isResetInventoryIfCreative, isCachingEnabled,
isKickOnWrongPasswordEnabled, getEnablePasswordVerifier,
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
protectInventoryBeforeLogInEnabled, isBackupActivated,
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
@ -202,7 +202,7 @@ public final class Settings {
}
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);
plugin.checkProtocolLib();
@ -581,6 +581,14 @@ public final class Settings {
set("settings.useWelcomeMessage", 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")) {
List<String> str = new ArrayList<>();
str.add("123456");