use of net.md_5.bungee.api.CommandSender in project DiscordBot by LXGaming.
the class DiscordChatCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
StringBuilder stringBuilder = new StringBuilder();
for (String arg : args) {
stringBuilder.append(arg + " ");
}
if (stringBuilder.toString().trim().length() == 0) {
sender.sendMessage(new ComponentBuilder("Message cannot be blank!").color(ChatColor.RED).create());
return;
}
Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get(this.name).getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get(this.name)).setName(sender.getName()).setNick("").setServer("Unknown").setMessage(stringBuilder.toString().trim()).setDiscord(true).setMinecraft(true).setConsole(true).setRedis(true);
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) sender;
if (DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(player.getUniqueId())) {
player.sendMessage(new ComponentBuilder("DiscordChat disabled. '/DiscordBot Toggle' to enable").color(ChatColor.RED).create());
return;
}
message.setName(player.getName()).setNick(player.getDisplayName());
if (player.getServer() != null && player.getServer().getInfo() != null) {
message.setServer(player.getServer().getInfo().getName());
}
}
DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
}
use of net.md_5.bungee.api.CommandSender in project SkinsRestorerX by DoNotSpamPls.
the class SkinsRestorer method checkVersion.
private String checkVersion(CommandSender console) {
try {
HttpsURLConnection con = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=2124").openConnection();
con.setDoOutput(true);
con.setRequestMethod("GET");
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
if (version.length() <= 13)
return version;
} catch (Exception ex) {
ex.printStackTrace();
console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §cFailed to check for an update on Spigot."));
}
return getVersion();
}
use of net.md_5.bungee.api.CommandSender in project SkinsRestorerX by DoNotSpamPls.
the class AdminCommands method execute.
@SuppressWarnings("deprecation")
public void execute(final CommandSender sender, final String[] args) {
if (sender.hasPermission("skinsrestorer.cmds")) {
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
Locale.load();
Config.load(SkinsRestorer.getInstance().getResourceAsStream("config.yml"));
sender.sendMessage(new TextComponent(Locale.RELOAD));
} else if (args.length == 2 && args[0].equalsIgnoreCase("drop")) {
StringBuilder sb = new StringBuilder();
SkinStorage.removeSkinData(sb.toString());
sender.sendMessage(Locale.SKIN_DATA_DROPPED.replace("%player", sb.toString()));
} else if (args.length > 2 && args[0].equalsIgnoreCase("set")) {
final String skin = args[2];
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(args[1]);
if (player == null)
for (ProxiedPlayer pl : ProxyServer.getInstance().getPlayers()) if (pl.getName().startsWith(args[1])) {
player = pl;
break;
}
if (player == null) {
sender.sendMessage(Locale.NOT_ONLINE);
return;
}
final ProxiedPlayer p = player;
ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
try {
MojangAPI.getUUID(skin);
SkinStorage.setPlayerSkin(p.getName(), skin);
SkinApplier.applySkin(p);
sender.sendMessage(Locale.SKIN_CHANGE_SUCCESS);
} catch (MojangAPI.SkinRequestException e) {
sender.sendMessage(e.getReason());
}
});
} else if (args.length == 1 && args[0].equalsIgnoreCase("config")) {
sender.sendMessage("§e[§2SkinsRestorer§e] §2/sr config has been removed from SkinsRestorer. Farewell!");
} else if (args.length > 0 && args[0].equalsIgnoreCase("props")) {
ProxiedPlayer p;
if (args.length == 1) {
if (!(sender instanceof ProxiedPlayer)) {
sender.sendMessage(Locale.NOT_PLAYER);
}
p = (ProxiedPlayer) sender;
} else {
StringBuilder name = new StringBuilder();
for (int i = 1; i < args.length; i++) if (args.length == 2)
name.append(args[i]);
else if (i + 1 == args.length)
name.append(args[i]);
else
name.append(args[i]).append(" ");
p = ProxyServer.getInstance().getPlayer(name.toString());
if (p == null) {
sender.sendMessage(Locale.NOT_ONLINE);
return;
}
}
InitialHandler h = (InitialHandler) p.getPendingConnection();
LoginResult.Property prop = h.getLoginProfile().getProperties()[0];
if (prop == null) {
sender.sendMessage(Locale.NO_SKIN_DATA);
return;
}
CommandSender cons = ProxyServer.getInstance().getConsole();
cons.sendMessage("\n§aName: §8" + prop.getName());
cons.sendMessage("\n§aValue : §8" + prop.getValue());
cons.sendMessage("\n§aSignature : §8" + prop.getSignature());
byte[] decoded = Base64.getDecoder().decode(prop.getValue());
cons.sendMessage("\n§aValue Decoded: §e" + Arrays.toString(decoded));
sender.sendMessage("\n§e" + Arrays.toString(decoded));
sender.sendMessage("§cMore info in console!");
} else {
if (!Locale.SR_LINE.isEmpty())
sender.sendMessage(Locale.SR_LINE);
sender.sendMessage(Locale.HELP_ADMIN.replace("%ver%", SkinsRestorer.getInstance().getVersion()));
if (!Locale.SR_LINE.isEmpty())
sender.sendMessage(Locale.SR_LINE);
}
} else {
sender.sendMessage(Locale.PLAYER_HAS_NO_PERMISSION);
}
}
use of net.md_5.bungee.api.CommandSender in project FireAPI by FireBlade-Serv.
the class FireFriends method sendGeneratedListOther.
public void sendGeneratedListOther(CommandSender sender, String name) throws IOException {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
if (!this.instance.getSQL().hasFireAccount(name)) {
sender.sendMessage(new TextComponent(this.pre + "§cErreur ce joueur n'existe pas !"));
return;
}
if (hasFriends(name)) {
if (getOnlineFriends(name).size() == 0) {
sender.sendMessage(new TextComponent(this.pre + name + " n'a §caucun§r ami connecté sur le serveur"));
} else if (getOnlineFriends(name).size() == 1) {
sender.sendMessage(new TextComponent(this.pre + name + " a §eun§r ami connecté sur le serveur"));
} else {
sender.sendMessage(new TextComponent(this.pre + name + " a §e" + getOnlineFriends(name).size() + "§r amis connectés sur le serveur"));
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§c" + name + " n'a pas d'amis :("));
return;
}
List<String> list = config.getStringList("data." + name);
for (ProxiedPlayer connected : getOnlineFriends(name)) {
sender.sendMessage(new TextComponent(this.pre + "§a" + connected.getName() + "§r est actuellement sur le §e" + connected.getServer().getInfo().getName()));
list.remove(connected.getName());
}
for (String names : list) {
sender.sendMessage(new TextComponent(this.pre + "§8" + names + "§r est actuellement §chors-ligne"));
}
}
use of net.md_5.bungee.api.CommandSender in project FireAPI by FireBlade-Serv.
the class FriendsCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length == 0) {
if (sender instanceof ProxiedPlayer) {
sender.sendMessage(new TextComponent(this.pre + "/amis add <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis remove <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis list"));
sender.sendMessage(new TextComponent(this.pre + "/amis join <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis accept <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis gui"));
}
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "/amis show <pseudo>"));
}
} else if (args.length == 1) {
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer pp = (ProxiedPlayer) sender;
if (args[0].equalsIgnoreCase("add")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis add <pseuso>"));
} else if (args[0].equalsIgnoreCase("remove")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis remove <pseudo>"));
} else if (args[0].equalsIgnoreCase("list")) {
try {
this.friends.sendGeneratedList(pp);
} catch (IOException e) {
e.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("join")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis join <pseudo>"));
} else if (args[0].equalsIgnoreCase("accept")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis accept <pseudo>"));
} else if (args[0].equalsIgnoreCase("gui")) {
List<String> names = new ArrayList<>();
for (ProxiedPlayer pps : this.api.getBungeePlugin().getProxy().getPlayers()) {
names.add(pps.getName());
}
try {
c.sendPacket(new PacketFriends(new FriendsActionTransmetterGUI(pp.getName(), pp.getServer().getInfo().getName().concat("-spigot"), this.friends.getAllFriends(pp.getName()), names)));
} catch (IOException e) {
e.printStackTrace();
}
} else {
if (sender instanceof ProxiedPlayer) {
sender.sendMessage(new TextComponent(this.pre + "/amis add <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis remove <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis list"));
sender.sendMessage(new TextComponent(this.pre + "/amis join <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis accept <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis gui"));
}
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "/amis show <pseudo>"));
}
}
} else {
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("accept")) {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, la console ne peut avoir d'amis :'(" + " (sauf Glowstoner mdr, sauf que c'est moi qui écrit ces lignes sur Eclipse," + " serais-je skyzophrène ?) C'est probable dit quelqu'un à l'horizon ... §oC'est le début d'une" + " longue histoire"));
}
}
if (args[0].equalsIgnoreCase("show")) {
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis show <pseudo>"));
} else {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'avez pas la permission d'utiliser cette fonctionnalité !"));
}
}
} else if (args.length == 2) {
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer pp = (ProxiedPlayer) sender;
ProxiedPlayer target = getPlayerByName(args[1]);
FirePlayer fp = new FirePlayer(pp, this.api);
if (args[0].equalsIgnoreCase("add")) {
if (target == null) {
pp.sendMessage(new TextComponent(this.pre + "§cErreur, aucun joueur trouvé pour \"" + args[1] + "\" !"));
return;
}
if (target.equals(pp)) {
pp.sendMessage(new TextComponent(this.pre + "§cVous devriez pensez à soigner votre skyzophrènie"));
return;
}
try {
if (!this.friends.isAlreadyFriends(pp, target)) {
if (this.friends.canHaveMoreFriends(fp)) {
pp.sendMessage(new TextComponent(this.pre + "§aVous avez bien " + "envoyé votre demande à §2" + target.getName()));
this.friends.sendRequest(pp, target);
} else {
pp.sendMessage(new TextComponent(this.pre + "§cErreur vous avez ateint le nombre maximum d'amis pour votre grade !"));
}
} else {
pp.sendMessage(new TextComponent(this.pre + "§cErreur, vous êtes déjà " + "ami avec " + target.getName() + " !"));
}
} catch (IOException e) {
e.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("remove")) {
try {
this.friends.removeFriend(pp, args[1]);
} catch (IOException ex) {
ex.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("join")) {
sender.sendMessage(new TextComponent(this.pre + "§5Indisponible pour le moment !"));
} else if (args[0].equalsIgnoreCase("accept")) {
if (target == null) {
pp.sendMessage(new TextComponent(this.pre + "§cErreur, aucun joueur trouvé pour \"" + args[1] + "\" !"));
return;
}
try {
this.friends.acceptRequest(pp, target);
} catch (IOException e) {
e.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("show")) {
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
try {
this.friends.sendGeneratedListOther(sender, args[1]);
} catch (IOException ex) {
ex.printStackTrace();
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'avez pas la permission d'utiliser cette fonctionnalité !"));
}
} else {
if (sender instanceof ProxiedPlayer) {
sender.sendMessage(new TextComponent(this.pre + "/amis add <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis remove <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis list"));
sender.sendMessage(new TextComponent(this.pre + "/amis join <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis accept <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis gui"));
}
if (sender.hasPermission("fireapi.friends.showother")) {
sender.sendMessage(new TextComponent(this.pre + "/amis show <pseudo>"));
}
}
} else {
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("accept")) {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, la console ne peut avoir d'amis :'(" + " (sauf Glowstoner mdr, sauf que c'est moi qui écrit ses lignes sur Eclipse," + " serais-je skyzophrène ?) C'est probable dit quelqu'un à l'horizon ... C'est le début d'une" + " longue histoire"));
} else {
try {
this.friends.sendGeneratedListOther(sender, args[1]);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
}
Aggregations