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
cc9beed9
Commit
cc9beed9
authored
Apr 19, 2022
by
SpikeHD
Browse files
calculate ascension based on level provided to givechar command
parent
a5caf3d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/commands/PlayerCommands.java
View file @
cc9beed9
...
@@ -181,7 +181,7 @@ public final class PlayerCommands {
...
@@ -181,7 +181,7 @@ public final class PlayerCommands {
@Command
(
label
=
"givechar"
,
aliases
=
{
"givec"
},
usage
=
"Usage: givechar <playerId> <avatarId> [level]"
)
@Command
(
label
=
"givechar"
,
aliases
=
{
"givec"
},
usage
=
"Usage: givechar <playerId> <avatarId> [level]"
)
public
static
class
GiveCharCommand
implements
CommandHandler
{
public
static
class
GiveCharCommand
implements
CommandHandler
{
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
int
target
,
avatarID
,
level
=
1
;
int
target
,
avatarID
,
level
=
1
,
ascension
=
1
;
if
(
args
.
size
()
<
2
)
{
if
(
args
.
size
()
<
2
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: givechar <player> <avatarId> [level]"
);
CommandHandler
.
sendMessage
(
null
,
"Usage: givechar <player> <avatarId> [level]"
);
...
@@ -244,8 +244,16 @@ public final class PlayerCommands {
...
@@ -244,8 +244,16 @@ public final class PlayerCommands {
CommandHandler
.
sendMessage
(
null
,
"Invalid avatar id."
);
return
;
CommandHandler
.
sendMessage
(
null
,
"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
;
}
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
avatar
.
setLevel
(
level
);
avatar
.
setLevel
(
level
);
avatar
.
setPromoteLevel
(
ascension
);
targetPlayer
.
addAvatar
(
avatar
);
targetPlayer
.
addAvatar
(
avatar
);
}
}
...
@@ -261,6 +269,7 @@ public final class PlayerCommands {
...
@@ -261,6 +269,7 @@ public final class PlayerCommands {
int
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
avatarID
=
Integer
.
parseInt
(
args
.
get
(
1
));
int
avatarID
=
Integer
.
parseInt
(
args
.
get
(
1
));
int
level
=
1
;
if
(
args
.
size
()
>
2
)
level
=
Integer
.
parseInt
(
args
.
get
(
2
));
int
level
=
1
;
if
(
args
.
size
()
>
2
)
level
=
Integer
.
parseInt
(
args
.
get
(
2
));
int
ascension
=
1
;
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerById
(
target
);
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerById
(
target
);
if
(
targetPlayer
==
null
)
{
if
(
targetPlayer
==
null
)
{
...
@@ -272,8 +281,16 @@ public final class PlayerCommands {
...
@@ -272,8 +281,16 @@ public final class PlayerCommands {
CommandHandler
.
sendMessage
(
null
,
"Invalid avatar id."
);
return
;
CommandHandler
.
sendMessage
(
null
,
"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
;
}
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
avatar
.
setLevel
(
level
);
avatar
.
setLevel
(
level
);
avatar
.
setPromoteLevel
(
ascension
);
targetPlayer
.
addAvatar
(
avatar
);
targetPlayer
.
addAvatar
(
avatar
);
}
catch
(
NumberFormatException
ignored
)
{
}
catch
(
NumberFormatException
ignored
)
{
...
...
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