mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
Add option to prevent replying from vanished players (#3703)
Closes #2066
This commit is contained in:
parent
4d9a10147a
commit
bb43e8f7b6
@ -4,6 +4,7 @@ import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.messaging.SimpleMessageRecipient;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class Console implements IMessageRecipient {
|
||||
public static final String NAME = "Console";
|
||||
@ -80,4 +81,9 @@ public final class Console implements IMessageRecipient {
|
||||
public void setReplyRecipient(final IMessageRecipient recipient) {
|
||||
this.messageRecipient.setReplyRecipient(recipient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHiddenFrom(Player player) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -289,6 +289,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isLastMessageReplyRecipient();
|
||||
|
||||
boolean isReplyToVanished();
|
||||
|
||||
BigDecimal getMinimumPayAmount();
|
||||
|
||||
boolean isPayExcludesIgnoreList();
|
||||
|
@ -1293,6 +1293,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("last-message-reply-recipient", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplyToVanished() {
|
||||
return config.getBoolean("last-message-reply-vanished", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMinimumPayAmount() {
|
||||
return new BigDecimal(config.getString("minimum-pay-amount", "0.001"));
|
||||
|
@ -567,6 +567,11 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return isAfk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHiddenFrom(Player player) {
|
||||
return !player.canSee(getBase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
|
@ -42,7 +42,8 @@ public class Commandr extends EssentialsCommand {
|
||||
|
||||
final IMessageRecipient target = messageSender.getReplyRecipient();
|
||||
// Check to make sure the sender does have a quick-reply recipient
|
||||
if (target == null) {
|
||||
if (target == null || (!ess.getSettings().isReplyToVanished() && sender.isPlayer() && target.isHiddenFrom(sender.getPlayer()))) {
|
||||
messageSender.setReplyRecipient(null);
|
||||
throw new Exception(tl("foreverAlone"));
|
||||
}
|
||||
messageSender.sendMessage(target, message);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.earth2me.essentials.messaging;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Represents an interface for message recipients.
|
||||
*/
|
||||
@ -113,4 +115,6 @@ public interface IMessageRecipient {
|
||||
return this == SUCCESS || this == SUCCESS_BUT_AFK;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isHiddenFrom(Player player);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.PrivateMessagePreSendEvent;
|
||||
import net.ess3.api.events.PrivateMessageSentEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@ -190,4 +191,9 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||
public void setReplyRecipient(final IMessageRecipient replyRecipient) {
|
||||
this.replyRecipient = new WeakReference<>(replyRecipient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHiddenFrom(Player player) {
|
||||
return parent.isHiddenFrom(player);
|
||||
}
|
||||
}
|
||||
|
@ -563,6 +563,11 @@ last-message-reply-recipient: true
|
||||
# Default is 180 (3 minutes)
|
||||
last-message-reply-recipient-timeout: 180
|
||||
|
||||
# Changes the default /reply functionality.
|
||||
# If true, /reply will not check if the person you're replying to has vanished.
|
||||
# If false, players will not be able to /reply to players who they can no longer see due to vanish.
|
||||
last-message-reply-vanished: false
|
||||
|
||||
# Toggles whether or not left clicking mobs with a milk bucket turns them into a baby.
|
||||
milk-bucket-easter-egg: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user