From e74a959d7481a4514cd91389949c68a382997706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sun, 7 Apr 2019 19:55:48 +0200 Subject: Created basic ban functionality (IP bans not yet supported) --- .../bungeeBans/commands/GetBanCommand.java | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java (limited to 'src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java') diff --git a/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java b/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java new file mode 100644 index 0000000..5ff213a --- /dev/null +++ b/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java @@ -0,0 +1,66 @@ +package com.redstoner.bungeeBans.commands; + +import com.mojang.api.profiles.Profile; +import com.redstoner.bungeeBans.BanManager; +import com.redstoner.bungeeBans.Util; +import com.redstoner.bungeeBans.json.PlayerBan; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.plugin.Command; + +public class GetBanCommand extends Command { + private BanManager bm; + + public GetBanCommand(BanManager bm) { + super("getban", "bungeebans.getban"); + + this.bm = bm; + } + + @Override + public void execute(CommandSender sender, String[] args) { + if (args.length != 1) { + sender.sendMessage( + new ComponentBuilder(ChatColor.RED + "Invalid command! ") + .append("Usage: ") + .append(ChatColor.AQUA + "/getban ") + .append(ChatColor.GOLD + " ") + .create() + ); + + return; + } + + Profile[] profiles = Util.findProfilesByNames(args[0]); + + if (profiles.length != 1) { + sender.sendMessage(new TextComponent(ChatColor.RED + "Invalid name!")); + return; + } + + String uuid = Util.dashUUID(profiles[0].getId()); + String name = profiles[0].getName(); + + PlayerBan ban = bm.getBan(uuid); + + if (ban == null) { + sender.sendMessage(new TextComponent(ChatColor.RED + "That player is not banned!")); + return; + } + + sender.sendMessage( + new ComponentBuilder(ChatColor.GREEN + "Player ") + .append(ChatColor.AQUA + name) + .append(ChatColor.GREEN + " with uuid ") + .append(ChatColor.AQUA + uuid) + .append(ChatColor.GREEN + " is banned for ") + .append(ChatColor.AQUA + ban.getReason()) + .append(ChatColor.GREEN + " until ") + .append(ChatColor.AQUA + ban.getExpires()) + .create() + ); + + } +} -- cgit v1.2.3