From 846cbc0c6cdd4135e835317ec8591fbe7aee67ed Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Thu, 2 May 2024 20:44:09 -0700 Subject: [PATCH] Add optional parameter so specify private message sender name --- .../stendhal/server/entity/RPEntity.java | 26 ++++++++++++++ .../stendhal/server/entity/player/Player.java | 35 ++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/games/stendhal/server/entity/RPEntity.java b/src/games/stendhal/server/entity/RPEntity.java index 37ddf1c33a9..af99db26778 100644 --- a/src/games/stendhal/server/entity/RPEntity.java +++ b/src/games/stendhal/server/entity/RPEntity.java @@ -2705,6 +2705,32 @@ public void sendPrivateText(final NotificationType type, final String text) { // does nothing in this implementation. } + /** + * Sends a message that only this entity can read. + * + * @param sender + * Name of entity sending message. + * @param text + * Message contents. + */ + public void sendPrivateText(final String sender, final String text) { + // does nothing in this implementation. + } + + /** + * Sends a message that only this entity can read. + * + * @param type + * NotificationType. + * @param sender + * Name of entity sending message. + * @param text + * Message contents. + */ + public void sendPrivateText(final NotificationType type, final String sender, final String text) { + // does nothing in this implementation. + } + /** * Retrieves total ATK value of held weapons. */ diff --git a/src/games/stendhal/server/entity/player/Player.java b/src/games/stendhal/server/entity/player/Player.java index 97261ed68e5..8398648728b 100644 --- a/src/games/stendhal/server/entity/player/Player.java +++ b/src/games/stendhal/server/entity/player/Player.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2023 - Arianne * + * (C) Copyright 2003-2024 - Arianne * *************************************************************************** *************************************************************************** * * @@ -1032,6 +1032,39 @@ public void sendPrivateText(final NotificationType type, final String text) { this.notifyWorldAboutChanges(); } + /** + * Sends a message that only this entity can read. + * + * @param sender + * Name of entity sending message. + * @param text + * Message contents. + */ + @Override + public void sendPrivateText(final String sender, final String text) { + sendPrivateText(getServerNotificationType(clientVersion), sender, text); + } + + /** + * Sends a message that only this entity can read. + * + * @param type + * NotificationType. + * @param sender + * Name of entity sending message. + * @param text + * Message contents. + */ + @Override + public void sendPrivateText(final NotificationType type, final String sender, final String text) { + /* + RPEvent event = new PrivateTextEvent(type, sender, text); + this.addEvent(event); + this.notifyWorldAboutChanges(); + */ + sendPrivateText(type, sender + " tells you: " + text); + } + /** * Sets the name of the last player who privately talked to this player * using the /tell command. It needs to be stored non-persistently so that