Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
KrewsOrg 2019-06-16 15:14:59 +01:00
commit 847b938fe8
12 changed files with 107 additions and 28 deletions

View File

@ -67,7 +67,7 @@ DROP PROCEDURE IF EXISTS DEFAULT_YTTV_PLAYLISTS;
ALTER TABLE `permissions` ALTER TABLE `permissions`
ADD COLUMN `cmd_update_youtube_playlists` enum('0','1') NOT NULL DEFAULT '0'; ADD COLUMN `cmd_update_youtube_playlists` enum('0','1') NOT NULL DEFAULT '0';
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_update_youtube_playlists', 'update_youtube;update_youtube_playlists') INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_update_youtube_playlists', 'update_youtube;update_youtube_playlists');
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_update_youtube_playlists', 'YouTube playlists have been refreshed!'); INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_update_youtube_playlists', 'YouTube playlists have been refreshed!');
DROP PROCEDURE IF EXISTS UPDATE_TEAM_WIREDS; DROP PROCEDURE IF EXISTS UPDATE_TEAM_WIREDS;

View File

@ -0,0 +1,10 @@
ALTER TABLE `permissions`
ADD COLUMN `cmd_add_youtube_playlist` enum('0','1') NOT NULL DEFAULT '0';
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_add_youtube_playlist', 'add_youtube;add_playlist;add_youtube_playlist');
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.usage', 'Usage: base_item_id youtube_playlist_id');
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.no_base_item', 'A base item with that ID could not be found.');
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.failed_playlist', 'Error: unable to fetch the given YouTube playlist.');
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_add_youtube_playlist', 'The playlist has been added successfully!');
UPDATE `emulator_texts` SET `value` = 'Superwired Usage Information. Possible reward types:<br/>badge: BADGE CODE<br/>Credits: credits#amount<br/>Pixels: pixels#amount<br/>Points: points#amount<br/>Respect: respect#amount<br/>Furniture: furni#FurnitureID<br/>Catalog Item: cata#CatalogItemID' WHERE `key` = 'hotel.wired.superwired.info';

View File

@ -589,24 +589,10 @@ public class CatalogManager {
return this.catalogPages.get(pageId); return this.catalogPages.get(pageId);
} }
public CatalogPage getCatalogPage(final String captionSafe) { public CatalogPage getCatalogPage(String captionSafe) {
final CatalogPage[] page = {null}; return this.catalogPages.valueCollection().stream()
.filter(p -> p != null && p.getPageName() != null && p.getPageName().equalsIgnoreCase(captionSafe))
synchronized (this.catalogPages) { .findAny().orElse(null);
this.catalogPages.forEachValue(new TObjectProcedure<CatalogPage>() {
@Override
public boolean execute(CatalogPage object) {
if (object.getPageName().equalsIgnoreCase(captionSafe)) {
page[0] = object;
return false;
}
return true;
}
});
return page[0];
}
} }

View File

@ -0,0 +1,59 @@
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.YoutubeManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class AddYoutubePlaylistCommand extends Command {
public AddYoutubePlaylistCommand() {
super("cmd_add_youtube_playlist", Emulator.getTexts().getValue("commands.keys.cmd_add_youtube_playlist").split(";"));
}
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
if (params.length < 3) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.usage"));
return true;
}
int itemId;
try {
itemId = Integer.valueOf(params[1]);
} catch (NumberFormatException e) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.no_base_item"));
return true;
}
if (Emulator.getGameEnvironment().getItemManager().getItem(itemId) == null) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.no_base_item"));
return true;
}
YoutubeManager.YoutubePlaylist playlist = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistDataById(params[2]);
if (playlist == null) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.failed_playlist"));
return true;
}
Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.valueOf(params[1]), playlist);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `youtube_playlists` (`item_id`, `playlist_id`) VALUES (?, ?)")) {
statement.setInt(1, itemId);
statement.setString(2, params[2]);
statement.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_add_youtube_playlist"));
return true;
}
}

View File

@ -276,6 +276,8 @@ public class CommandHandler {
addCommand(new UpdateWordFilterCommand()); addCommand(new UpdateWordFilterCommand());
addCommand(new UserInfoCommand()); addCommand(new UserInfoCommand());
addCommand(new WordQuizCommand()); addCommand(new WordQuizCommand());
addCommand(new UpdateYoutubePlaylistsCommand());
addCommand(new AddYoutubePlaylistCommand());
addCommand(new TestCommand()); addCommand(new TestCommand());
} }

View File

