You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 15:36:17 +00:00
🆙 Logic for the Youtube Broadcast
This commit is contained in:
@@ -175,7 +175,30 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
private volatile boolean muted;
|
private volatile boolean muted;
|
||||||
private RoomSpecialTypes roomSpecialTypes;
|
private RoomSpecialTypes roomSpecialTypes;
|
||||||
private TraxManager traxManager;
|
private TraxManager traxManager;
|
||||||
|
|
||||||
|
private String youtubeCurrentVideo = "";
|
||||||
|
private String youtubeSenderName = "";
|
||||||
|
private final java.util.List<String> youtubePlaylist = new java.util.concurrent.CopyOnWriteArrayList<>();
|
||||||
|
private final java.util.Set<Integer> youtubeWatchers = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
public String getYoutubeCurrentVideo() { return this.youtubeCurrentVideo; }
|
||||||
|
public String getYoutubeSenderName() { return this.youtubeSenderName; }
|
||||||
|
public java.util.List<String> getYoutubePlaylist() { return this.youtubePlaylist; }
|
||||||
|
public java.util.Set<Integer> getYoutubeWatchers() { return this.youtubeWatchers; }
|
||||||
|
|
||||||
|
public void setYoutubeVideo(String videoId, String senderName, java.util.List<String> playlist) {
|
||||||
|
this.youtubeCurrentVideo = videoId;
|
||||||
|
this.youtubeSenderName = senderName;
|
||||||
|
this.youtubePlaylist.clear();
|
||||||
|
if (playlist != null) this.youtubePlaylist.addAll(playlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearYoutubeVideo() {
|
||||||
|
this.youtubeCurrentVideo = "";
|
||||||
|
this.youtubeSenderName = "";
|
||||||
|
this.youtubePlaylist.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public final THashMap<String, Object> cache;
|
public final THashMap<String, Object> cache;
|
||||||
|
|
||||||
public Room(ResultSet set) throws SQLException {
|
public Room(ResultSet set) throws SQLException {
|
||||||
|
|||||||
@@ -987,6 +987,17 @@ public class RoomManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!room.getYoutubeCurrentVideo().isEmpty()) {
|
||||||
|
habbo.getClient().sendResponse(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomBroadcastComposer(
|
||||||
|
room.getYoutubeCurrentVideo(),
|
||||||
|
room.getYoutubeSenderName(),
|
||||||
|
room.getYoutubePlaylist()).compose());
|
||||||
|
}
|
||||||
|
if (!room.getYoutubeWatchers().isEmpty()) {
|
||||||
|
habbo.getClient().sendResponse(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomWatchersComposer(
|
||||||
|
room.getYoutubeWatchers()).compose());
|
||||||
|
}
|
||||||
|
|
||||||
WiredManager.triggerUserEntersRoom(room, habbo.getRoomUnit());
|
WiredManager.triggerUserEntersRoom(room, habbo.getRoomUnit());
|
||||||
room.habboEntered(habbo);
|
room.habboEntered(habbo);
|
||||||
|
|
||||||
|
|||||||
@@ -677,5 +677,9 @@ public class PacketManager {
|
|||||||
this.registerHandler(Incoming.GameCenterLeaveGameEvent, GameCenterLeaveGameEvent.class);
|
this.registerHandler(Incoming.GameCenterLeaveGameEvent, GameCenterLeaveGameEvent.class);
|
||||||
this.registerHandler(Incoming.GameCenterEvent, GameCenterEvent.class);
|
this.registerHandler(Incoming.GameCenterEvent, GameCenterEvent.class);
|
||||||
this.registerHandler(Incoming.GameCenterRequestGameStatusEvent, GameCenterRequestGameStatusEvent.class);
|
this.registerHandler(Incoming.GameCenterRequestGameStatusEvent, GameCenterRequestGameStatusEvent.class);
|
||||||
|
|
||||||
|
// YouTube Room Broadcast
|
||||||
|
this.registerHandler(Incoming.YouTubeRoomPlayEvent, com.eu.habbo.messages.incoming.rooms.youtube.YouTubeRoomPlayEvent.class);
|
||||||
|
this.registerHandler(Incoming.YouTubeRoomWatchingEvent, com.eu.habbo.messages.incoming.rooms.youtube.YouTubeRoomWatchingEvent.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -436,4 +436,8 @@ public class Incoming {
|
|||||||
public static final int SetActivePrefixEvent = 7012;
|
public static final int SetActivePrefixEvent = 7012;
|
||||||
public static final int DeletePrefixEvent = 7013;
|
public static final int DeletePrefixEvent = 7013;
|
||||||
public static final int PurchasePrefixEvent = 7014;
|
public static final int PurchasePrefixEvent = 7014;
|
||||||
|
|
||||||
|
// YouTube Room Broadcast
|
||||||
|
public static final int YouTubeRoomPlayEvent = 8001;
|
||||||
|
public static final int YouTubeRoomWatchingEvent = 8002;
|
||||||
}
|
}
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.rooms.youtube;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomBroadcastComposer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class YouTubeRoomPlayEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
Habbo habbo = this.client.getHabbo();
|
||||||
|
if (habbo == null) return;
|
||||||
|
|
||||||
|
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||||
|
if (room == null) return;
|
||||||
|
|
||||||
|
// Only the room owner or users with rights can broadcast
|
||||||
|
if (!room.isOwner(habbo) && !room.hasRights(habbo)) return;
|
||||||
|
|
||||||
|
String videoId = this.packet.readString();
|
||||||
|
|
||||||
|
int playlistCount = this.packet.readInt();
|
||||||
|
List<String> playlist = new ArrayList<>();
|
||||||
|
for (int i = 0; i < playlistCount && i < 50; i++) {
|
||||||
|
playlist.add(this.packet.readString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the current video + playlist on the room
|
||||||
|
room.setYoutubeVideo(videoId, habbo.getHabboInfo().getUsername(), playlist);
|
||||||
|
|
||||||
|
// Broadcast to everyone in the room
|
||||||
|
room.sendComposer(
|
||||||
|
new YouTubeRoomBroadcastComposer(videoId, habbo.getHabboInfo().getUsername(), playlist).compose()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.rooms.youtube;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomWatchersComposer;
|
||||||
|
|
||||||
|
public class YouTubeRoomWatchingEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
Habbo habbo = this.client.getHabbo();
|
||||||
|
if (habbo == null) return;
|
||||||
|
|
||||||
|
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||||
|
if (room == null) return;
|
||||||
|
|
||||||
|
boolean watching = this.packet.readBoolean();
|
||||||
|
int userId = habbo.getHabboInfo().getId();
|
||||||
|
|
||||||
|
if (watching) {
|
||||||
|
room.getYoutubeWatchers().add(userId);
|
||||||
|
} else {
|
||||||
|
room.getYoutubeWatchers().remove(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
room.sendComposer(
|
||||||
|
new YouTubeRoomWatchersComposer(room.getYoutubeWatchers()).compose()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -571,4 +571,8 @@ public class Outgoing {
|
|||||||
public static final int ActivePrefixUpdatedComposer = 7003;
|
public static final int ActivePrefixUpdatedComposer = 7003;
|
||||||
public static final int AvailableCommandsComposer = 4050;
|
public static final int AvailableCommandsComposer = 4050;
|
||||||
|
|
||||||
|
// YouTube Room Broadcast
|
||||||
|
public static final int YouTubeRoomBroadcastComposer = 8001;
|
||||||
|
public static final int YouTubeRoomWatchersComposer = 8002;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.eu.habbo.messages.outgoing.rooms.youtube;
|
||||||
|
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class YouTubeRoomBroadcastComposer extends MessageComposer {
|
||||||
|
private final String videoId;
|
||||||
|
private final String senderName;
|
||||||
|
private final List<String> playlist;
|
||||||
|
|
||||||
|
public YouTubeRoomBroadcastComposer(String videoId, String senderName, List<String> playlist) {
|
||||||
|
this.videoId = videoId;
|
||||||
|
this.senderName = senderName;
|
||||||
|
this.playlist = playlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ServerMessage composeInternal() {
|
||||||
|
this.response.init(Outgoing.YouTubeRoomBroadcastComposer);
|
||||||
|
this.response.appendString(this.videoId);
|
||||||
|
this.response.appendString(this.senderName);
|
||||||
|
this.response.appendInt(this.playlist.size());
|
||||||
|
for (String id : this.playlist) {
|
||||||
|
this.response.appendString(id);
|
||||||
|
}
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.eu.habbo.messages.outgoing.rooms.youtube;
|
||||||
|
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class YouTubeRoomWatchersComposer extends MessageComposer {
|
||||||
|
private final Set<Integer> watcherIds;
|
||||||
|
|
||||||
|
public YouTubeRoomWatchersComposer(Set<Integer> watcherIds) {
|
||||||
|
this.watcherIds = watcherIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ServerMessage composeInternal() {
|
||||||
|
this.response.init(Outgoing.YouTubeRoomWatchersComposer);
|
||||||
|
this.response.appendInt(this.watcherIds.size());
|
||||||
|
for (int id : this.watcherIds) {
|
||||||
|
this.response.appendInt(id);
|
||||||
|
}
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user