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


Java ScoreboardAction类代码示例

本文整理汇总了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;
}
 
开发者ID:lucko,项目名称:helper,代码行数:19,代码来源:PacketScoreboardObjective.java

示例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));
    }
}
 
开发者ID:games647,项目名称:ScoreboardStats,代码行数:23,代码来源:PacketListener.java

示例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));
}
 
开发者ID:lucko,项目名称:helper,代码行数:13,代码来源:PacketScoreboardObjective.java

示例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;
}
 
开发者ID:lucko,项目名称:helper,代码行数:13,代码来源:PacketScoreboardObjective.java

示例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);
}
 
开发者ID:lucko,项目名称:helper,代码行数:11,代码来源:PacketScoreboardObjective.java

示例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);
}
 
开发者ID:games647,项目名称:ScoreboardStats,代码行数:9,代码来源:Objective.java

示例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);
}
 
开发者ID:games647,项目名称:ScoreboardStats,代码行数:12,代码来源:Objective.java

示例8: getAction

import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public ScoreboardAction getAction() {
    return handle.getScoreboardActions().read(0);
}
 
开发者ID:Tom7653,项目名称:DeprecatedNametags,代码行数:4,代码来源:WrapperScoreboardScore.java

示例9: setScoreboardAction

import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public void setScoreboardAction(ScoreboardAction value) {
    handle.getScoreboardActions().write(0, value);
}
 
开发者ID:Tom7653,项目名称:DeprecatedNametags,代码行数:4,代码来源:WrapperScoreboardScore.java

示例10: removeScore

import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; //导入依赖的package包/类
public void removeScore(String name) {
    scores.remove(name);
    sendScorePacket(name, 0, ScoreboardAction.REMOVE);
}
 
开发者ID:games647,项目名称:ScoreboardStats,代码行数:5,代码来源:Objective.java


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