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


Java Bukkit.getConsoleSender方法代碼示例

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


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

示例1: onUpdateEnd

import org.bukkit.Bukkit; //導入方法依賴的package包/類
protected void onUpdateEnd(File file, CommandSender caller) {
    try {
        method.update(file, getPlugin());
    } catch (IOException e) {
        getLogger().log(Level.SEVERE,"Error while updating, please update the resource manually", e);
        if(caller != Bukkit.getConsoleSender()) {
            caller.sendMessage(ChatColor.RED + "An error occurred while updating the resource, please update it manually");
        }
        file.delete();
        return;
    }
    getLogger().info("Update succeeded, please restart the server");
    if(caller != Bukkit.getConsoleSender()) {
        caller.sendMessage(ChatColor.GREEN + "Update succeeded, please restart the server");
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:17,代碼來源:DownloadableUpdateChecker.java

示例2: getInstance

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static ConsoleCommandSender getInstance() {
    if (Bukkit.getConsoleSender() != null) {
        return Bukkit.getConsoleSender();
    } else {
        return new ColouredConsoleSender();
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:8,代碼來源:ColouredConsoleSender.java

示例3: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
    String message = ChatColor.DARK_GRAY + ": " + ChatColor.WHITE
            + Chat.applyAllFilters(sender, String.join(" ", skipArgs(args, 1)));
    CommandSender receiver = args[0].equalsIgnoreCase("CONSOLE")
            ? Bukkit.getConsoleSender() : Bukkit.getPlayer(args[0]);

    if (!Utils.isVisible(sender, receiver))
        return;

    if (receiver instanceof Player && AFK.isAFK((Player) receiver))
        sender.sendMessage(ChatColor.GRAY + "This player is AFK, and may not receive your message.");

    // Send display to sender
    String rName = Utils.getSenderName(receiver);
    sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.BOLD + "TO " + rName + message);
    if (sender instanceof Player)
        MetadataManager.setMetadata((Player) sender, "lastWhisper", receiver.getName());

    // Send display to receiver.
    if (receiver instanceof Player) {
        Player p = (Player) receiver;
        if (KCPlayer.getWrapper(p).isIgnoring(sender))
            return;

        p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, .75F);
        MetadataManager.setMetadata(p, "lastWhisper", sender.getName());
    }

    receiver.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.BOLD + "FROM " + Utils.getSenderName(sender) + message);
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:32,代碼來源:CommandMessage.java

示例4: addClaims

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Adds a collection of {@link Claim}s to this {@link ClaimableFaction}.
 *
 * @param adding
 *            the {@link Claim}s to add
 * @param sender
 *            the {@link CommandSender} adding the {@link Claim}s
 * @return true if the {@link Claim}s were successfully added
 */
public boolean addClaims(Collection<Claim> adding, @Nullable CommandSender sender) {
    if (sender == null)
        sender = Bukkit.getConsoleSender();

    FactionClaimChangeEvent event = new FactionClaimChangeEvent(sender, ClaimChangeCause.CLAIM, adding, this);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled() || !claims.addAll(adding)) {
        return false;
    }

    Bukkit.getPluginManager().callEvent(new FactionClaimChangedEvent(sender, ClaimChangeCause.CLAIM, adding));
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:23,代碼來源:ClaimableFaction.java

示例5: DefaultDownloadNotifier

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public DefaultDownloadNotifier(DownloadSession session, CommandSender caller) {
    this.session = session;
    this.caller = caller;
    this.isCallerConsole = caller == Bukkit.getConsoleSender();
    start();
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:7,代碼來源:DefaultDownloadNotifier.java

示例6: belongsTo

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean belongsTo(CommandSender sender) {
    return sender == Bukkit.getConsoleSender();
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:5,代碼來源:ConsoleIdentity.java

示例7: onPlayerChat

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent event)
{
  String message = event.getMessage();
  Player player = event.getPlayer();
  
  PlayerFaction playerFaction = this.plugin.getFactionManager().getPlayerFaction(player);
  ChatChannel chatChannel = playerFaction == null ? ChatChannel.PUBLIC : playerFaction.getMember(player).getChatChannel();
  
  Set<Player> recipients = event.getRecipients();
  if ((chatChannel == ChatChannel.FACTION) || (chatChannel == ChatChannel.ALLIANCE)) {
    if (isGlobalChannel(message))
    {
      message = message.substring(1, message.length()).trim();
      event.setMessage(message);
    }
    else
    {
      Collection<Player> online = playerFaction.getOnlinePlayers();
      if (chatChannel == ChatChannel.ALLIANCE)
      {
        Collection<PlayerFaction> allies = playerFaction.getAlliedFactions();
        for (PlayerFaction ally : allies) {
          online.addAll(ally.getOnlinePlayers());
        }
      }
      recipients.retainAll(online);
      event.setFormat(chatChannel.getRawFormat(player));
      
      Bukkit.getPluginManager().callEvent(new FactionChatEvent(true, playerFaction, player, chatChannel, recipients, event.getMessage()));
      return;
    }
  }
  String format = this.essentials.getSettings().getChatFormat(this.essentials.getUser(player).getGroup());
  String displayName = ChatColor.WHITE + format;
  
  event.setFormat(format);
  event.setCancelled(true);
  
  ConsoleCommandSender console = Bukkit.getConsoleSender();
  console.sendMessage(getFormattedMessage(player, playerFaction, displayName, message, console));
  for (Player recipient : event.getRecipients()) {
    recipient.sendMessage(getFormattedMessage(player, playerFaction, displayName, message, recipient));
  }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:46,代碼來源:ChatListener.java

示例8: removeClaims

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Removes a collection of {@link Claim}s for this {@link Faction}.
 *
 * @param toRemove
 *            the {@link Claim}s to remove
 * @param sender
 *            the {@link CommandSender} removing {@link Claim}s
 * @return true if the {@link Claim}s were successfully removed
 */
public boolean removeClaims(Collection<Claim> toRemove, @Nullable CommandSender sender) {
    if (sender == null) {
        sender = Bukkit.getConsoleSender();
    }

    int expected = this.claims.size() - toRemove.size();

    FactionClaimChangeEvent event = new FactionClaimChangeEvent(sender, ClaimChangeCause.UNCLAIM, new ArrayList<>(toRemove), this);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled() || !this.claims.removeAll(toRemove)) { // we clone the collection so we can show what we removed to the event.
        return false;
    }

    if (expected != this.claims.size()) {
        return false;
    }

    if (this instanceof PlayerFaction) {
        PlayerFaction playerFaction = (PlayerFaction) this;
        Location home = playerFaction.getHome();
        HCF plugin = HCF.getPlugin();

        int refund = 0;
        for (Claim claim : toRemove) {
            refund += plugin.getClaimHandler().calculatePrice(claim, expected, true);
            if (expected > 0)
                expected--;

            if (home != null && claim.contains(home)) {
                playerFaction.setHome(null);
                playerFaction.broadcast(ChatColor.RED.toString() + ChatColor.BOLD + "Your factions' home was unset as its residing claim was removed.");
                break;
            }
        }

        plugin.getEconomyManager().addBalance(playerFaction.getLeader().getUniqueId(), refund);
        playerFaction.broadcast(ChatColor.YELLOW + "Faction leader was refunded " + ChatColor.GREEN + EconomyManager.ECONOMY_SYMBOL + refund + ChatColor.YELLOW + " due to a land unclaim.");
    }

    Bukkit.getPluginManager().callEvent(new FactionClaimChangedEvent(sender, ClaimChangeCause.UNCLAIM, toRemove));
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:52,代碼來源:ClaimableFaction.java

示例9: getSender

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public CommandSender getSender() {
	return Bukkit.getConsoleSender();
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:5,代碼來源:VPConsole.java


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