本文整理汇总了Java中fr.evercraft.everapi.message.format.EFormatString类的典型用法代码示例。如果您正苦于以下问题:Java EFormatString类的具体用法?Java EFormatString怎么用?Java EFormatString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EFormatString类属于fr.evercraft.everapi.message.format包,在下文中一共展示了EFormatString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getList
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public EMessageBuilder getList(String name, EMessageBuilder builder, ConfigurationNode node, boolean prefix) {
try {
List<String> messages = node.getList(TypeToken.of(String.class));
if (!messages.isEmpty()) {
if (this.plugin.getChat() != null) {
builder.chat(new EFormatListString(this.plugin.getChat().replace(messages)), prefix);
} else {
builder.chat(new EFormatListString(node.getList(TypeToken.of(String.class))), prefix);
}
}
} catch (ObjectMappingException e) {
this.plugin.getELogger().warn("Impossible de charger la liste des messages : '" + name + "'");
builder.chat(new EFormatString(name), false);
}
return builder;
}
示例2: getFormatString
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public Optional<EFormatString> getFormatString(ConfigurationNode node) {
if (!node.getString("").isEmpty()) {
if (this.plugin.getChat() != null) {
return Optional.of(new EFormatString(this.plugin.getChat().replace(node.getString(""))));
} else {
return Optional.of(new EFormatString(node.getString("")));
}
}
return Optional.empty();
}
示例3: getDisplayNameHover
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public Text getDisplayNameHover(Set<Context> contexts) {
Builder builder = EFormatString.of(this.getDisplayName(contexts))
.toText(this.getReplaces()).toBuilder()
.onShiftClick(TextActions.insertText(this.getName()));
this.getSuggest(contexts).ifPresent(suggest -> builder.onClick(TextActions.suggestCommand(suggest)));
this.getHover(contexts).ifPresent(hover -> builder.onHover(TextActions.showText(hover)));
return builder.build();
}
示例4: getHover
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public Optional<Text> getHover(Set<Context> contexts) {
Optional<String> optHover = this.getOption(contexts, "hover");
if (optHover.isPresent()) {
return Optional.of(EFormatString.of(optHover.get()).toText(this.getReplaces()));
}
return Optional.empty();
}
示例5: getSuggest
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public Optional<String> getSuggest(Set<Context> contexts) {
Optional<String> optSuggest = this.getOption(contexts, "suggest");
if (optSuggest.isPresent()) {
return Optional.of(EFormatString.of(optSuggest.get()).toString(this.getReplaces()));
}
return Optional.empty();
}
示例6: deserialize
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
@Override
public EFormat deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
if (node.getValue() instanceof List) {
return new EFormatListString(node.getList(TypeToken.of(String.class)));
} else if (node.getValue() instanceof String) {
return new EFormatString(node.getString(""));
} else {
return new EFormatTemplate(node.getValue(TypeToken.of(TextTemplate.class)));
}
}
示例7: serialize
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
@Override
public void serialize(TypeToken<?> type, EFormat format, ConfigurationNode node) throws ObjectMappingException {
if (format instanceof EFormatListString) {
node.setValue(((EFormatListString) format).getMessage());
} else if (format instanceof EFormatString) {
node.setValue(((EFormatString) format).getMessage());
} else if (format instanceof EFormatTemplate) {
node.setValue(((EFormatTemplate) format).getMessage());
} else {
throw new ObjectMappingException();
}
}
示例8: replace
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public CompletableFuture<Boolean> replace(final CommandSource source) {
List<Text> list = new ArrayList<Text>();
for(EReplacesServer value : EReplacesServer.values()) {
if (value.getFunction().isPresent()) {
list.add(EFormatString.of("&c" + value.name() + " : &r" + value.getName())
.toText(this.plugin.getChat().getReplaceServer()));
}
}
this.plugin.getManagerService().getEPagination().sendTo(Text.of("Replace Server"), list, source);
return CompletableFuture.completedFuture(true);
}
示例9: replaceMessage
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public static String replaceMessage(final EChat chat, final Subject player, String message) {
Map<Pattern, EReplace<?>> replaces = new HashMap<Pattern, EReplace<?>>();
if (!player.hasPermission(EEPermissions.MSG_COLOR.get())) {
message = message.replaceAll(ChatService.REGEX_COLOR, "");
}
if (!player.hasPermission(EEPermissions.MSG_FORMAT.get())) {
message = message.replaceAll(ChatService.REGEX_FORMAT, "");
}
if (!player.hasPermission(EEPermissions.MSG_MAGIC.get())) {
message = message.replaceAll(ChatService.REGEX_MAGIC, "");
}
if (player.hasPermission(EEPermissions.MSG_CHARACTER.get())) {
replaces.putAll(chat.getReplaceCharacters());
}
if (player.hasPermission(EEPermissions.MSG_COMMAND.get())) {
replaces.putAll(chat.getReplaceCommand());
}
if (player.hasPermission(EEPermissions.MSG_ICONS.get())) {
replaces.putAll(chat.getReplaceIcons());
}
if (player.hasPermission(EEPermissions.MSG_URL.get())) {
replaces.putAll(chat.getReplaceUrl());
}
if (replaces.isEmpty()) return message;
return EFormatString.of(message).toString(replaces);
}
示例10: sendMessage
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public Text sendMessage(final EPlayer player, String original) {
String format = this.getFormat(player.getPlayer().get());
Map<Pattern, EReplace<?>> replaces = player.getReplaces();
if (!player.hasPermission(ECPermissions.COLOR.get())) {
original = original.replaceAll(ChatService.REGEX_COLOR, "");
}
if (!player.hasPermission(ECPermissions.FORMAT.get())) {
original = original.replaceAll(ChatService.REGEX_FORMAT, "");
}
if (!player.hasPermission(ECPermissions.MAGIC.get())) {
original = original.replaceAll(ChatService.REGEX_MAGIC, "");
}
if (player.hasPermission(ECPermissions.CHARACTER.get())) {
replaces.putAll(this.getReplaceCharacters());
}
if (player.hasPermission(ECPermissions.COMMAND.get())) {
replaces.putAll(this.getReplaceCommand());
}
if (player.hasPermission(ECPermissions.ICONS.get())) {
replaces.putAll(this.getReplaceIcons());
}
if (player.hasPermission(ECPermissions.URL.get())) {
replaces.putAll(this.getReplaceUrl());
}
replaces.put(Pattern.compile("\\{MESSAGE}"), EReplace.of(EFormatString.of(original).toText(replaces)));
return EFormatString.of(format).toText(replaces);
}
示例11: format
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
@Override
public Text format(final BigDecimal amount, final int numFractionDigits) {
Map<Pattern, EReplace<?>> replaces = new HashMap<Pattern, EReplace<?>>();
replaces.put(Pattern.compile("\\{amount}"), EReplace.of(amount.setScale(numFractionDigits, BigDecimal.ROUND_HALF_UP).toString()));
replaces.put(Pattern.compile("\\{symbol}"), EReplace.of(this.symbol));
if (amount.compareTo(BigDecimal.ONE) <= 0) {
replaces.put(Pattern.compile("\\{currency}"), EReplace.of(this.singular));
} else {
replaces.put(Pattern.compile("\\{currency}"), EReplace.of(this.plural));
}
return EFormatString.of(this.format).toText(replaces);
}
示例12: EKMessages
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
private EKMessages(final String french) {
this(EMessageFormat.builder().chat(new EFormatString(french), true));
}
示例13: replace
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public String replace(final String message) {
Preconditions.checkNotNull(message, "message");
return EFormatString.of(message).toString(this.getReplaceVariables());
}
示例14: getFormat
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public default EFormat getFormat() {
if (this.getMessage().getChat().isPresent()) {
return this.getMessage().getChat().get().getMessage();
}
return new EFormatString("");
}
示例15: getPrefix
import fr.evercraft.everapi.message.format.EFormatString; //导入依赖的package包/类
public EFormat getPrefix() {
return this.prefix.isPresent() ? this.prefix.get().getFormat() : new EFormatString("");
}