Class PlayerBadgeHandler

java.lang.Object
io.github.thecsdev.tcdcommons.api.badge.PlayerBadgeHandler
All Implemented Interfaces:
it.unimi.dsi.fastutil.objects.ObjectIterable<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>>, Iterable<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>>
Direct Known Subclasses:
ServerPlayerBadgeHandler

public class PlayerBadgeHandler extends Object implements it.unimi.dsi.fastutil.objects.ObjectIterable<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>>
A handler for managing the PlayerBadges assigned to a player.

This class serves as a container for keeping track of which badges a player has at any given time.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.util.Identifier
    The unique Identifier used to associate PlayerBadgeHandlers with ServerPlayerEntitys.
    protected final it.unimi.dsi.fastutil.objects.Object2IntMap<net.minecraft.util.Identifier>
    A set that stores the Identifiers of the PlayerBadges assigned to this player.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Clears all PlayerBadge stats from the statMap.
    final int
    getValue(net.minecraft.util.Identifier badgeId)
    Obtains the Integer value associated with a PlayerBadge's Identifier.
    final void
    increaseValue(net.minecraft.util.Identifier badgeId, int by)
    Increases the Integer value associated with a PlayerBadge's Identifier, by a given Integer amount.
    final it.unimi.dsi.fastutil.objects.ObjectIterator<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>>
     
    void
    setValue(net.minecraft.util.Identifier badgeId, int value)
    Sets the Integer value associated with a PlayerBadge's Identifier.
    static final Map<String,List<net.minecraft.util.Identifier>>
    toMapByModId(Iterable<net.minecraft.util.Identifier> badgeIDs)
    Creates a new Map, maps the PlayerBadge Identifiers by their corresponding "mod IDs", and returns the Map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface it.unimi.dsi.fastutil.objects.ObjectIterable

    spliterator
  • Field Details

  • Constructor Details

    • PlayerBadgeHandler

      public PlayerBadgeHandler()
  • Method Details

    • iterator

      public final it.unimi.dsi.fastutil.objects.ObjectIterator<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>> iterator()
      Specified by:
      iterator in interface Iterable<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>>
      Specified by:
      iterator in interface it.unimi.dsi.fastutil.objects.ObjectIterable<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<net.minecraft.util.Identifier>>
    • getValue

      public final int getValue(net.minecraft.util.Identifier badgeId)
      Obtains the Integer value associated with a PlayerBadge's Identifier.
      Parameters:
      badgeId - The PlayerBadge's unique Identifier.
    • setValue

      public void setValue(net.minecraft.util.Identifier badgeId, int value) throws NullPointerException
      Sets the Integer value associated with a PlayerBadge's Identifier.
      Parameters:
      badgeId - The PlayerBadge's unique Identifier.
      value - The new value.
      Throws:
      NullPointerException
    • increaseValue

      public final void increaseValue(net.minecraft.util.Identifier badgeId, int by)
      Increases the Integer value associated with a PlayerBadge's Identifier, by a given Integer amount.
      Parameters:
      badgeId - The PlayerBadge's unique Identifier.
      by - The amount to increase the value by.
    • clearBadges

      public final void clearBadges()
      Clears all PlayerBadge stats from the statMap.
    • toMapByModId

      public static final Map<String,List<net.minecraft.util.Identifier>> toMapByModId(Iterable<net.minecraft.util.Identifier> badgeIDs)
      Creates a new Map, maps the PlayerBadge Identifiers by their corresponding "mod IDs", and returns the Map.
      Parameters:
      badgeIDs - An Iterable Object containing the set of PlayerBadge Identifiers.