Java Code Examples for org.bukkit.command.CommandSender#sendMessage()
The following examples show how to use
org.bukkit.command.CommandSender#sendMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelpCommand.java From PerWorldInventory with GNU General Public License v3.0 | 7 votes |
@Override public void executeCommand(CommandSender sender, List<String> args) { if (sender instanceof Player) { // Send the pretty version sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------"); sender.sendMessage(ChatColor.DARK_GRAY + " [ " + ChatColor.BLUE + "PerWorldInventory Commands" + ChatColor.DARK_GRAY + " ]"); sender.sendMessage(ChatColor.GRAY + "Commands may be run using either " + ChatColor.WHITE + "/perworldinventory" + ChatColor.GRAY + " or " + ChatColor.WHITE + "/pwi"); sender.sendMessage(""); sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory convert multiverse" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Convert data from Multiverse-Inventories"); sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory help" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Shows this help page"); sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory reload" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Reloads all configuration files"); sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory version" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Shows the version and authors of the server"); sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory setworlddefault [group|serverDefault]" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Set the default inventory loadout for a world, or the server default." + '\n' + ChatColor.YELLOW + "The group you are standing in will be used if no group is specified."); sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------"); } else { // Sender is the console, no pretty stuff for you! sender.sendMessage("-----------------------------------------------------"); sender.sendMessage("PerWorldInventory commands:"); sender.sendMessage("/perworldinventory convert - Convert MultiVerse-Inventories data"); sender.sendMessage("/perworldinventory help - Displays this help"); sender.sendMessage("/perworldinventory version - Shows the version of the server"); sender.sendMessage("/perworldinventory reload - Reload config and world files"); sender.sendMessage("-----------------------------------------------------"); } }
Example 2
Source File: SentinelTargetCommands.java From Sentinel with MIT License | 6 votes |
@Command(aliases = {"sentinel"}, usage = "removeavoid TYPE", desc = "Stops avoding a target.", modifiers = {"removeavoid"}, permission = "sentinel.removeavoid", min = 2, max = 2) @Requirements(livingEntity = true, ownership = true, traits = {SentinelTrait.class}) public void removeAvoid(CommandContext args, CommandSender sender, SentinelTrait sentinel) { SentinelTargetLabel targetLabel = new SentinelTargetLabel(args.getString(1)); if (!testLabel(sender, targetLabel)) { return; } if (targetLabel.removeFromList(sentinel.allAvoids)) { sender.sendMessage(SentinelCommand.prefixGood + "No longer avoiding that target!"); } else { sender.sendMessage(SentinelCommand.prefixBad + "Was already not tracking that target!"); } }
Example 3
Source File: AddHoloCommand.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@Override public boolean execute(CommandSender sender, ArrayList<String> args) { if (!super.hasPermission(sender)) { return false; } if (!BedwarsRel.getInstance().isHologramsEnabled()) { String missingholodependency = BedwarsRel.getInstance().getMissingHoloDependency(); sender.sendMessage(ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(sender, "errors.holodependencynotfound", ImmutableMap.of("dependency", missingholodependency)))); return true; } Player player = (Player) sender; BedwarsRel.getInstance().getHolographicInteractor() .addHologramLocation(player.getEyeLocation()); BedwarsRel.getInstance().getHolographicInteractor().updateHolograms(); return true; }
Example 4
Source File: HelpCommand.java From PetMaster with GNU General Public License v3.0 | 6 votes |
/** * Sends a packet message to the server in order to display a clickable and hoverable message. A suggested command * is displayed in the chat when clicked on, and an additional help message appears when a command is hovered. * * @param sender * @param message * @param command * @param hover */ public void sendJsonClickableHoverableMessage(CommandSender sender, String message, String command, String hover) { // Send clickable and hoverable message if sender is a player and if no exception is caught. if (sender instanceof Player) { try { FancyMessageSender.sendHoverableCommandMessage((Player) sender, message, command, hover, "gold"); } catch (Exception ex) { plugin.getLogger() .severe("Errors while trying to display clickable and hoverable message in /petm help command. " + "Displaying standard message instead."); sender.sendMessage(message); } } else { sender.sendMessage(message); } }
Example 5
Source File: BukkitSenderFactory.java From LuckPerms with MIT License | 5 votes |
@Override protected void sendMessage(CommandSender sender, String s) { // we can safely send async for players and the console if (sender instanceof Player || sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender) { sender.sendMessage(s); return; } // otherwise, send the message sync getPlugin().getBootstrap().getScheduler().executeSync(new SyncMessengerAgent(sender, s)); }
Example 6
Source File: UpgradeCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void admin(CommandSender sender, String[] args, Island island) { Player p = (Player) sender; if (island != null) { p.openInventory(island.getUpgradeGUI().getInventory()); } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } }
Example 7
Source File: NickNamerErrorHandler.java From NickNamer with MIT License | 5 votes |
@Override public void handlePermissionException(final PermissionException exception, CommandSender sender, Command command, String[] args) { sender.sendMessage(MESSAGE_LOADER.getMessage("permission", "permission", new MessageFormatter() { @Override public String format(String key, String message) { return String.format(message, exception.getPermission()); } })); }
Example 8
Source File: PermissionGroups.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void execute(CommandSender sender, List<String> arguments) { sender.sendMessage(ChatColor.BLUE + "AuthMe permission groups"); String name = arguments.isEmpty() ? sender.getName() : arguments.get(0); Player player = Bukkit.getPlayer(name); if (player == null) { sender.sendMessage("Player " + name + " could not be found"); } else { sender.sendMessage("Player " + name + " has permission groups: " + String.join(", ", permissionsManager.getGroups(player))); sender.sendMessage("Primary group is: " + permissionsManager.getGroups(player)); } }
Example 9
Source File: GiveCrystalsCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 3) { sender.sendMessage(Utils.color(IridiumSkyblock.getConfiguration().prefix) + "/is givecrystals <player> <amount>"); return; } if (Bukkit.getPlayer(args[1]) != null) { OfflinePlayer player = Bukkit.getPlayer(args[1]); if (player != null) { Island island = User.getUser(player).getIsland(); if (island != null) { try { int amount = Integer.parseInt(args[2]); island.setCrystals(island.getCrystals() + amount); sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().giveCrystals.replace("%crystals%", args[2]).replace("%player%", player.getName()).replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); if (player.getPlayer() != null) player.getPlayer().sendMessage(Utils.color(IridiumSkyblock.getMessages().givenCrystals.replace("%crystals%", args[2]).replace("%player%", sender.getName()).replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } catch (Exception e) { sender.sendMessage(args[2] + "is not a number"); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().playerNoIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().playerOffline.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } }
Example 10
Source File: LimboPlayerViewer.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void execute(CommandSender sender, List<String> arguments) { if (arguments.isEmpty()) { sender.sendMessage(ChatColor.BLUE + "AuthMe limbo viewer"); sender.sendMessage("/authme debug limbo <player>: show a player's limbo info"); sender.sendMessage("Available limbo records: " + applyToLimboPlayersMap(limboService, Map::keySet)); return; } LimboPlayer memoryLimbo = limboService.getLimboPlayer(arguments.get(0)); Player player = bukkitService.getPlayerExact(arguments.get(0)); LimboPlayer diskLimbo = player != null ? limboPersistence.getLimboPlayer(player) : null; if (memoryLimbo == null && player == null) { sender.sendMessage(ChatColor.BLUE + "No AuthMe limbo data"); sender.sendMessage("No limbo data and no player online with name '" + arguments.get(0) + "'"); return; } sender.sendMessage(ChatColor.BLUE + "Player / limbo / disk limbo info for '" + arguments.get(0) + "'"); new InfoDisplayer(sender, player, memoryLimbo, diskLimbo) .sendEntry("Is op", Player::isOp, LimboPlayer::isOperator) .sendEntry("Walk speed", Player::getWalkSpeed, LimboPlayer::getWalkSpeed) .sendEntry("Can fly", Player::getAllowFlight, LimboPlayer::isCanFly) .sendEntry("Fly speed", Player::getFlySpeed, LimboPlayer::getFlySpeed) .sendEntry("Location", p -> formatLocation(p.getLocation()), l -> formatLocation(l.getLocation())) .sendEntry("Prim. group", p -> permissionsManager.hasGroupSupport() ? permissionsManager.getPrimaryGroup(p) : "N/A", LimboPlayer::getGroups); }
Example 11
Source File: NickCommands.java From NickNamer with MIT License | 5 votes |
@Command(name = "listNames", aliases = { "nicklist", "listnick" }, description = "Get a list of used names", max = 0) @Permission("nick.command.name.list") public void listNick(final CommandSender sender) { Collection<String> usedNicks = NickNamerAPI.getNickManager().getUsedNicks(); if (usedNicks.isEmpty()) { sender.sendMessage(CommandUtil.MESSAGE_LOADER.getMessage("name.error.list.empty", "name.error.list.empty")); return; } sender.sendMessage(CommandUtil.MESSAGE_LOADER.getMessage("name.list.used", "name.list.used")); for (final String used : usedNicks) { Collection<UUID> usedByIds = NickNamerAPI.getNickManager().getPlayersWithNick(used); final Set<String> usedByNames = new HashSet<>(); for (UUID uuid : usedByIds) { OfflinePlayer player = Bukkit.getOfflinePlayer(uuid); if (player != null) { usedByNames.add(player.getName()); } else { usedByNames.add(uuid.toString()); } } sender.sendMessage(CommandUtil.MESSAGE_LOADER.getMessage("name.list.format", "name.list.format", new MessageFormatter() { @Override public String format(String key, String message) { return String.format(message, used, usedByNames.toString()); } })); } }
Example 12
Source File: CommandList.java From TrMenu with MIT License | 5 votes |
@Override public void onCommand(CommandSender sender, Command command, String label, String[] args) { String filter = args.length > 0 ? ArrayUtil.arrayJoin(args, 0).toLowerCase() : null; TLocale.sendTo(sender, "COMMANDS.LIST"); TrMenuAPI.getMenuIds().stream().filter(m -> filter == null || m.toLowerCase().contains(filter)).forEach(id -> TellrawJson.create().append(Strings.replaceWithOrder(TLocale.asString("COMMANDS.LIST-FORMAT"), id + ".yml")).hoverText("§7点击立即打开!").clickCommand("/trmenu open " + id).send(sender)); sender.sendMessage(""); }
Example 13
Source File: BankCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void admin(CommandSender sender, String[] args, Island island) { Player p = (Player) sender; if (island != null) { p.openInventory(island.getBankGUI().getInventory()); } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } }
Example 14
Source File: TeamPMCommand.java From UHC with MIT License | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(messages.getRaw("players only")); return true; } if (args.length == 0) { sender.sendMessage(messages.getRaw("no message")); return true; } final Team team = module.getScoreboard().getPlayerTeam((OfflinePlayer) sender); if (team == null) { sender.sendMessage(messages.getRaw("not in team")); return true; } final Iterable<Player> online = Iterables.filter( Iterables.transform(team.getPlayers(), FunctionalUtil.ONLINE_VERSION), Predicates.notNull() ); final Map<String, String> context = ImmutableMap.<String, String>builder() .put("team prefix", team.getPrefix()) .put("team display name", team.getDisplayName()) .put("team name", team.getName()) .put("sender", sender.getName()) .put("message", Joiner.on(" ").join(args)) .build(); final String message = messages.evalTemplate("message format", context); for (final Player player : online) { player.sendMessage(message); } return true; }
Example 15
Source File: SlimefunLocalization.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public void sendMessage(CommandSender sender, String key, boolean addPrefix, UnaryOperator<String> function) { if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { return; } String prefix = addPrefix ? getPrefix() : ""; if (sender instanceof Player) { sender.sendMessage(ChatColors.color(prefix + function.apply(getMessage((Player) sender, key)))); } else { sender.sendMessage(ChatColor.stripColor(ChatColors.color(prefix + function.apply(getMessage(key))))); } }
Example 16
Source File: Main.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("ce") || cmd.getName().equalsIgnoreCase("customenchantments")) { String result = commandC.processCommand(sender, args); if (result != "") sender.sendMessage(result); return true; } return false; }
Example 17
Source File: HistoryModule.java From Modern-LWC with MIT License | 5 votes |
/** * Send the history list to a player * * @param sender * @param relatedHistory * @param page * @param maxPages * @param historyCount */ public void sendHistoryList(CommandSender sender, List<History> relatedHistory, int page, int maxPages, int historyCount) { String format = "%4s%12s%12s%12s"; // Header LWC.getInstance().sendLocale(sender, "lwc.history.list", "header", String.format(format, "Id", "Player", "Type", "Status"), "size", relatedHistory.size(), "page", page, "totalpages", maxPages, "totalhistory", historyCount); // Send all that is found to them for (History history : relatedHistory) { sender.sendMessage(String.format(format, ("" + history.getId()), history.getPlayer(), history.getType(), history.getStatus())); } }
Example 18
Source File: PurgePlayerCommand.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private void executeCommand(CommandSender sender, String name, String option) { if ("force".equals(option) || !dataSource.isAuthAvailable(name)) { OfflinePlayer offlinePlayer = bukkitService.getOfflinePlayer(name); purgeExecutor.executePurge(singletonList(offlinePlayer), singletonList(name.toLowerCase())); sender.sendMessage("Purged data for player " + name); } else { sender.sendMessage("This player is still registered! Are you sure you want to proceed? " + "Use '/authme purgeplayer " + name + " force' to run the command anyway"); } }
Example 19
Source File: InventoryClearCommand.java From Minepacks with GNU General Public License v3.0 | 4 votes |
@Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if(sender.hasPermission(Permissions.INVENTORY_CLEAR)) { if(args.length > 0) { if(sender.hasPermission(Permissions.INVENTORY_CLEAR_OTHER)) { for(String name : args) { Player player = plugin.getServer().getPlayer(name); if(player == null) { messageUnknownPlayer.send(sender, name); } else { clearInventory(player, sender); } } } else { plugin.messageNoPermission.send(sender); } } else if(sender instanceof Player) { clearInventory((Player) sender, sender); } else { sender.sendMessage("/clear <player_name>"); //TODO } } else { plugin.messageNoPermission.send(sender); } return true; }
Example 20
Source File: DiscordChatCommand.java From DiscordBot with Apache License 2.0 | 4 votes |
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!sender.hasPermission(this.permission)) { sender.sendMessage(ChatColor.RED + "You do not have permission!"); return true; } StringBuilder stringBuilder = new StringBuilder(); for (String arg : args) { stringBuilder.append(arg + " "); } if (stringBuilder.toString().trim().length() == 0) { sender.sendMessage(ChatColor.RED + "Message cannot be blank!"); return true; } 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 Player) { Player player = (Player) sender; if (DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(player.getUniqueId())) { player.sendMessage(ChatColor.RED + "DiscordChat disabled. '/DiscordBot Toggle' to enable"); return true; } message.setName(player.getName()).setNick(player.getDisplayName()); if (player.getServer() != null && player.getServer().getName() != null) { message.setServer(player.getServer().getName()); } } DiscordBotCore.getInstance().getMessageSender().sendMessage(message); return true; }