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
1b9d1e4b
Commit
1b9d1e4b
authored
Apr 23, 2022
by
Magix
Committed by
GitHub
Apr 23, 2022
Browse files
Merge pull request #162 from omg-xtao/development
Add Teleport command
parents
d612530c
2dd89321
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/PositionCommand.java
View file @
1b9d1e4b
...
...
@@ -17,6 +17,7 @@ public final class PositionCommand implements CommandHandler {
return
;
}
sender
.
dropMessage
(
String
.
format
(
"Coord: %.3f, %.3f, %.3f"
,
sender
.
getPos
().
getX
(),
sender
.
getPos
().
getY
(),
sender
.
getPos
().
getZ
()));
sender
.
dropMessage
(
String
.
format
(
"Coord: %.3f, %.3f, %.3f\nScene id: %d"
,
sender
.
getPos
().
getX
(),
sender
.
getPos
().
getY
(),
sender
.
getPos
().
getZ
(),
sender
.
getSceneId
()));
}
}
src/main/java/emu/grasscutter/command/commands/TelePortCommand.java
0 → 100644
View file @
1b9d1e4b
package
emu.grasscutter.command.commands
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.utils.Position
;
import
java.util.List
;
@Command
(
label
=
"teleport"
,
usage
=
"teleport <x> <y> <z>"
,
aliases
=
{
"tp"
},
description
=
"Change the player's position."
,
permission
=
"player.teleport"
)
public
class
TelePortCommand
implements
CommandHandler
{
@Override
public
void
execute
(
GenshinPlayer
sender
,
List
<
String
>
args
)
{
if
(
sender
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"Run this command in-game."
);
return
;
}
if
(
args
.
size
()
<
3
){
CommandHandler
.
sendMessage
(
sender
,
"Usage: /tp <x> <y> <z> [scene id]"
);
return
;
}
try
{
float
x
=
Float
.
parseFloat
(
args
.
get
(
0
));
float
y
=
Float
.
parseFloat
(
args
.
get
(
1
));
float
z
=
Float
.
parseFloat
(
args
.
get
(
2
));
int
sceneId
=
sender
.
getSceneId
();
if
(
args
.
size
()
==
4
){
sceneId
=
Integer
.
parseInt
(
args
.
get
(
3
));
}
Position
target
=
new
Position
(
x
,
y
,
z
);
boolean
result
=
sender
.
getWorld
().
transferPlayerToScene
(
sender
,
sceneId
,
target
);
if
(!
result
)
{
CommandHandler
.
sendMessage
(
sender
,
"Invalid position."
);
}
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
"Invalid position."
);
}
}
}
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