本文整理匯總了Java中org.bukkit.command.CommandSender.sendMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java CommandSender.sendMessage方法的具體用法?Java CommandSender.sendMessage怎麽用?Java CommandSender.sendMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.command.CommandSender
的用法示例。
在下文中一共展示了CommandSender.sendMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
Player player = (Player) sender;
LogoutTimer logoutTimer = plugin.getTimerManager().getLogoutTimer();
if (!logoutTimer.setCooldown(player, player.getUniqueId())) {
sender.sendMessage(ChatColor.YELLOW + "Your " + logoutTimer.getDisplayName() + ChatColor.YELLOW + " timer is already active.");
return true;
}
sender.sendMessage(ChatColor.YELLOW + "Your " + logoutTimer.getDisplayName() + ChatColor.YELLOW + " timer has started.");
return true;
}
示例2: execute
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
boolean success = false;
if (!owningPlugin.isEnabled()) {
return false;
}
if (!testPermission(sender)) {
return true;
}
try {
success = executor.onCommand(sender, this, commandLabel, args);
} catch (Throwable ex) {
throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " + owningPlugin.getDescription().getFullName(), ex);
}
if (!success && usageMessage.length() > 0) {
for (String line : usageMessage.replace("<command>", commandLabel).split("\n")) {
sender.sendMessage(line);
}
}
return success;
}
示例3: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
return true;
}
long duration = JavaUtils.parse(args[1]);
if (duration == -1L) {
sender.sendMessage(ChatColor.RED + "Invalid duration, use the correct format: 10m 1s");
return true;
}
SettingsYML.DEFAULT_DEATHBAN_DURATION = duration;
Command.broadcastCommandMessage(sender, ChatColor.RED + "Base death-ban time set to " + DurationFormatUtils.formatDurationWords(duration, true, true) + " (not including multipliers, etc).");
return true;
}
示例4: setInputs
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public void setInputs(CommandSender initiator, String[] args) {
if (this.shouldLearn) {
initiator
.sendMessage("Stop the learning before testing. use /nn stoplearning");
return;
}
if (args.length > 1) {
boolean test = false;
try {
test = Boolean.parseBoolean(args[1]);
} catch (Exception e) {
}
binary.changeValueAt(0, 0, test);
} else {
initiator.sendMessage("Provide one value (True or false)");
}
}
示例5: executeConsole
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public void executeConsole(CommandSender sender, String[] args) {
if (args.length != 2) {
sender.sendMessage(ChatColor.RED + "Use as /removeunlock <name> <unlock>");
} else if (args.length == 2) {
Unlock unlock = Unlock.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.removeUnlock(unlock);
sender.sendMessage("Removed unlock " + unlock + " from " + pd2.getName());
} else {
sender.sendMessage("User is not online.");
}
}
}
示例6: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
FactionUser factionUser = plugin.getUserManager().getUser(((Player) sender).getUniqueId());
boolean newStatus = !factionUser.isCapzoneEntryAlerts();
factionUser.setCapzoneEntryAlerts(newStatus);
sender.sendMessage(ChatColor.YELLOW + "You will now " + (newStatus ? ChatColor.GREEN.toString() : ChatColor.RED + "un") + "able" + ChatColor.YELLOW + " to see capture zone entry messages.");
return true;
}
示例7: sendHelp
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
private void sendHelp(CommandSender sender) {
sender.sendMessage("");
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSlimefun &2v" + plugin.getDescription().getVersion()));
sender.sendMessage("");
for (int i = 0; i < arguments.size(); i++) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&3" + arguments.get(i) + " &b") + descriptions.get(i));
}
}
示例8: executeConsole
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public void executeConsole(CommandSender sender, String[] args) {
if (args.length == 2) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.setRank(args[1]);
sender.sendMessage(ChatColor.GREEN + p2.getName() + "'s rank set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
p2.sendMessage(ChatColor.GREEN + "Your rank was set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
} else {
sender.sendMessage("User is not online");
}
}
}
示例9: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 3) {
sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
return true;
}
Faction faction = plugin.getFactionManager().getFaction(args[2]);
if (faction != null) {
sender.sendMessage(ChatColor.RED + "There is already a faction named " + args[2] + '.');
return true;
}
faction = plugin.getFactionManager().getFaction(args[1]);
if (!(faction instanceof EventFaction)) {
sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'.");
return true;
}
String oldName = faction.getName();
faction.setName(args[2], sender);
sender.sendMessage(ChatColor.YELLOW + "Renamed event " + ChatColor.WHITE + oldName + ChatColor.YELLOW + " to " + ChatColor.WHITE + faction.getName() + ChatColor.YELLOW + '.');
return true;
}
示例10: showHelpText
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
/**
* Shows help text for this command
*/
public final boolean showHelpText(CommandSender sender, String[] args) {
if (!sender.hasPermission(this.permission)) {
sender.sendMessage(ChatColor.RED + "You do not have permission to do that!");
return true;
}
sender.sendMessage("==== " + ChatColor.GOLD + "/" + this.getName() + ChatColor.RESET + " ====");
return this.helpLogic(sender, args);
}
示例11: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can have faction invites.");
return true;
}
List<String> receivedInvites = new ArrayList<>();
for (Faction faction : plugin.getFactionManager().getFactions()) {
if (faction instanceof PlayerFaction) {
PlayerFaction targetPlayerFaction = (PlayerFaction) faction;
if (targetPlayerFaction.getInvitedPlayerNames().contains(sender.getName())) {
receivedInvites.add(targetPlayerFaction.getDisplayName(sender));
}
}
}
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction((Player) sender);
String delimiter = ChatColor.WHITE + ", " + ChatColor.GRAY;
if (playerFaction != null) {
Set<String> sentInvites = playerFaction.getInvitedPlayerNames();
sender.sendMessage(ChatColor.AQUA + "Sent by " + playerFaction.getDisplayName(sender) + ChatColor.AQUA + " (" + sentInvites.size() + ')' + ChatColor.DARK_AQUA + ": " + ChatColor.GRAY
+ (sentInvites.isEmpty() ? "Your faction has not invited anyone." : StringUtils.join(sentInvites, delimiter) + '.'));
}
sender.sendMessage(ChatColor.AQUA + "Requested (" + receivedInvites.size() + ')' + ChatColor.DARK_AQUA + ": " + ChatColor.GRAY
+ (receivedInvites.isEmpty() ? "No factions have invited you." : StringUtils.join(receivedInvites, ChatColor.WHITE + delimiter) + '.'));
return true;
}
示例12: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
public static boolean onCommand(CommandSender sender, Command command, String label, String[] args){
if(plugin == null) sender.getServer().getLogger().info("CommandManager Not Init !");
if (command.getName().equalsIgnoreCase(ExpRateChangeCommand.COMMAND)){
return new ExpRateChangeCommand().onCommand(sender,label,args);
}else {
sender.sendMessage(ChatColor.RED + "Unknown Command");
return true;
}
}
示例13: loadmaps
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Command(aliases = {"loadmaps"}, desc = "Load maps.")
@CommandPermissions({"tgm.loadmaps"})
public static void loadmaps(CommandContext cmd, CommandSender sender) {
TGM.get().getMatchManager().getMapLibrary().refreshMaps();
TGM.get().getMatchManager().getMapRotation().refresh();
sender.sendMessage(ChatColor.GREEN + "Refreshed map library and rotation.");
}
示例14: validatePlayer
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
private static boolean validatePlayer(CommandSender sender, String playerName) {
Player player = RPGInventory.getInstance().getServer().getPlayer(playerName);
if (player == null) {
sender.sendMessage(StringUtils.coloredLine("&cPlayer '" + playerName + "' not found!"));
}
return validatePlayer(sender, player);
}
示例15: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
return true;
}
PlayerFaction playerFaction = plugin.getFactionManager().getContainingPlayerFaction(args[1]);
if (playerFaction == null) {
sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
return true;
}
FactionMember factionMember = playerFaction.getMember(args[1]);
if (factionMember == null) {
sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
return true;
}
if (factionMember.getRole() == Role.LEADER) {
sender.sendMessage(ChatColor.RED + factionMember.getName() + " is already the leader of " + playerFaction.getDisplayName(sender) + ChatColor.RED + '.');
return true;
}
FactionMember leader = playerFaction.getLeader();
String oldLeaderName = leader == null ? "none" : leader.getName();
String newLeaderName = factionMember.getName();
// Demote the previous leader, promoting the new.
if (leader != null) {
leader.setRole(Role.CAPTAIN);
}
factionMember.setRole(Role.LEADER);
playerFaction.broadcast(ChatColor.YELLOW + sender.getName() + " has forcefully set the leader to " + newLeaderName + '.');
sender.sendMessage(ChatColor.GOLD.toString() + ChatColor.BOLD + "Leader of " + playerFaction.getName() + " was forcefully set from " + oldLeaderName + " to " + newLeaderName + '.');
return true;
}