aboutsummaryrefslogtreecommitdiff
path: root/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java
blob: 5a40e16cc66a743fe619b9bd56e9d4a67a2638d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package me.lucko.spark.nukkit;

import cn.nukkit.Player;
import cn.nukkit.command.CommandSender;
import me.lucko.spark.common.command.sender.AbstractCommandSender;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;

import java.util.UUID;

public class NukkitCommandSender extends AbstractCommandSender<CommandSender> {

    public NukkitCommandSender(CommandSender delegate) {
        super(delegate);
    }

    @Override
    public String getName() {
        return this.delegate.getName();
    }

    @Override
    public UUID getUniqueId() {
        if (this.delegate instanceof Player) {
            return ((Player) this.delegate).getUniqueId();
        }
        return null;
    }

    @Override
    public void sendMessage(Component message) {
        this.delegate.sendMessage(LegacyComponentSerializer.legacySection().serialize(message));
    }

    @Override
    public boolean hasPermission(String permission) {
        return this.delegate.hasPermission(permission);
    }
}