当前位置: 首页>>代码示例>>Java>>正文


Java Player.getName方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getName方法的具体用法?Java Player.getName怎么用?Java Player.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String[] args) {    	
   	if (args.length != 2) {
   		Chat.player(sender, "&2[Pets] &cUsage: /pet rename [old name] [new name]");
   		return true;
   	}

   	Player p = (Player) sender;
   	String username = p.getName();
   	for (PetInstance pet : PetInstance.getList()) {
   		if (pet.getName().equalsIgnoreCase(args[0])) {
    		if (pet.getOwner().equalsIgnoreCase(username)) {
    			String name = args[1];
    			if (name.length() > 16)
    				name = name.substring(0, 16);
    			Chat.player(p, "&2[Pets] &aYou have renamed &e" + pet.getName() + "&a to &e" + name);
    			pet.setName(name);
    			return true;
    		}
   		}
   	}
   	
   	Chat.player(p, "&2[Pets] &cYou do not own a pet by the name of &e" + args[0] + "\n     &7&oBuy customized pets at www.mczone.co/shop");
       return true;
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:26,代码来源:PetRenameCmd.java

示例2: onPlayerChat

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
	Player p = event.getPlayer();
	Gamer g = Hive.getInstance().getGamer(p);
	
	String prefix = "";
	String name = p.getName();
	String msg = event.getMessage();
	
	if (g.getRank() != null)
		prefix = g.getRank().getType().getPrefix();
	
	String result = Chat.colors(prefix + "&7" + name + "&f: ") + msg;
	if (g.getRank().getType().getLevel() >= 5)
		result = Chat.colors(result);
	
	// Symbol % has formatting issues
	event.setFormat(result.replace("%", "%%"));
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:20,代码来源:GeneralEvents.java

示例3: setUserTag

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Works perfectly
 * @param p
 */

public void setUserTag(Player p, String tag){
    UUID id = p.getUniqueId();
    String name = p.getName();

    try {
        PreparedStatement prep = conn.prepareStatement("INSERT INTO " + playerData + " (uuid, nick, tag) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE tag ='"+tag+"', nick = '" + name + "';");
        prep.setString(1, id.toString());
        prep.setString(2, name);
        prep.setString(3, tag);
        prep.execute();

    } catch(SQLException e){
        Bukkit.getLogger().info("[DogTags] Failed to add "+ name + " to database.");
        Bukkit.getLogger().info("[DogTags] Error '"+e.getLocalizedMessage()+"'.");
    }
}
 
开发者ID:Chazmondo,项目名称:DogTags,代码行数:22,代码来源:MySQLConnection.java

示例4: onFactionChat

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onFactionChat(FactionChatEvent event)
{
  Player player = event.getPlayer();
  Faction faction = event.getFaction();
  String format = ChatColor.GOLD + "[" + ChatColor.RED + event.getChatChannel().getDisplayName() + ": " + ChatColor.YELLOW + faction.getName() + ChatColor.GOLD + "] " + ChatColor.GRAY + event.getFactionMember().getRole().getAstrix() + player.getName() + ": " + ChatColor.YELLOW + event.getMessage();
  HashSet<Player> recipients = new HashSet();
  recipients.removeAll(event.getRecipients());
  for (CommandSender recipient : recipients) {
    if ((recipient instanceof Player))
    {
      Player target = (Player)recipient;
      FactionUser user = event.isAsynchronous() ? this.plugin.getUserManager().getUserAsync(target.getUniqueId()) : this.plugin.getUserManager().getUser(player.getUniqueId());
      Collection<UUID> spying = user.getFactionChatSpying();
      if ((spying.contains(ALL_UUID)) || (spying.contains(faction.getUniqueID()))) {
        recipient.sendMessage(format);
      }
    }
  }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:FactionChatSpyArgument.java

示例5: onChat

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onChat(AsyncPlayerChatEvent event){
    if(plugin.getConfig().getString("chatformat").equals("true")){
        Player player = event.getPlayer();
        String message = event.getMessage();
        event.setCancelled(true);
        String playerNameWithPrefixSuffix = player.getName() + ": ";
        try {
            playerNameWithPrefixSuffix = ChatColor.translateAlternateColorCodes('&', (!RankManager.getRankPrefix(player).equals(" ")?RankManager.getRankPrefix(player) : "") + RankManager.getRankNameColor(player) +" "+ player.getName() +(!RankManager.getRankSuffix(player).equals(" ")? " "+ RankManager.getRankSuffix(player) : "") + ChatColor.GRAY + ": ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        for(Player p : event.getRecipients()){
            p.sendMessage(playerNameWithPrefixSuffix + ChatColor.WHITE + message);
        }
    }
}
 
开发者ID:Warvale,项目名称:Ace,代码行数:18,代码来源:RankListener.java

示例6: onBlockBreak

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockBreak(final BlockBreakEvent event) {
    final Player player = event.getPlayer();
    if(player.getGameMode() == GameMode.CREATIVE) {
        return;
    }
    if(player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) return;;
    final Block block = event.getBlock();
    final Location blockLocation = block.getLocation();
    if(block.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(blockLocation.toString())) {
        int count = 1;
        for(int x = -5; x < 5; ++x) {
            for(int y = -5; y < 5; ++y) {
                for(int z = -5; z < 5; ++z) {
                    final Block otherBlock = blockLocation.clone().add((double) x, (double) y, (double) z).getBlock();
                    if(!otherBlock.equals(block) && otherBlock.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(otherBlock.getLocation().toString())) {
                        ++count;
                    }
                }
            }
        }
       
        String message;
        for(Player on : Bukkit.getOnlinePlayers()) {
            if(plugin.getFactionManager().getPlayerFaction(player.getUniqueId()) != null) {
                 message = plugin.getFactionManager().getPlayerFaction(player.getUniqueId()).getRelation(on).toChatColour() + player.getName() + ChatColor.GRAY + " has found " + ChatColor.AQUA + count + ChatColor.GRAY + " diamond(s).";
                on.sendMessage(message);
            }else{
                message = ChatColor.AQUA + "[" + ChatColor.GRAY + "♠" + ChatColor.AQUA + "]" + ChatColor.GRAY + " " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + " has just spotted " + ChatColor.BLUE + count + ChatColor.GRAY +" diamonds!";
                on.sendMessage(message);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:FoundDiamondsListener.java

示例7: onPlayerQuit

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerQuit(PlayerQuitEvent event) {
	Player player = event.getPlayer();

	Craft craft = Craft.getPlayerCraft(player);

	if (craft != null) {
		if (craft.isNameOnBoard.get(player.getName())) {
			Craft.reboardNames.put(player.getName(), craft);

			craft.isNameOnBoard.put(player.getName(), false);
			if (craft.driverName == player.getName()) {
				craft.haveControl = false;
				craft.releaseHelm();
			}

			boolean abandonCheck = true;
			for (String s : craft.isNameOnBoard.keySet()) {
				if (craft.isNameOnBoard.get(s)) {
					abandonCheck = false;
				}
			}

			if (abandonCheck) {
				craft.abandoned = true;
				craft.captainAbandoned = true;
			} else if (player.getName() == craft.captainName) {
				craft.captainAbandoned = true;
			}
		}

		for (Periscope p : craft.periscopes) {
			if (p.user == player) {
				p.user = null;
				break;
			}
		}
	}

}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:41,代码来源:NavyCraft_PlayerListener.java

示例8: onCommand

import org.bukkit.entity.Player; //导入方法依赖的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

示例9: createFor

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public IPet createFor(Player owner){
      Throwable throwable;
      try {
          return this.petConstructor.newInstance(owner);
}catch(Exception e){
	throwable = e;
}
      throw new IllegalStateException("Failed to create pet object for " + owner.getName(), throwable);
  }
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:10,代码来源:PetRegistrationEntry.java

示例10: onJoin

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * When the player joins the server
 * <p>
 * SERVER JOIN
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent event) {
    if(!Moo.getInstance().isConnected()) return;
    event.setJoinMessage(null);
    Player player = event.getPlayer();

    PlayerData data = new PlayerData();
    data.setUuid(player.getUniqueId());
    data.setLastName(player.getName());
    data.setLastIp(player.getAddress().getHostString());

    // changes state
    Permissible oldPermissible = PermissionInjector.getPermissible(player);
    CustomPermissible customPermissible = new CustomPermissible(player, data.getUuid(), oldPermissible);
    PermissionInjector.inject(player, customPermissible);

    MooQueries.getInstance().changePlayerState(data, PacketPlayerState.State.JOIN_SERVER, response -> {
    });

    // UPDATE SERVER INFO
    Lightning.getInstance().updateServerInfo();

    // SET JOIN MESSAGE
    String playerName = MooQueries.getInstance().getGroup(player.getUniqueId()).getColor() + player.getName();
    Bukkit.getServer().broadcastMessage(LanguageManager.get("join-message-pattern", playerName));
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:32,代码来源:ServerListener.java

示例11: sendLink

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void sendLink(Player player, String url, boolean clickableLinksTellraw) {
    String linkText = "Click here to login";
    String hoverText = "Login to the web sandbox as " + player.getName();

    // There are two strategies since TextComponents fails with on Glowstone with an error:
    // java.lang.UnsupportedOperationException: Not supported yet.
    // at org.bukkit.entity.Player$Spigot.sendMessage(Player.java:1734)
    // see https://github.com/GlowstoneMC/Glowkit-Legacy/pull/8
    if (clickableLinksTellraw) {
        JSONObject json = new JSONObject();
        json.put("text", linkText);
        json.put("bold", true);

        JSONObject clickEventJson = new JSONObject();
        clickEventJson.put("action", "open_url");
        clickEventJson.put("value", url);
        json.put("clickEvent", clickEventJson);

        JSONObject hoverEventJson = new JSONObject();
        hoverEventJson.put("action", "show_text");
        JSONObject hoverTextObject = new JSONObject();
        hoverTextObject.put("text", hoverText);
        hoverEventJson.put("value", hoverTextObject);
        json.put("hoverEvent", hoverEventJson);

        Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + json.toJSONString());
    } else {
        TextComponent message = new TextComponent(linkText);
        message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
        message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] { new TextComponent(hoverText) }));
        message.setBold(true);

        player.spigot().sendMessage(message);
    }
}
 
开发者ID:satoshinm,项目名称:WebSandboxMC,代码行数:36,代码来源:ClickableLinks.java

示例12: saveNameAndId

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Inject void saveNameAndId(Player bukkit) {
    name = bukkit.getName();
    uuid = bukkit.getUniqueId();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:MatchPlayer.java

示例13: resolve

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public String resolve(Player player, String id) {
    return player.getName();
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:5,代码来源:PlayerNamePlaceholder.java

示例14: getCachedInventory

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static CachedInventory getCachedInventory(Player player, boolean dead) {
    List<String> effects = new ArrayList<>();
    player.getActivePotionEffects().forEach(effect -> effects.add(effect.getType().getName() + " " + effect.getAmplifier() + " (" + TimeUtil.formatSeconds(effect.getDuration() / 20) + ")"));
    return new CachedInventory(player.getName(), (dead ? 0.0 : Math.round(player.getHealth())), player.getFoodLevel(), effects, InventoryUtils.playerInventoryFromPlayer(player));
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:6,代码来源:Cache.java

示例15: sendWhisper

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void sendWhisper(Player sender, String targetName, PlayerDataRPG pd, String message) {
    if (System.currentTimeMillis() - lastSentPM.getOrDefault(pd.getName(), 0l) < 100) {
        SakiShieldCore.warn(pd, Activity.FAST_CHAT);
        return;
    }
    if (PunishmentManager.isMuted(sender)) {
        pd.sendMessage(ChatColor.RED + "You are muted and cannot message others!");
        pd.sendMessage(ChatColor.RED + PunishmentManager.getMuteReason(sender));
        return;
    }
    Player target = plugin.getServer().getPlayerExact(targetName);
    if (target != null && target.isOnline() && plugin.getPD(target) != null) {
        if (target == sender) {
            sender.sendMessage(ChatColor.RED + "You can't message yourself, silly! That's what thinking is for.");
            return;
        }
        PlayerDataRPG pd2 = plugin.getPD(target);
        if (pd2.isIgnoring(pd)) {
            pd.sendMessage(ChatColor.RED + pd2.getName() + " is ignoring you and is not receiving your messages.");
            return;
        }
        String senderName = pd.getChatNameColor() + sender.getName();
        String receiverName = pd2.getChatNameColor() + target.getName();

        FancyMessage fm = new FancyMessage();
        fm.text("[");
        fm.color(ChatColor.GRAY);
        fm.then(senderName);
        ChatManager.chatHover(fm, pd);
        fm.then("->");
        fm.color(ChatColor.GRAY);
        fm.then(receiverName);
        ChatManager.chatHover(fm, pd2);
        fm.then("] ");
        fm.color(ChatColor.GRAY);
        fm.then(pd.getOption(SakiOption.CHAT_FILTER) || pd2.getOption(SakiOption.CHAT_FILTER) ? ChatFilter.getFiltered(message) : message);
        fm.style(ChatColor.ITALIC);
        fm.send(sender);
        if (PunishmentManager.isMuted(target)) {
            sender.sendMessage(ChatColor.RED + target.getName() + " is currently muted and won't be able to respond.");
        }
        if (!ChatManager.shadowMute.contains(sender.getName())) {
            fm.send(target);
            if (!ChatManager.lastReceivedWhisperFrom.containsKey(target.getName()) || !ChatManager.lastReceivedWhisperFrom.get(target.getName()).equals(sender.getName()))
                RSound.playSound(target, Sound.ENTITY_EXPERIENCE_ORB_PICKUP);
            else if (!ChatManager.lastReceivedWhisperTime.containsKey(target.getName()) || System.currentTimeMillis() - ChatManager.lastReceivedWhisperTime.get(target.getName()) > 30000)
                RSound.playSound(target, Sound.ENTITY_EXPERIENCE_ORB_PICKUP);
            ChatManager.lastReceivedWhisperFrom.put(target.getName(), sender.getName());
            ChatManager.lastReceivedWhisperFrom.put(sender.getName(), target.getName());
            ChatManager.lastReceivedWhisperTime.put(target.getName(), System.currentTimeMillis());
        }
        for (String m : ChatManager.monitors) {
            Player monitor = plugin.getServer().getPlayerExact(m);
            if (monitor != null && monitor.isOnline()) {
                if (sender != monitor && target != monitor) {
                    monitor.sendMessage(ChatColor.DARK_GRAY + "[MONITOR]");
                    fm.send(monitor);
                }
            }
        }
        Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + ChatColor.stripColor(fm.toOldMessageFormat()));
    } else {
        sender.sendMessage(ChatColor.RED + "Could not find online player '" + targetName + "'.");
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:66,代码来源:ChatManager.java


注:本文中的org.bukkit.entity.Player.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。