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


Java WrappedChatComponent.fromText方法代码示例

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


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

示例1: onPacketSending

import com.comphenix.protocol.wrappers.WrappedChatComponent; //导入方法依赖的package包/类
@Override
public void onPacketSending( PacketEvent event ) {
	final Player          player = event.getPlayer();
	final PacketContainer packet = event.getPacket();
	
	// Translate all four lines if necessary:
	boolean                changed        = false;
	WrappedChatComponent[] chatComponents = packet.getChatComponentArrays().read( 0 );
	for ( int i = 0; i < chatComponents.length; ++i ) {
		WrappedChatComponent chat = chatComponents[i];
		if ( chat != null ) {
			String message    = this.restoreTextFromChatComponent( chat );
			String translated = this.translateMessageIfAppropriate( this.i18n.getLocale( player.getUniqueId() ), message );
			
			if ( message != translated ) {
				chatComponents[i] = WrappedChatComponent.fromText( translated );
				changed = true;
			}
		}
	}
	
	if ( changed ) {
		// Only write back when really needed:
		packet.getChatComponentArrays().write( 0, chatComponents );
	}
}
 
开发者ID:BlackyPaw,项目名称:I18N,代码行数:27,代码来源:InterceptorSign.java

示例2: playerInfoPacket

import com.comphenix.protocol.wrappers.WrappedChatComponent; //导入方法依赖的package包/类
public static PacketContainer playerInfoPacket(
        String displayName,
        Integer latency,
        GameMode gameMode,
        String name,
        UUID uuid,
        Skin skin,
        EnumWrappers.PlayerInfoAction action
) {
    PacketContainer result = new PacketContainer(PLAYER_INFO);
    WrappedGameProfile profile = new WrappedGameProfile(uuid, name);
    if (action == EnumWrappers.PlayerInfoAction.ADD_PLAYER) {
        if (skin == null) {
            skin = Tablist.DEFAULT_SKIN_TEXTURE;
        }
        profile.getProperties().put(Skin.MULTIMAP_KEY, skin.toWrappedSignedProperty());
    }
    PlayerInfoData playerInfoData = new PlayerInfoData(
            profile,
            Optional.ofNullable(latency).map(PacketUtil::getPossibleLatency).orElse(0),
            Optional.ofNullable(gameMode).map(EnumWrappers.NativeGameMode::fromBukkit).orElse(EnumWrappers.NativeGameMode.NOT_SET),
            WrappedChatComponent.fromText(Optional.ofNullable(displayName).orElse(""))
    );
    result.getPlayerInfoDataLists().writeSafely(0, Collections.singletonList(playerInfoData));
    result.getPlayerInfoAction().writeSafely(0, action);
    return result;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:28,代码来源:PacketUtil.java

示例3: stringsToChatComponent

import com.comphenix.protocol.wrappers.WrappedChatComponent; //导入方法依赖的package包/类
public static WrappedChatComponent stringsToChatComponent(String[] strings) {
    if (strings.length == 0) {
        return WrappedChatComponent.fromText("");
    }
    StringJoiner joiner = new StringJoiner(", {\"text\":\"\n\"}, ", "{\"extra\":[", "],\"text\":\"\"}");
    for (String string : strings) {
        joiner.add(WrappedChatComponent.fromText(string).getJson());
    }
    Logging.debug(PacketUtil.class, "Final JSON: " + joiner.toString());
    return WrappedChatComponent.fromJson(joiner.toString());
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:12,代码来源:PacketUtil.java

示例4: getInfoWrapper

import com.comphenix.protocol.wrappers.WrappedChatComponent; //导入方法依赖的package包/类
public static WrapperPlayServerPlayerInfo getInfoWrapper(UUID playeruuid, PlayerInfoAction action) {
    WrapperPlayServerPlayerInfo wrapper = new WrapperPlayServerPlayerInfo();
    wrapper.setAction(action);
    WrappedGameProfile profile = new WrappedGameProfile(playeruuid, NameGenerator.newName());
    PlayerInfoData data = new PlayerInfoData(profile, 1, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(NameGenerator.newName()));
    List<PlayerInfoData> listdata = new ArrayList<>();
    listdata.add(data);
    wrapper.setData(listdata);
    return wrapper;
}
 
开发者ID:TechzoneMC,项目名称:SimpleAntiAura,代码行数:11,代码来源:AuraCheck.java

示例5: getPlayerInfoData

import com.comphenix.protocol.wrappers.WrappedChatComponent; //导入方法依赖的package包/类
private PlayerInfoData getPlayerInfoData(WrappedGameProfile profile, int ping, String displayName) {
    if (displayName != null) {
        // min width
        while (displayName.length() < this.minColumnWidth)
            displayName += " ";

        // max width
        if (this.maxColumnWidth > 0)
            while (displayName.length() > this.maxColumnWidth)
                displayName = displayName.substring(0, displayName.length() - 1);
    }

    return new PlayerInfoData(profile, ping, NativeGameMode.SURVIVAL, displayName == null ? null : WrappedChatComponent.fromText(displayName));
}
 
开发者ID:thekeenant,项目名称:tabbed,代码行数:15,代码来源:SimpleTabList.java


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