diff options
author | Desco1 <mario2-18-12@hotmail.com> | 2020-08-18 19:28:20 +0200 |
---|---|---|
committer | Desco1 <mario2-18-12@hotmail.com> | 2020-08-18 19:28:20 +0200 |
commit | da78feeab0e2af3c0f7f382eb79fa6f01d9fc7d2 (patch) | |
tree | 4ca77eced2ee0e563a71002b224d333815ad0575 /src/main/java/me/Danker/commands/GetkeyCommand.java | |
parent | 976e2efc4991202cf0d2dc86eb0d38a22be4de48 (diff) | |
download | SkyblockMod-da78feeab0e2af3c0f7f382eb79fa6f01d9fc7d2.tar.gz SkyblockMod-da78feeab0e2af3c0f7f382eb79fa6f01d9fc7d2.tar.bz2 SkyblockMod-da78feeab0e2af3c0f7f382eb79fa6f01d9fc7d2.zip |
Added clipboard as a parameter for the getkey command
Diffstat (limited to 'src/main/java/me/Danker/commands/GetkeyCommand.java')
-rw-r--r-- | src/main/java/me/Danker/commands/GetkeyCommand.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/main/java/me/Danker/commands/GetkeyCommand.java b/src/main/java/me/Danker/commands/GetkeyCommand.java index 80354fe..d32a56e 100644 --- a/src/main/java/me/Danker/commands/GetkeyCommand.java +++ b/src/main/java/me/Danker/commands/GetkeyCommand.java @@ -1,5 +1,9 @@ package me.Danker.commands; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; + import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -28,14 +32,23 @@ public class GetkeyCommand extends CommandBase implements ICommand { @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer)arg0; - final ConfigHandler cf = new ConfigHandler(); - - if (cf.getString("api", "APIKey").equals("")) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "API key not set. Set your API key using /setkey.")); - } else { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Your set API key is " + EnumChatFormatting.DARK_GREEN + cf.getString("api", "APIKey"))); - } + EntityPlayer player = (EntityPlayer)arg0; + ConfigHandler cf = new ConfigHandler(); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringSelection stringSelection = new StringSelection(cf.getString("api", "APIKey")); + + if (cf.getString("api", "APIKey").equals("")) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "API key not set. Set your API key using /setkey.")); + } + else if (arg1.length == 0) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Your set API key is " + EnumChatFormatting.DARK_GREEN + cf.getString("api", "APIKey"))); + } else if (arg1[0].equalsIgnoreCase("clipboard")){ + clipboard.setContents(stringSelection, null); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Your set API key has been copied to the clipboard.")); + } else { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Wrong command usage: /getkey (clipboard)")); + } + } } |