當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。