mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-15 07:05:52 +01:00
Fix afk message being sent when event cancelled (#3915)
This commit is contained in:
parent
671983724a
commit
141512f2f7
@ -668,7 +668,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
public void updateActivity(final boolean broadcast, final AfkStatusChangeEvent.Cause cause) {
|
public void updateActivity(final boolean broadcast, final AfkStatusChangeEvent.Cause cause) {
|
||||||
if (isAfk()) {
|
if (isAfk()) {
|
||||||
setAfk(false, cause);
|
setAfk(false, cause);
|
||||||
if (broadcast && !isHidden()) {
|
if (broadcast && !isHidden() && !isAfk()) {
|
||||||
setDisplayNick();
|
setDisplayNick();
|
||||||
final String msg = tl("userIsNotAway", getDisplayName());
|
final String msg = tl("userIsNotAway", getDisplayName());
|
||||||
final String selfmsg = tl("userIsNotAwaySelf", getDisplayName());
|
final String selfmsg = tl("userIsNotAwaySelf", getDisplayName());
|
||||||
@ -729,7 +729,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
final long autoafk = ess.getSettings().getAutoAfk();
|
final long autoafk = ess.getSettings().getAutoAfk();
|
||||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk.auto")) {
|
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk.auto")) {
|
||||||
setAfk(true, AfkStatusChangeEvent.Cause.ACTIVITY);
|
setAfk(true, AfkStatusChangeEvent.Cause.ACTIVITY);
|
||||||
if (!isHidden()) {
|
if (isAfk() && !isHidden()) {
|
||||||
setDisplayNick();
|
setDisplayNick();
|
||||||
final String msg = tl("userIsAway", getDisplayName());
|
final String msg = tl("userIsAway", getDisplayName());
|
||||||
final String selfmsg = tl("userIsAwaySelf", getDisplayName());
|
final String selfmsg = tl("userIsAwaySelf", getDisplayName());
|
||||||
|
@ -61,7 +61,14 @@ public class Commandafk extends EssentialsCommand {
|
|||||||
user.setDisplayNick();
|
user.setDisplayNick();
|
||||||
String msg = "";
|
String msg = "";
|
||||||
String selfmsg = "";
|
String selfmsg = "";
|
||||||
if (!user.toggleAfk(AfkStatusChangeEvent.Cause.COMMAND)) {
|
|
||||||
|
final boolean currentStatus = user.isAfk();
|
||||||
|
final boolean afterStatus = user.toggleAfk(AfkStatusChangeEvent.Cause.COMMAND);
|
||||||
|
if (currentStatus == afterStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!afterStatus) {
|
||||||
if (!user.isHidden()) {
|
if (!user.isHidden()) {
|
||||||
msg = tl("userIsNotAway", user.getDisplayName());
|
msg = tl("userIsNotAway", user.getDisplayName());
|
||||||
selfmsg = tl("userIsNotAwaySelf", user.getDisplayName());
|
selfmsg = tl("userIsNotAwaySelf", user.getDisplayName());
|
||||||
|
Loading…
Reference in New Issue
Block a user