generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split emote loading into different emote provider
- Loading branch information
Showing
6 changed files
with
107 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/client/java/net/vinrobot/mcemote/client/providers/FFZRoomEmoteProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.vinrobot.mcemote.client.providers; | ||
|
||
import net.vinrobot.mcemote.api.FrankerFaceZService; | ||
import net.vinrobot.mcemote.api.ffz.Platform; | ||
import net.vinrobot.mcemote.client.font.impl.FFZEmote; | ||
|
||
import java.io.IOException; | ||
|
||
public class FFZRoomEmoteProvider implements IEmoteProvider { | ||
private final String userId; | ||
|
||
public FFZRoomEmoteProvider(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
@Override | ||
public void registerEmotes(IEmoteRegistry registry) throws IOException, InterruptedException { | ||
final FrankerFaceZService service = new FrankerFaceZService(); | ||
|
||
service.fetchRoom(Platform.TWITCH, this.userId) | ||
.sets().values().stream() | ||
.flatMap(emoteSet -> emoteSet.emoticons().stream()) | ||
.map(FFZEmote::new) | ||
.forEach(registry::registerEmote); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/client/java/net/vinrobot/mcemote/client/providers/IEmoteProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package net.vinrobot.mcemote.client.providers; | ||
|
||
public interface IEmoteProvider { | ||
void registerEmotes(IEmoteRegistry registry) throws Exception; | ||
} |
7 changes: 7 additions & 0 deletions
7
src/client/java/net/vinrobot/mcemote/client/providers/IEmoteRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package net.vinrobot.mcemote.client.providers; | ||
|
||
import net.vinrobot.mcemote.client.font.Emote; | ||
|
||
public interface IEmoteRegistry { | ||
void registerEmote(Emote emote); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/client/java/net/vinrobot/mcemote/client/providers/STVGlobalEmoteProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.vinrobot.mcemote.client.providers; | ||
|
||
import net.vinrobot.mcemote.api.SevenTVService; | ||
import net.vinrobot.mcemote.client.font.impl.SevenTVEmote; | ||
|
||
import java.io.IOException; | ||
|
||
public class STVGlobalEmoteProvider implements IEmoteProvider { | ||
@Override | ||
public void registerEmotes(IEmoteRegistry registry) throws IOException, InterruptedException { | ||
final SevenTVService service = new SevenTVService(); | ||
|
||
service.fetchGlobalEmoteSet() | ||
.emotes().stream() | ||
.map(SevenTVEmote::new) | ||
.forEach(registry::registerEmote); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/client/java/net/vinrobot/mcemote/client/providers/STVUserEmoteProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package net.vinrobot.mcemote.client.providers; | ||
|
||
import net.vinrobot.mcemote.api.SevenTVService; | ||
import net.vinrobot.mcemote.api.seventv.Platform; | ||
import net.vinrobot.mcemote.client.font.impl.SevenTVEmote; | ||
|
||
import java.io.IOException; | ||
|
||
public class STVUserEmoteProvider implements IEmoteProvider { | ||
private final String userId; | ||
|
||
public STVUserEmoteProvider(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
@Override | ||
public void registerEmotes(IEmoteRegistry registry) throws IOException, InterruptedException { | ||
final SevenTVService service = new SevenTVService(); | ||
|
||
service.fetchUser(Platform.TWITCH, this.userId) | ||
.emote_set().emotes().stream() | ||
.map(SevenTVEmote::new) | ||
.forEach(registry::registerEmote); | ||
} | ||
} |