Skip to content

Commit 8bfb56f

Browse files
committed
fix blindness when timeout = 0
1 parent f785d9d commit 8bfb56f

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void executeCommand(CommandSender sender, List<String> arguments) {
2929

3030
// Make sure the command arguments are valid
3131
final Player player = (Player) sender;
32-
if (arguments.isEmpty() || (Settings.getEnablePasswordVerifier && arguments.size() < 2)) {
32+
if (arguments.isEmpty() || (Settings.enablePasswordConfirmation && arguments.size() < 2)) {
3333
m.send(player, MessageKey.USAGE_REGISTER);
3434
return;
3535
}
@@ -49,7 +49,7 @@ public void executeCommand(CommandSender sender, List<String> arguments) {
4949
management.performRegister(player, thePass, email);
5050
return;
5151
}
52-
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) {
52+
if (arguments.size() > 1 && Settings.enablePasswordConfirmation) {
5353
if (!arguments.get(0).equals(arguments.get(1))) {
5454
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
5555
return;

src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public void run() {
107107

108108
});
109109
}
110-
if (!Settings.noTeleport)
110+
111+
if (!Settings.noTeleport) {
111112
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
112113
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
113114

@@ -117,26 +118,32 @@ public void run() {
117118
plugin.getServer().getPluginManager().callEvent(tpEvent);
118119
if (!tpEvent.isCancelled()) {
119120
if (player.isOnline() && tpEvent.getTo() != null) {
120-
if (tpEvent.getTo().getWorld() != null)
121+
if (tpEvent.getTo().getWorld() != null) {
121122
player.teleport(tpEvent.getTo());
123+
}
122124
}
123125
}
124126
}
125127

126128
});
127129
}
130+
}
131+
128132
placePlayerSafely(player, spawnLoc);
129133
LimboCache.getInstance().updateLimboPlayer(player);
134+
130135
// protect inventory
131136
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
132137
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
133138
plugin.getServer().getPluginManager().callEvent(ev);
134139
if (ev.isCancelled()) {
135140
plugin.inventoryProtector.sendInventoryPacket(player);
136-
if (!Settings.noConsoleSpam)
141+
if (!Settings.noConsoleSpam) {
137142
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
143+
}
138144
}
139145
}
146+
140147
} else {
141148
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
142149
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@@ -155,7 +162,8 @@ public void run() {
155162
if (!Settings.isForcedRegistrationEnabled) {
156163
return;
157164
}
158-
if (!Settings.noTeleport)
165+
166+
if (!Settings.noTeleport) {
159167
if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
160168
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
161169

@@ -165,29 +173,26 @@ public void run() {
165173
plugin.getServer().getPluginManager().callEvent(tpEvent);
166174
if (!tpEvent.isCancelled()) {
167175
if (player.isOnline() && tpEvent.getTo() != null) {
168-
if (tpEvent.getTo().getWorld() != null)
176+
if (tpEvent.getTo().getWorld() != null) {
169177
player.teleport(tpEvent.getTo());
178+
}
170179
}
171180
}
172181
}
173182

174183
});
175184
}
185+
}
176186

177187
}
178188

179189
if (!LimboCache.getInstance().hasLimboPlayer(name)) {
180190
LimboCache.getInstance().addLimboPlayer(player);
181191
}
192+
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
182193

183194
final int timeOut = Settings.getRegistrationTimeout * 20;
184-
int msgInterval = Settings.getWarnMessageInterval;
185-
if (timeOut > 0) {
186-
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
187-
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
188-
}
189195

190-
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
191196
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
192197
@Override
193198
public void run() {
@@ -205,11 +210,24 @@ public void run() {
205210
player.performCommand("motd");
206211
}
207212
if (Settings.applyBlindEffect) {
208-
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
213+
int blindTimeOut;
214+
// Allow infinite blindness effect
215+
if(timeOut < 0) {
216+
blindTimeOut = 99999;
217+
} else {
218+
blindTimeOut = timeOut;
219+
}
220+
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2));
209221
}
210222
}
211223

212224
});
225+
226+
int msgInterval = Settings.getWarnMessageInterval;
227+
if (timeOut > 0) {
228+
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
229+
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
230+
}
213231

214232
if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) {
215233
if (plugin.sessions.containsKey(name)) {

src/main/java/fr/xephi/authme/settings/Settings.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class Settings {
6767
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
6868
isSaveQuitLocationEnabled, isForceSurvivalModeEnabled,
6969
isResetInventoryIfCreative, isCachingEnabled,
70-
isKickOnWrongPasswordEnabled, getEnablePasswordVerifier,
70+
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
7171
protectInventoryBeforeLogInEnabled, isBackupActivated,
7272
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
7373
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
@@ -202,7 +202,7 @@ public static void loadVariables() {
202202
}
203203

204204
getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
205-
getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true);
205+
enablePasswordConfirmation = configFile.getBoolean("settings.restrictions.enablePasswordConfirmation", true);
206206

207207
protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
208208
plugin.checkProtocolLib();
@@ -581,6 +581,14 @@ public void mergeConfig() {
581581
set("settings.useWelcomeMessage", true);
582582
changes = true;
583583
}
584+
if (!contains("settings.restrictions.enablePasswordConfirmation")) {
585+
set("settings.restrictions.enablePasswordConfirmation", true);
586+
changes = true;
587+
}
588+
if (contains("settings.restrictions.enablePasswordVerifier")) {
589+
set("settings.restrictions.enablePasswordVerifier", null);
590+
changes = true;
591+
}
584592
if (!contains("settings.security.unsafePasswords")) {
585593
List<String> str = new ArrayList<>();
586594
str.add("123456");

0 commit comments

Comments
 (0)