Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ public interface ISettings extends IConf {

long getAutoAfk();

long getAutoAfkKick();
long getAutoAfkKick(User user);

long getAutoAfkKick(String set);

Set<String> getAfkLimits();

boolean getFreezeAfkPlayers();

Expand Down
24 changes: 22 additions & 2 deletions Essentials/src/main/java/com/earth2me/essentials/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,28 @@ public long getAutoAfk() {
}

@Override
public long getAutoAfkKick() {
return config.getLong("auto-afk-kick", -1);
public long getAutoAfkKick(final User user) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a user belong to multiple sets? If so, I would think that the most generous limit should be used. If not, you can return after the first limit is found (and eliminate the variable limit).

long limit = -1;
final Set<String> limitList = getAfkLimits();
if (limitList != null) {
for (String set : limitList) {
if (user.isAuthorized("essentials.auto-afk-kick." + set)) {
limit = getAutoAfkKick(set);
}
}
}
return limit;
}

@Override
public long getAutoAfkKick(final String set) {
return config.getLong("auto-afk-kick." + set, config.getLong("auto-afk-kick.default", -1));
}

@Override
public Set<String> getAfkLimits() {
final ConfigurationSection section = config.getConfigurationSection("auto-afk-kick");
return section == null ? null : section.getKeys(false);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion Essentials/src/main/java/com/earth2me/essentials/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ public void checkActivity() {
return;
}

final long autoafkkick = ess.getSettings().getAutoAfkKick();
final long autoafkkick = ess.getSettings().getAutoAfkKick(this);
if (autoafkkick > 0
&& lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
&& !isAuthorized("essentials.kick.exempt")
Expand Down