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


Java Player.getName方法代碼示例

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


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

示例1: onOpened

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Listener
public void onOpened(PlayerOpenedCrateEvent event) {
    Player player = event.getPlayer();
    Manager manager = event.getManager();
    Drop drop = event.getDrop();
    if (manager.isSendOpenMessage()) {
        Optional<String> optional_custom_open_message = manager.getCustomOpenMessage();
        if (optional_custom_open_message.isPresent()) {
            player.sendMessage(TextSerializers.FORMATTING_CODE.
                    deserialize(optional_custom_open_message.get().
                            replace("%MANAGER%", manager.getName())));
        } else {
            player.sendMessage(LanguageUtils.getText("SUCCESSFULLY_OPENED_MANAGER",
                    new Pair<String, String>("%MANAGER%", manager.getName())));
        }
    }
    if (GWMCrates.getInstance().isLogOpenedCrates()) {
        try {
            String time = LocalTime.now().withNano(0).format(DateTimeFormatter.ISO_LOCAL_TIME);
            String player_name = player.getName();
            String player_uuid = player.getUniqueId().toString();
            String manager_name = manager.getName();
            String manager_id = manager.getId();
            String drop_name = drop == null ? "null" : drop.getId().orElse("Unknown ID");
            Location<World> location = player.getLocation();
            String player_location = location.getExtent().getName() + ' ' + location.getBlockX() + ' ' + location.getBlockY() + ' ' + location.getBlockZ();
            LOG_FILE_WRITER.write(LanguageUtils.getPhrase("CRATE_OPENING_LOG_MESSAGE",
                    new Pair("%TIME%", time),
                    new Pair("%PLAYER%", player_name),
                    new Pair("%PLAYER_UUID%", player_uuid),
                    new Pair("%MANAGER_NAME%", manager_name),
                    new Pair("%MANAGER_ID%", manager_id),
                    new Pair("%DROP%", drop_name),
                    new Pair("%LOCATION%", player_location)) + '\n');
            LOG_FILE_WRITER.flush();
        } catch (Exception e) {
            GWMCrates.getInstance().getLogger().warn("Exception logging crate opening!", e);
        }
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:41,代碼來源:DebugCrateListener.java

示例2: onPlayerJoin

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
	Player player = (Player) event.getTargetEntity();
	String username = player.getName();
	if ((AurionsVoteListener.SQLType == "MySQL") && (dbHost.isEmpty() || dbHost == null || dbUser.isEmpty()
			|| dbUser == null || dbPass.isEmpty() || dbPass == null)) {
		if (player.hasPermission("*") || player.hasPermission("listener.top")) {
			player.sendMessage(
					Text.builder("<AurionsVoteListener> Please config Database.").color(TextColors.RED).build());
		}
	} else {
		if (SwitchSQL.QueueUsername(username)) {

			List<String> service = SwitchSQL.QueueReward(username);
			int totalVote = service.size();
			for (int i = 0; i < service.size(); i++) {
				RewardsTask.rewardoflline(username, service.get(i));
				SwitchSQL.removeQueue(username, service.get(i));
			}
			MessageChannel messageChannel = MessageChannel.TO_PLAYERS;

			messageChannel.send(AurionsVoteListener.GetInstance()
					.formatmessage(offlineBroadcast.replace("<amt>", String.valueOf(totalVote)), "", username));
			player.sendMessage(Text.of(AurionsVoteListener.GetInstance().formatmessage(
					offlinePlayerMessage.replace("<amt>", String.valueOf(totalVote)), "", username)));
		} else {
		}
		if (joinmessage) {
			for (int i = 0; i < AurionsVoteListener.messagejoin.size(); i++) {
				player.sendMessage(formatmessage(AurionsVoteListener.messagejoin.get(i), "", username));
			}
		}
	}
}
 
開發者ID:Mineaurion,項目名稱:AurionVoteListener,代碼行數:35,代碼來源:AurionsVoteListener.java

示例3: getPlayerSession

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
private PlayerSession getPlayerSession(Player player) {
    return new PlayerSession(
            0,
            player.getName(),
            player.getUniqueId().toString(),
            playerJoins.get(player.getUniqueId()),
            getTime(),
            player.getConnection().getAddress().getAddress().getHostAddress()
    );
}
 
開發者ID:MinecraftMarket,項目名稱:MinecraftMarket-Plugin,代碼行數:11,代碼來源:SpongeStats.java

示例4: getPlayerString

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
public static String getPlayerString(Player player) {
	return player.getName() + " (" + player.getUniqueId().toString() + ')';
}
 
開發者ID:AuraDevelopmentTeam,項目名稱:InvSync,代碼行數:4,代碼來源:DataSource.java


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