本文整理汇总了Java中org.spongepowered.api.statistic.Statistic类的典型用法代码示例。如果您正苦于以下问题:Java Statistic类的具体用法?Java Statistic怎么用?Java Statistic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Statistic类属于org.spongepowered.api.statistic包,在下文中一共展示了Statistic类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replace
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
@Override
public Text replace(Text text, @Nullable Object player) {
if (player instanceof Player) {
Player p = (Player) player;
for (String var : TextUtil.getVariables(text)) {
if (var.startsWith("%stat:")) {
try {
String stat = var.replace("%", "").split(":")[1];
Long value = p.get(Keys.STATISTICS).get().get(Sponge.getRegistry().getType(Statistic.class, stat).get());
if (value == null) value = 0L;
text = TextUtil.replace(text, var, Messages.toText(value + ""));
} catch (Exception ex) {
text = TextUtil.replace(text, var, Text.of());
}
}
}
}
return text;
}
示例2: getStatisticValues
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
public Map<Statistic, Long> getStatisticValues() {
final Map<Statistic, Long> map = new HashMap<>();
for (Map.Entry<String, StatisticEntry> entry : this.statisticEntries.entrySet()) {
final LanternStatistic statistic = entry.getValue().getStatistic();
if (statistic != null) {
map.put(statistic, entry.getValue().get());
}
}
return map;
}
示例3: StatisticView
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
public StatisticView(Statistic value) {
super(value);
this.stat = value.getId();
}
示例4: register
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
@Override
protected void register(Statistic catalogType) {
super.register(catalogType);
}
示例5: internalRegister
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
void internalRegister(Statistic catalogType, boolean disallowInbuiltPluginIds) {
super.register(catalogType, disallowInbuiltPluginIds);
this.byInternalId.put(((LanternStatistic) catalogType).getInternalId(), catalogType);
}
示例6: getByInternalId
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
public Optional<Statistic> getByInternalId(String internalId) {
return Optional.ofNullable(this.byInternalId.get(checkNotNull(internalId, "internalId")));
}
示例7: get
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
public StatisticEntry get(Statistic statistic) {
return this.statisticEntries.computeIfAbsent(((LanternStatistic) statistic).getInternalId(),
id -> new StatisticEntry((LanternStatistic) statistic));
}
示例8: build
import org.spongepowered.api.statistic.Statistic; //导入依赖的package包/类
@Override
protected Statistic build(String pluginId, String id, String name, Translation translation, StatisticType type, NumberFormat format,
String internalId, @Nullable Criterion criterion) {
return new LanternStatistic(pluginId, id, name, translation, internalId, format, criterion, type);
}