本文整理汇总了Java中org.spongepowered.api.scoreboard.Score.setScore方法的典型用法代码示例。如果您正苦于以下问题:Java Score.setScore方法的具体用法?Java Score.setScore怎么用?Java Score.setScore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.scoreboard.Score
的用法示例。
在下文中一共展示了Score.setScore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToObjective
import org.spongepowered.api.scoreboard.Score; //导入方法依赖的package包/类
private static Score addToObjective(Objective objective, @Nullable Score score, Text name, int value) {
if (score == null) {
score = objective.getOrCreateScore(name);
score.setScore(value);
} else {
objective.addScore(score);
}
return score;
}
示例2: deserialize
import org.spongepowered.api.scoreboard.Score; //导入方法依赖的package包/类
@Override
public ScoreText deserialize(JsonElement element, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final JsonObject obj = element.getAsJsonObject();
final Text name = LanternTexts.fromLegacy(obj.get(SCORE_NAME).getAsString());
// Try to parse the value
int value = 0;
try {
value = Integer.parseInt(obj.get(SCORE_VALUE).getAsString());
} catch (NumberFormatException ignored) {
}
final String baseObjective = obj.get(SCORE_MAIN_OBJECTIVE).getAsString();
final Set<Objective> objectives = new HashSet<>();
if (!baseObjective.isEmpty()) {
this.tryAddObjective(baseObjective, objectives);
}
if ((element = obj.get(SCORE_EXTRA_OBJECTIVES)) != null) {
final JsonArray array = element.getAsJsonArray();
for (JsonElement jsonElement : array) {
this.tryAddObjective(jsonElement.getAsString(), objectives);
}
}
String override = null;
if ((element = obj.get(SCORE_OVERRIDE)) != null) {
override = element.getAsString();
}
final Score score = new LanternScore(name);
// TODO: How to handle the objectives?
// We cannot add them to the score without attaching the
// score to the objective
score.setScore(value);
final ScoreText.Builder builder = Text.builder(score).override(override);
deserialize(obj, builder, context);
return builder.build();
}