Java Code Examples for net.dv8tion.jda.api.entities.Role#DEFAULT_COLOR_RAW

The following examples show how to use net.dv8tion.jda.api.entities.Role#DEFAULT_COLOR_RAW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbedBuilder.java    From JDA with Apache License 2.0 6 votes vote down vote up
/**
 * Resets this builder to default state.
 * <br>All parts will be either empty or null after this method has returned.
 *
 * @return The current EmbedBuilder with default values
 */
@Nonnull
public EmbedBuilder clear()
{
    description.setLength(0);
    fields.clear();
    url = null;
    title = null;
    timestamp = null;
    color = Role.DEFAULT_COLOR_RAW;
    thumbnail = null;
    author = null;
    footer = null;
    image = null;
    return this;
}
 
Example 2
Source File: EmbedBuilder.java    From JDA with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the given embed is empty. Empty embeds will throw an exception if built
 *
 * @return true if the embed is empty and cannot be built
 */
public boolean isEmpty()
{
    return title == null
        && timestamp == null
        && thumbnail == null
        && author == null
        && footer == null
        && image == null
        && color == Role.DEFAULT_COLOR_RAW
        && description.length() == 0
        && fields.isEmpty();
}
 
Example 3
Source File: RoleManagerImpl.java    From JDA with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@CheckReturnValue
public RoleManagerImpl reset(long fields)
{
    super.reset(fields);
    if ((fields & NAME) == NAME)
        this.name = null;
    if ((fields & COLOR) == COLOR)
        this.color = Role.DEFAULT_COLOR_RAW;
    return this;
}
 
Example 4
Source File: RoleManagerImpl.java    From JDA with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@CheckReturnValue
public RoleManagerImpl reset()
{
    super.reset();
    this.name = null;
    this.color = Role.DEFAULT_COLOR_RAW;
    return this;
}
 
Example 5
Source File: RoleUpdateColorEvent.java    From JDA with Apache License 2.0 4 votes vote down vote up
/**
 * The old color
 *
 * @return The old color, or null
 */
@Nullable
public Color getOldColor()
{
    return previous != Role.DEFAULT_COLOR_RAW ? new Color(previous) : null;
}
 
Example 6
Source File: RoleUpdateColorEvent.java    From JDA with Apache License 2.0 4 votes vote down vote up
/**
 * The new color
 *
 * @return The new color, or null
 */
@Nullable
public Color getNewColor()
{
    return next != Role.DEFAULT_COLOR_RAW ? new Color(next) : null;
}
 
Example 7
Source File: GuildRoleUpdateHandler.java    From JDA with Apache License 2.0 4 votes vote down vote up
@Override
protected Long handleInternally(DataObject content)
{
    final long guildId = content.getLong("guild_id");
    if (getJDA().getGuildSetupController().isLocked(guildId))
        return guildId;

    DataObject rolejson = content.getObject("role");
    GuildImpl guild = (GuildImpl) getJDA().getGuildById(guildId);
    if (guild == null)
    {
        getJDA().getEventCache().cache(EventCache.Type.GUILD, guildId, responseNumber, allContent, this::handle);
        EventCache.LOG.debug("Received a Role Update for a Guild that is not yet cached: {}", content);
        return null;
    }

    final long roleId = rolejson.getLong("id");
    RoleImpl role = (RoleImpl) guild.getRolesView().get(roleId);
    if (role == null)
    {
        getJDA().getEventCache().cache(EventCache.Type.ROLE, roleId, responseNumber, allContent, this::handle);
        EventCache.LOG.debug("Received a Role Update for Role that is not yet cached: {}", content);
        return null;
    }

    String name = rolejson.getString("name");
    int color = rolejson.getInt("color");
    if (color == 0)
        color = Role.DEFAULT_COLOR_RAW;
    int position = rolejson.getInt("position");
    long permissions = rolejson.getLong("permissions");
    boolean hoisted = rolejson.getBoolean("hoist");
    boolean mentionable = rolejson.getBoolean("mentionable");

    if (!Objects.equals(name, role.getName()))
    {
        String oldName = role.getName();
        role.setName(name);
        getJDA().handleEvent(
                new RoleUpdateNameEvent(
                        getJDA(), responseNumber,
                        role, oldName));
    }
    if (color != role.getColorRaw())
    {
        int oldColor = role.getColorRaw();
        role.setColor(color);
        getJDA().handleEvent(
                new RoleUpdateColorEvent(
                        getJDA(), responseNumber,
                        role, oldColor));
    }
    if (!Objects.equals(position, role.getPositionRaw()))
    {
        int oldPosition = role.getPosition();
        int oldPositionRaw = role.getPositionRaw();
        role.setRawPosition(position);
        getJDA().handleEvent(
                new RoleUpdatePositionEvent(
                        getJDA(), responseNumber,
                        role, oldPosition, oldPositionRaw));
    }
    if (!Objects.equals(permissions, role.getPermissionsRaw()))
    {
        long oldPermissionsRaw = role.getPermissionsRaw();
        role.setRawPermissions(permissions);
        getJDA().handleEvent(
                new RoleUpdatePermissionsEvent(
                        getJDA(), responseNumber,
                        role, oldPermissionsRaw));
    }

    if (hoisted != role.isHoisted())
    {
        boolean wasHoisted = role.isHoisted();
        role.setHoisted(hoisted);
        getJDA().handleEvent(
                new RoleUpdateHoistedEvent(
                        getJDA(), responseNumber,
                        role, wasHoisted));
    }
    if (mentionable != role.isMentionable())
    {
        boolean wasMentionable = role.isMentionable();
        role.setMentionable(mentionable);
        getJDA().handleEvent(
                new RoleUpdateMentionableEvent(
                        getJDA(), responseNumber,
                        role, wasMentionable));
    }
    return null;
}
 
Example 8
Source File: RoleImpl.java    From JDA with Apache License 2.0 4 votes vote down vote up
@Override
public Color getColor()
{
    return color != Role.DEFAULT_COLOR_RAW ? new Color(color) : null;
}
 
Example 9
Source File: EmbedBuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the Color of the embed.
 *
 * <a href="https://raw.githubusercontent.com/DV8FromTheWorld/JDA/assets/assets/docs/embeds/02-setColor.png" target="_blank">Example</a>
 *
 * @param  color
 *         The {@link java.awt.Color Color} of the embed
 *         or {@code null} to use no color
 *
 * @return the builder after the color has been set
 *
 * @see    #setColor(int)
 */
@Nonnull
public EmbedBuilder setColor(@Nullable Color color)
{
    this.color = color == null ? Role.DEFAULT_COLOR_RAW : color.getRGB();
    return this;
}