Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
a1681255
Commit
a1681255
authored
Jun 24, 2022
by
KingRainbow44
Browse files
Replace `CommandResponseEvent` with `ReceiveCommandFeedbackEvent`
parent
74151c20
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/CommandHandler.java
View file @
a1681255
...
@@ -3,6 +3,7 @@ package emu.grasscutter.command;
...
@@ -3,6 +3,7 @@ package emu.grasscutter.command;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.event.game.CommandResponseEvent
;
import
emu.grasscutter.server.event.game.CommandResponseEvent
;
import
emu.grasscutter.server.event.game.ReceiveCommandFeedbackEvent
;
import
emu.grasscutter.server.event.types.ServerEvent
;
import
emu.grasscutter.server.event.types.ServerEvent
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
...
@@ -17,15 +18,21 @@ public interface CommandHandler {
...
@@ -17,15 +18,21 @@ public interface CommandHandler {
* @param message The message to send.
* @param message The message to send.
*/
*/
static
void
sendMessage
(
Player
player
,
String
message
)
{
static
void
sendMessage
(
Player
player
,
String
message
)
{
// Call command feedback event.
ReceiveCommandFeedbackEvent
event
=
new
ReceiveCommandFeedbackEvent
(
player
,
message
);
event
.
call
();
if
(
event
.
isCanceled
())
{
// If event is not cancelled, continue.
return
;
}
// Send message to target.
if
(
player
==
null
)
{
if
(
player
==
null
)
{
Grasscutter
.
getLogger
().
info
(
m
essage
);
Grasscutter
.
getLogger
().
info
(
event
.
getM
essage
()
);
}
else
{
}
else
{
player
.
dropMessage
(
m
essage
);
player
.
dropMessage
(
event
.
getM
essage
()
);
}
}
CommandResponseEvent
event
=
new
CommandResponseEvent
(
ServerEvent
.
Type
.
GAME
,
player
,
message
);
event
.
call
();
}
}
static
void
sendTranslatedMessage
(
Player
player
,
String
messageKey
,
Object
...
args
)
{
static
void
sendTranslatedMessage
(
Player
player
,
String
messageKey
,
Object
...
args
)
{
sendMessage
(
player
,
translate
(
player
,
messageKey
,
args
));
sendMessage
(
player
,
translate
(
player
,
messageKey
,
args
));
}
}
...
...
src/main/java/emu/grasscutter/server/event/game/CommandResponseEvent.java
View file @
a1681255
package
emu.grasscutter.server.event.game
;
package
emu.grasscutter.server.event.game
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.event.types.GameEvent
;
import
emu.grasscutter.server.event.types.ServerEvent
;
import
emu.grasscutter.server.event.types.ServerEvent
;
/**
* @deprecated Will be removed in 1.2.3-dev or 1.3.0.
*/
@Deprecated
(
since
=
"1.2.2-dev"
,
forRemoval
=
true
)
public
class
CommandResponseEvent
extends
ServerEvent
{
public
class
CommandResponseEvent
extends
ServerEvent
{
private
String
message
;
private
String
message
;
private
Player
player
;
private
Player
player
;
...
...
src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java
0 → 100644
View file @
a1681255
package
emu.grasscutter.server.event.game
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.event.Cancellable
;
import
emu.grasscutter.server.event.types.ServerEvent
;
import
javax.annotation.Nullable
;
public
final
class
ReceiveCommandFeedbackEvent
extends
ServerEvent
implements
Cancellable
{
@Nullable
private
final
Player
player
;
private
String
message
;
public
ReceiveCommandFeedbackEvent
(
@Nullable
Player
player
,
String
message
)
{
super
(
Type
.
GAME
);
this
.
player
=
player
;
this
.
message
=
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getMessage
()
{
return
this
.
message
;
}
@Nullable
public
Player
getPlayer
()
{
return
this
.
player
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment