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


Java Objective类代码示例

本文整理汇总了Java中org.spongepowered.api.scoreboard.objective.Objective的典型用法代码示例。如果您正苦于以下问题:Java Objective类的具体用法?Java Objective怎么用?Java Objective使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Objective类属于org.spongepowered.api.scoreboard.objective包,在下文中一共展示了Objective类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setScore

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public void setScore(int score) {
    if (this.score == score) {
        return;
    }
    this.score = score;
    final Multimap<Scoreboard, Objective> scoreboards = HashMultimap.create();
    for (Objective objective : this.objectives) {
        for (Scoreboard scoreboard : ((LanternObjective) objective).scoreboards) {
            scoreboards.put(scoreboard, objective);
        }
    }
    if (!scoreboards.isEmpty()) {
        final Map<Objective, Message> messages = new HashMap<>();
        for (Map.Entry<Scoreboard, Objective> entry : scoreboards.entries()) {
            ((LanternScoreboard) entry.getKey()).sendToPlayers(() -> Collections.singletonList(
                    messages.computeIfAbsent(entry.getValue(), obj -> new MessagePlayOutScoreboardScore.CreateOrUpdate(
                            obj.getName(), this.legacyName, score))));
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:LanternScore.java

示例2: updateDisplaySlot

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public void updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) throws IllegalStateException {
    checkNotNull(displaySlot, "displaySlot");
    if (objective == null) {
        final Objective oldObjective = this.objectivesInSlot.remove(displaySlot);
        if (oldObjective != null) {
            // Clear the display slot on the client
            this.sendToPlayers(() -> Collections.singletonList(
                    new MessagePlayOutScoreboardDisplayObjective(null, displaySlot)));
        }
    } else {
        checkState(this.objectives.containsValue(objective),
                "The specified objective does not exist in this scoreboard.");
        if (this.objectivesInSlot.put(displaySlot, objective) != objective) {
            // Update the displayed objective on the client
            this.sendToPlayers(() -> Collections.singletonList(
                    new MessagePlayOutScoreboardDisplayObjective(objective.getName(), displaySlot)));
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:21,代码来源:LanternScoreboard.java

示例3: onGameStarted

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Listener
//Scoreboards are loaded when the world is loaded so load it here
public void onGameStarted(GameStartedServerEvent gameStartedServerEvent) {
    Optional<Scoreboard> serverScoreboard = Sponge.getServer().getServerScoreboard();
    if (serverScoreboard.isPresent()) {
        Scoreboard globalScoreboard = serverScoreboard.get();
        if (configuration.getConfig().isNametagHealth()) {
            globalScoreboard.getObjective(PomData.ARTIFACT_ID).ifPresent(globalScoreboard::removeObjective);

            Objective objective = Objective.builder()
                    .name(PomData.ARTIFACT_ID)
                    .displayName(Text.of(TextColors.DARK_RED, "Health"))
                    .criterion(Criteria.DUMMY)
                    .objectiveDisplayMode(ObjectiveDisplayModes.INTEGER)
                    .build();
            globalScoreboard.addObjective(objective);
            globalScoreboard.updateDisplaySlot(objective, DisplaySlots.BELOW_NAME);
        }
    } else {
        logger.warn("Global scoreboard couldn't be loaded");
    }
}
 
开发者ID:games647,项目名称:HealthName,代码行数:23,代码来源:HealthName.java

示例4: registerNewObjective

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public org.bukkit.scoreboard.Objective registerNewObjective(String name, String criteria)
        throws IllegalArgumentException {
    checkArgument(name != null, "Name must not be null");
    Objective.Builder builder = Objective.builder();
    //noinspection ConstantConditions
    builder.name(name);
    if (criteria != null) {
        //TODO: no idea whether this is right
        Optional<Criterion> criterion = Pore.getGame().getRegistry().getType(Criterion.class, criteria);
        if (criterion.isPresent()) {
            builder.criterion(criterion.get());
        }
    }
    return PoreObjective.of(builder.build());
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:17,代码来源:PoreScoreboard.java

示例5: swapBuffers

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
private void swapBuffers() {
    this.scoreboard.updateDisplaySlot(this.buffer, DisplaySlots.SIDEBAR);

    Objective temp = this.buffer;

    this.buffer = this.objective;
    this.objective = temp;
}
 
开发者ID:MinusKube,项目名称:Netherboard,代码行数:9,代码来源:SPlayerBoard.java

示例6: addObjective

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public boolean addObjective(EPlayer player, int priority, DisplaySlot display, Objective objective) {
	Optional<Objective> objective_player = player.getScoreboard().getObjective(display);
	if (!objective_player.isPresent() || getPriority(display, objective_player.get()) <= priority) {
		// Supprime l'ancien
		if (objective_player.isPresent()) {
			player.getScoreboard().removeObjective(objective_player.get());
		}
		
		// Ajoute le nouveau
		if (!player.getScoreboard().getObjective(objective.getName()).isPresent()) {
			player.getScoreboard().addObjective(objective);
			player.getScoreboard().updateDisplaySlot(objective, display);
			
			// Event
			if (objective_player.isPresent()) {
				this.postReplace(player, objective_player.get(), objective, display);
			} else {
				this.postAdd(player, objective, display);
			}
			
			return true;
		} else {
			this.plugin.getELogger().warn("Multi-Objective (player='" + player.getIdentifier() + "';objective='" + objective.getName() + "')");
		}
	}
	return false;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:29,代码来源:EScoreBoardService.java

示例7: removeObjective

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public boolean removeObjective(EPlayer player, DisplaySlot display, String identifier) {
	Optional<Objective> objective = player.getScoreboard().getObjective(display);
	if (objective.isPresent() && objective.get().getName().equals(identifier)) {
		player.getScoreboard().removeObjective(objective.get());
		
		// Event 
		this.postRemove(player, objective.get(), display);
		return true;
	}
	return false;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:13,代码来源:EScoreBoardService.java

示例8: postAdd

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
private void postAdd(EPlayer player, Objective objective, DisplaySlot display) {
	this.plugin.getELogger().debug("Event ScoreBoardEvent.Add : ("
			+ "uuid='" + player.getUniqueId() + "';"
			+ "objective='" + objective.getName() + "';"
			+ "display='" + display.getName() + "')");
	this.plugin.getGame().getEventManager().post(ESpongeEventFactory.createScoreBoardEventAdd(player, objective, display, Cause.source(this.plugin).build()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:8,代码来源:EScoreBoardService.java

示例9: postRemove

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
private void postRemove(EPlayer player, Objective objective, DisplaySlot display) {
	this.plugin.getELogger().debug("Event ScoreBoardEvent.Remove : ("
			+ "uuid='" + player.getUniqueId() + "';"
			+ "objective='" + objective.getName() + "';"
			+ "display='" + display.getName() + "')");
	this.plugin.getGame().getEventManager().post(ESpongeEventFactory.createScoreBoardEventRemove(player, objective, display, Cause.source(this.plugin).build()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:8,代码来源:EScoreBoardService.java

示例10: postReplace

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
private void postReplace(EPlayer player, Objective objective, Objective new_objective, DisplaySlot display) {
	this.plugin.getELogger().debug("Event ScoreBoardEvent.Replace : ("
			+ "uuid='" + player.getUniqueId() + "';"
			+ "objective='" + objective.getName() + "';"
			+ "new_objective='" + new_objective.getName() + "';"
			+ "display='" + display.getName() + "')");
	this.plugin.getGame().getEventManager().post(ESpongeEventFactory.createScoreBoardEventReplace(player, objective, new_objective, display, Cause.source(this.plugin).build()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:9,代码来源:EScoreBoardService.java

示例11: ScoreBoardEvent

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
public ScoreBoardEvent(EPlayer player, Action action, Objective objective, String identifier,
		DisplaySlot displaySlot, Cause cause) {
	super();
	this.player = player;
	this.action = action;
	this.objective = objective;
	this.identifier = identifier;
	this.displaySlot = displaySlot;
	this.cause = cause;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:11,代码来源:ScoreBoardEvent.java

示例12: addToObjective

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的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;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:ScoreboardIO.java

示例13: deserialize

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的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();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:37,代码来源:JsonTextScoreSerializer.java

示例14: from

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public LanternObjectiveBuilder from(Objective value) {
    this.name(value.getName())
            .criterion(value.getCriterion())
            .displayName(value.getDisplayName())
            .objectiveDisplayMode(value.getDisplayMode());
    return this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:LanternObjectiveBuilder.java

示例15: build

import org.spongepowered.api.scoreboard.objective.Objective; //导入依赖的package包/类
@Override
public Objective build() throws IllegalStateException {
    checkState(this.name != null, "name is not set");
    checkState(this.displayName != null, "displayName is not set");
    checkState(this.criterion != null, "criterion is not set");
    return new LanternObjective(this.name, this.criterion, this.objectiveDisplayMode, this.displayName);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternObjectiveBuilder.java


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