ChangeSceneCommand.java 1.46 KB
Newer Older
KingRainbow44's avatar
KingRainbow44 committed
1
2
3
4
package emu.grasscutter.command.commands;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
Melledy's avatar
Melledy committed
5
import emu.grasscutter.game.player.Player;
KingRainbow44's avatar
KingRainbow44 committed
6
7
8
9
10
11
12

import java.util.List;

@Command(label = "changescene", usage = "changescene <scene id>",
        description = "Changes your scene", aliases = {"scene"}, permission = "player.changescene")
public final class ChangeSceneCommand implements CommandHandler {
    @Override
13
    public void execute(Player sender, List<String> args) {
KingRainbow44's avatar
KingRainbow44 committed
14
15
16
17
18
19
20
21
22
23
24
25
        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));
26
27
28
29
30
31
            
            if (sceneId == sender.getSceneId()) {
            	CommandHandler.sendMessage(sender, "You are already in that scene");
            	return;
            }
            
KingRainbow44's avatar
KingRainbow44 committed
32
33
            boolean result = sender.getWorld().transferPlayerToScene(sender, sceneId, sender.getPos());
            CommandHandler.sendMessage(sender, "Changed to scene " + sceneId);
34
            
KingRainbow44's avatar
KingRainbow44 committed
35
            if (!result) {
36
                CommandHandler.sendMessage(sender, "Scene does not exist");
KingRainbow44's avatar
KingRainbow44 committed
37
38
39
40
41
42
            }
        } catch (Exception e) {
            CommandHandler.sendMessage(sender, "Usage: changescene <scene id>");
        }
    }
}