Added commands

This commit is contained in:
Norbi Peti 2016-10-29 20:45:52 +02:00
parent d30964bec8
commit e6829fb7c9
4 changed files with 106 additions and 7 deletions

View file

@ -2,10 +2,12 @@ package buttondevteam.discordplugin;
import buttondevteam.lib.TBMCPlayer;
public class DiscordPlayer {
private TBMCPlayer player;
public class DiscordPlayer extends TBMCPlayer {
public String getDiscordID() {
return null; // TODO: Return player.getData("discordid") or similar
return getData();
}
public void setDiscrodID(String id) {
setData(id);
}
}

View file

@ -1,15 +1,17 @@
package buttondevteam.discordplugin.mccommands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.TBMCPlayer;
public class AcceptMCCommand extends DiscordMCCommandBase {
@Override
public String GetDiscordCommandPath() {
return "connect";
return "accept";
}
@Override
@ -37,9 +39,9 @@ public class AcceptMCCommand extends DiscordMCCommandBase {
String did = ConnectCommand.WaitingToConnect.get(sender.getName());
if (did == null) {
sender.sendMessage("§cYou don't have a pending connection to Discord.");
return false;
return true;
}
new DiscordPlayer(did); // TODO: Add to player storage
TBMCPlayer.getPlayerAs((Player) sender, DiscordPlayer.class).setDiscrodID(did);
return true;
}

View file

@ -0,0 +1,47 @@
package buttondevteam.discordplugin.mccommands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.TBMCPlayer;
public class DeclineMCCommand extends DiscordMCCommandBase {
@Override
public String GetDiscordCommandPath() {
return "decline";
}
@Override
public String[] GetHelpText(String alias) {
return new String[] { //
"§6---- Decline Discord connection ----", //
"Decline a pending connection between your Discord and Minecraft account.", //
"To start the connection process, do §b@ChromaBot connect <MCname>§r in the #bot channel on Discord", //
"Usage: /" + alias + " decline" //
};
}
@Override
public boolean GetModOnly() {
return false;
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
String did = ConnectCommand.WaitingToConnect.remove(sender.getName());
if (did == null) {
sender.sendMessage("§cYou don't have a pending connection to Discord.");
return true;
}
return true;
}
}

View file

@ -0,0 +1,48 @@
package buttondevteam.discordplugin.mccommands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.TBMCPlayer;
import buttondevteam.lib.chat.TBMCCommandBase;
public class DiscordMCCommand extends TBMCCommandBase {
@Override
public String GetCommandPath() {
return "discord";
}
@Override
public String[] GetHelpText(String alias) {
return new String[] { // TODO
"§6---- Decline Discord connection ----", //
"Decline a pending connection between your Discord and Minecraft account.", //
"To start the connection process, do §b@ChromaBot connect <MCname>§r in the #bot channel on Discord", //
"Usage: /" + alias + " decline" //
};
}
@Override
public boolean GetModOnly() {
return false;
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
String did = ConnectCommand.WaitingToConnect.remove(sender.getName());
if (did == null) {
sender.sendMessage("§cYou don't have a pending connection to Discord.");
return true;
}
return true;
}
}