
com.github.twitch4j.chat.events.channel.ChannelStateEvent Maven / Gradle / Ivy
package com.github.twitch4j.chat.events.channel;
import com.github.twitch4j.chat.events.AbstractChannelEvent;
import com.github.twitch4j.common.events.domain.EventChannel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Value;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@Value
@Getter
@EqualsAndHashCode(callSuper = false)
public class ChannelStateEvent extends AbstractChannelEvent {
public enum ChannelState {
BROADCAST_LANG,
EMOTE,
FOLLOWERS,
R9K,
SLOW,
SUBSCRIBERS;
}
private final Map states;
/**
* Event Constructor
*
* @param channel The channel that this event originates from.
* @param state The changed state triggering the event
* @param value The value representing the state
*/
public ChannelStateEvent(EventChannel channel, ChannelState state, Object value) {
super(channel);
Map states = new HashMap<>();
states.put(state, value);
this.states = Collections.unmodifiableMap(states);
}
public ChannelStateEvent(EventChannel channel, Map state) {
super(channel);
Map states = new HashMap<>();
states.putAll(state);
this.states = Collections.unmodifiableMap(states);
}
public Object getState(ChannelState state) {
return states.getOrDefault(state, null);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy