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
b3a91700
Commit
b3a91700
authored
May 06, 2022
by
KingRainbow44
Browse files
Convert to the superior language system. (pt. 3)
parent
c0b1ec1b
Changes
17
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/CoopCommand.java
View file @
b3a91700
...
...
@@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"coop"
,
usage
=
"coop [host UID]"
,
description
=
"Forces someone to join the world of others"
,
permission
=
"server.coop"
)
public
final
class
CoopCommand
implements
CommandHandler
{
...
...
@@ -20,26 +22,25 @@ public final class CoopCommand implements CommandHandler {
Player
host
=
sender
;
switch
(
args
.
size
())
{
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
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.coop.usage"
));
if
(
sender
==
null
)
// Console doesn't have a self to summon to
return
;
}
break
;
case
1
:
// Summon target to argument
try
{
int
hostId
=
Integer
.
parseInt
(
args
.
get
(
0
));
host
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
hostId
);
if
(
host
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
P
layer_
is_
offline
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.execution.p
layer_offline
_error"
)
);
return
;
}
break
;
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_playerId
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.execution.uid_error"
)
);
return
;
}
default
:
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
C
oop
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.c
oop
.
usage
"
)
);
return
;
}
...
...
@@ -49,6 +50,6 @@ public final class CoopCommand implements CommandHandler {
}
host
.
getServer
().
getMultiplayerManager
().
applyEnterMp
(
targetPlayer
,
host
.
getUid
());
targetPlayer
.
getServer
().
getMultiplayerManager
().
applyEnterMpReply
(
host
,
targetPlayer
.
getUid
(),
true
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
C
oop
_
success
.
replace
(
"{host}"
,
host
.
getNickname
()).
replace
(
"{target}"
,
targetPlayer
.
getNickname
()));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.c
oop
.
success
"
,
targetPlayer
.
getNickname
(),
host
.
getNickname
()));
}
}
src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java
View file @
b3a91700
...
...
@@ -13,6 +13,8 @@ import emu.grasscutter.game.player.Player;
import
java.util.*
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"giveall"
,
usage
=
"giveall [amount]"
,
description
=
"Gives all items"
,
aliases
=
{
"givea"
},
permission
=
"player.giveall"
,
threading
=
true
)
public
final
class
GiveAllCommand
implements
CommandHandler
{
...
...
@@ -32,21 +34,21 @@ public final class GiveAllCommand implements CommandHandler {
try
{
amount
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
I
nvalid
_
amount
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.generic.i
nvalid
.
amount
"
)
);
return
;
}
break
;
default
:
// invalid
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
G
iveAll
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.g
iveAll
.
usage
"
)
);
return
;
}
this
.
giveAllItems
(
targetPlayer
,
amount
);
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
GiveAll_done
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.giveAll.success"
,
targetPlayer
.
getNickname
())
);
}
public
void
giveAllItems
(
Player
player
,
int
amount
)
{
CommandHandler
.
sendMessage
(
player
,
G
ra
sscutter
.
getLanguage
().
GiveAll_item
);
CommandHandler
.
sendMessage
(
player
,
t
ra
nslate
(
"commands.giveAll.started"
)
);
for
(
AvatarData
avatarData:
GameData
.
getAvatarDataMap
().
values
())
{
//Exclude test avatar
...
...
src/main/java/emu/grasscutter/command/commands/GiveArtifactCommand.java
View file @
b3a91700
...
...
@@ -14,6 +14,8 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"giveart"
,
usage
=
"giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]"
,
description
=
"Gives the player a specified artifact"
,
aliases
=
{
"gart"
},
permission
=
"player.giveart"
)
public
final
class
GiveArtifactCommand
implements
CommandHandler
{
@Override
...
...
@@ -24,7 +26,7 @@ public final class GiveArtifactCommand implements CommandHandler {
}
if
(
args
.
size
()
<
2
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
G
iveArtifact
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.g
iveArtifact
.
usage
"
)
);
return
;
}
...
...
@@ -32,12 +34,12 @@ public final class GiveArtifactCommand implements CommandHandler {
try
{
itemId
=
Integer
.
parseInt
(
args
.
remove
(
0
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Invalid_a
rtifact
_
id
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.giveA
rtifact
.
id
_error"
)
);
return
;
}
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
itemId
);
if
(
itemData
.
getItemType
()
!=
ItemType
.
ITEM_RELIQUARY
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Invalid_a
rtifact
_
id
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.giveA
rtifact
.
id
_error"
)
);
return
;
}
...
...
@@ -45,7 +47,7 @@ public final class GiveArtifactCommand implements CommandHandler {
try
{
mainPropId
=
Integer
.
parseInt
(
args
.
remove
(
0
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_arguments
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.generic.execution.argument_error"
)
);
return
;
}
...
...
@@ -59,7 +61,7 @@ public final class GiveArtifactCommand implements CommandHandler {
}
catch
(
NumberFormatException
ignored
)
{
// Could be a stat,times string so no need to panic
}
Array
List
<
Integer
>
appendPropIdList
=
new
ArrayList
<>();
List
<
Integer
>
appendPropIdList
=
new
ArrayList
<>();
try
{
args
.
forEach
(
it
->
{
String
[]
arr
;
...
...
@@ -74,7 +76,7 @@ public final class GiveArtifactCommand implements CommandHandler {
appendPropIdList
.
addAll
(
Collections
.
nCopies
(
n
,
Integer
.
parseInt
(
it
)));
});
}
catch
(
Exception
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_arguments
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.execution.argument_error"
)
);
return
;
}
...
...
@@ -85,7 +87,7 @@ public final class GiveArtifactCommand implements CommandHandler {
item
.
getAppendPropIdList
().
addAll
(
appendPropIdList
);
targetPlayer
.
getInventory
().
addItem
(
item
,
ActionReason
.
SubfieldDrop
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
GiveArtifact_given
.
replace
(
"{itemId}
"
,
Integer
.
toString
(
itemId
)
).
replace
(
"target"
,
Integer
.
toString
(
targetPlayer
.
getUid
())));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.giveArtifact.success
"
,
Integer
.
toString
(
itemId
),
Integer
.
toString
(
targetPlayer
.
getUid
())));
}
}
src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java
View file @
b3a91700
package
emu.grasscutter.command.commands
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.entity.EntityAvatar
;
...
...
@@ -12,6 +11,8 @@ import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"killcharacter"
,
usage
=
"killcharacter"
,
aliases
=
{
"suicide"
,
"kill"
},
description
=
"Kills the players current character"
,
permission
=
"player.killcharacter"
)
public
final
class
KillCharacterCommand
implements
CommandHandler
{
...
...
@@ -32,6 +33,6 @@ public final class KillCharacterCommand implements CommandHandler {
targetPlayer
.
getScene
().
removeEntity
(
entity
);
entity
.
onDeath
(
0
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
KillCharacter_kill_current_character
.
replace
(
"{name}
"
,
targetPlayer
.
getNickname
()));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.killCharacter.success
"
,
targetPlayer
.
getNickname
()));
}
}
src/main/java/emu/grasscutter/command/commands/ListCommand.java
View file @
b3a91700
...
...
@@ -8,6 +8,8 @@ import emu.grasscutter.game.player.Player;
import
java.util.List
;
import
java.util.Map
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"list"
,
usage
=
"list [uid]"
,
description
=
"List online players"
,
aliases
=
{
"players"
})
public
final
class
ListCommand
implements
CommandHandler
{
...
...
@@ -21,7 +23,7 @@ public final class ListCommand implements CommandHandler {
needUID
=
args
.
get
(
0
).
equals
(
"uid"
);
}
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
List_message
.
replace
(
"{size}
"
,
Integer
.
toString
(
playersMap
.
size
())));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.list.success
"
,
Integer
.
toString
(
playersMap
.
size
())));
if
(
playersMap
.
size
()
!=
0
)
{
StringBuilder
playerSet
=
new
StringBuilder
();
...
...
src/main/java/emu/grasscutter/command/commands/PermissionCommand.java
View file @
b3a91700
...
...
@@ -22,7 +22,7 @@ public final class PermissionCommand implements CommandHandler {
}
if
(
args
.
size
()
!=
2
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
P
ermission
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.p
ermission
.
usage
"
)
);
return
;
}
...
...
@@ -31,23 +31,23 @@ public final class PermissionCommand implements CommandHandler {
Account
account
=
targetPlayer
.
getAccount
();
if
(
account
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Account_not_find
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.permission.account_error"
)
);
return
;
}
switch
(
action
)
{
default
:
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
P
ermission
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.p
ermission
.
usage
"
)
);
break
;
case
"add"
:
if
(
account
.
addPermission
(
permission
))
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
P
ermission
_
add
);
}
else
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
P
ermission
_
ha
ve_permission
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.p
ermission
.
add
"
)
);
}
else
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.p
ermission
.
ha
s_error"
)
);
break
;
case
"remove"
:
if
(
account
.
removePermission
(
permission
))
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
P
ermission
_
remove
);
}
else
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
P
ermission
_
not_have_
p
er
mission
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.p
ermission
.
remove
"
)
);
}
else
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.p
ermission
.
not_have_er
ror"
)
);
break
;
}
...
...
src/main/java/emu/grasscutter/command/commands/ResetShopLimitCommand.java
View file @
b3a91700
...
...
@@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"resetshop"
,
usage
=
"resetshop"
,
description
=
"Reset target player's shop refresh time."
,
permission
=
"server.resetshop"
)
public
final
class
ResetShopLimitCommand
implements
CommandHandler
{
...
...
@@ -19,6 +21,6 @@ public final class ResetShopLimitCommand implements CommandHandler {
targetPlayer
.
getShopLimit
().
forEach
(
x
->
x
.
setNextRefreshTime
(
0
));
targetPlayer
.
save
();
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
S
uccess
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.status.s
uccess
"
)
);
}
}
src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java
View file @
b3a91700
package
emu.grasscutter.command.commands
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.player.Player
;
...
...
@@ -20,12 +19,12 @@ public final class SendMessageCommand implements CommandHandler {
return
;
}
if
(
args
.
size
()
==
0
)
{
CommandHandler
.
sendMessage
(
null
,
Grasscutter
.
getLanguage
().
S
endMessage
_
usage
);
CommandHandler
.
sendMessage
(
null
,
translate
(
"commands.s
endMessage
.
usage
"
)
);
return
;
}
String
message
=
String
.
join
(
" "
,
args
);
CommandHandler
.
sendMessage
(
targetPlayer
,
message
);
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
S
en
a
Message
_message_sent
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.s
en
d
Message
.success"
)
);
}
}
\ No newline at end of file
src/main/java/emu/grasscutter/command/commands/SetFetterLevelCommand.java
View file @
b3a91700
...
...
@@ -2,7 +2,6 @@ package emu.grasscutter.command.commands;
import
java.util.List
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.data.GameData
;
...
...
@@ -10,6 +9,8 @@ import emu.grasscutter.game.avatar.Avatar;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"setfetterlevel"
,
usage
=
"setfetterlevel <level>"
,
description
=
"Sets your fetter level for your current active character"
,
aliases
=
{
"setfetterlvl"
,
"setfriendship"
},
permission
=
"player.setfetterlevel"
)
...
...
@@ -23,14 +24,14 @@ public final class SetFetterLevelCommand implements CommandHandler {
}
if
(
args
.
size
()
!=
1
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
S
etFetterLevel
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.s
etFetterLevel
.
usage
"
)
);
return
;
}
try
{
int
fetterLevel
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
fetterLevel
<
0
||
fetterLevel
>
10
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
SetFetterLevel_fetter_level_must_between_0_and_10
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.setFetterLevel.range_error"
)
);
return
;
}
Avatar
avatar
=
targetPlayer
.
getTeamManager
().
getCurrentAvatarEntity
().
getAvatar
();
...
...
@@ -42,9 +43,9 @@ public final class SetFetterLevelCommand implements CommandHandler {
avatar
.
save
();
targetPlayer
.
sendPacket
(
new
PacketAvatarFetterDataNotify
(
avatar
));
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
SetFetterLevel_fetter_set_level
.
replace
(
"{level}"
,
Integer
.
toString
(
fetterLevel
))
)
;
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.setFetterLevel.success"
,
fetterLevel
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
SetFetterLevel_invalid_fetter_level
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.setFetterLevel.level_error"
)
);
}
}
...
...
src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java
View file @
b3a91700
...
...
@@ -33,7 +33,6 @@ public final class SetStatsCommand implements CommandHandler {
Map
<
String
,
Stat
>
stats
=
new
HashMap
<>();
public
SetStatsCommand
()
{
Language
lang
=
Grasscutter
.
getLanguage
();
// Default stats
stats
.
put
(
"maxhp"
,
new
Stat
(
FightProperty
.
FIGHT_PROP_MAX_HP
.
toString
(),
FightProperty
.
FIGHT_PROP_MAX_HP
,
false
));
stats
.
put
(
"hp"
,
new
Stat
(
FightProperty
.
FIGHT_PROP_CUR_HP
.
toString
(),
FightProperty
.
FIGHT_PROP_CUR_HP
,
false
));
...
...
src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java
View file @
b3a91700
...
...
@@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"setworldlevel"
,
usage
=
"setworldlevel <level>"
,
description
=
"Sets your world level (Relog to see proper effects)"
,
aliases
=
{
"setworldlvl"
},
permission
=
"player.setworldlevel"
)
...
...
@@ -20,14 +22,14 @@ public final class SetWorldLevelCommand implements CommandHandler {
}
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
S
etWorldLevel
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.s
etWorldLevel
.
usage
"
)
);
return
;
}
try
{
int
level
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
level
>
8
||
level
<
0
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
SetWorldLevel_world_level_must_between_0_and_8
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.setWorldLevel.value_error"
)
);
return
;
}
...
...
@@ -35,9 +37,9 @@ public final class SetWorldLevelCommand implements CommandHandler {
targetPlayer
.
getWorld
().
setWorldLevel
(
level
);
targetPlayer
.
setWorldLevel
(
level
);
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
SetWorldLevel_set_world_level
.
replace
(
"{level}
"
,
Integer
.
toString
(
level
)));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.setWorldLevel.success
"
,
Integer
.
toString
(
level
)));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
null
,
Grasscutter
.
getLanguage
().
S
etWorldLevel
_
invalid_world_level
);
CommandHandler
.
sendMessage
(
null
,
translate
(
"commands.s
etWorldLevel
.
invalid_world_level
"
)
);
}
}
}
src/main/java/emu/grasscutter/command/commands/SpawnCommand.java
View file @
b3a91700
...
...
@@ -20,6 +20,8 @@ import javax.swing.text.html.parser.Entity;
import
java.util.List
;
import
java.util.Random
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"spawn"
,
usage
=
"spawn <entityId> [amount] [level(monster only)]"
,
description
=
"Spawns an entity near you"
,
permission
=
"server.spawn"
)
public
final
class
SpawnCommand
implements
CommandHandler
{
...
...
@@ -39,23 +41,23 @@ public final class SpawnCommand implements CommandHandler {
try
{
level
=
Integer
.
parseInt
(
args
.
get
(
2
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_arguments
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.execution.argument_error"
)
);
}
// Fallthrough
case
2
:
try
{
amount
=
Integer
.
parseInt
(
args
.
get
(
1
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_
amount
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.generic.error.
amount
"
)
);
}
// Fallthrough
case
1
:
try
{
id
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_
entity
_id
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.generic.error.
entity
Id"
)
);
}
break
;
default
:
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
S
pawn
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.s
pawn
.
usage
"
)
);
return
;
}
...
...
@@ -63,7 +65,7 @@ public final class SpawnCommand implements CommandHandler {
GadgetData
gadgetData
=
GameData
.
getGadgetDataMap
().
get
(
id
);
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
id
);
if
(
monsterData
==
null
&&
gadgetData
==
null
&&
itemData
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_
entity
_id
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.generic.error.
entity
Id"
)
);
return
;
}
Scene
scene
=
targetPlayer
.
getScene
();
...
...
@@ -99,7 +101,7 @@ public final class SpawnCommand implements CommandHandler {
scene
.
addEntity
(
entity
);
}
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Spawn_message
.
replace
(
"{amount}
"
,
Integer
.
toString
(
amount
)
).
replace
(
"{id}"
,
Integer
.
toString
(
id
)));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.spawn.success
"
,
Integer
.
toString
(
amount
),
Integer
.
toString
(
id
)));
}
private
Position
GetRandomPositionInCircle
(
Position
origin
,
double
radius
){
...
...
src/main/java/emu/grasscutter/command/commands/StopCommand.java
View file @
b3a91700
...
...
@@ -7,17 +7,19 @@ import emu.grasscutter.game.player.Player;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"stop"
,
usage
=
"stop"
,
description
=
"Stops the server"
,
permission
=
"server.stop"
)
public
final
class
StopCommand
implements
CommandHandler
{
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
CommandHandler
.
sendMessage
(
null
,
Grasscutter
.
getLanguage
().
Stop_message
);
CommandHandler
.
sendMessage
(
null
,
translate
(
"commands.stop.success"
)
);
for
(
Player
p
:
Grasscutter
.
getGameServer
().
getPlayers
().
values
())
{
CommandHandler
.
sendMessage
(
p
,
Grasscutter
.
getLanguage
().
Stop_message
);
CommandHandler
.
sendMessage
(
p
,
translate
(
"commands.stop.success"
)
);
}
System
.
exit
(
1
);
System
.
exit
(
1
000
);
}
}
src/main/java/emu/grasscutter/command/commands/TeleportAllCommand.java
View file @
b3a91700
...
...
@@ -8,6 +8,8 @@ import emu.grasscutter.utils.Position;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"tpall"
,
usage
=
"tpall"
,
description
=
"Teleports all players in your world to your position"
,
permission
=
"player.tpall"
)
public
final
class
TeleportAllCommand
implements
CommandHandler
{
...
...
@@ -19,7 +21,7 @@ public final class TeleportAllCommand implements CommandHandler {
}
if
(!
targetPlayer
.
getWorld
().
isMultiplayer
())
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
T
eleportAll
_message
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.t
eleportAll
.error"
)
);
return
;
}
...
...
@@ -30,5 +32,7 @@ public final class TeleportAllCommand implements CommandHandler {
player
.
getWorld
().
transferPlayerToScene
(
player
,
targetPlayer
.
getSceneId
(),
pos
);
}
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.teleportAll.success"
));
}
}
src/main/java/emu/grasscutter/command/commands/TeleportCommand.java
View file @
b3a91700
...
...
@@ -8,6 +8,8 @@ import emu.grasscutter.utils.Position;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"teleport"
,
usage
=
"teleport <x> <y> <z> [scene id]"
,
aliases
=
{
"tp"
},
description
=
"Change the player's position."
,
permission
=
"player.teleport"
)
public
final
class
TeleportCommand
implements
CommandHandler
{
...
...
@@ -41,7 +43,7 @@ public final class TeleportCommand implements CommandHandler {
try
{
sceneId
=
Integer
.
parseInt
(
args
.
get
(
3
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
G
ra
sscutter
.
getLanguage
().
Invalid_arguments
);
CommandHandler
.
sendMessage
(
sender
,
t
ra
nslate
(
"commands.execution.argument_error"
)
);
}
// Fallthrough
case
3
:
try
{
...
...
@@ -49,20 +51,23 @@ public final class TeleportCommand implements CommandHandler {
y
=
parseRelative
(
args
.
get
(
1
),
y
);
z
=
parseRelative
(
args
.
get
(
2
),
z
);
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
T
eleport
_
invalid_position
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.t
eleport
.
invalid_position
"
)
);
}
break
;
default
:
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
T
eleport
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.t
eleport
.
usage
"
)
);
return
;
}
Position
target_pos
=
new
Position
(
x
,
y
,
z
);
boolean
result
=
targetPlayer
.
getWorld
().
transferPlayerToScene
(
targetPlayer
,
sceneId
,
target_pos
);
if
(!
result
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
T
eleport
_
invalid_position
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.t
eleport
.
invalid_position
"
)
);
}
else
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Teleport_message
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()).
replace
(
"{x}"
,
Float
.
toString
(
x
)).
replace
(
"{y}"
,
Float
.
toString
(
y
)).
replace
(
"{z}"
,
Float
.
toString
(
z
)).
replace
(
"{id}"
,
Integer
.
toString
(
sceneId
)));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.teleport.success"
,
targetPlayer
.
getNickname
(),
Float
.
toString
(
x
),
Float
.
toString
(
y
),
Float
.
toString
(
z
),
Integer
.
toString
(
sceneId
))
);
}
}
...
...
src/main/java/emu/grasscutter/command/commands/WeatherCommand.java
View file @
b3a91700
...
...
@@ -9,6 +9,8 @@ import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"weather"
,
usage
=
"weather <weatherId> [climateId]"
,
description
=
"Changes the weather."
,
aliases
=
{
"w"
},
permission
=
"player.weather"
)
public
final
class
WeatherCommand
implements
CommandHandler
{
...
...
@@ -27,17 +29,17 @@ public final class WeatherCommand implements CommandHandler {
try
{
climateId
=
Integer
.
parseInt
(
args
.
get
(
1
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
W
eather
_
invalid_id
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.w
eather
.
invalid_id
"
)
);
}
case
1
:
try
{
weatherId
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
W
eather
_
invalid_id
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.w
eather
.
invalid_id
"
)
);
}
break
;
default
:
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
W
eather
_
usage
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.w
eather
.
usage
"
)
);
return
;
}
...
...
@@ -46,7 +48,6 @@ public final class WeatherCommand implements CommandHandler {
targetPlayer
.
getScene
().
setWeather
(
weatherId
);
targetPlayer
.
getScene
().
setClimate
(
climate
);
targetPlayer
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
targetPlayer
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Weather_message
.
replace
(
"{weatherId}"
,
Integer
.
toString
(
weatherId
)).
replace
(
"{climateId}"
,
Integer
.
toString
(
climateId
)));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.weather.success"
,
Integer
.
toString
(
weatherId
),
Integer
.
toString
(
climateId
)));
}
}
src/main/java/emu/grasscutter/server/dispatch/authentication/DefaultAuthenticationHandler.java
View file @
b3a91700
...
...
@@ -8,6 +8,8 @@ import emu.grasscutter.server.dispatch.json.LoginResultJson;
import
express.http.Request
;
import
express.http.Response
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
public
class
DefaultAuthenticationHandler
implements
AuthenticationHandler
{
@Override
...
...
@@ -34,11 +36,9 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
// Check if account exists, else create a new one.
if
(
account
==
null
)
{
// Account doesnt exist, so we can either auto create it if the config value is
// set
// Account doesn't exist, so we can either auto create it if the config value is set.
if
(
Grasscutter
.
getConfig
().
getDispatchOptions
().
AutomaticallyCreateAccounts
)
{
// This account has been created AUTOMATICALLY. There will be no permissions
// added.
// This account has been created AUTOMATICALLY. There will be no permissions added.
account
=
DatabaseHelper
.
createAccountWithId
(
requestData
.
account
,
0
);
for
(
String
permission
:
Grasscutter
.
getConfig
().
getDispatchOptions
().
defaultPermissions
)
{
...
...
@@ -51,19 +51,18 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
responseData
.
data
.
account
.
email
=
account
.
getEmail
();
Grasscutter
.
getLogger
().
info
(
G
ra
sscutter
.
getLanguage
().
Client_failed_login_
account_create
.
replace
(
"{ip}"
,
req
.
ip
()).
replace
(
"{uid}"
,
responseData
.
data
.
account
.
uid
));
Grasscutter
.
getLogger
().
info
(
t
ra
nslate
(
"messages.dispatch.account.
account_
login_
create
_success"
,
req
.
ip
()
,
responseData
.
data
.
account
.
uid
));
}
else
{
responseData
.
retcode
=
-
201
;
responseData
.
message
=
G
ra
sscutter
.
getLanguage
().
Username_not_found_create_failed
;
responseData
.
message
=
t
ra
nslate
(
"messages.dispatch.account.username_create_error"
)
;
Grasscutter
.
getLogger
().
info
(
G
ra
sscutter
.
getLanguage
().
Client_failed_login_account_no_found
.
replace
(
"{ip}
"
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
t
ra
nslate
(
"messages.dispatch.account.account_login_create_error
"
,
req
.
ip
()));
}
}
else
{
responseData
.
retcode
=
-
201
;
responseData
.
message
=
G
ra
sscutter
.
getLanguage
().
Username_not_found
;
responseData
.
message
=
t
ra
nslate
(
"messages.dispatch.account.username_error"
)
;
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_failed_login_account_no_found
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
translate
(
"messages.dispatch.account.account_login_exist_error"
,
req
.
ip
()));
}
}
else
{
// Account was found, log the player in
...
...
@@ -72,7 +71,7 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
responseData
.
data
.
account
.
email
=
account
.
getEmail
();
Grasscutter
.
getLogger
().
info
(
G
ra
sscutter
.
getLanguage
().
Clie
nt
_
login
.
replace
(
"{ip}"
,
req
.
ip
()).
replace
(
"{uid}"
,
responseData
.
data
.
account
.
uid
));
Grasscutter
.
getLogger
().
info
(
t
ra
nslate
(
"messages.dispatch.accou
nt
.
login
_success"
,
req
.
ip
()
,
responseData
.
data
.
account
.
uid
));
}
return
responseData
;
...
...
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