mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
Merge pull request #2454 from AgentTroll/patch-2415
Fixes #2415 - Command for last reply message option
This commit is contained in:
commit
4395245aab
@ -184,5 +184,9 @@ public interface IUser {
|
|||||||
|
|
||||||
void setPromptingClearConfirm(boolean prompt);
|
void setPromptingClearConfirm(boolean prompt);
|
||||||
|
|
||||||
|
boolean isLastMessageReplyRecipient();
|
||||||
|
|
||||||
|
void setLastMessageReplyRecipient(boolean enabled);
|
||||||
|
|
||||||
Map<User, BigDecimal> getConfirmingPayments();
|
Map<User, BigDecimal> getConfirmingPayments();
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
acceptingPay = _getAcceptingPay();
|
acceptingPay = _getAcceptingPay();
|
||||||
confirmPay = _getConfirmPay();
|
confirmPay = _getConfirmPay();
|
||||||
confirmClear = _getConfirmClear();
|
confirmClear = _getConfirmClear();
|
||||||
|
lastMessageReplyRecipient = _getLastMessageReplyRecipient();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal money;
|
private BigDecimal money;
|
||||||
@ -982,6 +983,22 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean lastMessageReplyRecipient;
|
||||||
|
|
||||||
|
private boolean _getLastMessageReplyRecipient() {
|
||||||
|
return config.getBoolean("last-message-reply-recipient", ess.getSettings().isLastMessageReplyRecipient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLastMessageReplyRecipient() {
|
||||||
|
return this.lastMessageReplyRecipient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastMessageReplyRecipient(boolean enabled) {
|
||||||
|
this.lastMessageReplyRecipient = enabled;
|
||||||
|
config.setProperty("last-message-reply-recipient", enabled);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getConfigUUID() {
|
public UUID getConfigUUID() {
|
||||||
return config.uuid;
|
return config.uuid;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.CommandSource;
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
public class Commandrtoggle extends EssentialsToggleCommand {
|
||||||
|
public Commandrtoggle() {
|
||||||
|
super("rtoggle", "essentials.rtoggle.others");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||||
|
handleToggleWithArgs(server, user, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
|
||||||
|
toggleOtherPlayers(server, sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void togglePlayer(CommandSource sender, User user, Boolean enabled) throws NotEnoughArgumentsException {
|
||||||
|
if (enabled == null) {
|
||||||
|
enabled = !user.isLastMessageReplyRecipient();
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setLastMessageReplyRecipient(enabled);
|
||||||
|
|
||||||
|
user.sendMessage(!enabled ? tl("replyLastRecipientDisabled") : tl("replyLastRecipientEnabled"));
|
||||||
|
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||||
|
sender.sendMessage(!enabled ? tl("replyLastRecipientDisabledFor", user.getDisplayName()) : tl("replyLastRecipientEnabledFor", user.getDisplayName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package com.earth2me.essentials.messaging;
|
package com.earth2me.essentials.messaging;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.IEssentials;
|
import com.earth2me.essentials.IEssentials;
|
||||||
import com.earth2me.essentials.IUser;
|
import com.earth2me.essentials.IUser;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a simple reusable implementation of {@link IMessageRecipient}. This class provides functionality for the following methods:
|
* Represents a simple reusable implementation of {@link IMessageRecipient}. This class provides functionality for the following methods:
|
||||||
* <ul>
|
* <ul>
|
||||||
@ -119,11 +119,13 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
|||||||
|
|
||||||
User user = getUser(this);
|
User user = getUser(this);
|
||||||
boolean afk = false;
|
boolean afk = false;
|
||||||
|
boolean isLastMessageReplyRecipient = ess.getSettings().isLastMessageReplyRecipient();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (user.isIgnoreMsg() && sender instanceof IUser && !((IUser) sender).isAuthorized("essentials.msgtoggle.bypass")) { // Don't ignore console and senders with permission
|
if (user.isIgnoreMsg() && sender instanceof IUser && !((IUser) sender).isAuthorized("essentials.msgtoggle.bypass")) { // Don't ignore console and senders with permission
|
||||||
return MessageResponse.MESSAGES_IGNORED;
|
return MessageResponse.MESSAGES_IGNORED;
|
||||||
}
|
}
|
||||||
afk = user.isAfk();
|
afk = user.isAfk();
|
||||||
|
isLastMessageReplyRecipient = user.isLastMessageReplyRecipient();
|
||||||
// Check whether this recipient ignores the sender, only if the sender is not the console.
|
// Check whether this recipient ignores the sender, only if the sender is not the console.
|
||||||
if (sender instanceof IUser && user.isIgnoredPlayer((IUser) sender)) {
|
if (sender instanceof IUser && user.isIgnoredPlayer((IUser) sender)) {
|
||||||
return MessageResponse.SENDER_IGNORED;
|
return MessageResponse.SENDER_IGNORED;
|
||||||
@ -132,7 +134,7 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
|||||||
// Display the formatted message to this recipient.
|
// Display the formatted message to this recipient.
|
||||||
sendMessage(tl("msgFormat", sender.getDisplayName(), tl("me"), message));
|
sendMessage(tl("msgFormat", sender.getDisplayName(), tl("me"), message));
|
||||||
|
|
||||||
if (ess.getSettings().isLastMessageReplyRecipient()) {
|
if (isLastMessageReplyRecipient) {
|
||||||
// If this recipient doesn't have a reply recipient, initiate by setting the first
|
// If this recipient doesn't have a reply recipient, initiate by setting the first
|
||||||
// message sender to this recipient's replyRecipient.
|
// message sender to this recipient's replyRecipient.
|
||||||
long timeout = ess.getSettings().getLastMessageReplyRecipientTimeout() * 1000;
|
long timeout = ess.getSettings().getLastMessageReplyRecipientTimeout() * 1000;
|
||||||
|
@ -480,11 +480,13 @@ mails-per-minute: 1000
|
|||||||
# Set to -1 to disable, and essentials.tempban.unlimited can be used to override.
|
# Set to -1 to disable, and essentials.tempban.unlimited can be used to override.
|
||||||
max-tempban-time: -1
|
max-tempban-time: -1
|
||||||
|
|
||||||
# Changes /reply functionality. If true, /r goes to the person you messaged last, otherwise the first person that messaged you.
|
# Changes the default /reply functionality. This can be changed on a per-player basis using /rtoggle.
|
||||||
|
# If true, /r goes to the person you messaged last, otherwise the first person that messaged you.
|
||||||
# If false, /r goes to the last person that messaged you.
|
# If false, /r goes to the last person that messaged you.
|
||||||
last-message-reply-recipient: true
|
last-message-reply-recipient: true
|
||||||
|
|
||||||
# If last-message-reply-recipient is true, this specifies the duration, in seconds, that would need to elapse for the
|
# If last-message-reply-recipient is enabled for a particular player,
|
||||||
|
# this specifies the duration, in seconds, that would need to elapse for the
|
||||||
# reply-recipient to update when receiving a message.
|
# reply-recipient to update when receiving a message.
|
||||||
# Default is 180 (3 minutes)
|
# Default is 180 (3 minutes)
|
||||||
last-message-reply-recipient-timeout: 180
|
last-message-reply-recipient-timeout: 180
|
||||||
|
@ -453,6 +453,10 @@ repairAlreadyFixed=\u00a74This item does not need repairing.
|
|||||||
repairEnchanted=\u00a74You are not allowed to repair enchanted items.
|
repairEnchanted=\u00a74You are not allowed to repair enchanted items.
|
||||||
repairInvalidType=\u00a74This item cannot be repaired.
|
repairInvalidType=\u00a74This item cannot be repaired.
|
||||||
repairNone=\u00a74There were no items that needed repairing.
|
repairNone=\u00a74There were no items that needed repairing.
|
||||||
|
replyLastRecipientDisabled=\u00a76Replying to last message recipient \u00a7cdisabled\u00a76.
|
||||||
|
replyLastRecipientDisabledFor=\u00a76Replying to last message recipient \u00a7cdisabled \u00a76for \u00a7c{0}\u00a76.
|
||||||
|
replyLastRecipientEnabled=\u00a76Replying to last message recipient \u00a7cenabled\u00a76.
|
||||||
|
replyLastRecipientEnabledFor=\u00a76Replying to last message recipient \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
|
||||||
requestAccepted=\u00a76Teleport request accepted.
|
requestAccepted=\u00a76Teleport request accepted.
|
||||||
requestAcceptedFrom=\u00a7c{0} \u00a76accepted your teleport request.
|
requestAcceptedFrom=\u00a7c{0} \u00a76accepted your teleport request.
|
||||||
requestDenied=\u00a76Teleport request denied.
|
requestDenied=\u00a76Teleport request denied.
|
||||||
|
@ -324,6 +324,10 @@ commands:
|
|||||||
description: Quickly reply to the last player to message you.
|
description: Quickly reply to the last player to message you.
|
||||||
usage: /<command> <message>
|
usage: /<command> <message>
|
||||||
aliases: [er,reply,ereply]
|
aliases: [er,reply,ereply]
|
||||||
|
rtoggle:
|
||||||
|
description: Change whether the recipient of the reply is last recipient or last sender
|
||||||
|
usage: /<command> [player] [on|off]
|
||||||
|
aliases: [ertoggle, replytoggle, ereplytoggle]
|
||||||
realname:
|
realname:
|
||||||
description: Displays the username of a user based on nick.
|
description: Displays the username of a user based on nick.
|
||||||
usage: /<command> <nickname>
|
usage: /<command> <nickname>
|
||||||
|
Loading…
Reference in New Issue
Block a user