mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 00:58:50 +01:00
Fix leave messages being sent when vanished (#5009)
This commit is contained in:
parent
09dc49aacb
commit
b135fcf086
@ -260,6 +260,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
user.setGodModeEnabled(false);
|
||||
}
|
||||
if (user.isVanished()) {
|
||||
user.setLeavingHidden(true);
|
||||
user.setVanished(false);
|
||||
}
|
||||
user.setLogoutLocation();
|
||||
@ -334,6 +335,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
user.setLastLogin(currentTime);
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
user.setLeavingHidden(false);
|
||||
|
||||
// Check for new username. If they don't want the message, let's just say it's false.
|
||||
final boolean newUsername = ess.getSettings().isCustomNewUsernameMessage() && lastAccountName != null && !lastAccountName.equals(user.getBase().getName());
|
||||
|
@ -94,6 +94,15 @@ public interface IUser {
|
||||
*/
|
||||
boolean isHidden();
|
||||
|
||||
/**
|
||||
* Whether the user was hidden before leaving the server.
|
||||
*
|
||||
* @return true if the user was hidden.
|
||||
*/
|
||||
boolean isLeavingHidden();
|
||||
|
||||
void setLeavingHidden(boolean leavingHidden);
|
||||
|
||||
void setHidden(boolean vanish);
|
||||
|
||||
boolean isGodModeEnabled();
|
||||
|
@ -68,6 +68,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
// User properties
|
||||
private transient boolean vanished;
|
||||
private boolean hidden = false;
|
||||
private boolean leavingHidden = false;
|
||||
private boolean rightClickJump = false;
|
||||
private boolean invSee = false;
|
||||
private boolean recipeSee = false;
|
||||
@ -681,6 +682,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return hidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeavingHidden() {
|
||||
return leavingHidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeavingHidden(boolean leavingHidden) {
|
||||
this.leavingHidden = leavingHidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHidden(final boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
|
@ -120,7 +120,7 @@ public class BukkitListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onVanishStatusChange(VanishStatusChangeEvent event) {
|
||||
if (!jda.getSettings().isVanishFakeJoinLeave()) {
|
||||
if (!jda.getSettings().isVanishFakeJoinLeave() || event.getAffected().isLeavingHidden()) {
|
||||
return;
|
||||
}
|
||||
if (event.getValue()) {
|
||||
@ -235,7 +235,7 @@ public class BukkitListener implements Listener {
|
||||
}
|
||||
|
||||
private boolean isVanishHide(final IUser user) {
|
||||
return jda.getSettings().isVanishHideMessages() && user.isHidden();
|
||||
return jda.getSettings().isVanishHideMessages() && (user.isHidden() || user.isLeavingHidden());
|
||||
}
|
||||
|
||||
private void sendDiscordMessage(final MessageType messageType, final String message) {
|
||||
|
Loading…
Reference in New Issue
Block a user