本文整理汇总了Java中com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction类的典型用法代码示例。如果您正苦于以下问题:Java ScoreboardAction类的具体用法?Java ScoreboardAction怎么用?Java ScoreboardAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScoreboardAction类属于com.comphenix.protocol.wrappers.EnumWrappers包,在下文中一共展示了ScoreboardAction类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newScorePacket
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
private PacketContainer newScorePacket(String name, int value, ScoreboardAction action) {
// http://wiki.vg/Protocol#Update_Score
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_SCORE);
// set "Entity name" - aka the name of the score - limited to 40.
packet.getStrings().write(0, name);
// set the action - 0 to create/update an item. 1 to remove an item.
packet.getScoreboardActions().write(0, action);
// set objective name - The name of the objective the score belongs to
packet.getStrings().write(1, getId());
// set value of the score- The score to be displayed next to the entry. Only sent when Action does not equal 1.
packet.getIntegers().write(0, value);
return packet;
}
示例2: handleScorePacket
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
private void handleScorePacket(Player player, PacketContainer packet) {
String scoreName = packet.getStrings().read(0);
String parent = packet.getStrings().read(1);
int score = packet.getIntegers().read(0);
//state id
ScoreboardAction action = packet.getScoreboardActions().read(0);
//Packet receiving validation
if (parent.length() > 16) {
//Invalid packet
return;
}
PlayerScoreboard scoreboard = manager.getScoreboard(player);
//scores actually only have two state id, because these
if (action == ScoreboardAction.CHANGE) {
scoreboard.getObjective(parent).ifPresent(objective -> objective.scores.put(scoreName, score));
} else if (action == ScoreboardAction.REMOVE) {
scoreboard.getObjective(parent).ifPresent(objective -> objective.scores.remove(scoreName, score));
}
}
示例3: setScore
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
@Override
public void setScore(String name, int value) {
Preconditions.checkNotNull(name, "name");
name = trimScore(Color.colorize(name));
Integer oldValue = scores.put(name, value);
if (oldValue != null && oldValue == value) {
return;
}
scoreboard.broadcastPacket(subscribed, newScorePacket(name, value, ScoreboardAction.CHANGE));
}
示例4: removeScore
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
@Override
public boolean removeScore(String name) {
Preconditions.checkNotNull(name, "name");
name = trimScore(Color.colorize(name));
if (scores.remove(name) == null) {
return false;
}
scoreboard.broadcastPacket(subscribed, newScorePacket(name, 0, ScoreboardAction.REMOVE));
return true;
}
示例5: subscribe
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
@Override
public void subscribe(Player player) {
Preconditions.checkNotNull(player, "player");
scoreboard.sendPacket(newObjectivePacket(UpdateType.CREATE), player);
scoreboard.sendPacket(newDisplaySlotPacket(getDisplaySlot()), player);
for (Map.Entry<String, Integer> score : getScores().entrySet()) {
scoreboard.sendPacket(newScorePacket(score.getKey(), score.getValue(), ScoreboardAction.CHANGE), player);
}
subscribed.add(player);
}
示例6: setScores
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public void setScores(String name, int value) {
Integer oldVal = scores.put(name, value);
if (oldVal != null && oldVal == value) {
return;
}
sendScorePacket(name, value, ScoreboardAction.CHANGE);
}
示例7: sendScorePacket
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
private void sendScorePacket(String name, int score, ScoreboardAction action) {
PacketContainer packet = new PacketContainer(SCOREBOARD_SCORE);
packet.getStrings().write(0, name);
packet.getStrings().write(1, objectiveId);
packet.getIntegers().write(0, score);
packet.getScoreboardActions().write(0, action);
scoreboard.sendPacket(packet);
}
示例8: getAction
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public ScoreboardAction getAction() {
return handle.getScoreboardActions().read(0);
}
示例9: setScoreboardAction
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public void setScoreboardAction(ScoreboardAction value) {
handle.getScoreboardActions().write(0, value);
}
示例10: removeScore
import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public void removeScore(String name) {
scores.remove(name);
sendScorePacket(name, 0, ScoreboardAction.REMOVE);
}