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
69cb03f4
Commit
69cb03f4
authored
Apr 19, 2022
by
KingRainbow44
Browse files
Command reformat
parent
2572d55c
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/commands/PlayerCommands.java
View file @
69cb03f4
...
...
@@ -185,38 +185,29 @@ public final class PlayerCommands {
}
}
@Command
(
label
=
"givechar"
,
aliases
=
{
"givec"
},
usage
=
"Usage: givechar <playerId> <avatarId> [level]"
)
@Command
(
label
=
"givechar"
,
aliases
=
{
"givec"
},
usage
=
"Usage: givechar <player|avatarId> [avatarId] [level]"
)
public
static
class
GiveCharCommand
implements
CommandHandler
{
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
int
target
,
avatarI
D
,
level
=
1
,
ascension
=
1
;
int
target
,
avatarI
d
,
level
=
1
,
ascension
=
1
;
if
(
args
.
size
()
<
2
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: givechar <player> <avatarId> [level]"
);
CommandHandler
.
sendMessage
(
player
,
"Usage: givechar <player> <avatarId> [level]"
);
return
;
}
switch
(
args
.
size
())
{
default
:
CommandHandler
.
sendMessage
(
null
,
"Usage: givechar <player> <avatarId> [level]"
);
CommandHandler
.
sendMessage
(
player
,
"Usage: givechar <player> <avatarId> [level]"
);
return
;
case
1
:
try
{
avatarID
=
Integer
.
parseInt
(
args
.
get
(
0
));
target
=
player
.
getAccount
().
getPlayerId
();
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from avatar name using GM Handbook.
CommandHandler
.
sendMessage
(
player
,
"Invalid avatar id."
);
return
;
}
break
;
case
2
:
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
)
{
target
=
player
.
getUid
();
level
=
Integer
.
parseInt
(
args
.
get
(
1
));
avatarI
D
=
Integer
.
parseInt
(
args
.
get
(
0
));
avatarI
d
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
else
{
avatarI
D
=
Integer
.
parseInt
(
args
.
get
(
1
));
avatarI
d
=
Integer
.
parseInt
(
args
.
get
(
1
));
}
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from avatar name using GM Handbook.
...
...
@@ -231,7 +222,7 @@ public final class PlayerCommands {
CommandHandler
.
sendMessage
(
player
,
"Invalid player ID."
);
return
;
}
avatarI
D
=
Integer
.
parseInt
(
args
.
get
(
1
));
avatarI
d
=
Integer
.
parseInt
(
args
.
get
(
1
));
level
=
Integer
.
parseInt
(
args
.
get
(
2
));
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from avatar name using GM Handbook.
...
...
@@ -243,22 +234,22 @@ public final class PlayerCommands {
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
if
(
targetPlayer
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"Player not found."
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Player not found."
);
return
;
}
AvatarData
avatarData
=
GenshinData
.
getAvatarDataMap
().
get
(
avatarI
D
);
AvatarData
avatarData
=
GenshinData
.
getAvatarDataMap
().
get
(
avatarI
d
);
if
(
avatarData
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"Invalid avatar id."
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Invalid avatar id."
);
return
;
}
// Calculate ascension level.
if
(
level
<=
40
)
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
);
}
else
if
(
level
>
20
)
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
)
-
3
;
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
f
);
}
else
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
f
)
-
3
;
}
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarI
D
);
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarI
d
);
avatar
.
setLevel
(
level
);
avatar
.
setPromoteLevel
(
ascension
);
...
...
@@ -279,7 +270,7 @@ public final class PlayerCommands {
int
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
avatarID
=
Integer
.
parseInt
(
args
.
get
(
1
));
int
level
=
1
;
if
(
args
.
size
()
>
2
)
level
=
Integer
.
parseInt
(
args
.
get
(
2
));
int
ascension
=
1
;
int
ascension
;
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
if
(
targetPlayer
==
null
)
{
...
...
@@ -293,9 +284,9 @@ public final class PlayerCommands {
// Calculate ascension level.
if
(
level
<=
40
)
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
);
}
else
if
(
level
>
20
)
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
)
-
3
;
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
f
);
}
else
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
f
)
-
3
;
}
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
...
...
@@ -461,7 +452,7 @@ public final class PlayerCommands {
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: setworldlevel <level>"
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Usage: setworldlevel <level>"
);
return
;
}
try
{
...
...
@@ -498,22 +489,19 @@ public final class PlayerCommands {
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: changescene <scene id>"
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Usage: changescene <scene id>"
);
return
;
}
int
sceneId
=
0
;
try
{
sceneId
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
catch
(
Exception
e
)
{
return
;
}
int
sceneId
=
Integer
.
parseInt
(
args
.
get
(
0
));
boolean
result
=
player
.
getWorld
().
transferPlayerToScene
(
player
,
sceneId
,
player
.
getPos
());
if
(!
result
)
{
CommandHandler
.
sendMessage
(
null
,
"Scene does not exist or you are already in it"
);
}
}
catch
(
Exception
e
)
{
CommandHandler
.
sendMessage
(
player
,
"Usage: changescene <scene id>"
);
return
;
}
}
}
}
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