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
37c2ee5e
Commit
37c2ee5e
authored
May 05, 2022
by
AnimeGitB
Committed by
Melledy
May 05, 2022
Browse files
Command Targeting overhaul fixes
parent
d8b2e787
Changes
13
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/CommandMap.java
View file @
37c2ee5e
...
@@ -12,7 +12,7 @@ import java.util.*;
...
@@ -12,7 +12,7 @@ import java.util.*;
public
final
class
CommandMap
{
public
final
class
CommandMap
{
private
final
Map
<
String
,
CommandHandler
>
commands
=
new
HashMap
<>();
private
final
Map
<
String
,
CommandHandler
>
commands
=
new
HashMap
<>();
private
final
Map
<
String
,
Command
>
annotations
=
new
HashMap
<>();
private
final
Map
<
String
,
Command
>
annotations
=
new
HashMap
<>();
private
final
Map
<
String
,
Play
er
>
targetPlayers
=
new
HashMap
<>();
private
final
Map
<
String
,
Integ
er
>
targetPlayer
Id
s
=
new
HashMap
<>();
private
static
final
String
consoleId
=
"console"
;
private
static
final
String
consoleId
=
"console"
;
public
CommandMap
()
{
public
CommandMap
()
{
this
(
false
);
this
(
false
);
...
@@ -122,24 +122,29 @@ public final class CommandMap {
...
@@ -122,24 +122,29 @@ public final class CommandMap {
String
targetUidStr
=
null
;
String
targetUidStr
=
null
;
if
(
label
.
startsWith
(
"@"
))
{
// @[UID]
if
(
label
.
startsWith
(
"@"
))
{
// @[UID]
targetUidStr
=
label
.
substring
(
1
);
targetUidStr
=
label
.
substring
(
1
);
}
else
if
(
label
==
"target"
)
{
// target [[@]UID]
}
else
if
(
label
.
equalsIgnoreCase
(
"target"
))
{
// target [[@]UID]
if
(
args
.
size
()
>
0
)
{
targetUidStr
=
args
.
get
(
0
);
targetUidStr
=
args
.
get
(
0
);
if
(
targetUidStr
.
startsWith
(
"@"
))
{
if
(
targetUidStr
.
startsWith
(
"@"
))
{
targetUidStr
=
targetUidStr
.
substring
(
1
);
targetUidStr
=
targetUidStr
.
substring
(
1
);
}
}
}
else
{
targetUidStr
=
""
;
}
}
}
if
(
targetUidStr
==
""
)
{
// Clears default targetPlayer
if
(
targetUidStr
!=
null
)
{
targetPlayers
.
remove
(
playerId
);
if
(
targetUidStr
.
equals
(
""
))
{
// Clears default targetPlayer
targetPlayerIds
.
remove
(
playerId
);
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Target_cleared
);
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Target_cleared
);
return
;
return
;
}
else
if
(
targetUidStr
!=
null
)
{
// Sets default targetPlayer to the UID given
}
else
{
// Sets default targetPlayer to the UID given
try
{
try
{
int
uid
=
Integer
.
parseInt
(
targetUidStr
);
int
uid
=
Integer
.
parseInt
(
targetUidStr
);
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
uid
);
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
uid
);
if
(
targetPlayer
==
null
)
{
if
(
targetPlayer
==
null
)
{
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Player_not_found_or_offline
);
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Player_not_found_or_offline
);
}
else
{
}
else
{
targetPlayers
.
put
(
playerId
,
targetPlayer
);
targetPlayer
Id
s
.
put
(
playerId
,
uid
);
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Target_set
.
replace
(
"{uid}"
,
targetUidStr
));
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Target_set
.
replace
(
"{uid}"
,
targetUidStr
));
}
}
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
...
@@ -147,6 +152,7 @@ public final class CommandMap {
...
@@ -147,6 +152,7 @@ public final class CommandMap {
}
}
return
;
return
;
}
}
}
// Get command handler.
// Get command handler.
CommandHandler
handler
=
this
.
commands
.
get
(
label
);
CommandHandler
handler
=
this
.
commands
.
get
(
label
);
...
@@ -178,7 +184,18 @@ public final class CommandMap {
...
@@ -178,7 +184,18 @@ public final class CommandMap {
}
}
// If there's still no targetPlayer at this point, use previously-set target
// If there's still no targetPlayer at this point, use previously-set target
if
(
targetPlayer
==
null
)
{
if
(
targetPlayer
==
null
)
{
targetPlayer
=
targetPlayers
.
getOrDefault
(
playerId
,
null
);
if
(
targetPlayerIds
.
containsKey
(
playerId
))
{
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
targetPlayerIds
.
get
(
playerId
));
// We check every time in case the target goes offline after being targeted
if
(
targetPlayer
==
null
)
{
CommandHandler
.
sendMessage
(
player
,
Grasscutter
.
getLanguage
().
Player_not_found_or_offline
);
return
;
}
}
else
{
// If there's still no targetPlayer at this point, use local player
if
(
targetPlayer
==
null
)
{
targetPlayer
=
player
;
}
}
}
}
// Check for permission.
// Check for permission.
...
...
src/main/java/emu/grasscutter/command/commands/ClearCommand.java
View file @
37c2ee5e
...
@@ -32,7 +32,7 @@ public final class ClearCommand implements CommandHandler {
...
@@ -32,7 +32,7 @@ public final class ClearCommand implements CommandHandler {
.
filter
(
item
->
item
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
.
filter
(
item
->
item
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
.
filter
(
item
->
!
item
.
isLocked
()
&&
!
item
.
isEquipped
())
.
filter
(
item
->
!
item
.
isLocked
()
&&
!
item
.
isEquipped
())
.
forEach
(
item
->
playerInventory
.
removeItem
(
item
,
item
.
getCount
()));
.
forEach
(
item
->
playerInventory
.
removeItem
(
item
,
item
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_weapons
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_weapons
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
}
}
case
"art"
->
{
case
"art"
->
{
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
...
@@ -40,7 +40,7 @@ public final class ClearCommand implements CommandHandler {
...
@@ -40,7 +40,7 @@ public final class ClearCommand implements CommandHandler {
.
filter
(
item
->
item
.
getLevel
()
==
1
&&
item
.
getExp
()
==
0
)
.
filter
(
item
->
item
.
getLevel
()
==
1
&&
item
.
getExp
()
==
0
)
.
filter
(
item
->
!
item
.
isLocked
()
&&
!
item
.
isEquipped
())
.
filter
(
item
->
!
item
.
isLocked
()
&&
!
item
.
isEquipped
())
.
forEach
(
item
->
playerInventory
.
removeItem
(
item
,
item
.
getCount
()));
.
forEach
(
item
->
playerInventory
.
removeItem
(
item
,
item
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
}
}
case
"mat"
->
{
case
"mat"
->
{
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
...
@@ -48,7 +48,7 @@ public final class ClearCommand implements CommandHandler {
...
@@ -48,7 +48,7 @@ public final class ClearCommand implements CommandHandler {
.
filter
(
item
->
item
.
getLevel
()
==
1
&&
item
.
getExp
()
==
0
)
.
filter
(
item
->
item
.
getLevel
()
==
1
&&
item
.
getExp
()
==
0
)
.
filter
(
item
->
!
item
.
isLocked
()
&&
!
item
.
isEquipped
())
.
filter
(
item
->
!
item
.
isLocked
()
&&
!
item
.
isEquipped
())
.
forEach
(
item
->
playerInventory
.
removeItem
(
item
,
item
.
getCount
()));
.
forEach
(
item
->
playerInventory
.
removeItem
(
item
,
item
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
}
}
case
"all"
->
{
case
"all"
->
{
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
...
@@ -56,34 +56,34 @@ public final class ClearCommand implements CommandHandler {
...
@@ -56,34 +56,34 @@ public final class ClearCommand implements CommandHandler {
.
filter
(
item1
->
item1
.
getLevel
()
==
1
&&
item1
.
getExp
()
==
0
)
.
filter
(
item1
->
item1
.
getLevel
()
==
1
&&
item1
.
getExp
()
==
0
)
.
filter
(
item1
->
!
item1
.
isLocked
()
&&
!
item1
.
isEquipped
())
.
filter
(
item1
->
!
item1
.
isLocked
()
&&
!
item1
.
isEquipped
())
.
forEach
(
item1
->
playerInventory
.
removeItem
(
item1
,
item1
.
getCount
()));
.
forEach
(
item1
->
playerInventory
.
removeItem
(
item1
,
item1
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item2
->
item2
.
getItemType
()
==
ItemType
.
ITEM_MATERIAL
)
.
filter
(
item2
->
item2
.
getItemType
()
==
ItemType
.
ITEM_MATERIAL
)
.
filter
(
item2
->
!
item2
.
isLocked
()
&&
!
item2
.
isEquipped
())
.
filter
(
item2
->
!
item2
.
isLocked
()
&&
!
item2
.
isEquipped
())
.
forEach
(
item2
->
playerInventory
.
removeItem
(
item2
,
item2
.
getCount
()));
.
forEach
(
item2
->
playerInventory
.
removeItem
(
item2
,
item2
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item3
->
item3
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
.
filter
(
item3
->
item3
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
.
filter
(
item3
->
item3
.
getLevel
()
==
1
&&
item3
.
getExp
()
==
0
)
.
filter
(
item3
->
item3
.
getLevel
()
==
1
&&
item3
.
getExp
()
==
0
)
.
filter
(
item3
->
!
item3
.
isLocked
()
&&
!
item3
.
isEquipped
())
.
filter
(
item3
->
!
item3
.
isLocked
()
&&
!
item3
.
isEquipped
())
.
forEach
(
item3
->
playerInventory
.
removeItem
(
item3
,
item3
.
getCount
()));
.
forEach
(
item3
->
playerInventory
.
removeItem
(
item3
,
item3
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_artifacts
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item4
->
item4
.
getItemType
()
==
ItemType
.
ITEM_FURNITURE
)
.
filter
(
item4
->
item4
.
getItemType
()
==
ItemType
.
ITEM_FURNITURE
)
.
filter
(
item4
->
!
item4
.
isLocked
()
&&
!
item4
.
isEquipped
())
.
filter
(
item4
->
!
item4
.
isLocked
()
&&
!
item4
.
isEquipped
())
.
forEach
(
item4
->
playerInventory
.
removeItem
(
item4
,
item4
.
getCount
()));
.
forEach
(
item4
->
playerInventory
.
removeItem
(
item4
,
item4
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_furniture
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_furniture
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item5
->
item5
.
getItemType
()
==
ItemType
.
ITEM_DISPLAY
)
.
filter
(
item5
->
item5
.
getItemType
()
==
ItemType
.
ITEM_DISPLAY
)
.
filter
(
item5
->
!
item5
.
isLocked
()
&&
!
item5
.
isEquipped
())
.
filter
(
item5
->
!
item5
.
isLocked
()
&&
!
item5
.
isEquipped
())
.
forEach
(
item5
->
playerInventory
.
removeItem
(
item5
,
item5
.
getCount
()));
.
forEach
(
item5
->
playerInventory
.
removeItem
(
item5
,
item5
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_displays
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_displays
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
playerInventory
.
getItems
().
values
().
stream
()
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item6
->
item6
.
getItemType
()
==
ItemType
.
ITEM_VIRTUAL
)
.
filter
(
item6
->
item6
.
getItemType
()
==
ItemType
.
ITEM_VIRTUAL
)
.
filter
(
item6
->
!
item6
.
isLocked
()
&&
!
item6
.
isEquipped
())
.
filter
(
item6
->
!
item6
.
isLocked
()
&&
!
item6
.
isEquipped
())
.
forEach
(
item6
->
playerInventory
.
removeItem
(
item6
,
item6
.
getCount
()));
.
forEach
(
item6
->
playerInventory
.
removeItem
(
item6
,
item6
.
getCount
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_virtuals
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_virtuals
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Clear_everything
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Clear_everything
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
}
}
}
}
}
}
...
...
src/main/java/emu/grasscutter/command/commands/CoopCommand.java
View file @
37c2ee5e
...
@@ -20,17 +20,21 @@ public final class CoopCommand implements CommandHandler {
...
@@ -20,17 +20,21 @@ public final class CoopCommand implements CommandHandler {
Player
host
=
sender
;
Player
host
=
sender
;
switch
(
args
.
size
())
{
switch
(
args
.
size
())
{
case
0
:
// Summon target to self
case
0
:
// Summon target to self
if
(
sender
==
null
)
{
// Console doesn't have a self to summon to
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Coop_usage
);
return
;
}
break
;
break
;
case
1
:
// Summon target to argument
case
1
:
// Summon target to argument
try
{
try
{
int
hostId
=
Integer
.
parseInt
(
args
.
get
(
1
));
int
hostId
=
Integer
.
parseInt
(
args
.
get
(
0
));
host
=
send
er
.
getServer
().
getPlayerByUid
(
hostId
);
host
=
Grasscutt
er
.
get
Game
Server
().
getPlayerByUid
(
hostId
);
if
(
host
==
null
)
{
if
(
host
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Player_is_offline
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Player_is_offline
);
return
;
return
;
}
}
break
;
break
;
}
catch
(
Exception
e
)
{
}
catch
(
NumberFormat
Exception
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Invalid_playerId
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Invalid_playerId
);
return
;
return
;
}
}
...
@@ -39,12 +43,12 @@ public final class CoopCommand implements CommandHandler {
...
@@ -39,12 +43,12 @@ public final class CoopCommand implements CommandHandler {
return
;
return
;
}
}
// There's no target==host check but this just places them in multiplayer in their own world which seems fine.
if
(
targetPlayer
.
isInMultiplayer
())
{
if
(
targetPlayer
.
isInMultiplayer
())
{
send
er
.
getServer
().
getMultiplayerManager
().
leaveCoop
(
targetPlayer
);
targetPlay
er
.
getServer
().
getMultiplayerManager
().
leaveCoop
(
targetPlayer
);
}
}
sender
.
getServer
().
getMultiplayerManager
().
applyEnterMp
(
targetPlayer
,
host
.
getUid
());
host
.
getServer
().
getMultiplayerManager
().
applyEnterMp
(
targetPlayer
,
host
.
getUid
());
send
er
.
getServer
().
getMultiplayerManager
().
applyEnterMpReply
(
host
,
targetPlayer
.
getUid
(),
true
);
targetPlay
er
.
getServer
().
getMultiplayerManager
().
applyEnterMpReply
(
host
,
targetPlayer
.
getUid
(),
true
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Coop_success
.
replace
(
"{host}"
,
host
.
getNickname
()).
replace
(
"{target}"
,
targetPlayer
.
getNickname
()));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Coop_success
.
replace
(
"{host}"
,
host
.
getNickname
()).
replace
(
"{target}"
,
targetPlayer
.
getNickname
()));
}
}
}
}
src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java
View file @
37c2ee5e
...
@@ -37,7 +37,7 @@ public final class GiveAllCommand implements CommandHandler {
...
@@ -37,7 +37,7 @@ public final class GiveAllCommand implements CommandHandler {
}
}
break
;
break
;
default
:
// invalid
default
:
// invalid
CommandHandler
.
sendMessage
(
null
,
Grasscutter
.
getLanguage
().
GiveAll_usage
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
GiveAll_usage
);
return
;
return
;
}
}
...
...
src/main/java/emu/grasscutter/command/commands/GiveArtifactCommand.java
View file @
37c2ee5e
...
@@ -52,7 +52,7 @@ public final class GiveArtifactCommand implements CommandHandler {
...
@@ -52,7 +52,7 @@ public final class GiveArtifactCommand implements CommandHandler {
int
level
=
1
;
int
level
=
1
;
try
{
try
{
int
last
=
Integer
.
parseInt
(
args
.
get
(
args
.
size
()-
1
));
int
last
=
Integer
.
parseInt
(
args
.
get
(
args
.
size
()-
1
));
if
(
last
>
0
&&
last
<
2
1
)
{
// Luckily appendPropIds aren't in the range of [1,2
0
]
if
(
last
>
0
&&
last
<
2
2
)
{
// Luckily appendPropIds aren't in the range of [1,2
1
]
level
=
last
;
level
=
last
;
args
.
remove
(
args
.
size
()-
1
);
args
.
remove
(
args
.
size
()-
1
);
}
}
...
...
src/main/java/emu/grasscutter/command/commands/GodModeCommand.java
View file @
37c2ee5e
...
@@ -35,6 +35,6 @@ public final class GodModeCommand implements CommandHandler {
...
@@ -35,6 +35,6 @@ public final class GodModeCommand implements CommandHandler {
}
}
targetPlayer
.
setGodmode
(
enabled
);
targetPlayer
.
setGodmode
(
enabled
);
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Godmode_status
.
replace
(
"{status}"
,
(
enabled
?
Grasscutter
.
getLanguage
().
Enabled
:
Grasscutter
.
getLanguage
().
Disabled
)).
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Godmode_status
.
replace
(
"{status}"
,
(
enabled
?
Grasscutter
.
getLanguage
().
Enabled
:
Grasscutter
.
getLanguage
().
Disabled
)).
replace
(
"{name}"
,
targetPlayer
.
getNickname
()));
}
}
}
}
src/main/java/emu/grasscutter/command/commands/PositionCommand.java
View file @
37c2ee5e
...
@@ -20,6 +20,6 @@ public final class PositionCommand implements CommandHandler {
...
@@ -20,6 +20,6 @@ public final class PositionCommand implements CommandHandler {
}
}
Position
pos
=
targetPlayer
.
getPos
();
Position
pos
=
targetPlayer
.
getPos
();
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
Position_message
.
replace
(
"{x}"
,
Float
.
toString
(
pos
.
getX
())).
replace
(
"{y}"
,
Float
.
toString
(
pos
.
getY
())).
replace
(
"{z}"
,
Float
.
toString
(
pos
.
getZ
())).
replace
(
"{id}"
,
Integer
.
toString
(
send
er
.
getSceneId
())));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
Position_message
.
replace
(
"{x}"
,
Float
.
toString
(
pos
.
getX
())).
replace
(
"{y}"
,
Float
.
toString
(
pos
.
getY
())).
replace
(
"{z}"
,
Float
.
toString
(
pos
.
getZ
())).
replace
(
"{id}"
,
Integer
.
toString
(
targetPlay
er
.
getSceneId
())));
}
}
}
}
src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java
View file @
37c2ee5e
...
@@ -23,7 +23,7 @@ public final class ResetConstCommand implements CommandHandler {
...
@@ -23,7 +23,7 @@ public final class ResetConstCommand implements CommandHandler {
if
(
args
.
size
()
>
0
&&
args
.
get
(
0
).
equalsIgnoreCase
(
"all"
))
{
if
(
args
.
size
()
>
0
&&
args
.
get
(
0
).
equalsIgnoreCase
(
"all"
))
{
targetPlayer
.
getAvatars
().
forEach
(
this
::
resetConstellation
);
targetPlayer
.
getAvatars
().
forEach
(
this
::
resetConstellation
);
targetPlayer
.
dropMessage
(
Grasscutter
.
getLanguage
().
ResetConst_reset_all
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
ResetConst_reset_all
);
}
else
{
}
else
{
EntityAvatar
entity
=
targetPlayer
.
getTeamManager
().
getCurrentAvatarEntity
();
EntityAvatar
entity
=
targetPlayer
.
getTeamManager
().
getCurrentAvatarEntity
();
if
(
entity
==
null
)
{
if
(
entity
==
null
)
{
...
@@ -33,7 +33,7 @@ public final class ResetConstCommand implements CommandHandler {
...
@@ -33,7 +33,7 @@ public final class ResetConstCommand implements CommandHandler {
Avatar
avatar
=
entity
.
getAvatar
();
Avatar
avatar
=
entity
.
getAvatar
();
this
.
resetConstellation
(
avatar
);
this
.
resetConstellation
(
avatar
);
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
ResetConst_reset_all_done
.
replace
(
"{name}"
,
avatar
.
getAvatarData
().
getName
()));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
ResetConst_reset_all_done
.
replace
(
"{name}"
,
avatar
.
getAvatarData
().
getName
()));
}
}
}
}
...
...
src/main/java/emu/grasscutter/command/commands/RestartCommand.java
View file @
37c2ee5e
...
@@ -11,6 +11,9 @@ public final class RestartCommand implements CommandHandler {
...
@@ -11,6 +11,9 @@ public final class RestartCommand implements CommandHandler {
@Override
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
if
(
sender
==
null
)
{
return
;
}
sender
.
getSession
().
close
();
sender
.
getSession
().
close
();
}
}
}
}
src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java
View file @
37c2ee5e
...
@@ -27,7 +27,7 @@ public final class SetWorldLevelCommand implements CommandHandler {
...
@@ -27,7 +27,7 @@ public final class SetWorldLevelCommand implements CommandHandler {
try
{
try
{
int
level
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
level
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
level
>
8
||
level
<
0
)
{
if
(
level
>
8
||
level
<
0
)
{
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
SetWorldLevel_world_level_must_between_0_and_8
);
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
SetWorldLevel_world_level_must_between_0_and_8
);
return
;
return
;
}
}
...
@@ -35,7 +35,7 @@ public final class SetWorldLevelCommand implements CommandHandler {
...
@@ -35,7 +35,7 @@ public final class SetWorldLevelCommand implements CommandHandler {
targetPlayer
.
getWorld
().
setWorldLevel
(
level
);
targetPlayer
.
getWorld
().
setWorldLevel
(
level
);
targetPlayer
.
setWorldLevel
(
level
);
targetPlayer
.
setWorldLevel
(
level
);
se
nder
.
drop
Message
(
Grasscutter
.
getLanguage
().
SetWorldLevel_set_world_level
.
replace
(
"{level}"
,
Integer
.
toString
(
level
)));
CommandHa
nd
l
er
.
send
Message
(
sender
,
Grasscutter
.
getLanguage
().
SetWorldLevel_set_world_level
.
replace
(
"{level}"
,
Integer
.
toString
(
level
)));
}
catch
(
NumberFormatException
ignored
)
{
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
null
,
Grasscutter
.
getLanguage
().
SetWorldLevel_invalid_world_level
);
CommandHandler
.
sendMessage
(
null
,
Grasscutter
.
getLanguage
().
SetWorldLevel_invalid_world_level
);
}
}
...
...
src/main/java/emu/grasscutter/command/commands/TalentCommand.java
View file @
37c2ee5e
...
@@ -56,7 +56,7 @@ public final class TalentCommand implements CommandHandler {
...
@@ -56,7 +56,7 @@ public final class TalentCommand implements CommandHandler {
return
;
return
;
}
}
EntityAvatar
entity
=
send
er
.
getTeamManager
().
getCurrentAvatarEntity
();
EntityAvatar
entity
=
targetPlay
er
.
getTeamManager
().
getCurrentAvatarEntity
();
Avatar
avatar
=
entity
.
getAvatar
();
Avatar
avatar
=
entity
.
getAvatar
();
String
cmdSwitch
=
args
.
get
(
0
);
String
cmdSwitch
=
args
.
get
(
0
);
switch
(
cmdSwitch
)
{
switch
(
cmdSwitch
)
{
...
...
src/main/java/emu/grasscutter/command/commands/TeleportCommand.java
View file @
37c2ee5e
...
@@ -46,8 +46,8 @@ public final class TeleportCommand implements CommandHandler {
...
@@ -46,8 +46,8 @@ public final class TeleportCommand implements CommandHandler {
case
3
:
case
3
:
try
{
try
{
x
=
parseRelative
(
args
.
get
(
0
),
x
);
x
=
parseRelative
(
args
.
get
(
0
),
x
);
y
=
parseRelative
(
args
.
get
(
0
),
y
);
y
=
parseRelative
(
args
.
get
(
1
),
y
);
z
=
parseRelative
(
args
.
get
(
0
),
z
);
z
=
parseRelative
(
args
.
get
(
2
),
z
);
}
catch
(
NumberFormatException
ignored
)
{
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Teleport_invalid_position
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Teleport_invalid_position
);
}
}
...
...
src/main/java/emu/grasscutter/command/commands/WeatherCommand.java
View file @
37c2ee5e
...
@@ -43,9 +43,9 @@ public final class WeatherCommand implements CommandHandler {
...
@@ -43,9 +43,9 @@ public final class WeatherCommand implements CommandHandler {
ClimateType
climate
=
ClimateType
.
getTypeByValue
(
climateId
);
ClimateType
climate
=
ClimateType
.
getTypeByValue
(
climateId
);
send
er
.
getScene
().
setWeather
(
weatherId
);
targetPlay
er
.
getScene
().
setWeather
(
weatherId
);
send
er
.
getScene
().
setClimate
(
climate
);
targetPlay
er
.
getScene
().
setClimate
(
climate
);
send
er
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
send
er
));
targetPlay
er
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
targetPlay
er
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Weather_message
.
replace
(
"{weatherId}"
,
Integer
.
toString
(
weatherId
)).
replace
(
"{climateId}"
,
Integer
.
toString
(
climateId
)));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Weather_message
.
replace
(
"{weatherId}"
,
Integer
.
toString
(
weatherId
)).
replace
(
"{climateId}"
,
Integer
.
toString
(
climateId
)));
}
}
...
...
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