Skip to content

Commit 764e6d2

Browse files
committed
introduce DialogReceiver
1 parent 367d1a9 commit 764e6d2

File tree

3 files changed

+108
-92
lines changed

3 files changed

+108
-92
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package minevalley.core.api.messaging;
2+
3+
import minevalley.core.api.messaging.clickable.ChatMenu;
4+
import minevalley.core.api.messaging.clickable.ClickableOption;
5+
import minevalley.core.api.messaging.instruction.Instruction;
6+
import minevalley.core.api.messaging.types.MessageType;
7+
import net.kyori.adventure.text.ComponentLike;
8+
import org.jetbrains.annotations.Contract;
9+
10+
import javax.annotation.Nonnull;
11+
import java.util.function.Consumer;
12+
13+
@SuppressWarnings("unused")
14+
public interface DialogReceiver {
15+
16+
/**
17+
* Sends a message to the receiver.
18+
*
19+
* @param message the message to send
20+
* @param menu the menu to send
21+
* @return the menu that was sent
22+
* @throws IllegalArgumentException if the message or menu is null
23+
*/
24+
@Nonnull
25+
@Contract("_, _ -> new")
26+
ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull ClickableOption... menu)
27+
throws IllegalArgumentException;
28+
29+
/**
30+
* Sends a message to the receiver.
31+
*
32+
* @param message the message to send
33+
* @param instruction the instruction to send
34+
* @param menu the menu to send
35+
* @return the menu that was sent
36+
* @throws IllegalArgumentException if the message, instruction or menu is null
37+
*/
38+
@Nonnull
39+
@Contract("_, _, _ -> new")
40+
ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull Instruction instruction,
41+
@Nonnull ClickableOption... menu) throws IllegalArgumentException;
42+
43+
/**
44+
* Sends a message to the receiver.
45+
*
46+
* @param type the type of message
47+
* @param message the message to send
48+
* @param menu the menu to send
49+
* @return the menu that was sent
50+
* @throws IllegalArgumentException if the type, message or menu is null
51+
*/
52+
@Nonnull
53+
@Contract("_, _, _ -> new")
54+
ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull ClickableOption... menu)
55+
throws IllegalArgumentException;
56+
57+
/**
58+
* Sends a message to the receiver.
59+
*
60+
* @param type the type of message
61+
* @param message the message to send
62+
* @param instruction the instruction to send
63+
* @param menu the menu to send
64+
* @return the menu that was sent
65+
* @throws IllegalArgumentException if the type, message, instruction or menu is null
66+
*/
67+
@Nonnull
68+
@Contract("_, _, _, _ -> new")
69+
ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull Instruction instruction,
70+
@Nonnull ClickableOption... menu) throws IllegalArgumentException;
71+
72+
/**
73+
* Sends a message to the receiver and waits for an input.
74+
*
75+
* @param text the text to send
76+
* @param callback the callback to call when the user inputs something
77+
* @throws IllegalArgumentException if the text or callback is null
78+
*/
79+
void input(@Nonnull String text, @Nonnull Consumer<String> callback) throws IllegalArgumentException;
80+
81+
/**
82+
* Sends a message to the receiver and waits for an input.
83+
*
84+
* @param text the text to send
85+
* @param instruction the instruction to send
86+
* @param callback the callback to call when the user inputs something
87+
* @throws IllegalArgumentException if the text, instruction or callback is null
88+
*/
89+
void input(@Nonnull String text, @Nonnull Instruction instruction, @Nonnull Consumer<String> callback)
90+
throws IllegalArgumentException;
91+
92+
/**
93+
* Checks if the receiver is currently in a chat input.
94+
*
95+
* @return true if the receiver is in a chat input, false otherwise
96+
*/
97+
@Contract(pure = true)
98+
boolean isInChatInput();
99+
100+
/**
101+
* Leaves the current chat input.
102+
* <p>
103+
* If the receiver is not in a chat input, this method does nothing.
104+
*/
105+
void leaveChatInput();
106+
}

