use of org.spongepowered.common.scoreboard.SpongeDisplaySlot in project SpongeCommon by SpongePowered.
the class SpongeRegistryLoaders method displaySlot.
public static RegistryLoader<DisplaySlot> displaySlot() {
return RegistryLoader.of(l -> {
l.add(0, DisplaySlots.LIST, k -> new SpongeDisplaySlot(0));
l.add(1, DisplaySlots.SIDEBAR, k -> new SpongeDisplaySlot(1));
l.add(2, DisplaySlots.BELOW_NAME, k -> new SpongeDisplaySlot(2));
SpongeDisplaySlotFactory.ColorMapping.COLOR_TO_DISPLAY_SLOT_MAP.forEach((color, s) -> l.add(SpongeDisplaySlot.slotIdFromFormatting(color), s, k -> new SpongeDisplaySlot(color)));
});
}
use of org.spongepowered.common.scoreboard.SpongeDisplaySlot in project SpongeCommon by SpongePowered.
the class MixinScoreboardLogic method scoreboard$updateDisplaySlot.
public void scoreboard$updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) {
if (objective != null && !objective.getScoreboards().contains(this)) {
throw new IllegalStateException("Attempting to set an objective's display slot that does not exist on this scoreboard!");
}
int index = ((SpongeDisplaySlot) displaySlot).getIndex();
this.objectiveDisplaySlots[index] = objective == null ? null : ((SpongeObjective) objective).getObjectiveFor(this);
this.sendToPlayers(new SPacketDisplayObjective(index, this.objectiveDisplaySlots[index]));
}
use of org.spongepowered.common.scoreboard.SpongeDisplaySlot in project SpongeCommon by SpongePowered.
the class DisplaySlotRegistryModule method registerDefaults.
@Override
public void registerDefaults() {
this.displaySlotMappings.put("minecraft:list", new SpongeDisplaySlot("list", null, 0));
this.displaySlotMappings.put("minecraft:sidebar", new SpongeDisplaySlot("sidebar", null, 1));
this.displaySlotMappings.put("minecraft:below_name", new SpongeDisplaySlot("below_name", null, 2));
for (Map.Entry<TextFormatting, SpongeTextColor> entry : TextColorRegistryModule.enumChatColor.entrySet()) {
final String id = entry.getValue().getId().toLowerCase(Locale.ENGLISH);
final SpongeDisplaySlot value = new SpongeDisplaySlot(id, entry.getValue(), entry.getKey().getColorIndex() + 3);
this.displaySlotMappings.put("minecraft:" + id, value);
}
}
Aggregations