当前位置: 首页>>代码示例>>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;未经允许,请勿转载。