ChangeScene.java 1.31 KB
Newer Older
Jaida Wu's avatar
Jaida Wu committed
1
2
3
4
5
6
7
8
9
10
11
12
package emu.grasscutter.command.commands;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer;

import java.util.List;

@Command(label = "changescene", usage = "changescene <scene id>",
        description = "Changes your scene", aliases = {"scene"}, permission = "player.changescene")
public class ChangeScene implements CommandHandler {
    @Override
KingRainbow44's avatar
KingRainbow44 committed
13
    public void execute(GenshinPlayer sender, List<String> args) {
Jaida Wu's avatar
Jaida Wu committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        if (sender == null) {
            CommandHandler.sendMessage(null, "Run this command in-game.");
            return;
        }

        if (args.size() < 1) {
            CommandHandler.sendMessage(sender, "Usage: changescene <scene id>");
            return;
        }

        try {
            int sceneId = Integer.parseInt(args.get(0));
            boolean result = sender.getWorld().transferPlayerToScene(sender, sceneId, sender.getPos());

            CommandHandler.sendMessage(sender, "Changed to scene " + sceneId);
            if (!result) {
                CommandHandler.sendMessage(sender, "Scene does not exist or you are already in it");
            }
        } catch (Exception e) {
            CommandHandler.sendMessage(sender, "Usage: changescene <scene id>");
        }
    }
}