Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit d868bf0

Browse files
committed
Add raid events to the api and to tipeeestream
1 parent c2b3217 commit d868bf0

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
5+
import java.time.OffsetDateTime;
6+
7+
/**
8+
* Another streamer has started a raid against your stream.
9+
*/
10+
public class Raid<T extends User> {
11+
private final T streamer;
12+
private final String message;
13+
private final int viewerCount;
14+
private final OffsetDateTime time;
15+
16+
public Raid(T streamer, String message, int viewerCount, OffsetDateTime time) {
17+
this.streamer = streamer;
18+
this.message = message;
19+
this.viewerCount = viewerCount;
20+
this.time = time;
21+
}
22+
23+
/**
24+
* Get the stream which started the raid.
25+
*
26+
* @return initiating streamer
27+
*/
28+
public T getStreamer() {
29+
return streamer;
30+
}
31+
32+
/**
33+
* Get the message from the initiating streamer.
34+
*
35+
* @return the raid message
36+
*/
37+
public String getMessage() {
38+
return message;
39+
}
40+
41+
/**
42+
* Get the viewer count with which the streamer raids you.
43+
*
44+
* @return the viewer count of the raid
45+
*/
46+
public int getViewerCount() {
47+
return viewerCount;
48+
}
49+
50+
/**
51+
* Get the time when the raid has started
52+
*
53+
* @return raid time
54+
*/
55+
public OffsetDateTime getTime() {
56+
return time;
57+
}
58+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Raid;
5+
6+
import java.time.OffsetDateTime;
7+
8+
public class TipeeestreamRaid extends Raid<User> {
9+
public TipeeestreamRaid(User streamer, String message, int viewerCount, OffsetDateTime time) {
10+
super(streamer, message, viewerCount, time);
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.codeoverflow.chatoverflow.api.io.event.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Raid;
4+
5+
/**
6+
* Generic event for raids
7+
*/
8+
public class RaidEvent<T extends Raid> {
9+
10+
private final T info;
11+
12+
protected RaidEvent(T raidInfo) {
13+
this.info = raidInfo;
14+
}
15+
16+
/**
17+
* Get the Raid object that contains all information about that raid
18+
*
19+
* @return all info about that raid
20+
*/
21+
public T getInfo() {
22+
return info;
23+
}
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream.TipeeestreamRaid;
4+
import org.codeoverflow.chatoverflow.api.io.event.stream.RaidEvent;
5+
6+
/**
7+
* Event that is triggered by tipeeestream if a streamer raids your channel
8+
*/
9+
public class TipeeestreamRaidEvent extends RaidEvent<TipeeestreamRaid> implements TipeeestreamEvent {
10+
public TipeeestreamRaidEvent(TipeeestreamRaid raidInfo) {
11+
super(raidInfo);
12+
}
13+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TipeeestreamEventInput.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ default void registerDonationEventHandler(Consumer<TipeeestreamDonationEvent> ev
4343
default void registerCheerEventHandler(Consumer<TipeeestreamCheerEvent> eventHandler) {
4444
registerEventHandler(eventHandler, TipeeestreamCheerEvent.class);
4545
}
46+
47+
/**
48+
* Register an event handler that listens to all {@link TipeeestreamRaidEvent}
49+
*
50+
* @param eventHandler consumer that receives the Events
51+
*/
52+
default void registerRaidEventHandler(Consumer<TipeeestreamRaidEvent> eventHandler) {
53+
registerEventHandler(eventHandler, TipeeestreamRaidEvent.class);
54+
}
4655
}

0 commit comments

Comments
 (0)