@ -14,6 +14,9 @@ public class LayCommand extends Command {
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception { public boolean handle(GameClient gameClient, String[] params) throws Exception {
if (gameClient.getHabbo().getRoomUnit() == null || !gameClient.getHabbo().getRoomUnit().canForcePosture())
return true;
gameClient.getHabbo().getRoomUnit().cmdLay = true; gameClient.getHabbo().getRoomUnit().cmdLay = true;
gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo()); gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo());
gameClient.getHabbo().getRoomUnit().cmdSit = true; gameClient.getHabbo().getRoomUnit().cmdSit = true;

View File

@ -90,11 +90,9 @@ public class YoutubeManager {
youtubeDataLoaderPool.submit(() -> { youtubeDataLoaderPool.submit(() -> {
ArrayList<YoutubePlaylist> playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); ArrayList<YoutubePlaylist> playlists = this.playlists.getOrDefault(itemId, new ArrayList<>());
YoutubePlaylist playlist = this.playlistCache.containsKey(playlistId) ? this.playlistCache.get(playlistId) : this.getPlaylistDataById(playlistId); YoutubePlaylist playlist = this.getPlaylistDataById(playlistId);
if (playlist != null) { if (playlist != null) {
playlists.add(playlist); playlists.add(playlist);
this.playlistCache.put(playlistId, playlist);
} else { } else {
Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId); Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId);
} }
@ -117,7 +115,9 @@ public class YoutubeManager {
Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
} }
private YoutubePlaylist getPlaylistDataById(String playlistId) { public YoutubePlaylist getPlaylistDataById(String playlistId) {
if (this.playlistCache.containsKey(playlistId)) return this.playlistCache.get(playlistId);
try { try {
URL myUrl = new URL("https://www.youtube.com/playlist?list=" + playlistId); URL myUrl = new URL("https://www.youtube.com/playlist?list=" + playlistId);
@ -159,6 +159,8 @@ public class YoutubeManager {
br.close(); br.close();
this.playlistCache.put(playlistId, playlist);
return playlist; return playlist;
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -170,4 +172,8 @@ public class YoutubeManager {
public ArrayList<YoutubePlaylist> getPlaylistsForItemId(int itemId) { public ArrayList<YoutubePlaylist> getPlaylistsForItemId(int itemId) {
return this.playlists.get(itemId); return this.playlists.get(itemId);
} }
public void addPlaylistToItem(int itemId, YoutubePlaylist playlist) {
this.playlists.computeIfAbsent(itemId, k -> new ArrayList<>()).add(playlist);
}
} }

View File

@ -86,7 +86,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
public boolean saveData(ClientMessage packet) { public boolean saveData(ClientMessage packet) {
packet.readInt(); packet.readInt();
this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; this.teamColor = GameTeamColors.values()[packet.readInt()];
return true; return true;
} }

View File

@ -86,7 +86,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
public boolean saveData(ClientMessage packet) { public boolean saveData(ClientMessage packet) {
packet.readInt(); packet.readInt();
this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; this.teamColor = GameTeamColors.values()[packet.readInt()];
return true; return true;
} }

View File

@ -118,7 +118,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
@Override @Override
public boolean saveData(ClientMessage packet, GameClient gameClient) { public boolean saveData(ClientMessage packet, GameClient gameClient) {
packet.readInt(); packet.readInt();
this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; this.teamColor = GameTeamColors.values()[packet.readInt()];
int unknownInt = packet.readInt(); int unknownInt = packet.readInt();
packet.readString(); packet.readString();
this.setDelay(packet.readInt()); this.setDelay(packet.readInt());

View File

@ -3931,11 +3931,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void makeSit(Habbo habbo) { public void makeSit(Habbo habbo) {
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { if (habbo.getRoomUnit() == null) return;
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) || !habbo.getRoomUnit().canForcePosture()) {
return; return;
} }
this.dance(habbo, DanceType.NONE); this.dance(habbo, DanceType.NONE);
habbo.getRoomUnit().cmdSit = true; habbo.getRoomUnit().cmdSit = true;
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]);
@ -3994,6 +3995,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
if (item.getBaseItem().getType() == FurnitureType.FLOOR) { if (item.getBaseItem().getType() == FurnitureType.FLOOR) {
if (this.layout == null) return;
this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
} }
} }

View File

@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport; import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport;
import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.DanceType;
@ -722,4 +724,12 @@ public class RoomUnit {
public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) { public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) {
this.canLeaveRoomByDoor = canLeaveRoomByDoor; this.canLeaveRoomByDoor = canLeaveRoomByDoor;
} }
public boolean canForcePosture() {
if (this.room == null) return false;
HabboItem topItem = this.room.getTopItemAt(this.getX(), this.getY());
return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
}
} }