src/main/java/minevalley/core/api/messaging/MessageReceiver.java

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,6 @@ public interface MessageReceiver {
9797
*/
9898
void sendMessage(@Nonnull ComponentLike message, @Nonnull Instruction instruction) throws IllegalArgumentException;
9999

100-
/**
101-
* Sends a message to the receiver.
102-
*
103-
* @param message the message to send
104-
* @param menu the menu to send
105-
* @return the menu that was sent
106-
* @throws IllegalArgumentException if the message or menu is null
107-
*/
108-
@Nonnull
109-
@Contract("_, _ -> new")
110-
ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull ClickableOption... menu)
111-
throws IllegalArgumentException;
112-
113-
/**
114-
* Sends a message to the receiver.
115-
*
116-
* @param message the message to send
117-
* @param instruction the instruction to send
118-
* @param menu the menu to send
119-
* @return the menu that was sent
120-
* @throws IllegalArgumentException if the message, instruction or menu is null
121-
*/
122-
@Nonnull
123-
@Contract("_, _, _ -> new")
124-
ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull Instruction instruction,
125-
@Nonnull ClickableOption... menu) throws IllegalArgumentException;
126-
127100
/**
128101
* Sends a message to the receiver.
129102
*
@@ -144,35 +117,6 @@ ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull Instruction instru
144117
void sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull Instruction instruction)
145118
throws IllegalArgumentException;
146119

147-
/**
148-
* Sends a message to the receiver.
149-
*
150-
* @param type the type of message
151-
* @param message the message to send
152-
* @param menu the menu to send
153-
* @return the menu that was sent
154-
* @throws IllegalArgumentException if the type, message or menu is null
155-
*/
156-
@Nonnull
157-
@Contract("_, _, _ -> new")
158-
ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull ClickableOption... menu)
159-
throws IllegalArgumentException;
160-
161-
/**
162-
* Sends a message to the receiver.
163-
*
164-
* @param type the type of message
165-
* @param message the message to send
166-
* @param instruction the instruction to send
167-
* @param menu the menu to send
168-
* @return the menu that was sent
169-
* @throws IllegalArgumentException if the type, message, instruction or menu is null
170-
*/
171-
@Nonnull
172-
@Contract("_, _, _, _ -> new")
173-
ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull Instruction instruction,
174-
@Nonnull ClickableOption... menu) throws IllegalArgumentException;
175-
176120
/**
177121
* Shows a title to the receiver.
178122
*

src/main/java/minevalley/core/api/users/OnlineUser.java

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import minevalley.core.api.audio.SoundReceiver;
44
import minevalley.core.api.economy.AccountUser;
55
import minevalley.core.api.economy.BankAccount;
6+
import minevalley.core.api.messaging.DialogReceiver;
67
import minevalley.core.api.messaging.MessageReceiver;
78
import minevalley.core.api.messaging.instruction.Instruction;
89
import minevalley.core.api.regions.utils.PlayerLocation;
@@ -30,7 +31,7 @@
3031
import java.util.function.Consumer;
3132

3233
@SuppressWarnings("unused")
33-
public interface OnlineUser extends User, MessageReceiver, SoundReceiver {
34+
public interface OnlineUser extends User, DialogReceiver, MessageReceiver, SoundReceiver {
3435

3536
/**
3637
* Gets the player object of this user.
@@ -82,41 +83,6 @@ default void closeInventory() {
8283
player().closeInventory();
8384
}
8485

85-
/**
86-
* Sends a message to the receiver and waits for an input.
87-
*
88-
* @param text the text to send
89-
* @param callback the callback to call when the user inputs something
90-
* @throws IllegalArgumentException if the text or callback is null
91-
*/
92-
void input(@Nonnull String text, @Nonnull Consumer<String> callback) throws IllegalArgumentException;
93-
94-
/**
95-
* Sends a message to the receiver and waits for an input.
96-
*
97-
* @param text the text to send
98-
* @param instruction the instruction to send
99-
* @param callback the callback to call when the user inputs something
100-
* @throws IllegalArgumentException if the text, instruction or callback is null
101-
*/
102-
void input(@Nonnull String text, @Nonnull Instruction instruction, @Nonnull Consumer<String> callback)
103-
throws IllegalArgumentException;
104-
105-
/**
106-
* Checks if the receiver is currently in a chat input.
107-
*
108-
* @return true if the receiver is in a chat input, false otherwise
109-
*/
110-
@Contract(pure = true)
111-
boolean isInChatInput();
112-
113-
/**
114-
* Leaves the current chat input.
115-
* <p>
116-
* If the receiver is not in a chat input, this method does nothing.
117-
*/
118-
void leaveChatInput();
119-
12086
/**
12187
* Gets whether this user is currently logged in via labymod.
12288
* <br>

0 commit comments

Comments
 (0)