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


Java CommandSender.getName方法代碼示例

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


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

示例1: getPlayerFromSender

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
public FPPlayer getPlayerFromSender(CommandSender sender)
{
	String playername = sender.getName();
	
	FPPlayer player = players.get(playername);
	if(player == null)
	{
		player = newPlayer(playername);
	}
	return player;
}
 
開發者ID:Ecconia,項目名稱:FusePort,代碼行數:12,代碼來源:PlayerCache.java

示例2: build

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
/**
 * Create an instance of a message with a given sender
 * and message
 *
 * @param sender Sender of the moderator message
 * @param modChannel Channel of the moderator message
 * @param message Prefix color of the sender
 *
 * @return New instance
 */
public static JsonModMessage build(CommandSender sender, ModChannel modChannel, String message)
{
    if (sender instanceof Player)
    {
        String prefix ="";//TODO SamaGamesAPI.get().getPermissionsManager().getPrefix(SamaGamesAPI.get().getPermissionsManager().getApi().getUser(((Player) sender).getUniqueId()));
        ChatColor pr = (prefix == null) ? ChatColor.AQUA : ChatColor.getByChar(prefix.charAt(prefix.length() - 1));

        return new JsonModMessage(sender.getName(), modChannel, pr, message);
    }
    else
    {
        return new JsonModMessage(sender.getName(), modChannel, ChatColor.AQUA, message);
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:25,代碼來源:JsonModMessage.java

示例3: onCommand

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (Rank.getRank(sender.getName()).getType().getLevel() < RankType.MOD.getLevel()) {
		Chat.player(sender, "&cYou don't have permission to do this.");
		return true;
	}
    if (args.length < 2) {
    	Chat.player(sender, "&cUsage: /ban [username] [reason]");
    	return true;
    }
    
    String username = null;
    String reason = Chat.stripColor(StringUtils.join(args, " ", 1, args.length));
    
    Player p = Bukkit.getPlayerExact(args[0]);
    if (p != null)
    	username = p.getName();
    else {
    	String check = Hive.getInstance().getUsername(args[0]);
    	if (check != null)
    		username = check;
    }
    if (username == null) {
    	Chat.player(sender, "&cNo player found by the name of, " + args[0]);
    	return true;
    }
    String prefix = "INSERT INTO infractions (username,staff,type,reason) VALUES ";
    String content = "('" + username + "','" + sender.getName() + "','ban','" + reason + "')";
    Hive.getInstance().getDatabase().update(prefix + content);
    
    Chat.player(sender, "&4[Ban] &b" + username + " &7&ofor &c" + reason);
    
    Ban i = new Ban(username, reason, Hive.getInstance().getServerTime());
  	if (p != null && p.isOnline())
  		p.kickPlayer(i.getKickMessage());
  	
    return true;
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:39,代碼來源:BanCmd.java

示例4: onCommand

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (Rank.getRank(sender.getName()).getType().getLevel() < RankType.MOD.getLevel()) {
		Chat.player(sender, "&cYou don't have permission to do this.");
		return true;
	}
    if (args.length < 2) {
    	Chat.player(sender, "&cUsage: /kick [username] [reason]");
    	return true;
    }
    
    String username = null;
    String reason = Chat.stripColor(StringUtils.join(args, " ", 1, args.length));
    
    Player p = Bukkit.getPlayerExact(args[0]);
    if (p == null) {
    	Chat.player(sender, "&cNo user online by the name of, " + args[0]);
    	return true;
    }
    username = p.getName();
    
    String prefix = "INSERT INTO infractions (username,staff,type,reason) VALUES ";
    String content = "('" + username + "','" + sender.getName() + "','kick','" + reason + "')";
    Hive.getInstance().getDatabase().update(prefix + content);
    
    Chat.player(sender, "&4[Kick] &b" + username + " &7&ofor &c" + reason);
    
    Kick i = new Kick(username, reason, Hive.getInstance().getServerTime());
  	if (p != null && p.isOnline())
  		p.kickPlayer(i.getKickMessage());
  	
    return true;
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:34,代碼來源:KickCmd.java

示例5: onFactionCreate

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onFactionCreate(FactionCreateEvent event) {
    Faction faction = event.getFaction();
    if (faction instanceof PlayerFaction) {
        CommandSender sender = event.getSender();
        for (Player player : Bukkit.getOnlinePlayers()) {
            Relation relation = faction.getRelation(player);
            String msg = ChatColor.YELLOW + "The faction " + relation.toChatColour() + (player == null ? faction.getName() : faction.getName()) + ChatColor.YELLOW + " has been " + ChatColor.GREEN
                    + "created" + ChatColor.YELLOW + " by " + ChatColor.AQUA + (sender instanceof Player ? ((Player) sender).getName() : sender.getName()) + ChatColor.YELLOW + '.';
            player.sendMessage(msg);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:14,代碼來源:FactionListener.java

示例6: onFactionRemove

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onFactionRemove(FactionRemoveEvent event) {
    Faction faction = event.getFaction();
    if (faction instanceof PlayerFaction) {
        CommandSender sender = event.getSender();
        for (Player player : Bukkit.getOnlinePlayers()) {
            Relation relation = faction.getRelation(player);
            String msg = ChatColor.YELLOW + "The faction " + relation.toChatColour() + (player == null ? faction.getName() : faction.getName()) + ChatColor.YELLOW + " has been " + ChatColor.RED
                    + "disbanded" + ChatColor.YELLOW + " by " + ChatColor.AQUA + (sender instanceof Player ? ((Player) sender).getName() : sender.getName()) + ChatColor.YELLOW + '.';
            player.sendMessage(msg);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:14,代碼來源:FactionListener.java

示例7: onCommand

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  	if (Rank.getRank(sender.getName()).getType().getLevel() < RankType.MOD.getLevel()) {
  		Chat.player(sender, "&cYou don't have permission to do this.");
  		return true;
  	}
      if (args.length < 3) {
      	Chat.player(sender, "&cUsage: /tempban [username] [time] [reason]");
      	return true;
      }
      
      String username = null;
      String reason = Chat.stripColor(StringUtils.join(args, " ", 2, args.length));
      
      Player p = Bukkit.getPlayerExact(args[0]);
      if (p != null)
      	username = p.getName();
      else {
      	String check = Hive.getInstance().getUsername(args[0]);
      	if (check != null)
      		username = check;
      }
      if (username == null) {
      	Chat.player(sender, "&cNo player found by the name of, " + args[0]);
      	return true;
      }
      
      int duration = parseTime(args[1]);
      if (duration == 0) {
          Chat.player(sender, "&cInvalid duration! (ex. 10m, 6h, 1d, 1w)");
          return true;
      }
      String prefix = "INSERT INTO infractions (username,staff,type,end,reason) VALUES ";
      String content = "('" + username + "','" + sender.getName() + "','tempban',DATE_ADD(now(), INTERVAL " + duration + " SECOND),'" + reason + "')";
      Hive.getInstance().getDatabase().update(prefix + content);
      Chat.player(sender, "&4[Tempban] &b" + username + " &7&ofor &c" + reason + " &7(" + getDuration(args[1]) + ")");
      
      Date expires = null;
      ResultSet r = Hive.getInstance().getDatabase().query("SELECT DATE_ADD(now(), INTERVAL " + duration + " SECOND)");
      try {
	while (r.next())
		expires = r.getTimestamp("DATE_ADD(now(), INTERVAL " + duration + " SECOND)");
} catch (SQLException e) {
	e.printStackTrace();
}
      	
      Tempban i = new Tempban(username, reason, Hive.getInstance().getServerTime(), expires);
    	if (p != null && p.isOnline())
    		p.kickPlayer(i.getKickMessage());
    	
  	return true;
  }
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:53,代碼來源:TempbanCmd.java

示例8: handleCommandSender

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Nonnull
private static String handleCommandSender(CommandSender sender) {
    return sender.getName();
}
 
開發者ID:zachbr,項目名稱:Debuggery,代碼行數:5,代碼來源:OutputFormatter.java

示例9: getSenderName

import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
/**
 * Get the colored name of this CommandSender
 * @param sender
 * @return name
 */
public static String getSenderName(CommandSender sender) {
    return hasWrapper(sender) ? KCPlayer.getWrapper(sender).getColoredUsername() : ChatColor.YELLOW + sender.getName();
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:9,代碼來源:Utils.java


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