當前位置: 首頁>>代碼示例>>Java>>正文


Java Command.broadcastCommandMessage方法代碼示例

本文整理匯總了Java中org.bukkit.command.Command.broadcastCommandMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java Command.broadcastCommandMessage方法的具體用法?Java Command.broadcastCommandMessage怎麽用?Java Command.broadcastCommandMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.command.Command的用法示例。


在下文中一共展示了Command.broadcastCommandMessage方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCommand

import org.bukkit.command.Command; //導入方法依賴的package包/類
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }
    final OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }
    final UUID targetUUID = target.getUniqueId();
    final FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    final Deathban deathban = factionTarget.getDeathban();
    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }
    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "A staff has revived " + target.getName() + ".");
    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:ReviveCommand.java

示例2: onCommand

import org.bukkit.command.Command; //導入方法依賴的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;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:20,代碼來源:LivesSetDeathbanTimeArgument.java

示例3: onCommand

import org.bukkit.command.Command; //導入方法依賴的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[1]);

    if (!(faction instanceof PlayerFaction)) {
        sender.sendMessage(ChatColor.RED + "Faction " + args[1] + " is either not found or is not a player faction.");
        return true;
    }

    Integer amount = JavaUtils.tryParseInt(args[2]);

    if (amount == null) {
        sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a number.");
        return true;
    }

    if (amount > SettingsYML.CONQUEST_REQUIRED_WIN_POINTS) {
        sender.sendMessage(ChatColor.RED + "Maximum points for Conquest is " + SettingsYML.CONQUEST_REQUIRED_WIN_POINTS + '.');
        return true;
    }

    PlayerFaction playerFaction = (PlayerFaction) faction;
    ((ConquestTracker) EventType.CONQUEST.getEventTracker()).setPoints(playerFaction, amount);

    Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Set the points of faction " + playerFaction.getName() + " to " + amount + '.');
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:33,代碼來源:ConquestSetpointsArgument.java

示例4: onCommand

import org.bukkit.command.Command; //導入方法依賴的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;
    }

    if (args[1].equalsIgnoreCase("all")) {
        if (!(sender instanceof ConsoleCommandSender)) {
            sender.sendMessage(ChatColor.RED + "This command can be only executed from console.");
            return true;
        }

        Conversable conversable = (Conversable) sender;
        conversable.beginConversation(factory.buildConversation(conversable));
        return true;
    }

    Faction faction = plugin.getFactionManager().getContainingFaction(args[1]);

    if (faction == null) {
        sender.sendMessage(ChatColor.RED + "Faction named or containing member with IGN or UUID " + args[1] + " not found.");
        return true;
    }

    if (plugin.getFactionManager().removeFaction(faction, sender)) {
        Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Disbanded faction " + faction.getName() + ChatColor.YELLOW + '.');
    }

    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:32,代碼來源:FactionRemoveArgument.java

示例5: onCommand

import org.bukkit.command.Command; //導入方法依賴的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().getContainingFaction(args[1]);

    if (faction == null) {
        sender.sendMessage(ChatColor.RED + "Faction named or containing member with IGN or UUID " + args[1] + " not found.");
        return true;
    }

    Double multiplier = JavaUtils.tryParseDouble(args[2]);

    if (multiplier == null) {
        sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a valid number.");
        return true;
    }

    if (multiplier < MIN_MULTIPLIER) {
        sender.sendMessage(ChatColor.RED + "Deathban multipliers may not be less than " + MIN_MULTIPLIER + '.');
        return true;
    }

    if (multiplier > MAX_MULTIPLIER) {
        sender.sendMessage(ChatColor.RED + "Deathban multipliers may not be more than " + MAX_MULTIPLIER + '.');
        return true;
    }

    double previousMultiplier = faction.getDeathbanMultiplier();
    faction.setDeathbanMultiplier(multiplier);

    Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Set deathban multiplier of " + faction.getName() + " from " + previousMultiplier + " to " + multiplier + '.');
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:38,代碼來源:FactionSetDeathbanMultiplierArgument.java

示例6: onCommand

import org.bukkit.command.Command; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    for (FactionUser user : plugin.getUserManager().getUsers().values()) {
        user.removeDeathban();
    }

    Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "All death-bans have been cleared.");
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:10,代碼來源:LivesClearDeathbansArgument.java

示例7: onCommand

import org.bukkit.command.Command; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }

    OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); // TODO: breaking

    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }

    UUID targetUUID = target.getUniqueId();
    FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    Deathban deathban = factionTarget.getDeathban();

    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }

    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "Staff revived " + target.getName() + ".");
    //sender.sendMessage(ChatColor.GREEN +"You have revived: " + target.getName() + ChatColor.GRAY + ChatColor.ITALIC + "(Click here to refund items)").setHoverText(ChatColor.GREEN + "Click here to refund items for: " + ChatColor.GRAY + target.getPlayer().getName().setClick(ClickAction.RUN_COMMAND, "/inv " + target.getPlayer().getName()));
    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:29,代碼來源:StaffReviveCommand.java

示例8: onCommand

import org.bukkit.command.Command; //導入方法依賴的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;
    }

    long newRegen = JavaUtils.parse(args[2]);

    if (newRegen < 0L) {
        sender.sendMessage(ChatColor.RED + "Faction DTR regeneration duration cannot be negative.");
        return true;
    }

    if (newRegen > FactionManager.MAX_DTR_REGEN_MILLIS) {
        sender.sendMessage(ChatColor.RED + "Cannot set factions DTR regen above " + FactionManager.MAX_DTR_REGEN_WORDS + ".");
        return true;
    }

    Faction faction = plugin.getFactionManager().getContainingFaction(args[1]);

    if (faction == null) {
        sender.sendMessage(ChatColor.RED + "Faction named or containing member with IGN or UUID " + args[1] + " not found.");
        return true;
    }

    if (!(faction instanceof PlayerFaction)) {
        sender.sendMessage(ChatColor.RED + "This type of faction does not use DTR.");
        return true;
    }

    PlayerFaction playerFaction = (PlayerFaction) faction;
    long previousRegenRemaining = playerFaction.getRemainingRegenerationTime();
    playerFaction.setRemainingRegenerationTime(newRegen);

    Command.broadcastCommandMessage(
            sender,
            ChatColor.YELLOW + "Set DTR regen of " + faction.getName()
                    + (previousRegenRemaining > 0L ? " from " + DurationFormatUtils.formatDurationWords(previousRegenRemaining, true, true) : "") + " to "
                    + DurationFormatUtils.formatDurationWords(newRegen, true, true) + '.');

    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:44,代碼來源:FactionSetDtrRegenArgument.java


注:本文中的org.bukkit.command.Command.broadcastCommandMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。