Archived
0
This repository has been archived on 2024-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
ChatAPI/net/nemez/chatapi/click/CallbackCommand.java

39 lines
1023 B
Java
Raw Normal View History

2017-07-22 12:31:16 +02:00
package net.nemez.chatapi.click;
import java.util.UUID;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.nemez.chatapi.ChatAPI;
public class CallbackCommand extends Command {
public CallbackCommand(String internalCommandName) {
super(internalCommandName);
}
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!(sender instanceof Player)) {
ChatAPI.send(sender, ChatAPI.MESSAGE_PLAYER_CLICK_CALLBACK);
return true;
}
if ((args.length == 1 && args[0].equals("help")) || args.length != 1) {
ChatAPI.send(sender, ChatAPI.MESSAGE_HELP_CLICK_CALLBACK);
return true;
}
int id;
try {
id = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
ChatAPI.send(sender, ChatAPI.MESSAGE_HELP_CLICK_CALLBACK);
return true;
}
UUID uuid = ((Player) sender).getUniqueId();
CallbackMap.execute(sender, uuid, id);
return true;
}
}