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 {
...
@@ -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
{
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
,
avatarI
D
,
level
=
1
,
ascension
=
1
;
int
target
,
avatarI
d
,
level
=
1
,
ascension
=
1
;
if
(
args
.
size
()
<
2
)
{
if
(
args
.
size
()
<
2
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: givechar <player> <avatarId> [level]"
);
CommandHandler
.
sendMessage
(
player
,
"Usage: givechar <player> <avatarId> [level]"
);
return
;
return
;
}
}
switch
(
args
.
size
())
{
switch
(
args
.
size
())
{
default
:
default
:
CommandHandler
.
sendMessage
(
null
,
"Usage: givechar <player> <avatarId> [level]"
);
CommandHandler
.
sendMessage
(
player
,
"Usage: givechar <player> <avatarId> [level]"
);
return
;
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
:
case
2
:
try
{
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
)
{
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
)
{
target
=
player
.
getUid
();
level
=
Integer
.
parseInt
(
args
.
get
(
1
));
target
=
player
.
getUid
();
level
=
Integer
.
parseInt
(
args
.
get
(
1
));
avatarI
D
=
Integer
.
parseInt
(
args
.
get
(
0
));
avatarI
d
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
else
{
}
else
{
avatarI
D
=
Integer
.
parseInt
(
args
.
get
(
1
));
avatarI
d
=
Integer
.
parseInt
(
args
.
get
(
1
));
}
}
}
catch
(
NumberFormatException
ignored
)
{
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from avatar name using GM Handbook.
// TODO: Parse from avatar name using GM Handbook.
...
@@ -231,7 +222,7 @@ public final class PlayerCommands {
...
@@ -231,7 +222,7 @@ public final class PlayerCommands {
CommandHandler
.
sendMessage
(
player
,
"Invalid player ID."
);
return
;
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
));
level
=
Integer
.
parseInt
(
args
.
get
(
2
));
}
catch
(
NumberFormatException
ignored
)
{
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from avatar name using GM Handbook.
// TODO: Parse from avatar name using GM Handbook.
...
@@ -243,22 +234,22 @@ public final class PlayerCommands {
...
@@ -243,22 +234,22 @@ public final class PlayerCommands {
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
if
(
targetPlayer
==
null
)
{
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
)
{
if
(
avatarData
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"Invalid avatar id."
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Invalid avatar id."
);
return
;
}
}
// Calculate ascension level.
// Calculate ascension level.
if
(
level
<=
40
)
{
if
(
level
<=
40
)
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
);
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
f
);
}
else
if
(
level
>
20
)
{
}
else
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
)
-
3
;
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
f
)
-
3
;
}
}
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarI
D
);
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarI
d
);
avatar
.
setLevel
(
level
);
avatar
.
setLevel
(
level
);
avatar
.
setPromoteLevel
(
ascension
);
avatar
.
setPromoteLevel
(
ascension
);
...
@@ -279,7 +270,7 @@ public final class PlayerCommands {
...
@@ -279,7 +270,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
;
int
ascension
;
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
if
(
targetPlayer
==
null
)
{
if
(
targetPlayer
==
null
)
{
...
@@ -293,9 +284,9 @@ public final class PlayerCommands {
...
@@ -293,9 +284,9 @@ public final class PlayerCommands {
// Calculate ascension level.
// Calculate ascension level.
if
(
level
<=
40
)
{
if
(
level
<=
40
)
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
);
ascension
=
(
int
)
Math
.
ceil
(
level
/
20
f
);
}
else
if
(
level
>
20
)
{
}
else
{
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
)
-
3
;
ascension
=
(
int
)
Math
.
ceil
(
level
/
10
f
)
-
3
;
}
}
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarID
);
...
@@ -461,7 +452,7 @@ public final class PlayerCommands {
...
@@ -461,7 +452,7 @@ public final class PlayerCommands {
@Override
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
if
(
args
.
size
()
<
1
)
{
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: setworldlevel <level>"
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Usage: setworldlevel <level>"
);
return
;
}
}
try
{
try
{
...
@@ -498,22 +489,19 @@ public final class PlayerCommands {
...
@@ -498,22 +489,19 @@ public final class PlayerCommands {
@Override
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
if
(
args
.
size
()
<
1
)
{
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: changescene <scene id>"
);
return
;
CommandHandler
.
sendMessage
(
player
,
"Usage: changescene <scene id>"
);
return
;
}
}
int
sceneId
=
0
;
try
{
try
{
sceneId
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
sceneId
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
catch
(
Exception
e
)
{
return
;
}
boolean
result
=
player
.
getWorld
().
transferPlayerToScene
(
player
,
sceneId
,
player
.
getPos
());
boolean
result
=
player
.
getWorld
().
transferPlayerToScene
(
player
,
sceneId
,
player
.
getPos
());
if
(!
result
)
{
if
(!
result
)
{
CommandHandler
.
sendMessage
(
null
,
"Scene does not exist or you are already in it"
);
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