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
🆕 YoutubeTV broadcasting
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
INSERT INTO emulator_settings (`key`, `value`) VALUES ('packet.global.rate.limit', '50');
|
INSERT INTO emulator_settings (`key`, `value`) VALUES ('packet.global.rate.limit', '50');
|
||||||
|
|
||||||
|
ALTER TABLE `rooms` ADD COLUMN IF NOT EXISTS `youtube_enabled` TINYINT(1) NOT NULL DEFAULT 0;
|
||||||
@@ -178,11 +178,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
|
|
||||||
// YouTube room broadcast state: tracks the current video being broadcast
|
// YouTube room broadcast state: tracks the current video being broadcast
|
||||||
// by the room owner, the owner's playlist, and which users have the player open.
|
// by the room owner, the owner's playlist, and which users have the player open.
|
||||||
|
private boolean youtubeEnabled = false;
|
||||||
private String youtubeCurrentVideo = "";
|
private String youtubeCurrentVideo = "";
|
||||||
private String youtubeSenderName = "";
|
private String youtubeSenderName = "";
|
||||||
private final java.util.List<String> youtubePlaylist = new java.util.concurrent.CopyOnWriteArrayList<>();
|
private final java.util.List<String> youtubePlaylist = new java.util.concurrent.CopyOnWriteArrayList<>();
|
||||||
private final java.util.Set<Integer> youtubeWatchers = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
private final java.util.Set<Integer> youtubeWatchers = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
public boolean isYoutubeEnabled() { return this.youtubeEnabled; }
|
||||||
|
public void setYoutubeEnabled(boolean enabled) { this.youtubeEnabled = enabled; }
|
||||||
public String getYoutubeCurrentVideo() { return this.youtubeCurrentVideo; }
|
public String getYoutubeCurrentVideo() { return this.youtubeCurrentVideo; }
|
||||||
public String getYoutubeSenderName() { return this.youtubeSenderName; }
|
public String getYoutubeSenderName() { return this.youtubeSenderName; }
|
||||||
public java.util.List<String> getYoutubePlaylist() { return this.youtubePlaylist; }
|
public java.util.List<String> getYoutubePlaylist() { return this.youtubePlaylist; }
|
||||||
@@ -228,6 +231,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
this.allowPetsEat = set.getBoolean("allow_other_pets_eat");
|
this.allowPetsEat = set.getBoolean("allow_other_pets_eat");
|
||||||
this.allowWalkthrough = set.getBoolean("allow_walkthrough");
|
this.allowWalkthrough = set.getBoolean("allow_walkthrough");
|
||||||
this.hideWall = set.getBoolean("allow_hidewall");
|
this.hideWall = set.getBoolean("allow_hidewall");
|
||||||
|
try { this.youtubeEnabled = set.getBoolean("youtube_enabled"); } catch (Exception e) { this.youtubeEnabled = false; }
|
||||||
this.chatMode = set.getInt("chat_mode");
|
this.chatMode = set.getInt("chat_mode");
|
||||||
this.chatWeight = set.getInt("chat_weight");
|
this.chatWeight = set.getInt("chat_weight");
|
||||||
this.chatSpeed = set.getInt("chat_speed");
|
this.chatSpeed = set.getInt("chat_speed");
|
||||||
@@ -1120,7 +1124,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (this.needsUpdate) {
|
if (this.needsUpdate) {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource()
|
try (Connection connection = Emulator.getDatabase().getDataSource()
|
||||||
.getConnection(); PreparedStatement statement = connection.prepareStatement(
|
.getConnection(); PreparedStatement statement = connection.prepareStatement(
|
||||||
"UPDATE rooms SET name = ?, description = ?, password = ?, state = ?, users_max = ?, category = ?, score = ?, paper_floor = ?, paper_wall = ?, paper_landscape = ?, thickness_wall = ?, wall_height = ?, thickness_floor = ?, moodlight_data = ?, tags = ?, allow_other_pets = ?, allow_other_pets_eat = ?, allow_walkthrough = ?, allow_hidewall = ?, chat_mode = ?, chat_weight = ?, chat_speed = ?, chat_hearing_distance = ?, chat_protection =?, who_can_mute = ?, who_can_kick = ?, who_can_ban = ?, poll_id = ?, guild_id = ?, roller_speed = ?, override_model = ?, is_staff_picked = ?, promoted = ?, trade_mode = ?, move_diagonally = ?, owner_id = ?, owner_name = ?, jukebox_active = ?, hidewired = ?, allow_underpass = ? WHERE id = ?")) {
|
"UPDATE rooms SET name = ?, description = ?, password = ?, state = ?, users_max = ?, category = ?, score = ?, paper_floor = ?, paper_wall = ?, paper_landscape = ?, thickness_wall = ?, wall_height = ?, thickness_floor = ?, moodlight_data = ?, tags = ?, allow_other_pets = ?, allow_other_pets_eat = ?, allow_walkthrough = ?, allow_hidewall = ?, chat_mode = ?, chat_weight = ?, chat_speed = ?, chat_hearing_distance = ?, chat_protection =?, who_can_mute = ?, who_can_kick = ?, who_can_ban = ?, poll_id = ?, guild_id = ?, roller_speed = ?, override_model = ?, is_staff_picked = ?, promoted = ?, trade_mode = ?, move_diagonally = ?, owner_id = ?, owner_name = ?, jukebox_active = ?, hidewired = ?, allow_underpass = ?, youtube_enabled = ? WHERE id = ?")) {
|
||||||
statement.setString(1, this.name);
|
statement.setString(1, this.name);
|
||||||
statement.setString(2, this.description);
|
statement.setString(2, this.description);
|
||||||
statement.setString(3, this.password);
|
statement.setString(3, this.password);
|
||||||
@@ -1170,7 +1174,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
statement.setString(38, this.jukeboxActive ? "1" : "0");
|
statement.setString(38, this.jukeboxActive ? "1" : "0");
|
||||||
statement.setString(39, this.hideWired ? "1" : "0");
|
statement.setString(39, this.hideWired ? "1" : "0");
|
||||||
statement.setString(40, this.allowUnderpass ? "1" : "0");
|
statement.setString(40, this.allowUnderpass ? "1" : "0");
|
||||||
statement.setInt(41, this.id);
|
statement.setString(41, this.youtubeEnabled ? "1" : "0");
|
||||||
|
statement.setInt(42, this.id);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -1809,7 +1814,17 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupYoutubeWatcher(Habbo habbo) {
|
private void cleanupYoutubeWatcher(Habbo habbo) {
|
||||||
if (habbo != null && this.youtubeWatchers.remove(habbo.getHabboInfo().getId())) {
|
if (habbo == null) return;
|
||||||
|
int userId = habbo.getHabboInfo().getId();
|
||||||
|
|
||||||
|
// If the broadcast sender leaves, stop the broadcast for everyone
|
||||||
|
if (!this.youtubeCurrentVideo.isEmpty()
|
||||||
|
&& habbo.getHabboInfo().getUsername().equals(this.youtubeSenderName)) {
|
||||||
|
this.clearYoutubeVideo();
|
||||||
|
this.sendComposer(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomBroadcastComposer("", "", java.util.Collections.emptyList()).compose());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.youtubeWatchers.remove(userId)) {
|
||||||
this.sendComposer(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomWatchersComposer(this.youtubeWatchers).compose());
|
this.sendComposer(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomWatchersComposer(this.youtubeWatchers).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -790,7 +790,6 @@ public class RoomManager {
|
|||||||
habbo.getRoomUnit().setInvisible(false);
|
habbo.getRoomUnit().setInvisible(false);
|
||||||
room.addHabbo(habbo);
|
room.addHabbo(habbo);
|
||||||
|
|
||||||
// Pre-send own wearing badges so the client cache is populated before the user clicks themselves
|
|
||||||
habbo.getClient().sendResponse(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()));
|
habbo.getClient().sendResponse(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()));
|
||||||
|
|
||||||
List<Habbo> habbos = new ArrayList<>();
|
List<Habbo> habbos = new ArrayList<>();
|
||||||
@@ -987,6 +986,9 @@ public class RoomManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomSettingsComposer(
|
||||||
|
room.isYoutubeEnabled()).compose());
|
||||||
|
|
||||||
if (!room.getYoutubeCurrentVideo().isEmpty()) {
|
if (!room.getYoutubeCurrentVideo().isEmpty()) {
|
||||||
habbo.getClient().sendResponse(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomBroadcastComposer(
|
habbo.getClient().sendResponse(new com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomBroadcastComposer(
|
||||||
room.getYoutubeCurrentVideo(),
|
room.getYoutubeCurrentVideo(),
|
||||||
|
|||||||
@@ -681,5 +681,6 @@ public class PacketManager {
|
|||||||
// YouTube Room Broadcast
|
// YouTube Room Broadcast
|
||||||
this.registerHandler(Incoming.YouTubeRoomPlayEvent, com.eu.habbo.messages.incoming.rooms.youtube.YouTubeRoomPlayEvent.class);
|
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);
|
this.registerHandler(Incoming.YouTubeRoomWatchingEvent, com.eu.habbo.messages.incoming.rooms.youtube.YouTubeRoomWatchingEvent.class);
|
||||||
|
this.registerHandler(Incoming.YouTubeRoomSettingsEvent, com.eu.habbo.messages.incoming.rooms.youtube.YouTubeRoomSettingsEvent.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,4 +440,5 @@ public class Incoming {
|
|||||||
// YouTube Room Broadcast
|
// YouTube Room Broadcast
|
||||||
public static final int YouTubeRoomPlayEvent = 8001;
|
public static final int YouTubeRoomPlayEvent = 8001;
|
||||||
public static final int YouTubeRoomWatchingEvent = 8002;
|
public static final int YouTubeRoomWatchingEvent = 8002;
|
||||||
|
public static final int YouTubeRoomSettingsEvent = 8003;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -27,8 +27,7 @@ public class YouTubeRoomPlayEvent extends MessageHandler {
|
|||||||
|
|
||||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||||
if (room == null) return;
|
if (room == null) return;
|
||||||
|
if (!room.isYoutubeEnabled()) return;
|
||||||
// Only the room owner or users with rights can broadcast
|
|
||||||
if (!room.isOwner(habbo) && !room.hasRights(habbo)) return;
|
if (!room.isOwner(habbo) && !room.hasRights(habbo)) return;
|
||||||
|
|
||||||
String videoId = this.packet.readString();
|
String videoId = this.packet.readString();
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
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 com.eu.habbo.messages.outgoing.rooms.youtube.YouTubeRoomSettingsComposer;
|
||||||
|
|
||||||
|
public class YouTubeRoomSettingsEvent extends MessageHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
Habbo habbo = this.client.getHabbo();
|
||||||
|
if (habbo == null) return;
|
||||||
|
|
||||||
|
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||||
|
if (room == null) return;
|
||||||
|
if (!room.isOwner(habbo)) return;
|
||||||
|
|
||||||
|
boolean enabled = this.packet.readInt() == 1;
|
||||||
|
room.setYoutubeEnabled(enabled);
|
||||||
|
room.setNeedsUpdate(true);
|
||||||
|
room.sendComposer(new YouTubeRoomSettingsComposer(enabled).compose());
|
||||||
|
|
||||||
|
if (!enabled && !room.getYoutubeCurrentVideo().isEmpty()) {
|
||||||
|
room.clearYoutubeVideo();
|
||||||
|
room.sendComposer(new YouTubeRoomBroadcastComposer("", "", java.util.Collections.emptyList()).compose());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -574,5 +574,6 @@ public class Outgoing {
|
|||||||
// YouTube Room Broadcast
|
// YouTube Room Broadcast
|
||||||
public static final int YouTubeRoomBroadcastComposer = 8001;
|
public static final int YouTubeRoomBroadcastComposer = 8001;
|
||||||
public static final int YouTubeRoomWatchersComposer = 8002;
|
public static final int YouTubeRoomWatchersComposer = 8002;
|
||||||
|
public static final int YouTubeRoomSettingsComposer = 8003;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public class YouTubeRoomSettingsComposer extends MessageComposer {
|
||||||
|
private final boolean youtubeEnabled;
|
||||||
|
|
||||||
|
public YouTubeRoomSettingsComposer(boolean youtubeEnabled) {
|
||||||
|
this.youtubeEnabled = youtubeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ServerMessage composeInternal() {
|
||||||
|
this.response.init(Outgoing.YouTubeRoomSettingsComposer);
|
||||||
|
this.response.appendInt(this.youtubeEnabled ? 1 : 0);
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user