You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 07:26:18 +00:00
feat: add builders club catalog and room flow
This commit is contained in:
@@ -228,6 +228,10 @@ public class AchievementManager {
|
||||
}
|
||||
|
||||
public static int getAchievementProgressForHabbo(int userId, Achievement achievement) {
|
||||
if (achievement == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT progress FROM users_achievements WHERE user_id = ? AND achievement_name = ? LIMIT 1")) {
|
||||
statement.setInt(1, userId);
|
||||
statement.setString(2, achievement.name);
|
||||
@@ -393,4 +397,4 @@ public class AchievementManager {
|
||||
public TalentTrackLevel getTalentTrackLevel(TalentTrackType type, int level) {
|
||||
return this.talentTrackLevels.get(type).get(level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ public class CatalogManager {
|
||||
public static int PURCHASE_COOLDOWN = 1;
|
||||
public static boolean SORT_USING_ORDERNUM = false;
|
||||
public final TIntObjectMap<CatalogPage> catalogPages;
|
||||
public final TIntObjectMap<CatalogPage> buildersClubCatalogPages;
|
||||
public final TIntObjectMap<CatalogFeaturedPage> catalogFeaturedPages;
|
||||
public final THashMap<Integer, THashSet<Item>> prizes;
|
||||
public final THashMap<Integer, Integer> giftWrappers;
|
||||
@@ -197,6 +198,7 @@ public class CatalogManager {
|
||||
public final THashMap<Integer, TargetOffer> targetOffers;
|
||||
public final THashMap<Integer, ClothItem> clothing;
|
||||
public final TIntIntHashMap offerDefs;
|
||||
public final TIntIntHashMap buildersClubOfferDefs;
|
||||
public final Item ecotronItem;
|
||||
public final THashMap<Integer, CatalogLimitedConfiguration> limitedNumbers;
|
||||
private final List<Voucher> vouchers;
|
||||
@@ -204,6 +206,7 @@ public class CatalogManager {
|
||||
public CatalogManager() {
|
||||
long millis = System.currentTimeMillis();
|
||||
this.catalogPages = TCollections.synchronizedMap(new TIntObjectHashMap<>());
|
||||
this.buildersClubCatalogPages = TCollections.synchronizedMap(new TIntObjectHashMap<>());
|
||||
this.catalogFeaturedPages = new TIntObjectHashMap<>();
|
||||
this.prizes = new THashMap<>();
|
||||
this.giftWrappers = new THashMap<>();
|
||||
@@ -213,6 +216,7 @@ public class CatalogManager {
|
||||
this.targetOffers = new THashMap<>();
|
||||
this.clothing = new THashMap<>();
|
||||
this.offerDefs = new TIntIntHashMap();
|
||||
this.buildersClubOfferDefs = new TIntIntHashMap();
|
||||
this.vouchers = new ArrayList<>();
|
||||
this.limitedNumbers = new THashMap<>();
|
||||
|
||||
@@ -229,8 +233,10 @@ public class CatalogManager {
|
||||
|
||||
this.loadLimitedNumbers();
|
||||
this.loadCatalogPages();
|
||||
this.loadBuildersClubCatalogPages();
|
||||
this.loadCatalogFeaturedPages();
|
||||
this.loadCatalogItems();
|
||||
this.loadBuildersClubCatalogItems();
|
||||
this.loadClubOffers();
|
||||
this.loadTargetOffers();
|
||||
this.loadVouchers();
|
||||
@@ -315,6 +321,57 @@ public class CatalogManager {
|
||||
LOGGER.info("Loaded {} Catalog Pages!", this.catalogPages.size());
|
||||
}
|
||||
|
||||
private synchronized void loadBuildersClubCatalogPages() {
|
||||
this.buildersClubCatalogPages.clear();
|
||||
|
||||
final THashMap<Integer, CatalogPage> pages = new THashMap<>();
|
||||
pages.put(-1, new CatalogRootLayout());
|
||||
|
||||
String query = "SELECT id, parent_id, caption, caption AS caption_save, page_layout, icon_color, icon_image, 1 AS min_rank, order_num, visible, enabled, '0' AS club_only, 'BUILDERS_CLUB' AS catalog_mode, page_headline, page_teaser, page_special, page_text1, page_text2, page_text_details, page_text_teaser, '' AS includes FROM catalog_pages_bc ORDER BY parent_id, id";
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(query)) {
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
Class<? extends CatalogPage> pageClazz = pageDefinitions.get(set.getString("page_layout"));
|
||||
|
||||
if (pageClazz == null) {
|
||||
LOGGER.info("Unknown Builders Club Page Layout: {}", set.getString("page_layout"));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
CatalogPage page = pageClazz.getConstructor(ResultSet.class).newInstance(set);
|
||||
pages.put(page.getId(), page);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to load Builders Club layout: {}", set.getString("page_layout"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception", e);
|
||||
}
|
||||
|
||||
pages.forEachValue((object) -> {
|
||||
CatalogPage page = pages.get(object.parentId);
|
||||
|
||||
if (page != null) {
|
||||
if (page.id != object.id) {
|
||||
page.addChildPage(object);
|
||||
}
|
||||
} else {
|
||||
if (object.parentId != -2) {
|
||||
LOGGER.info("Builders Club parent page not found for {} (ID: {}, parent_id: {})", object.getPageName(), object.id, object.parentId);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
this.buildersClubCatalogPages.putAll(pages);
|
||||
|
||||
LOGGER.info("Loaded {} Builders Club Catalog Pages!", this.buildersClubCatalogPages.size());
|
||||
}
|
||||
|
||||
|
||||
private synchronized void loadCatalogFeaturedPages() {
|
||||
this.catalogFeaturedPages.clear();
|
||||
@@ -391,6 +448,53 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void loadBuildersClubCatalogItems() {
|
||||
this.buildersClubOfferDefs.clear();
|
||||
|
||||
String query = "SELECT id, item_ids, page_id, catalog_name, 0 AS cost_credits, 0 AS cost_points, 0 AS points_type, 1 AS amount, 0 AS limited_stack, 0 AS limited_sells, extradata, '0' AS club_only, '1' AS have_offer, id AS offer_id, order_number FROM catalog_items_bc";
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet set = statement.executeQuery(query)) {
|
||||
CatalogItem item;
|
||||
|
||||
while (set.next()) {
|
||||
if (set.getString("item_ids").equals("0")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CatalogPage page = this.buildersClubCatalogPages.get(set.getInt("page_id"));
|
||||
|
||||
if (page == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
item = page.getCatalogItem(set.getInt("id"));
|
||||
|
||||
if (item == null) {
|
||||
item = new CatalogItem(set);
|
||||
page.addItem(item);
|
||||
page.addOfferId(item.getOfferId());
|
||||
this.buildersClubOfferDefs.put(item.getOfferId(), item.getId());
|
||||
} else {
|
||||
item.update(set);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception", e);
|
||||
}
|
||||
|
||||
for (CatalogPage page : this.buildersClubCatalogPages.valueCollection()) {
|
||||
for (Integer id : page.getIncluded()) {
|
||||
CatalogPage includedPage = this.buildersClubCatalogPages.get(id);
|
||||
|
||||
if (includedPage != null) {
|
||||
page.getCatalogItems().putAll(includedPage.getCatalogItems());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadClubOffers() {
|
||||
this.clubOffers.clear();
|
||||
|
||||
@@ -585,6 +689,10 @@ public class CatalogManager {
|
||||
return this.catalogPages.get(pageId);
|
||||
}
|
||||
|
||||
public CatalogPage getCatalogPage(int pageId, CatalogPageType pageType) {
|
||||
return this.getCatalogPagesMap(pageType).get(pageId);
|
||||
}
|
||||
|
||||
public CatalogPage getCatalogPage(String captionSafe) {
|
||||
return this.catalogPages.valueCollection().stream()
|
||||
.filter(p -> p != null && p.getPageName() != null && p.getPageName().equalsIgnoreCase(captionSafe))
|
||||
@@ -603,9 +711,15 @@ public class CatalogManager {
|
||||
}
|
||||
|
||||
public CatalogItem getCatalogItem(int id) {
|
||||
return this.getCatalogItem(id, CatalogPageType.NORMAL);
|
||||
}
|
||||
|
||||
public CatalogItem getCatalogItem(int id, CatalogPageType pageType) {
|
||||
final CatalogItem[] item = {null};
|
||||
synchronized (this.catalogPages) {
|
||||
this.catalogPages.forEachValue(new TObjectProcedure<CatalogPage>() {
|
||||
final TIntObjectMap<CatalogPage> pagesMap = this.getCatalogPagesMap(pageType);
|
||||
|
||||
synchronized (pagesMap) {
|
||||
pagesMap.forEachValue(new TObjectProcedure<CatalogPage>() {
|
||||
@Override
|
||||
public boolean execute(CatalogPage object) {
|
||||
item[0] = object.getCatalogItem(id);
|
||||
@@ -620,17 +734,28 @@ public class CatalogManager {
|
||||
|
||||
|
||||
public List<CatalogPage> getCatalogPages(int parentId, final Habbo habbo) {
|
||||
final List<CatalogPage> pages = new ArrayList<>();
|
||||
return this.getCatalogPages(parentId, habbo, CatalogPageType.NORMAL);
|
||||
}
|
||||
|
||||
this.catalogPages.get(parentId).childPages.forEachValue(new TObjectProcedure<CatalogPage>() {
|
||||
public List<CatalogPage> getCatalogPages(int parentId, final Habbo habbo, final CatalogPageType pageType) {
|
||||
final List<CatalogPage> pages = new ArrayList<>();
|
||||
final TIntObjectMap<CatalogPage> pagesMap = this.getCatalogPagesMap(pageType);
|
||||
CatalogPage parentPage = pagesMap.get(parentId);
|
||||
|
||||
if (parentPage == null) {
|
||||
return pages;
|
||||
}
|
||||
|
||||
parentPage.childPages.forEachValue(new TObjectProcedure<CatalogPage>() {
|
||||
@Override
|
||||
public boolean execute(CatalogPage object) {
|
||||
|
||||
boolean isVisiblePage = object.visible;
|
||||
boolean hasRightRank = object.getRank() <= habbo.getHabboInfo().getRank().getId();
|
||||
boolean clubRightsOkay = !object.isClubOnly() || habbo.getHabboInfo().getHabboStats().hasActiveClub();
|
||||
boolean pageTypeMatches = (pageType == CatalogPageType.BUILDER) || object.getCatalogPageType().matches(pageType);
|
||||
|
||||
if (isVisiblePage && hasRightRank && clubRightsOkay) {
|
||||
if (isVisiblePage && hasRightRank && clubRightsOkay && pageTypeMatches) {
|
||||
pages.add(object);
|
||||
}
|
||||
return true;
|
||||
@@ -704,22 +829,42 @@ public class CatalogManager {
|
||||
}
|
||||
|
||||
|
||||
public CatalogPage createCatalogPage(String caption, String captionSave, int roomId, int icon, CatalogPageLayouts layout, int minRank, int parentId) {
|
||||
public CatalogPage createCatalogPage(String caption, String captionSave, int roomId, int icon, CatalogPageLayouts layout, int minRank, int parentId, CatalogPageType pageType, CatalogPageType catalogMode) {
|
||||
CatalogPage catalogPage = null;
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_pages (parent_id, caption, caption_save, icon_image, visible, enabled, min_rank, page_layout, room_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
boolean buildersClubPage = (pageType == CatalogPageType.BUILDER);
|
||||
String insertQuery = buildersClubPage
|
||||
? "INSERT INTO catalog_pages_bc (parent_id, caption, page_layout, icon_color, icon_image, order_num, visible, enabled) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
: "INSERT INTO catalog_pages (parent_id, caption, caption_save, icon_image, visible, enabled, min_rank, page_layout, room_id, catalog_mode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String selectQuery = buildersClubPage
|
||||
? "SELECT id, parent_id, caption, caption AS caption_save, page_layout, icon_color, icon_image, 1 AS min_rank, order_num, visible, enabled, '0' AS club_only, 'BUILDERS_CLUB' AS catalog_mode, page_headline, page_teaser, page_special, page_text1, page_text2, page_text_details, page_text_teaser, '' AS includes FROM catalog_pages_bc WHERE id = ?"
|
||||
: "SELECT * FROM catalog_pages WHERE id = ?";
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS)) {
|
||||
statement.setInt(1, parentId);
|
||||
statement.setString(2, caption);
|
||||
statement.setString(3, captionSave);
|
||||
statement.setInt(4, icon);
|
||||
statement.setString(5, "1");
|
||||
statement.setString(6, "1");
|
||||
statement.setInt(7, minRank);
|
||||
statement.setString(8, layout.name());
|
||||
statement.setInt(9, roomId);
|
||||
|
||||
if (buildersClubPage) {
|
||||
statement.setString(3, layout.name());
|
||||
statement.setInt(4, 1);
|
||||
statement.setInt(5, icon);
|
||||
statement.setInt(6, 1);
|
||||
statement.setString(7, "1");
|
||||
statement.setString(8, "1");
|
||||
} else {
|
||||
statement.setString(3, captionSave);
|
||||
statement.setInt(4, icon);
|
||||
statement.setString(5, "1");
|
||||
statement.setString(6, "1");
|
||||
statement.setInt(7, minRank);
|
||||
statement.setString(8, layout.name());
|
||||
statement.setInt(9, roomId);
|
||||
statement.setString(10, catalogMode.name());
|
||||
}
|
||||
statement.execute();
|
||||
try (ResultSet set = statement.getGeneratedKeys()) {
|
||||
if (set.next()) {
|
||||
try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM catalog_pages WHERE id = ?")) {
|
||||
try (PreparedStatement stmt = connection.prepareStatement(selectQuery)) {
|
||||
stmt.setInt(1, set.getInt(1));
|
||||
try (ResultSet page = stmt.executeQuery()) {
|
||||
if (page.next()) {
|
||||
@@ -744,7 +889,7 @@ public class CatalogManager {
|
||||
}
|
||||
|
||||
if (catalogPage != null) {
|
||||
this.catalogPages.put(catalogPage.getId(), catalogPage);
|
||||
this.getCatalogPagesMap(pageType).put(catalogPage.getId(), catalogPage);
|
||||
}
|
||||
|
||||
return catalogPage;
|
||||
@@ -1144,14 +1289,23 @@ public class CatalogManager {
|
||||
}
|
||||
|
||||
public List<ClubOffer> getClubOffers() {
|
||||
return this.getClubOffers(ClubOffer.WINDOW_HABBO_CLUB);
|
||||
}
|
||||
|
||||
public TIntObjectMap<CatalogPage> getCatalogPagesMap(CatalogPageType pageType) {
|
||||
return (pageType == CatalogPageType.BUILDER) ? this.buildersClubCatalogPages : this.catalogPages;
|
||||
}
|
||||
|
||||
public List<ClubOffer> getClubOffers(int windowId) {
|
||||
List<ClubOffer> offers = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<Integer, ClubOffer> entry : this.clubOffers.entrySet()) {
|
||||
if (!entry.getValue().isDeal()) {
|
||||
if (!entry.getValue().isDeal() && entry.getValue().belongsToWindow(windowId)) {
|
||||
offers.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
offers.sort(Comparator.comparingInt(ClubOffer::getId));
|
||||
return offers;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public abstract class CatalogPage implements Comparable<CatalogPage>, ISerialize
|
||||
protected boolean visible;
|
||||
protected boolean enabled;
|
||||
protected boolean clubOnly;
|
||||
protected CatalogPageType catalogPageType = CatalogPageType.NORMAL;
|
||||
protected String layout;
|
||||
protected String headerImage;
|
||||
protected String teaserImage;
|
||||
@@ -59,6 +60,11 @@ public abstract class CatalogPage implements Comparable<CatalogPage>, ISerialize
|
||||
this.visible = set.getBoolean("visible");
|
||||
this.enabled = set.getBoolean("enabled");
|
||||
this.clubOnly = set.getBoolean("club_only");
|
||||
try {
|
||||
this.catalogPageType = CatalogPageType.fromString(set.getString("catalog_mode"));
|
||||
} catch (SQLException ignored) {
|
||||
this.catalogPageType = CatalogPageType.NORMAL;
|
||||
}
|
||||
this.layout = set.getString("page_layout");
|
||||
this.headerImage = set.getString("page_headline");
|
||||
this.teaserImage = set.getString("page_teaser");
|
||||
@@ -128,6 +134,10 @@ public abstract class CatalogPage implements Comparable<CatalogPage>, ISerialize
|
||||
return this.clubOnly;
|
||||
}
|
||||
|
||||
public CatalogPageType getCatalogPageType() {
|
||||
return this.catalogPageType;
|
||||
}
|
||||
|
||||
public String getLayout() {
|
||||
return this.layout;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,33 @@ public enum CatalogPageType {
|
||||
|
||||
NORMAL,
|
||||
|
||||
BUILDER,
|
||||
|
||||
BUILDER
|
||||
BOTH;
|
||||
|
||||
public static CatalogPageType fromString(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return NORMAL;
|
||||
}
|
||||
|
||||
switch (value.trim().toUpperCase()) {
|
||||
case "BUILDERS_CLUB":
|
||||
case "BUILDER":
|
||||
case "BC":
|
||||
return BUILDER;
|
||||
case "BOTH":
|
||||
return BOTH;
|
||||
case "NORMAL":
|
||||
default:
|
||||
return NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matches(CatalogPageType requestedType) {
|
||||
if (this == BOTH || requestedType == BOTH) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this == requestedType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,30 @@ import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class ClubOffer implements ISerialize {
|
||||
public static final int WINDOW_HABBO_CLUB = 1;
|
||||
public static final int WINDOW_BUILDERS_CLUB = 2;
|
||||
public static final int WINDOW_BUILDERS_CLUB_ADDONS = 3;
|
||||
|
||||
public enum OfferType {
|
||||
HC,
|
||||
VIP,
|
||||
BUILDERS_CLUB,
|
||||
BUILDERS_CLUB_ADDON;
|
||||
|
||||
public static OfferType fromDatabase(String value) {
|
||||
if (value == null) {
|
||||
return HC;
|
||||
}
|
||||
|
||||
for (OfferType type : OfferType.values()) {
|
||||
if (type.name().equalsIgnoreCase(value)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return HC;
|
||||
}
|
||||
}
|
||||
|
||||
private final int id;
|
||||
|
||||
@@ -28,12 +52,16 @@ public class ClubOffer implements ISerialize {
|
||||
|
||||
private final int pointsType;
|
||||
|
||||
private final OfferType type;
|
||||
|
||||
|
||||
private final boolean vip;
|
||||
|
||||
|
||||
private final boolean deal;
|
||||
|
||||
private final boolean giftable;
|
||||
|
||||
public ClubOffer(ResultSet set) throws SQLException {
|
||||
this.id = set.getInt("id");
|
||||
this.name = set.getString("name");
|
||||
@@ -41,8 +69,10 @@ public class ClubOffer implements ISerialize {
|
||||
this.credits = set.getInt("credits");
|
||||
this.points = set.getInt("points");
|
||||
this.pointsType = set.getInt("points_type");
|
||||
this.vip = set.getString("type").equalsIgnoreCase("vip");
|
||||
this.type = OfferType.fromDatabase(set.getString("type"));
|
||||
this.vip = this.type == OfferType.VIP;
|
||||
this.deal = set.getString("deal").equals("1");
|
||||
this.giftable = set.getString("giftable").equals("1");
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@@ -69,6 +99,10 @@ public class ClubOffer implements ISerialize {
|
||||
return this.pointsType;
|
||||
}
|
||||
|
||||
public OfferType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isVip() {
|
||||
return this.vip;
|
||||
}
|
||||
@@ -77,13 +111,49 @@ public class ClubOffer implements ISerialize {
|
||||
return this.deal;
|
||||
}
|
||||
|
||||
public boolean isGiftable() {
|
||||
return this.giftable;
|
||||
}
|
||||
|
||||
public boolean isBuildersClubSubscription() {
|
||||
return this.type == OfferType.BUILDERS_CLUB;
|
||||
}
|
||||
|
||||
public boolean isBuildersClubAddon() {
|
||||
return this.type == OfferType.BUILDERS_CLUB_ADDON;
|
||||
}
|
||||
|
||||
public boolean isHabboClubOffer() {
|
||||
return this.type == OfferType.HC || this.type == OfferType.VIP;
|
||||
}
|
||||
|
||||
public boolean isSubscriptionOffer() {
|
||||
return !this.isBuildersClubAddon();
|
||||
}
|
||||
|
||||
public int getWindowId() {
|
||||
if (this.isBuildersClubAddon()) {
|
||||
return WINDOW_BUILDERS_CLUB_ADDONS;
|
||||
}
|
||||
|
||||
if (this.isBuildersClubSubscription()) {
|
||||
return WINDOW_BUILDERS_CLUB;
|
||||
}
|
||||
|
||||
return WINDOW_HABBO_CLUB;
|
||||
}
|
||||
|
||||
public boolean belongsToWindow(int windowId) {
|
||||
return this.getWindowId() == windowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ServerMessage message) {
|
||||
serialize(message, Emulator.getIntUnixTimestamp());
|
||||
}
|
||||
|
||||
public void serialize(ServerMessage message, int hcExpireTimestamp) {
|
||||
hcExpireTimestamp = Math.max(Emulator.getIntUnixTimestamp(), hcExpireTimestamp);
|
||||
public void serialize(ServerMessage message, int expireTimestamp) {
|
||||
expireTimestamp = Math.max(Emulator.getIntUnixTimestamp(), expireTimestamp);
|
||||
message.appendInt(this.id);
|
||||
message.appendString(this.name);
|
||||
message.appendBoolean(false); //unused
|
||||
@@ -96,27 +166,29 @@ public class ClubOffer implements ISerialize {
|
||||
|
||||
long secondsTotal = seconds;
|
||||
|
||||
int totalYears = (int) Math.floor((int) seconds / (86400.0 * 31 * 12));
|
||||
int totalYears = (int) Math.floor(seconds / (86400.0 * 31 * 12));
|
||||
seconds -= totalYears * (86400 * 31 * 12);
|
||||
|
||||
int totalMonths = (int) Math.floor((int) seconds / (86400.0 * 31));
|
||||
int totalMonths = (int) Math.floor(seconds / (86400.0 * 31));
|
||||
seconds -= totalMonths * (86400 * 31);
|
||||
|
||||
int totalDays = (int) Math.floor((int) seconds / 86400.0);
|
||||
int totalDays = (int) Math.floor(seconds / 86400.0);
|
||||
seconds -= totalDays * 86400L;
|
||||
|
||||
message.appendInt((int) secondsTotal / 86400 / 31);
|
||||
message.appendInt((int) seconds);
|
||||
message.appendBoolean(false); //giftable
|
||||
message.appendInt((int) seconds);
|
||||
message.appendInt(totalMonths);
|
||||
message.appendInt(totalDays);
|
||||
message.appendBoolean(this.giftable);
|
||||
message.appendInt(totalDays);
|
||||
|
||||
hcExpireTimestamp += secondsTotal;
|
||||
if (this.isSubscriptionOffer()) {
|
||||
expireTimestamp += secondsTotal;
|
||||
}
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
cal.setTimeInMillis(hcExpireTimestamp * 1000L);
|
||||
cal.setTimeInMillis(expireTimestamp * 1000L);
|
||||
message.appendInt(cal.get(Calendar.YEAR));
|
||||
message.appendInt(cal.get(Calendar.MONTH) + 1);
|
||||
message.appendInt(cal.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogItem;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageLayouts;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.catalog.layouts.RoomBundleLayout;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
@@ -41,7 +42,7 @@ public class RoomBundleCommand extends Command {
|
||||
points = Integer.parseInt(params[3]);
|
||||
pointsType = Integer.parseInt(params[4]);
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName(), "room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getRank().getId(), parentId);
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName(), "room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getRank().getId(), parentId, CatalogPageType.NORMAL, CatalogPageType.NORMAL);
|
||||
|
||||
if (page instanceof RoomBundleLayout) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type ) VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
|
||||
@@ -0,0 +1,574 @@
|
||||
package com.eu.habbo.habbohotel.rooms;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||
import com.eu.habbo.habbohotel.guilds.GuildRank;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubFurniCountComposer;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubSubscriptionStatusComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.SimpleAlertComposer;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class BuildersClubRoomSupport {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BuildersClubRoomSupport.class);
|
||||
|
||||
public static final int DEFAULT_TRIAL_FURNI_LIMIT = 50;
|
||||
// Uses the built-in system account row so Builders Club furni have a valid foreign-key owner in `items`,
|
||||
// while still being treated as virtual / non-user-owned everywhere else in the BC flow.
|
||||
public static final int VIRTUAL_OWNER_ID = 1;
|
||||
public static final String DISPLAY_OWNER_NAME = "Builders Club";
|
||||
|
||||
public enum SyncResult {
|
||||
UNCHANGED,
|
||||
LOCKED,
|
||||
UNLOCKED
|
||||
}
|
||||
|
||||
private BuildersClubRoomSupport() {
|
||||
}
|
||||
|
||||
public static int getFurniLimit(Habbo habbo) {
|
||||
if (habbo == null) {
|
||||
return DEFAULT_TRIAL_FURNI_LIMIT;
|
||||
}
|
||||
|
||||
return DEFAULT_TRIAL_FURNI_LIMIT + Math.max(0, habbo.getHabboStats().getBuildersClubBonusFurni());
|
||||
}
|
||||
|
||||
public static int getFurniLimit(int userId) {
|
||||
HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId);
|
||||
|
||||
if (habboInfo == null || habboInfo.getHabboStats() == null) {
|
||||
return DEFAULT_TRIAL_FURNI_LIMIT;
|
||||
}
|
||||
|
||||
return DEFAULT_TRIAL_FURNI_LIMIT + Math.max(0, habboInfo.getHabboStats().getBuildersClubBonusFurni());
|
||||
}
|
||||
|
||||
public static int getMembershipSecondsLeft(int userId) {
|
||||
HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId);
|
||||
|
||||
if (habboInfo == null || habboInfo.getHabboStats() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Subscription subscription = habboInfo.getHabboStats().getSubscription(Subscription.BUILDERS_CLUB);
|
||||
|
||||
if (subscription == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(0, subscription.getRemaining());
|
||||
}
|
||||
|
||||
public static boolean hasActiveMembership(int userId) {
|
||||
HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId);
|
||||
|
||||
return habboInfo != null
|
||||
&& habboInfo.getHabboStats() != null
|
||||
&& habboInfo.getHabboStats().hasSubscription(Subscription.BUILDERS_CLUB);
|
||||
}
|
||||
|
||||
public static int getTrackedFurniCount(int userId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) FROM builders_club_items WHERE user_id = ? AND room_id > 0")) {
|
||||
statement.setInt(1, userId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
return set.getInt(1);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception counting Builders Club furni", e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean hasTrackedItemsInOwnedRooms(int ownerId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT 1 FROM builders_club_items bci INNER JOIN rooms r ON r.id = bci.room_id WHERE r.owner_id = ? AND bci.room_id > 0 LIMIT 1")) {
|
||||
statement.setInt(1, ownerId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
return set.next();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception checking Builders Club room ownership", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean roomHasTrackedItems(int roomId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT 1 FROM builders_club_items WHERE room_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, roomId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
return set.next();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception checking Builders Club room items", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isTrackedItem(int itemId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT 1 FROM builders_club_items WHERE item_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, itemId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
return set.next();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception checking Builders Club tracked item", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getTrackedUserId(int itemId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM builders_club_items WHERE item_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, itemId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
return set.getInt("user_id");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception getting Builders Club tracked user", e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean hasPlacementVisitors(Room room, Habbo owner) {
|
||||
if (room == null || owner == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Habbo habbo : room.getHabbos()) {
|
||||
if (habbo == null || habbo.getHabboInfo() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getId() == owner.getHabboInfo().getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (habbo.hasPermission(Permission.ACC_ENTERANYROOM) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlacementBlockedByVisitors(Habbo habbo) {
|
||||
if (habbo == null || habbo.getHabboInfo() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasActiveMembership(habbo.getHabboInfo().getId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Room currentRoom = habbo.getHabboInfo().getCurrentRoom();
|
||||
|
||||
if (currentRoom == null || currentRoom.getOwnerId() != habbo.getHabboInfo().getId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hasPlacementVisitors(currentRoom, habbo);
|
||||
}
|
||||
|
||||
public static boolean canPlaceInCurrentRoom(Habbo habbo) {
|
||||
if (habbo == null || habbo.getHabboInfo() == null || habbo.getHabboInfo().getCurrentRoom() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return canPlaceInRoom(habbo, habbo.getHabboInfo().getCurrentRoom());
|
||||
}
|
||||
|
||||
public static boolean canPlaceInRoom(Habbo habbo, Room room) {
|
||||
if (habbo == null || habbo.getHabboInfo() == null || room == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (room.getOwnerId() == habbo.getHabboInfo().getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Room currentRoom = habbo.getHabboInfo().getCurrentRoom();
|
||||
|
||||
if (currentRoom == null || currentRoom.getId() != room.getId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return canUseGuildPlacementPool(habbo, room);
|
||||
}
|
||||
|
||||
public static int getPlacementPoolUserId(Habbo habbo) {
|
||||
if (habbo == null || habbo.getHabboInfo() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Room currentRoom = habbo.getHabboInfo().getCurrentRoom();
|
||||
|
||||
if (currentRoom == null) {
|
||||
return habbo.getHabboInfo().getId();
|
||||
}
|
||||
|
||||
if (currentRoom.getOwnerId() == habbo.getHabboInfo().getId()) {
|
||||
return habbo.getHabboInfo().getId();
|
||||
}
|
||||
|
||||
if (canUseGuildPlacementPool(habbo, currentRoom)) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(currentRoom.getGuildId());
|
||||
|
||||
if (guild != null && guild.getOwnerId() > 0) {
|
||||
return guild.getOwnerId();
|
||||
}
|
||||
}
|
||||
|
||||
return habbo.getHabboInfo().getId();
|
||||
}
|
||||
|
||||
public static int getPlacementPoolFurniCount(Habbo habbo) {
|
||||
int userId = getPlacementPoolUserId(habbo);
|
||||
|
||||
if (userId <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getTrackedFurniCount(userId);
|
||||
}
|
||||
|
||||
public static int getPlacementPoolFurniLimit(Habbo habbo) {
|
||||
int userId = getPlacementPoolUserId(habbo);
|
||||
|
||||
if (userId <= 0) {
|
||||
return DEFAULT_TRIAL_FURNI_LIMIT;
|
||||
}
|
||||
|
||||
return getFurniLimit(userId);
|
||||
}
|
||||
|
||||
public static void sendPlacementStatus(Habbo habbo) {
|
||||
if (habbo == null || habbo.getClient() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new BuildersClubFurniCountComposer(getTrackedFurniCount(habbo.getHabboInfo().getId())));
|
||||
habbo.getClient().sendResponse(new BuildersClubSubscriptionStatusComposer(habbo));
|
||||
}
|
||||
|
||||
public static void sendPlacementStatusForPool(Room room, int placementUserId) {
|
||||
if (placementUserId <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
THashSet<Integer> updatedUsers = new THashSet<>();
|
||||
|
||||
if (room != null) {
|
||||
for (Habbo habbo : room.getHabbos()) {
|
||||
if (habbo == null || habbo.getHabboInfo() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getPlacementPoolUserId(habbo) != placementUserId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sendPlacementStatus(habbo);
|
||||
updatedUsers.add(habbo.getHabboInfo().getId());
|
||||
}
|
||||
}
|
||||
|
||||
Habbo placementPoolHabbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(placementUserId);
|
||||
|
||||
if (placementPoolHabbo != null && placementPoolHabbo.getHabboInfo() != null && !updatedUsers.contains(placementPoolHabbo.getHabboInfo().getId())) {
|
||||
sendPlacementStatus(placementPoolHabbo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendCurrentRoomPlacementStatus(Room room) {
|
||||
if (room == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Habbo owner = room.getHabbo(room.getOwnerId());
|
||||
|
||||
if (owner == null || owner.getClient() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
owner.getClient().sendResponse(new com.eu.habbo.messages.outgoing.catalog.BuildersClubSubscriptionStatusComposer(owner));
|
||||
}
|
||||
|
||||
private static boolean canUseGuildPlacementPool(Habbo habbo, Room room) {
|
||||
if (habbo == null || room == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Guild guild = resolvePlacementGuild(room);
|
||||
|
||||
if (guild == null || guild.getOwnerId() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isGuildAdmin = room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_ADMIN);
|
||||
|
||||
if (!isGuildAdmin) {
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), habbo.getHabboInfo().getId());
|
||||
|
||||
isGuildAdmin = member != null && (member.getRank() == GuildRank.ADMIN || member.getRank() == GuildRank.OWNER);
|
||||
}
|
||||
|
||||
if (!isGuildAdmin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hasActiveMembership(habbo.getHabboInfo().getId()) && hasActiveMembership(guild.getOwnerId());
|
||||
}
|
||||
|
||||
private static Guild resolvePlacementGuild(Room room) {
|
||||
int guildId = resolveRoomGuildId(room);
|
||||
|
||||
if (guildId <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (room.getGuildId() != guildId) {
|
||||
room.setGuild(guildId);
|
||||
}
|
||||
|
||||
return Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||
}
|
||||
|
||||
private static int resolveRoomGuildId(Room room) {
|
||||
if (room == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (room.getGuildId() > 0) {
|
||||
return room.getGuildId();
|
||||
}
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM rooms WHERE id = ? LIMIT 1")) {
|
||||
statement.setInt(1, room.getId());
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
return set.getInt("guild_id");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception resolving Builders Club room guild", e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void trackPlacedItem(int itemId, int userId, int roomId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO builders_club_items (item_id, user_id, room_id) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE user_id = VALUES(user_id), room_id = VALUES(room_id)")) {
|
||||
statement.setInt(1, itemId);
|
||||
statement.setInt(2, userId);
|
||||
statement.setInt(3, roomId);
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception tracking Builders Club item placement", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearTrackedItemRoom(int itemId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("UPDATE builders_club_items SET room_id = 0 WHERE item_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, itemId);
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception clearing Builders Club room assignment", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteTrackedItem(int itemId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM builders_club_items WHERE item_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, itemId);
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception deleting Builders Club tracked item", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static SyncResult syncRoom(Room room) {
|
||||
if (room == null) {
|
||||
return SyncResult.UNCHANGED;
|
||||
}
|
||||
|
||||
boolean hasTrackedItems = roomHasTrackedItems(room.getId());
|
||||
boolean hasMembership = hasActiveMembership(room.getOwnerId());
|
||||
|
||||
if (hasTrackedItems && !hasMembership) {
|
||||
return lockRoom(room) ? SyncResult.LOCKED : SyncResult.UNCHANGED;
|
||||
}
|
||||
|
||||
if (room.isBuildersClubTrialLocked() && (!hasTrackedItems || hasMembership)) {
|
||||
return unlockRoom(room) ? SyncResult.UNLOCKED : SyncResult.UNCHANGED;
|
||||
}
|
||||
|
||||
return SyncResult.UNCHANGED;
|
||||
}
|
||||
|
||||
public static int syncOwnedRooms(int ownerId) {
|
||||
int changed = 0;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT id FROM rooms WHERE owner_id = ?")) {
|
||||
statement.setInt(1, ownerId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(set.getInt("id"), false);
|
||||
|
||||
if (syncRoom(room) != SyncResult.UNCHANGED) {
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception syncing Builders Club rooms", e);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public static void sendRoomLockedBubble(int ownerId) {
|
||||
sendBubbleNotification(ownerId, BubbleAlertKeys.BUILDERS_CLUB_ROOM_LOCKED, null);
|
||||
}
|
||||
|
||||
public static void sendRoomUnlockedBubble(int ownerId) {
|
||||
sendBubbleNotification(ownerId, BubbleAlertKeys.BUILDERS_CLUB_ROOM_UNLOCKED, null);
|
||||
}
|
||||
|
||||
public static void sendMembershipMadeBubble(int userId) {
|
||||
sendBubbleNotification(userId, BubbleAlertKeys.BUILDERS_CLUB_MEMBERSHIP_MADE, null);
|
||||
}
|
||||
|
||||
public static void sendMembershipExtendedBubble(int userId) {
|
||||
sendBubbleNotification(userId, BubbleAlertKeys.BUILDERS_CLUB_MEMBERSHIP_EXTENDED, null);
|
||||
}
|
||||
|
||||
public static void sendVisitDeniedOwnerBubble(int ownerId, String username) {
|
||||
THashMap<String, String> keys = new THashMap<>();
|
||||
keys.put("USERNAME", username);
|
||||
|
||||
sendBubbleNotification(ownerId, BubbleAlertKeys.BUILDERS_CLUB_VISIT_DENIED_OWNER, keys);
|
||||
}
|
||||
|
||||
public static void sendVisitDeniedVisitorAlert(int userId) {
|
||||
sendSimpleAlert(userId, "notification.builders_club.visit_denied_for_visitor.message");
|
||||
}
|
||||
|
||||
public static void sendMembershipExpiringAlert(int userId) {
|
||||
sendSimpleAlert(userId, "expiring.bc.membership.description");
|
||||
}
|
||||
|
||||
public static void sendMembershipExpiredAlert(int userId, boolean hasTrackedRooms) {
|
||||
sendSimpleAlert(
|
||||
userId,
|
||||
hasTrackedRooms
|
||||
? "notification.builders_club.membership_expired.message"
|
||||
: "notification.builders_club.membership_expired.message_no_rooms"
|
||||
);
|
||||
}
|
||||
|
||||
private static void sendBubbleNotification(int userId, BubbleAlertKeys key, THashMap<String, String> keys) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
||||
if (habbo == null || habbo.getClient() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (keys == null) {
|
||||
habbo.getClient().sendResponse(new BubbleAlertComposer(key.key));
|
||||
return;
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new BubbleAlertComposer(key.key, keys));
|
||||
}
|
||||
|
||||
private static void sendSimpleAlert(int userId, String messageKey) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
||||
if (habbo == null || habbo.getClient() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new SimpleAlertComposer(messageKey));
|
||||
}
|
||||
|
||||
private static boolean lockRoom(Room room) {
|
||||
if (room.isBuildersClubTrialLocked()) {
|
||||
if (room.getState() != RoomState.INVISIBLE) {
|
||||
room.setState(RoomState.INVISIBLE);
|
||||
room.setNeedsUpdate(true);
|
||||
room.save();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
room.setBuildersClubOriginalState(room.getState());
|
||||
room.setBuildersClubTrialLocked(true);
|
||||
room.setState(RoomState.INVISIBLE);
|
||||
room.setNeedsUpdate(true);
|
||||
room.save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean unlockRoom(Room room) {
|
||||
if (!room.isBuildersClubTrialLocked()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RoomState originalState = room.getBuildersClubOriginalState();
|
||||
|
||||
if (originalState == null) {
|
||||
originalState = RoomState.OPEN;
|
||||
}
|
||||
|
||||
room.setState(originalState);
|
||||
room.setBuildersClubTrialLocked(false);
|
||||
room.setBuildersClubOriginalState(originalState);
|
||||
room.setNeedsUpdate(true);
|
||||
room.save();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
private boolean allowUnderpass;
|
||||
private boolean jukeboxActive;
|
||||
private boolean hideWired;
|
||||
private boolean buildersClubTrialLocked;
|
||||
private RoomState buildersClubOriginalState;
|
||||
private RoomPromotion promotion;
|
||||
private volatile boolean needsUpdate;
|
||||
private volatile boolean loaded;
|
||||
@@ -236,6 +238,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.promoted = set.getString("promoted").equals("1");
|
||||
this.jukeboxActive = set.getString("jukebox_active").equals("1");
|
||||
this.hideWired = set.getString("hidewired").equals("1");
|
||||
this.buildersClubTrialLocked = set.getBoolean("builders_club_trial_locked");
|
||||
|
||||
String buildersClubOriginalState = set.getString("builders_club_original_state");
|
||||
|
||||
if (buildersClubOriginalState != null && !buildersClubOriginalState.isEmpty()) {
|
||||
try {
|
||||
this.buildersClubOriginalState = RoomState.valueOf(buildersClubOriginalState.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.buildersClubOriginalState = RoomState.OPEN;
|
||||
}
|
||||
} else {
|
||||
this.buildersClubOriginalState = RoomState.OPEN;
|
||||
}
|
||||
|
||||
this.bannedHabbos = new TIntObjectHashMap<>();
|
||||
|
||||
@@ -781,6 +796,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean trackedBuildersClubItem = BuildersClubRoomSupport.isTrackedItem(item.getId());
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) {
|
||||
Event furniturePickedUpEvent = new FurniturePickedUpEvent(item, picker);
|
||||
Emulator.getPluginManager().fireEvent(furniturePickedUpEvent);
|
||||
@@ -823,9 +840,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.sendComposer(new RemoveWallItemComposer(item).compose());
|
||||
}
|
||||
|
||||
if (trackedBuildersClubItem) {
|
||||
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
||||
return;
|
||||
}
|
||||
|
||||
Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker
|
||||
: Emulator.getGameServer().getGameClientManager().getHabbo(item.getUserId()));
|
||||
if (habbo != null) {
|
||||
if (!trackedBuildersClubItem && habbo != null) {
|
||||
habbo.getInventory().getItemsComponent().addItem(item);
|
||||
habbo.getClient().sendResponse(new AddHabboItemComposer(item));
|
||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
@@ -1129,7 +1151,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (this.needsUpdate) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource()
|
||||
.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 = ?, builders_club_trial_locked = ?, builders_club_original_state = ? WHERE id = ?")) {
|
||||
statement.setString(1, this.name);
|
||||
statement.setString(2, this.description);
|
||||
statement.setString(3, this.password);
|
||||
@@ -1179,7 +1201,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
statement.setString(38, this.jukeboxActive ? "1" : "0");
|
||||
statement.setString(39, this.hideWired ? "1" : "0");
|
||||
statement.setString(40, this.allowUnderpass ? "1" : "0");
|
||||
statement.setInt(41, this.id);
|
||||
statement.setString(41, this.buildersClubTrialLocked ? "1" : "0");
|
||||
statement.setString(42, (this.buildersClubOriginalState != null ? this.buildersClubOriginalState : RoomState.OPEN).name().toLowerCase());
|
||||
statement.setInt(43, this.id);
|
||||
statement.executeUpdate();
|
||||
this.needsUpdate = false;
|
||||
} catch (SQLException e) {
|
||||
@@ -1296,6 +1320,22 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public boolean isBuildersClubTrialLocked() {
|
||||
return this.buildersClubTrialLocked;
|
||||
}
|
||||
|
||||
public void setBuildersClubTrialLocked(boolean buildersClubTrialLocked) {
|
||||
this.buildersClubTrialLocked = buildersClubTrialLocked;
|
||||
}
|
||||
|
||||
public RoomState getBuildersClubOriginalState() {
|
||||
return this.buildersClubOriginalState;
|
||||
}
|
||||
|
||||
public void setBuildersClubOriginalState(RoomState buildersClubOriginalState) {
|
||||
this.buildersClubOriginalState = buildersClubOriginalState;
|
||||
}
|
||||
|
||||
public int getUsersMax() {
|
||||
return this.usersMax;
|
||||
}
|
||||
@@ -1395,11 +1435,28 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
public int getGuildId() {
|
||||
if (this.guild > 0) {
|
||||
return this.guild;
|
||||
}
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM rooms WHERE id = ? LIMIT 1")) {
|
||||
statement.setInt(1, this.id);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
this.guild = set.getInt("guild_id");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception resolving room guild", e);
|
||||
}
|
||||
|
||||
return this.guild;
|
||||
}
|
||||
|
||||
public boolean hasGuild() {
|
||||
return this.guild != 0;
|
||||
return this.getGuildId() != 0;
|
||||
}
|
||||
|
||||
public void setGuild(int guild) {
|
||||
@@ -2129,11 +2186,18 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
public RoomRightLevels getGuildRightLevel(Habbo habbo) {
|
||||
if (this.guild > 0 && habbo.getHabboStats().hasGuild(this.guild)) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild);
|
||||
int guildId = this.getGuildId();
|
||||
|
||||
if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild)
|
||||
.get(habbo.getHabboInfo().getId()) != null) {
|
||||
if (guildId > 0 && habbo != null && habbo.getHabboInfo() != null) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||
|
||||
if (guild == null) {
|
||||
return RoomRightLevels.NONE;
|
||||
}
|
||||
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), habbo.getHabboInfo().getId());
|
||||
|
||||
if ((member != null) && (member.getRank() == GuildRank.ADMIN || member.getRank() == GuildRank.OWNER)) {
|
||||
return RoomRightLevels.GUILD_ADMIN;
|
||||
}
|
||||
|
||||
|
||||
@@ -627,19 +627,28 @@ public class RoomItemManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (BuildersClubRoomSupport.isTrackedItem(item.getId()) && item.getUserId() != BuildersClubRoomSupport.VIRTUAL_OWNER_ID) {
|
||||
item.setUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
||||
item.needsUpdate(true);
|
||||
}
|
||||
|
||||
synchronized (this.furniOwnerCount) {
|
||||
this.furniOwnerCount.put(item.getUserId(), this.furniOwnerCount.get(item.getUserId()) + 1);
|
||||
}
|
||||
|
||||
synchronized (this.furniOwnerNames) {
|
||||
if (!this.furniOwnerNames.containsKey(item.getUserId())) {
|
||||
HabboInfo habbo = HabboManager.getOfflineHabboInfo(item.getUserId());
|
||||
|
||||
if (habbo != null) {
|
||||
this.furniOwnerNames.put(item.getUserId(), habbo.getUsername());
|
||||
if (item.getUserId() == BuildersClubRoomSupport.VIRTUAL_OWNER_ID && BuildersClubRoomSupport.isTrackedItem(item.getId())) {
|
||||
this.furniOwnerNames.put(item.getUserId(), BuildersClubRoomSupport.DISPLAY_OWNER_NAME);
|
||||
} else {
|
||||
LOGGER.error("Failed to find username for item (ID: {}, UserID: {})",
|
||||
item.getId(), item.getUserId());
|
||||
HabboInfo habbo = HabboManager.getOfflineHabboInfo(item.getUserId());
|
||||
|
||||
if (habbo != null) {
|
||||
this.furniOwnerNames.put(item.getUserId(), habbo.getUsername());
|
||||
} else {
|
||||
LOGGER.error("Failed to find username for item (ID: {}, UserID: {})",
|
||||
item.getId(), item.getUserId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -749,6 +758,9 @@ public class RoomItemManager {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean trackedBuildersClubItem = BuildersClubRoomSupport.isTrackedItem(item.getId());
|
||||
int trackedUserId = trackedBuildersClubItem ? BuildersClubRoomSupport.getTrackedUserId(item.getId()) : item.getUserId();
|
||||
|
||||
HabboItem i;
|
||||
synchronized (this.roomItems) {
|
||||
i = this.roomItems.remove(item.getId());
|
||||
@@ -771,6 +783,16 @@ public class RoomItemManager {
|
||||
// Unregister from special types
|
||||
this.unregisterItemFromSpecialTypes(item);
|
||||
}
|
||||
|
||||
if (trackedBuildersClubItem) {
|
||||
BuildersClubRoomSupport.deleteTrackedItem(item.getId());
|
||||
|
||||
if (BuildersClubRoomSupport.syncRoom(this.room) == BuildersClubRoomSupport.SyncResult.UNLOCKED) {
|
||||
BuildersClubRoomSupport.sendRoomUnlockedBubble(this.room.getOwnerId());
|
||||
}
|
||||
|
||||
BuildersClubRoomSupport.sendPlacementStatusForPool(this.room, trackedUserId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -992,6 +1014,8 @@ public class RoomItemManager {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean trackedBuildersClubItem = BuildersClubRoomSupport.isTrackedItem(item.getId());
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) {
|
||||
FurniturePickedUpEvent event = Emulator.getPluginManager()
|
||||
.fireEvent(new FurniturePickedUpEvent(item, picker));
|
||||
@@ -1036,6 +1060,11 @@ public class RoomItemManager {
|
||||
this.room.sendComposer(new RemoveWallItemComposer(item).compose());
|
||||
}
|
||||
|
||||
if (trackedBuildersClubItem) {
|
||||
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
||||
return;
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(item);
|
||||
}
|
||||
|
||||
@@ -1044,6 +1073,7 @@ public class RoomItemManager {
|
||||
*/
|
||||
public void ejectUserFurni(int userId) {
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
THashSet<HabboItem> inventoryItems = new THashSet<>();
|
||||
|
||||
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
|
||||
|
||||
@@ -1056,15 +1086,20 @@ public class RoomItemManager {
|
||||
|
||||
if (iterator.value().getUserId() == userId) {
|
||||
items.add(iterator.value());
|
||||
|
||||
if (!BuildersClubRoomSupport.isTrackedItem(iterator.value().getId())) {
|
||||
inventoryItems.add(iterator.value());
|
||||
}
|
||||
|
||||
iterator.value().setRoomId(0);
|
||||
}
|
||||
}
|
||||
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getInventory().getItemsComponent().addItems(items);
|
||||
habbo.getClient().sendResponse(new AddHabboItemComposer(items));
|
||||
if (habbo != null && !inventoryItems.isEmpty()) {
|
||||
habbo.getInventory().getItemsComponent().addItems(inventoryItems);
|
||||
habbo.getClient().sendResponse(new AddHabboItemComposer(inventoryItems));
|
||||
}
|
||||
|
||||
for (HabboItem i : items) {
|
||||
@@ -1116,15 +1151,23 @@ public class RoomItemManager {
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, THashSet<HabboItem>> entrySet : userItemsMap.entrySet()) {
|
||||
THashSet<HabboItem> inventoryItems = new THashSet<>();
|
||||
|
||||
for (HabboItem item : entrySet.getValue()) {
|
||||
if (!BuildersClubRoomSupport.isTrackedItem(item.getId())) {
|
||||
inventoryItems.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
for (HabboItem i : entrySet.getValue()) {
|
||||
this.pickUpItem(i, null);
|
||||
}
|
||||
|
||||
Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(entrySet.getKey());
|
||||
|
||||
if (user != null) {
|
||||
user.getInventory().getItemsComponent().addItems(entrySet.getValue());
|
||||
user.getClient().sendResponse(new AddHabboItemComposer(entrySet.getValue()));
|
||||
if (user != null && !inventoryItems.isEmpty()) {
|
||||
user.getInventory().getItemsComponent().addItems(inventoryItems);
|
||||
user.getClient().sendResponse(new AddHabboItemComposer(inventoryItems));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1268,7 +1311,7 @@ public class RoomItemManager {
|
||||
rotation %= 8;
|
||||
if (this.room.hasRights(habbo) || this.room.getGuildRightLevel(habbo)
|
||||
.isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasPermission(
|
||||
Permission.ACC_MOVEROTATE)) {
|
||||
Permission.ACC_MOVEROTATE) || BuildersClubRoomSupport.canPlaceInRoom(habbo, this.room)) {
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
@@ -1526,7 +1569,7 @@ public class RoomItemManager {
|
||||
item.setY(tile.y);
|
||||
item.setRotation(rotation);
|
||||
if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) {
|
||||
this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername());
|
||||
this.furniOwnerNames.put(item.getUserId(), this.resolveOwnerName(item, owner));
|
||||
}
|
||||
|
||||
item.needsUpdate(true);
|
||||
@@ -1563,7 +1606,7 @@ public class RoomItemManager {
|
||||
*/
|
||||
public FurnitureMovementError placeWallFurniAt(HabboItem item, String wallPosition, Habbo owner) {
|
||||
if (!(this.room.hasRights(owner) || this.room.getGuildRightLevel(owner)
|
||||
.isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) {
|
||||
.isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || BuildersClubRoomSupport.canPlaceInRoom(owner, this.room))) {
|
||||
return FurnitureMovementError.NO_RIGHTS;
|
||||
}
|
||||
|
||||
@@ -1578,7 +1621,7 @@ public class RoomItemManager {
|
||||
|
||||
item.setWallPosition(wallPosition);
|
||||
if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) {
|
||||
this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername());
|
||||
this.furniOwnerNames.put(item.getUserId(), this.resolveOwnerName(item, owner));
|
||||
}
|
||||
this.room.sendComposer(
|
||||
new AddWallItemComposer(item, this.getFurniOwnerName(item.getUserId())).compose());
|
||||
@@ -1590,6 +1633,14 @@ public class RoomItemManager {
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
private String resolveOwnerName(HabboItem item, Habbo owner) {
|
||||
if (item != null && item.getUserId() == BuildersClubRoomSupport.VIRTUAL_OWNER_ID) {
|
||||
return BuildersClubRoomSupport.DISPLAY_OWNER_NAME;
|
||||
}
|
||||
|
||||
return (owner != null) ? owner.getHabboInfo().getUsername() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves furniture to a new position with an explicit Z height.
|
||||
*/
|
||||
|
||||
@@ -569,6 +569,18 @@ public class RoomManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.isBuildersClubTrialLocked()
|
||||
&& habbo.getHabboInfo().getId() != room.getOwnerId()
|
||||
&& !overrideChecks
|
||||
&& !habbo.hasPermission(Permission.ACC_ANYROOMOWNER)
|
||||
&& !habbo.hasPermission(Permission.ACC_ENTERANYROOM)) {
|
||||
BuildersClubRoomSupport.sendVisitDeniedOwnerBubble(room.getOwnerId(), habbo.getHabboInfo().getUsername());
|
||||
BuildersClubRoomSupport.sendVisitDeniedVisitorAlert(habbo.getHabboInfo().getId());
|
||||
habbo.getClient().sendResponse(new HotelViewComposer());
|
||||
habbo.getHabboInfo().setLoadingRoom(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getRoomQueueId() != roomId) {
|
||||
Room queRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
|
||||
|
||||
@@ -782,6 +794,7 @@ public class RoomManager {
|
||||
|
||||
habbo.getRoomUnit().setInvisible(false);
|
||||
room.addHabbo(habbo);
|
||||
BuildersClubRoomSupport.sendCurrentRoomPlacementStatus(room);
|
||||
room.getUserVariableManager().restorePermanentAssignments(habbo);
|
||||
|
||||
// Pre-send own wearing badges so the client cache is populated before the user clicks themselves
|
||||
@@ -1018,6 +1031,7 @@ public class RoomManager {
|
||||
|
||||
this.logExit(habbo);
|
||||
room.removeHabbo(habbo, true);
|
||||
BuildersClubRoomSupport.sendCurrentRoomPlacementStatus(room);
|
||||
|
||||
if (redirectToHotelView) {
|
||||
habbo.getClient().sendResponse(new HotelViewComposer());
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||
import com.eu.habbo.habbohotel.guilds.GuildRank;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.outgoing.rooms.RoomAddRightsListComposer;
|
||||
@@ -90,11 +92,16 @@ public class RoomRightsManager {
|
||||
*/
|
||||
public RoomRightLevels getGuildRightLevel(Habbo habbo) {
|
||||
int guildId = this.room.getGuildId();
|
||||
if (guildId > 0 && habbo.getHabboStats().hasGuild(guildId)) {
|
||||
if (guildId > 0 && habbo != null && habbo.getHabboInfo() != null) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||
|
||||
if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild)
|
||||
.get(habbo.getHabboInfo().getId()) != null) {
|
||||
if (guild == null) {
|
||||
return RoomRightLevels.NONE;
|
||||
}
|
||||
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), habbo.getHabboInfo().getId());
|
||||
|
||||
if ((member != null) && (member.getRank() == GuildRank.ADMIN || member.getRank() == GuildRank.OWNER)) {
|
||||
return RoomRightLevels.GUILD_ADMIN;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ public class HabboStats implements Runnable {
|
||||
public int maxRooms;
|
||||
public int lastHCPayday;
|
||||
public int hcGiftsClaimed;
|
||||
public int buildersClubBonusFurni;
|
||||
public int hcMessageLastModified = Emulator.getIntUnixTimestamp();
|
||||
public THashSet<Subscription> subscriptions;
|
||||
|
||||
@@ -155,6 +156,7 @@ public class HabboStats implements Runnable {
|
||||
this.maxRooms = set.getInt("max_rooms");
|
||||
this.lastHCPayday = set.getInt("last_hc_payday");
|
||||
this.hcGiftsClaimed = set.getInt("hc_gifts_claimed");
|
||||
this.buildersClubBonusFurni = set.getInt("builders_club_bonus_furni");
|
||||
|
||||
this.nuxReward = this.nux;
|
||||
|
||||
@@ -327,7 +329,7 @@ public class HabboStats implements Runnable {
|
||||
int onlineTime = Emulator.getIntUnixTimestamp() - onlineTimeLast;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ?, ui_flags = ?, has_gotten_default_saved_searches = ?, max_friends = ?, max_rooms = ?, last_hc_payday = ?, hc_gifts_claimed = ? WHERE user_id = ? LIMIT 1")) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ?, ui_flags = ?, has_gotten_default_saved_searches = ?, max_friends = ?, max_rooms = ?, last_hc_payday = ?, hc_gifts_claimed = ?, builders_club_bonus_furni = ? WHERE user_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, this.achievementScore);
|
||||
statement.setInt(2, this.respectPointsReceived);
|
||||
statement.setInt(3, this.respectPointsGiven);
|
||||
@@ -366,7 +368,8 @@ public class HabboStats implements Runnable {
|
||||
statement.setInt(36, this.maxRooms);
|
||||
statement.setInt(37, this.lastHCPayday);
|
||||
statement.setInt(38, this.hcGiftsClaimed);
|
||||
statement.setInt(39, this.habboInfo.getId());
|
||||
statement.setInt(39, this.buildersClubBonusFurni);
|
||||
statement.setInt(40, this.habboInfo.getId());
|
||||
|
||||
statement.executeUpdate();
|
||||
}
|
||||
@@ -436,6 +439,10 @@ public class HabboStats implements Runnable {
|
||||
}
|
||||
|
||||
public int getAchievementProgress(Achievement achievement) {
|
||||
if (achievement == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this.achievementProgress.containsKey(achievement))
|
||||
return this.achievementProgress.get(achievement);
|
||||
|
||||
@@ -575,6 +582,18 @@ public class HabboStats implements Runnable {
|
||||
return totalGifts - this.hcGiftsClaimed;
|
||||
}
|
||||
|
||||
public int getBuildersClubBonusFurni() {
|
||||
return this.buildersClubBonusFurni;
|
||||
}
|
||||
|
||||
public void addBuildersClubBonusFurni(int amount) {
|
||||
if (amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.buildersClubBonusFurni += amount;
|
||||
}
|
||||
|
||||
public THashMap<Achievement, Integer> getAchievementProgress() {
|
||||
return this.achievementProgress;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ItemsComponent {
|
||||
public static THashMap<Integer, HabboItem> loadItems(Habbo habbo) {
|
||||
THashMap<Integer, HabboItem> itemsList = new THashMap<>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ? AND user_id = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.* FROM items LEFT JOIN builders_club_items ON builders_club_items.item_id = items.id WHERE items.room_id = ? AND items.user_id = ? AND builders_club_items.item_id IS NULL")) {
|
||||
statement.setInt(1, 0);
|
||||
statement.setInt(2, habbo.getHabboInfo().getId());
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public class Subscription {
|
||||
public static final String HABBO_CLUB = "HABBO_CLUB";
|
||||
public static final String BUILDERS_CLUB = "BUILDERS_CLUB";
|
||||
|
||||
private final int id;
|
||||
private final int userId;
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.eu.habbo.habbohotel.users.subscriptions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
public class SubscriptionBuildersClub extends Subscription {
|
||||
public SubscriptionBuildersClub(Integer id, Integer userId, String subscriptionType, Integer timestampStart, Integer duration, Boolean active) {
|
||||
super(id, userId, subscriptionType, timestampStart, duration, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated() {
|
||||
super.onCreated();
|
||||
if (BuildersClubRoomSupport.syncOwnedRooms(this.getUserId()) > 0) {
|
||||
BuildersClubRoomSupport.sendRoomUnlockedBubble(this.getUserId());
|
||||
}
|
||||
BuildersClubRoomSupport.sendMembershipMadeBubble(this.getUserId());
|
||||
this.sendStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExtended(int duration) {
|
||||
super.onExtended(duration);
|
||||
if (BuildersClubRoomSupport.syncOwnedRooms(this.getUserId()) > 0) {
|
||||
BuildersClubRoomSupport.sendRoomUnlockedBubble(this.getUserId());
|
||||
}
|
||||
BuildersClubRoomSupport.sendMembershipExtendedBubble(this.getUserId());
|
||||
this.sendStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpired() {
|
||||
super.onExpired();
|
||||
BuildersClubRoomSupport.syncOwnedRooms(this.getUserId());
|
||||
BuildersClubRoomSupport.sendMembershipExpiredAlert(
|
||||
this.getUserId(),
|
||||
BuildersClubRoomSupport.hasTrackedItemsInOwnedRooms(this.getUserId())
|
||||
);
|
||||
this.sendStatus();
|
||||
}
|
||||
|
||||
private void sendStatus() {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId());
|
||||
|
||||
if (habbo != null && habbo.getClient() != null) {
|
||||
BuildersClubRoomSupport.sendPlacementStatus(habbo);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -28,6 +28,7 @@ public class SubscriptionManager {
|
||||
|
||||
public void init() {
|
||||
this.types.put(Subscription.HABBO_CLUB, SubscriptionHabboClub.class);
|
||||
this.types.put(Subscription.BUILDERS_CLUB, SubscriptionBuildersClub.class);
|
||||
}
|
||||
|
||||
public void addSubscriptionType(String type, Class<? extends Subscription> clazz) {
|
||||
|
||||
@@ -240,7 +240,9 @@ public class PacketManager {
|
||||
this.registerHandler(Incoming.RequestGiftConfigurationEvent, RequestGiftConfigurationEvent.class);
|
||||
this.registerHandler(Incoming.GetMarketplaceConfigEvent, RequestMarketplaceConfigEvent.class);
|
||||
this.registerHandler(Incoming.RequestCatalogModeEvent, RequestCatalogModeEvent.class);
|
||||
this.registerHandler(Incoming.RequestCatalogIndexEvent, RequestCatalogIndexEvent.class);
|
||||
this.registerHandler(Incoming.BuildersClubQueryFurniCountEvent, BuildersClubQueryFurniCountEvent.class);
|
||||
this.registerHandler(Incoming.BuildersClubPlaceRoomItemEvent, BuildersClubPlaceRoomItemEvent.class);
|
||||
this.registerHandler(Incoming.BuildersClubPlaceWallItemEvent, BuildersClubPlaceWallItemEvent.class);
|
||||
this.registerHandler(Incoming.RequestCatalogPageEvent, RequestCatalogPageEvent.class);
|
||||
this.registerHandler(Incoming.CatalogBuyItemAsGiftEvent, CatalogBuyItemAsGiftEvent.class);
|
||||
this.registerHandler(Incoming.CatalogBuyItemEvent, CatalogBuyItemEvent.class);
|
||||
|
||||
@@ -84,6 +84,9 @@ public class Incoming {
|
||||
public static final int RequestRecylerLogicEvent = 398;
|
||||
public static final int RequestGuildJoinEvent = 998;
|
||||
public static final int RequestCatalogIndexEvent = 2529;
|
||||
public static final int BuildersClubQueryFurniCountEvent = 2529;
|
||||
public static final int BuildersClubPlaceRoomItemEvent = 1051;
|
||||
public static final int BuildersClubPlaceWallItemEvent = 462;
|
||||
public static final int RequestInventoryPetsEvent = 3095;
|
||||
public static final int ModToolRequestRoomVisitsEvent = 3526;
|
||||
public static final int ModToolWarnEvent = -1;//3763
|
||||
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.eu.habbo.messages.incoming.catalog;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogItem;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class BuildersClubPlaceRoomItemEvent extends MessageHandler {
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
int pageId = this.packet.readInt();
|
||||
int offerId = this.packet.readInt();
|
||||
String extraData = this.packet.readString();
|
||||
short x = this.packet.readInt().shortValue();
|
||||
short y = this.packet.readInt().shortValue();
|
||||
int rotation = this.packet.readInt();
|
||||
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
int placementUserId = BuildersClubRoomSupport.getPlacementPoolUserId(this.client.getHabbo());
|
||||
|
||||
if (room == null || !this.client.getHabbo().getRoomUnit().isInRoom()) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BuildersClubRoomSupport.canPlaceInCurrentRoom(this.client.getHabbo())) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "builder.placement_widget.error.not_group_admin"));
|
||||
BuildersClubRoomSupport.sendPlacementStatus(this.client.getHabbo());
|
||||
return;
|
||||
}
|
||||
|
||||
if (placementUserId <= 0) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BuildersClubRoomSupport.hasActiveMembership(this.client.getHabbo().getHabboInfo().getId())) {
|
||||
int trackedFurniCount = BuildersClubRoomSupport.getTrackedFurniCount(placementUserId);
|
||||
|
||||
if (trackedFurniCount >= BuildersClubRoomSupport.getFurniLimit(placementUserId)) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "room.error.max_furniture"));
|
||||
BuildersClubRoomSupport.sendPlacementStatus(this.client.getHabbo());
|
||||
return;
|
||||
}
|
||||
|
||||
if (BuildersClubRoomSupport.hasPlacementVisitors(room, this.client.getHabbo())) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "builder.placement_widget.error.visitors"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CatalogItem catalogItem = resolveCatalogItem(pageId, offerId);
|
||||
Item baseItem = resolveBaseItem(catalogItem, FurnitureType.FLOOR);
|
||||
|
||||
if (catalogItem == null || baseItem == null) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
RoomTile tile = room.getLayout().getTile(x, y);
|
||||
|
||||
if (tile == null) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(BuildersClubRoomSupport.VIRTUAL_OWNER_ID, baseItem, 0, 0, (extraData != null && !extraData.isEmpty()) ? extraData : catalogItem.getExtradata());
|
||||
|
||||
if (item == null) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation);
|
||||
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo());
|
||||
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
BuildersClubRoomSupport.trackPlacedItem(item.getId(), placementUserId, room.getId());
|
||||
|
||||
if (BuildersClubRoomSupport.syncRoom(room) == BuildersClubRoomSupport.SyncResult.LOCKED) {
|
||||
BuildersClubRoomSupport.sendRoomLockedBubble(room.getOwnerId());
|
||||
}
|
||||
|
||||
BuildersClubRoomSupport.sendPlacementStatusForPool(room, placementUserId);
|
||||
}
|
||||
|
||||
private CatalogItem resolveCatalogItem(int pageId, int offerId) {
|
||||
CatalogItem buildersClubItem = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(offerId, CatalogPageType.BUILDER);
|
||||
|
||||
if (buildersClubItem != null) {
|
||||
return buildersClubItem;
|
||||
}
|
||||
|
||||
int catalogItemId = Emulator.getGameEnvironment().getCatalogManager().offerDefs.get(offerId);
|
||||
|
||||
if (catalogItemId > 0) {
|
||||
return Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(catalogItemId);
|
||||
}
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId, CatalogPageType.BUILDER);
|
||||
|
||||
if (page == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CatalogItem catalogItem : page.getCatalogItems().valueCollection()) {
|
||||
if (catalogItem.getOfferId() == offerId) {
|
||||
return catalogItem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Item resolveBaseItem(CatalogItem catalogItem, FurnitureType expectedType) {
|
||||
if (catalogItem == null || catalogItem.getAmount() != 1 || catalogItem.getBaseItems().size() != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator<Item> iterator = catalogItem.getBaseItems().iterator();
|
||||
|
||||
if (!iterator.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Item baseItem = iterator.next();
|
||||
|
||||
if (baseItem == null || baseItem.getType() != expectedType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return baseItem;
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package com.eu.habbo.messages.incoming.catalog;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogItem;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class BuildersClubPlaceWallItemEvent extends MessageHandler {
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
int pageId = this.packet.readInt();
|
||||
int offerId = this.packet.readInt();
|
||||
String extraData = this.packet.readString();
|
||||
String wallPosition = this.packet.readString();
|
||||
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
int placementUserId = BuildersClubRoomSupport.getPlacementPoolUserId(this.client.getHabbo());
|
||||
|
||||
if (room == null || !this.client.getHabbo().getRoomUnit().isInRoom()) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BuildersClubRoomSupport.canPlaceInCurrentRoom(this.client.getHabbo())) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "builder.placement_widget.error.not_group_admin"));
|
||||
BuildersClubRoomSupport.sendPlacementStatus(this.client.getHabbo());
|
||||
return;
|
||||
}
|
||||
|
||||
if (placementUserId <= 0) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BuildersClubRoomSupport.hasActiveMembership(this.client.getHabbo().getHabboInfo().getId())) {
|
||||
int trackedFurniCount = BuildersClubRoomSupport.getTrackedFurniCount(placementUserId);
|
||||
|
||||
if (trackedFurniCount >= BuildersClubRoomSupport.getFurniLimit(placementUserId)) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "room.error.max_furniture"));
|
||||
BuildersClubRoomSupport.sendPlacementStatus(this.client.getHabbo());
|
||||
return;
|
||||
}
|
||||
|
||||
if (BuildersClubRoomSupport.hasPlacementVisitors(room, this.client.getHabbo())) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "builder.placement_widget.error.visitors"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CatalogItem catalogItem = resolveCatalogItem(pageId, offerId);
|
||||
Item baseItem = resolveBaseItem(catalogItem, FurnitureType.WALL);
|
||||
|
||||
if (catalogItem == null || baseItem == null) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(BuildersClubRoomSupport.VIRTUAL_OWNER_ID, baseItem, 0, 0, (extraData != null && !extraData.isEmpty()) ? extraData : catalogItem.getExtradata());
|
||||
|
||||
if (item == null) {
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
FurnitureMovementError error = room.placeWallFurniAt(item, wallPosition, this.client.getHabbo());
|
||||
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
BuildersClubRoomSupport.trackPlacedItem(item.getId(), placementUserId, room.getId());
|
||||
|
||||
if (BuildersClubRoomSupport.syncRoom(room) == BuildersClubRoomSupport.SyncResult.LOCKED) {
|
||||
BuildersClubRoomSupport.sendRoomLockedBubble(room.getOwnerId());
|
||||
}
|
||||
|
||||
BuildersClubRoomSupport.sendPlacementStatusForPool(room, placementUserId);
|
||||
}
|
||||
|
||||
private CatalogItem resolveCatalogItem(int pageId, int offerId) {
|
||||
CatalogItem buildersClubItem = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(offerId, CatalogPageType.BUILDER);
|
||||
|
||||
if (buildersClubItem != null) {
|
||||
return buildersClubItem;
|
||||
}
|
||||
|
||||
int catalogItemId = Emulator.getGameEnvironment().getCatalogManager().offerDefs.get(offerId);
|
||||
|
||||
if (catalogItemId > 0) {
|
||||
return Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(catalogItemId);
|
||||
}
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId, CatalogPageType.BUILDER);
|
||||
|
||||
if (page == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CatalogItem catalogItem : page.getCatalogItems().valueCollection()) {
|
||||
if (catalogItem.getOfferId() == offerId) {
|
||||
return catalogItem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Item resolveBaseItem(CatalogItem catalogItem, FurnitureType expectedType) {
|
||||
if (catalogItem == null || catalogItem.getAmount() != 1 || catalogItem.getBaseItems().size() != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator<Item> iterator = catalogItem.getBaseItems().iterator();
|
||||
|
||||
if (!iterator.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Item baseItem = iterator.next();
|
||||
|
||||
if (baseItem == null || baseItem.getType() != expectedType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return baseItem;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.eu.habbo.messages.incoming.catalog;
|
||||
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
|
||||
public class BuildersClubQueryFurniCountEvent extends MessageHandler {
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
BuildersClubRoomSupport.sendPlacementStatus(this.client.getHabbo());
|
||||
}
|
||||
}
|
||||
+35
-13
@@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.catalog.layouts.*;
|
||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.pets.PetManager;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomManager;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.users.HabboInventory;
|
||||
@@ -14,6 +15,8 @@ import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer;
|
||||
import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseUnavailableComposer;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubFurniCountComposer;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubSubscriptionStatusComposer;
|
||||
import com.eu.habbo.messages.outgoing.catalog.PurchaseOKComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
@@ -139,10 +142,10 @@ public class CatalogBuyItemEvent extends MessageHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (page instanceof ClubBuyLayout || page instanceof VipBuyLayout) {
|
||||
if (this.isClubOfferPage(page)) {
|
||||
ClubOffer item = Emulator.getGameEnvironment().getCatalogManager().clubOffers.get(itemId);
|
||||
|
||||
if (item == null) {
|
||||
if (item == null || !item.belongsToWindow(this.getClubOfferWindowId(page))) {
|
||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||
return;
|
||||
}
|
||||
@@ -170,20 +173,19 @@ public class CatalogBuyItemEvent extends MessageHandler {
|
||||
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS))
|
||||
this.client.getHabbo().givePoints(item.getPointsType(), -totalDuckets);
|
||||
|
||||
if (item.isBuildersClubAddon()) {
|
||||
this.client.getHabbo().getHabboStats().addBuildersClubBonusFurni(totalDays);
|
||||
this.client.sendResponse(new BuildersClubFurniCountComposer(BuildersClubRoomSupport.getTrackedFurniCount(this.client.getHabbo().getHabboInfo().getId())));
|
||||
this.client.sendResponse(new BuildersClubSubscriptionStatusComposer(this.client.getHabbo()));
|
||||
} else {
|
||||
String subscriptionType = item.isBuildersClubSubscription() ? Subscription.BUILDERS_CLUB : Subscription.HABBO_CLUB;
|
||||
|
||||
if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) {
|
||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||
throw new Exception("Unable to create or extend subscription");
|
||||
if (this.client.getHabbo().getHabboStats().createSubscription(subscriptionType, (totalDays * 86400)) == null) {
|
||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||
throw new Exception("Unable to create or extend subscription");
|
||||
}
|
||||
}
|
||||
|
||||
/*if (this.client.getHabbo().getHabboStats().getClubExpireTimestamp() <= Emulator.getIntUnixTimestamp())
|
||||
this.client.getHabbo().getHabboStats().setClubExpireTimestamp(Emulator.getIntUnixTimestamp());
|
||||
|
||||
this.client.getHabbo().getHabboStats().setClubExpireTimestamp(this.client.getHabbo().getHabboStats().getClubExpireTimestamp() + (totalDays * 86400));
|
||||
|
||||
this.client.sendResponse(new UserPermissionsComposer(this.client.getHabbo()));
|
||||
this.client.sendResponse(new UserClubComposer(this.client.getHabbo()));*/
|
||||
|
||||
this.client.sendResponse(new PurchaseOKComposer(null));
|
||||
this.client.sendResponse(new InventoryRefreshComposer());
|
||||
|
||||
@@ -223,4 +225,24 @@ public class CatalogBuyItemEvent extends MessageHandler {
|
||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isClubOfferPage(CatalogPage page) {
|
||||
return page instanceof ClubBuyLayout
|
||||
|| page instanceof VipBuyLayout
|
||||
|| page instanceof BuildersClubFrontPageLayout
|
||||
|| page instanceof BuildersClubAddonsLayout
|
||||
|| page instanceof BuildersClubLoyaltyLayout;
|
||||
}
|
||||
|
||||
private int getClubOfferWindowId(CatalogPage page) {
|
||||
if (page instanceof BuildersClubAddonsLayout) {
|
||||
return ClubOffer.WINDOW_BUILDERS_CLUB_ADDONS;
|
||||
}
|
||||
|
||||
if (page instanceof BuildersClubFrontPageLayout || page instanceof BuildersClubLoyaltyLayout) {
|
||||
return ClubOffer.WINDOW_BUILDERS_CLUB;
|
||||
}
|
||||
|
||||
return ClubOffer.WINDOW_HABBO_CLUB;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-8
@@ -1,20 +1,17 @@
|
||||
package com.eu.habbo.messages.incoming.catalog;
|
||||
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.CatalogModeComposer;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.messages.outgoing.catalog.CatalogPagesListComposer;
|
||||
|
||||
public class RequestCatalogModeEvent extends MessageHandler {
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
|
||||
String MODE = this.packet.readString();
|
||||
if (MODE.equalsIgnoreCase("normal")) {
|
||||
this.client.sendResponse(new CatalogModeComposer(0));
|
||||
this.client.sendResponse(new CatalogPagesListComposer(this.client.getHabbo(), MODE));
|
||||
} else {
|
||||
this.client.sendResponse(new CatalogModeComposer(1));
|
||||
this.client.sendResponse(new CatalogPagesListComposer(this.client.getHabbo(), MODE));
|
||||
this.client.sendResponse(new CatalogPagesListComposer(this.client.getHabbo(), MODE));
|
||||
|
||||
if (!MODE.equalsIgnoreCase("normal")) {
|
||||
BuildersClubRoomSupport.sendPlacementStatus(this.client.getHabbo());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.catalog;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.CatalogPageComposer;
|
||||
@@ -13,8 +14,9 @@ public class RequestCatalogPageEvent extends MessageHandler {
|
||||
int catalogPageId = this.packet.readInt();
|
||||
int offerId = this.packet.readInt();
|
||||
String mode = this.packet.readString();
|
||||
CatalogPageType requestedType = CatalogPageType.fromString(mode);
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(catalogPageId);
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(catalogPageId, requestedType);
|
||||
|
||||
if (catalogPageId > 0 && page != null) {
|
||||
if (page.getRank() <= this.client.getHabbo().getHabboInfo().getRank().getId() && page.isEnabled()) {
|
||||
|
||||
+21
-11
@@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -32,26 +33,35 @@ public class CatalogAdminCreateOfferEvent extends MessageHandler {
|
||||
int offerIdGroup = this.packet.readInt();
|
||||
int limitedStack = this.packet.readInt();
|
||||
int orderNumber = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
int newId = -1;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type, amount, club_only, extradata, have_offer, offer_id, limited_stack, order_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(pageType == CatalogPageType.BUILDER)
|
||||
? "INSERT INTO catalog_items_bc (page_id, item_ids, catalog_name, order_number, extradata) VALUES (?, ?, ?, ?, ?)"
|
||||
: "INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type, amount, club_only, extradata, have_offer, offer_id, limited_stack, order_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
Statement.RETURN_GENERATED_KEYS)) {
|
||||
statement.setInt(1, pageId);
|
||||
statement.setString(2, String.valueOf(itemId));
|
||||
statement.setString(3, catalogName);
|
||||
statement.setInt(4, costCredits);
|
||||
statement.setInt(5, costPoints);
|
||||
statement.setInt(6, pointsType);
|
||||
statement.setInt(7, amount);
|
||||
statement.setString(8, clubOnly == 1 ? "1" : "0");
|
||||
statement.setString(9, extradata);
|
||||
statement.setString(10, haveOffer ? "1" : "0");
|
||||
statement.setInt(11, offerIdGroup);
|
||||
statement.setInt(12, limitedStack);
|
||||
statement.setInt(13, orderNumber);
|
||||
|
||||
if (pageType == CatalogPageType.BUILDER) {
|
||||
statement.setInt(4, orderNumber);
|
||||
statement.setString(5, extradata);
|
||||
} else {
|
||||
statement.setInt(4, costCredits);
|
||||
statement.setInt(5, costPoints);
|
||||
statement.setInt(6, pointsType);
|
||||
statement.setInt(7, amount);
|
||||
statement.setString(8, clubOnly == 1 ? "1" : "0");
|
||||
statement.setString(9, extradata);
|
||||
statement.setString(10, haveOffer ? "1" : "0");
|
||||
statement.setInt(11, offerIdGroup);
|
||||
statement.setInt(12, limitedStack);
|
||||
statement.setInt(13, orderNumber);
|
||||
}
|
||||
statement.execute();
|
||||
|
||||
try (ResultSet keys = statement.getGeneratedKeys()) {
|
||||
|
||||
+4
-1
@@ -3,6 +3,7 @@ package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageLayouts;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -25,6 +26,8 @@ public class CatalogAdminCreatePageEvent extends MessageHandler {
|
||||
boolean enabled = this.packet.readBoolean();
|
||||
int orderNum = this.packet.readInt();
|
||||
int parentId = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
CatalogPageType catalogMode = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
CatalogPageLayouts pageLayout;
|
||||
try {
|
||||
@@ -34,7 +37,7 @@ public class CatalogAdminCreatePageEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage(
|
||||
caption, caption2, 0, iconType, pageLayout, minRank, parentId
|
||||
caption, caption2, 0, iconType, pageLayout, minRank, parentId, pageType, catalogMode
|
||||
);
|
||||
|
||||
if (page == null) {
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -18,9 +19,10 @@ public class CatalogAdminDeleteOfferEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
int offerId = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM catalog_items WHERE id = ?")) {
|
||||
PreparedStatement statement = connection.prepareStatement((pageType == CatalogPageType.BUILDER) ? "DELETE FROM catalog_items_bc WHERE id = ?" : "DELETE FROM catalog_items WHERE id = ?")) {
|
||||
statement.setInt(1, offerId);
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
+9
-3
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -19,21 +20,26 @@ public class CatalogAdminDeletePageEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
int pageId = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(pageId);
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId, pageType);
|
||||
|
||||
if (page == null) {
|
||||
this.client.sendResponse(new CatalogAdminResultComposer(false, "Page not found: " + pageId));
|
||||
return;
|
||||
}
|
||||
|
||||
String query = (pageType == CatalogPageType.BUILDER)
|
||||
? "DELETE FROM catalog_pages_bc WHERE id = ?"
|
||||
: "DELETE FROM catalog_pages WHERE id = ?";
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM catalog_pages WHERE id = ?")) {
|
||||
PreparedStatement statement = connection.prepareStatement(query)) {
|
||||
statement.setInt(1, pageId);
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
Emulator.getGameEnvironment().getCatalogManager().catalogPages.remove(pageId);
|
||||
Emulator.getGameEnvironment().getCatalogManager().getCatalogPagesMap(pageType).remove(pageId);
|
||||
|
||||
this.client.sendResponse(new CatalogAdminResultComposer(true, "Page deleted"));
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -19,9 +20,10 @@ public class CatalogAdminMoveOfferEvent extends MessageHandler {
|
||||
|
||||
int offerId = this.packet.readInt();
|
||||
int orderNumber = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items SET order_number = ? WHERE id = ?")) {
|
||||
PreparedStatement statement = connection.prepareStatement((pageType == CatalogPageType.BUILDER) ? "UPDATE catalog_items_bc SET order_number = ? WHERE id = ?" : "UPDATE catalog_items SET order_number = ? WHERE id = ?")) {
|
||||
statement.setInt(1, orderNumber);
|
||||
statement.setInt(2, offerId);
|
||||
statement.execute();
|
||||
|
||||
+6
-3
@@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -20,13 +21,15 @@ public class CatalogAdminMovePageEvent extends MessageHandler {
|
||||
int pageId = this.packet.readInt();
|
||||
int newParentId = this.packet.readInt();
|
||||
int newIndex = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
String tableName = (pageType == CatalogPageType.BUILDER) ? "catalog_pages_bc" : "catalog_pages";
|
||||
|
||||
// Special values: -1 = toggle enabled, -2 = toggle visible
|
||||
if (newParentId == -1) {
|
||||
// Toggle enabled
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"UPDATE catalog_pages SET enabled = IF(enabled = '1', '0', '1') WHERE id = ?")) {
|
||||
"UPDATE " + tableName + " SET enabled = IF(enabled = '1', '0', '1') WHERE id = ?")) {
|
||||
statement.setInt(1, pageId);
|
||||
statement.execute();
|
||||
}
|
||||
@@ -38,7 +41,7 @@ public class CatalogAdminMovePageEvent extends MessageHandler {
|
||||
// Toggle visible
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"UPDATE catalog_pages SET visible = IF(visible = '1', '0', '1') WHERE id = ?")) {
|
||||
"UPDATE " + tableName + " SET visible = IF(visible = '1', '0', '1') WHERE id = ?")) {
|
||||
statement.setInt(1, pageId);
|
||||
statement.execute();
|
||||
}
|
||||
@@ -49,7 +52,7 @@ public class CatalogAdminMovePageEvent extends MessageHandler {
|
||||
// Normal move: update parent and order
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"UPDATE catalog_pages SET parent_id = ?, order_num = ? WHERE id = ?")) {
|
||||
"UPDATE " + tableName + " SET parent_id = ?, order_num = ? WHERE id = ?")) {
|
||||
statement.setInt(1, newParentId);
|
||||
statement.setInt(2, newIndex);
|
||||
statement.setInt(3, pageId);
|
||||
|
||||
+23
-12
@@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -31,24 +32,34 @@ public class CatalogAdminSaveOfferEvent extends MessageHandler {
|
||||
int offerIdGroup = this.packet.readInt();
|
||||
int limitedStack = this.packet.readInt();
|
||||
int orderNumber = this.packet.readInt();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"UPDATE catalog_items SET page_id = ?, item_ids = ?, catalog_name = ?, cost_credits = ?, cost_points = ?, points_type = ?, amount = ?, club_only = ?, extradata = ?, have_offer = ?, offer_id = ?, limited_stack = ?, order_number = ? WHERE id = ?")) {
|
||||
(pageType == CatalogPageType.BUILDER)
|
||||
? "UPDATE catalog_items_bc SET page_id = ?, item_ids = ?, catalog_name = ?, order_number = ?, extradata = ? WHERE id = ?"
|
||||
: "UPDATE catalog_items SET page_id = ?, item_ids = ?, catalog_name = ?, cost_credits = ?, cost_points = ?, points_type = ?, amount = ?, club_only = ?, extradata = ?, have_offer = ?, offer_id = ?, limited_stack = ?, order_number = ? WHERE id = ?")) {
|
||||
statement.setInt(1, pageId);
|
||||
statement.setString(2, String.valueOf(itemId));
|
||||
statement.setString(3, catalogName);
|
||||
statement.setInt(4, costCredits);
|
||||
statement.setInt(5, costPoints);
|
||||
statement.setInt(6, pointsType);
|
||||
statement.setInt(7, amount);
|
||||
statement.setString(8, clubOnly == 1 ? "1" : "0");
|
||||
statement.setString(9, extradata);
|
||||
statement.setString(10, haveOffer ? "1" : "0");
|
||||
statement.setInt(11, offerIdGroup);
|
||||
statement.setInt(12, limitedStack);
|
||||
statement.setInt(13, orderNumber);
|
||||
statement.setInt(14, offerId);
|
||||
|
||||
if (pageType == CatalogPageType.BUILDER) {
|
||||
statement.setInt(4, orderNumber);
|
||||
statement.setString(5, extradata);
|
||||
statement.setInt(6, offerId);
|
||||
} else {
|
||||
statement.setInt(4, costCredits);
|
||||
statement.setInt(5, costPoints);
|
||||
statement.setInt(6, pointsType);
|
||||
statement.setInt(7, amount);
|
||||
statement.setString(8, clubOnly == 1 ? "1" : "0");
|
||||
statement.setString(9, extradata);
|
||||
statement.setString(10, haveOffer ? "1" : "0");
|
||||
statement.setInt(11, offerIdGroup);
|
||||
statement.setInt(12, limitedStack);
|
||||
statement.setInt(13, orderNumber);
|
||||
statement.setInt(14, offerId);
|
||||
}
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
|
||||
+37
-15
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.catalog.catalogadmin;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.catalogadmin.CatalogAdminResultComposer;
|
||||
@@ -31,30 +32,51 @@ public class CatalogAdminSavePageEvent extends MessageHandler {
|
||||
String headline = this.packet.readString();
|
||||
String teaser = this.packet.readString();
|
||||
String textDetails = this.packet.readString();
|
||||
CatalogPageType pageType = CatalogPageType.fromString(this.packet.readString());
|
||||
CatalogPageType catalogMode = CatalogPageType.fromString(this.packet.readString());
|
||||
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(pageId);
|
||||
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId, pageType);
|
||||
|
||||
if (page == null) {
|
||||
this.client.sendResponse(new CatalogAdminResultComposer(false, "Page not found: " + pageId));
|
||||
return;
|
||||
}
|
||||
|
||||
String query = (pageType == CatalogPageType.BUILDER)
|
||||
? "UPDATE catalog_pages_bc SET caption = ?, page_layout = ?, icon_image = ?, visible = ?, enabled = ?, order_num = ?, parent_id = ?, page_headline = ?, page_teaser = ?, page_text_details = ? WHERE id = ?"
|
||||
: "UPDATE catalog_pages SET caption = ?, caption_save = ?, page_layout = ?, icon_image = ?, min_rank = ?, visible = ?, enabled = ?, order_num = ?, parent_id = ?, page_headline = ?, page_teaser = ?, page_text_details = ?, catalog_mode = ? WHERE id = ?";
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(
|
||||
"UPDATE catalog_pages SET caption = ?, caption_save = ?, page_layout = ?, icon_image = ?, min_rank = ?, visible = ?, enabled = ?, order_num = ?, parent_id = ?, page_headline = ?, page_teaser = ?, page_text_details = ? WHERE id = ?")) {
|
||||
PreparedStatement statement = connection.prepareStatement(query)) {
|
||||
statement.setString(1, caption);
|
||||
statement.setString(2, caption2);
|
||||
statement.setString(3, layout);
|
||||
statement.setInt(4, iconType);
|
||||
statement.setInt(5, minRank);
|
||||
statement.setString(6, visible ? "1" : "0");
|
||||
statement.setString(7, enabled ? "1" : "0");
|
||||
statement.setInt(8, orderNum);
|
||||
statement.setInt(9, parentId);
|
||||
statement.setString(10, headline);
|
||||
statement.setString(11, teaser);
|
||||
statement.setString(12, textDetails);
|
||||
statement.setInt(13, pageId);
|
||||
|
||||
if (pageType == CatalogPageType.BUILDER) {
|
||||
statement.setString(2, layout);
|
||||
statement.setInt(3, iconType);
|
||||
statement.setString(4, visible ? "1" : "0");
|
||||
statement.setString(5, enabled ? "1" : "0");
|
||||
statement.setInt(6, orderNum);
|
||||
statement.setInt(7, parentId);
|
||||
statement.setString(8, headline);
|
||||
statement.setString(9, teaser);
|
||||
statement.setString(10, textDetails);
|
||||
statement.setInt(11, pageId);
|
||||
} else {
|
||||
statement.setString(2, caption2);
|
||||
statement.setString(3, layout);
|
||||
statement.setInt(4, iconType);
|
||||
statement.setInt(5, minRank);
|
||||
statement.setString(6, visible ? "1" : "0");
|
||||
statement.setString(7, enabled ? "1" : "0");
|
||||
statement.setInt(8, orderNum);
|
||||
statement.setInt(9, parentId);
|
||||
statement.setString(10, headline);
|
||||
statement.setString(11, teaser);
|
||||
statement.setString(12, textDetails);
|
||||
statement.setString(13, catalogMode.name());
|
||||
statement.setInt(14, pageId);
|
||||
}
|
||||
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer;
|
||||
import com.eu.habbo.messages.outgoing.guilds.RemoveGuildFromRoomComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer;
|
||||
import com.eu.habbo.plugin.events.guilds.GuildDeletedEvent;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
@@ -38,11 +37,15 @@ public class GuildDeleteEvent extends MessageHandler {
|
||||
|
||||
Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild);
|
||||
Emulator.getPluginManager().fireEvent(new GuildDeletedEvent(guild, this.client.getHabbo()));
|
||||
Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()).sendComposer(new RemoveGuildFromRoomComposer(guildId).compose());
|
||||
com.eu.habbo.habbohotel.rooms.Room guildRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId());
|
||||
|
||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
|
||||
if (guild.getRoomId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) {
|
||||
this.client.sendResponse(new RoomDataComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom(), this.client.getHabbo(), false, false));
|
||||
if (guildRoom != null) {
|
||||
for (Habbo habbo : guildRoom.getHabbos()) {
|
||||
if (habbo.getClient() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new RoomDataComposer(guildRoom, habbo, true, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -12,6 +12,7 @@ import com.eu.habbo.messages.outgoing.catalog.PurchaseOKComposer;
|
||||
import com.eu.habbo.messages.outgoing.guilds.GuildBoughtComposer;
|
||||
import com.eu.habbo.messages.outgoing.guilds.GuildEditFailComposer;
|
||||
import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer;
|
||||
import com.eu.habbo.plugin.events.guilds.GuildPurchasedEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -96,20 +97,29 @@ public class RequestGuildBuyEvent extends MessageHandler {
|
||||
r.removeAllRights();
|
||||
r.setNeedsUpdate(true);
|
||||
|
||||
Emulator.getGameEnvironment().getGuildManager().addGuild(guild);
|
||||
|
||||
if (Emulator.getConfig().getBoolean("imager.internal.enabled")) {
|
||||
Emulator.getBadgeImager().generate(guild);
|
||||
}
|
||||
|
||||
this.client.sendResponse(new PurchaseOKComposer());
|
||||
this.client.sendResponse(new GuildBoughtComposer(guild));
|
||||
for (Habbo habbo : r.getHabbos()) {
|
||||
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null));
|
||||
}
|
||||
r.refreshGuild(guild);
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new GuildPurchasedEvent(guild, this.client.getHabbo()));
|
||||
for (Habbo habbo : r.getHabbos()) {
|
||||
if (habbo.getClient() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Emulator.getGameEnvironment().getGuildManager().addGuild(guild);
|
||||
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null));
|
||||
|
||||
if (habbo.getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) {
|
||||
habbo.getClient().sendResponse(new RoomDataComposer(r, habbo, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new GuildPurchasedEvent(guild, this.client.getHabbo()));
|
||||
}
|
||||
} else {
|
||||
String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName()));
|
||||
|
||||
+31
-2
@@ -10,13 +10,16 @@ import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomManager;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||
import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub;
|
||||
import com.eu.habbo.messages.NoAuthMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubSubscriptionStatusComposer;
|
||||
import com.eu.habbo.messages.outgoing.commands.AvailableCommandsComposer;
|
||||
import com.eu.habbo.messages.outgoing.gamecenter.GameCenterAccountInfoComposer;
|
||||
import com.eu.habbo.messages.outgoing.gamecenter.GameCenterGameListComposer;
|
||||
@@ -34,7 +37,6 @@ import com.eu.habbo.messages.outgoing.modtool.ModToolComposer;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer;
|
||||
import com.eu.habbo.messages.outgoing.mysterybox.MysteryBoxKeysComposer;
|
||||
import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer;
|
||||
import com.eu.habbo.messages.outgoing.unknown.BuildersClubExpiredComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.*;
|
||||
import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent;
|
||||
import com.eu.habbo.plugin.events.users.UserLoginEvent;
|
||||
@@ -220,7 +222,7 @@ public class SecureLoginEvent extends MessageHandler {
|
||||
messages.add(new UserAchievementScoreComposer(this.client.getHabbo()).compose());
|
||||
messages.add(new IsFirstLoginOfDayComposer(true).compose());
|
||||
messages.add(new MysteryBoxKeysComposer().compose());
|
||||
messages.add(new BuildersClubExpiredComposer().compose());
|
||||
messages.add(new BuildersClubSubscriptionStatusComposer(this.client.getHabbo()).compose());
|
||||
messages.add(new CfhTopicsMessageComposer().compose());
|
||||
messages.add(new FavoriteRoomsCountComposer(this.client.getHabbo()).compose());
|
||||
messages.add(new GameCenterGameListComposer().compose());
|
||||
@@ -235,6 +237,33 @@ public class SecureLoginEvent extends MessageHandler {
|
||||
|
||||
this.client.sendResponses(messages);
|
||||
|
||||
if (!isSessionResume) {
|
||||
BuildersClubRoomSupport.syncOwnedRooms(this.client.getHabbo().getHabboInfo().getId());
|
||||
|
||||
boolean hasActiveBuildersClub = this.client.getHabbo().getHabboStats().hasSubscription(Subscription.BUILDERS_CLUB);
|
||||
boolean hadBuildersClubBefore = false;
|
||||
|
||||
for (com.eu.habbo.habbohotel.users.subscriptions.Subscription subscription : this.client.getHabbo().getHabboStats().subscriptions) {
|
||||
if (subscription.getSubscriptionType().equalsIgnoreCase(Subscription.BUILDERS_CLUB)) {
|
||||
hadBuildersClubBefore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasActiveBuildersClub) {
|
||||
int remaining = BuildersClubRoomSupport.getMembershipSecondsLeft(this.client.getHabbo().getHabboInfo().getId());
|
||||
|
||||
if (remaining > 0 && remaining <= (72 * 3600)) {
|
||||
BuildersClubRoomSupport.sendMembershipExpiringAlert(this.client.getHabbo().getHabboInfo().getId());
|
||||
}
|
||||
} else if (hadBuildersClubBefore) {
|
||||
BuildersClubRoomSupport.sendMembershipExpiredAlert(
|
||||
this.client.getHabbo().getHabboInfo().getId(),
|
||||
BuildersClubRoomSupport.hasTrackedItemsInOwnedRooms(this.client.getHabbo().getHabboInfo().getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Hardcoded
|
||||
//this.client.sendResponse(new ForumsTestComposer());
|
||||
this.client.sendResponse(new InventoryAchievementsComposer());
|
||||
|
||||
+27
@@ -3,9 +3,12 @@ package com.eu.habbo.messages.incoming.rooms.items;
|
||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubFurniCountComposer;
|
||||
import com.eu.habbo.messages.outgoing.catalog.BuildersClubSubscriptionStatusComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer;
|
||||
@@ -115,5 +118,29 @@ public class RoomPlaceItemEvent extends MessageHandler {
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId()));
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item.getId());
|
||||
item.setFromGift(false);
|
||||
|
||||
if (BuildersClubRoomSupport.isTrackedItem(item.getId())) {
|
||||
int trackedUserId = BuildersClubRoomSupport.getTrackedUserId(item.getId());
|
||||
|
||||
if (trackedUserId <= 0) {
|
||||
trackedUserId = this.client.getHabbo().getHabboInfo().getId();
|
||||
}
|
||||
|
||||
item.setUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
||||
BuildersClubRoomSupport.trackPlacedItem(item.getId(), trackedUserId, room.getId());
|
||||
|
||||
BuildersClubRoomSupport.SyncResult syncResult = BuildersClubRoomSupport.syncRoom(room);
|
||||
|
||||
if (syncResult == BuildersClubRoomSupport.SyncResult.LOCKED) {
|
||||
BuildersClubRoomSupport.sendRoomLockedBubble(room.getOwnerId());
|
||||
} else if (syncResult == BuildersClubRoomSupport.SyncResult.UNLOCKED) {
|
||||
BuildersClubRoomSupport.sendRoomUnlockedBubble(room.getOwnerId());
|
||||
}
|
||||
|
||||
if (trackedUserId == this.client.getHabbo().getHabboInfo().getId()) {
|
||||
this.client.sendResponse(new BuildersClubFurniCountComposer(BuildersClubRoomSupport.getTrackedFurniCount(trackedUserId)));
|
||||
this.client.sendResponse(new BuildersClubSubscriptionStatusComposer(this.client.getHabbo()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ public class UserSaveLookEvent extends MessageHandler {
|
||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(this.client.getHabbo()).compose());
|
||||
}
|
||||
this.client.getHabbo().getMessenger().connectionChanged(
|
||||
this.client.getHabbo(),
|
||||
this.client.getHabbo().isOnline(),
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom() != null
|
||||
);
|
||||
|
||||
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("AvatarLooks"));
|
||||
}
|
||||
|
||||
@@ -376,6 +376,7 @@ public class Outgoing {
|
||||
public final static int BullyReportedMessageComposer = 3285; // PRODUCTION-201611291003-338511768
|
||||
public final static int UnknownQuestComposer3 = 1122; // PRODUCTION-201611291003-338511768
|
||||
public final static int FriendToolbarNotificationComposer = 3082; // PRODUCTION-201611291003-338511768
|
||||
public final static int SimpleAlertComposer = 5100; // PRODUCTION-201611291003-338511768
|
||||
public final static int MessengerErrorComposer = 896; // PRODUCTION-201611291003-338511768
|
||||
public final static int CameraPriceComposer = 3878; // PRODUCTION-201611291003-338511768
|
||||
public final static int PetBreedingCompleted = 2527; // PRODUCTION-201611291003-338511768
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.eu.habbo.messages.outgoing.catalog;
|
||||
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
|
||||
public class BuildersClubFurniCountComposer extends MessageComposer {
|
||||
private final int furniCount;
|
||||
|
||||
public BuildersClubFurniCountComposer(int furniCount) {
|
||||
this.furniCount = furniCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.CatalogModeComposer);
|
||||
this.response.appendInt(this.furniCount);
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.eu.habbo.messages.outgoing.catalog;
|
||||
|
||||
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
|
||||
public class BuildersClubSubscriptionStatusComposer extends MessageComposer {
|
||||
private final int secondsLeft;
|
||||
private final int furniLimit;
|
||||
private final int maxFurniLimit;
|
||||
private final int secondsLeftWithGrace;
|
||||
private final boolean placementBlockedByVisitors;
|
||||
private final boolean placementAllowedInCurrentRoom;
|
||||
|
||||
public BuildersClubSubscriptionStatusComposer(Habbo habbo) {
|
||||
this(
|
||||
BuildersClubRoomSupport.getMembershipSecondsLeft(habbo.getHabboInfo().getId()),
|
||||
BuildersClubRoomSupport.getFurniLimit(habbo.getHabboInfo().getId()),
|
||||
BuildersClubRoomSupport.getFurniLimit(habbo.getHabboInfo().getId()),
|
||||
BuildersClubRoomSupport.getMembershipSecondsLeft(habbo.getHabboInfo().getId()),
|
||||
BuildersClubRoomSupport.isPlacementBlockedByVisitors(habbo),
|
||||
BuildersClubRoomSupport.canPlaceInCurrentRoom(habbo)
|
||||
);
|
||||
}
|
||||
|
||||
public BuildersClubSubscriptionStatusComposer(int secondsLeft, int furniLimit, int maxFurniLimit, int secondsLeftWithGrace, boolean placementBlockedByVisitors, boolean placementAllowedInCurrentRoom) {
|
||||
this.secondsLeft = Math.max(0, secondsLeft);
|
||||
this.furniLimit = Math.max(0, furniLimit);
|
||||
this.maxFurniLimit = Math.max(0, maxFurniLimit);
|
||||
this.secondsLeftWithGrace = Math.max(0, secondsLeftWithGrace);
|
||||
this.placementBlockedByVisitors = placementBlockedByVisitors;
|
||||
this.placementAllowedInCurrentRoom = placementAllowedInCurrentRoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.BuildersClubExpiredComposer);
|
||||
this.response.appendInt(this.secondsLeft);
|
||||
this.response.appendInt(this.furniLimit);
|
||||
this.response.appendInt(this.maxFurniLimit);
|
||||
this.response.appendInt(this.secondsLeftWithGrace);
|
||||
this.response.appendBoolean(this.placementBlockedByVisitors);
|
||||
this.response.appendBoolean(this.placementAllowedInCurrentRoom);
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.outgoing.catalog;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogPageType;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@@ -32,7 +33,8 @@ public class CatalogPagesListComposer extends MessageComposer {
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
try {
|
||||
List<CatalogPage> pages = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(-1, this.habbo);
|
||||
CatalogPageType requestedType = CatalogPageType.fromString(this.mode);
|
||||
List<CatalogPage> pages = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(-1, this.habbo, requestedType);
|
||||
|
||||
this.response.init(Outgoing.CatalogPagesListComposer);
|
||||
|
||||
@@ -47,7 +49,7 @@ public class CatalogPagesListComposer extends MessageComposer {
|
||||
this.response.appendInt(childCount);
|
||||
|
||||
for (int idx = 0; idx < childCount; idx++) {
|
||||
this.append(pages.get(idx), 1);
|
||||
this.append(pages.get(idx), 1, requestedType);
|
||||
}
|
||||
|
||||
this.response.appendBoolean(false);
|
||||
@@ -61,8 +63,8 @@ public class CatalogPagesListComposer extends MessageComposer {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void append(CatalogPage category, int depth) {
|
||||
List<CatalogPage> pagesList = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(category.getId(), this.habbo);
|
||||
private void append(CatalogPage category, int depth, CatalogPageType requestedType) {
|
||||
List<CatalogPage> pagesList = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(category.getId(), this.habbo, requestedType);
|
||||
|
||||
this.response.appendBoolean(category.isVisible());
|
||||
this.response.appendInt(category.getIconImage());
|
||||
@@ -87,7 +89,7 @@ public class CatalogPagesListComposer extends MessageComposer {
|
||||
this.response.appendInt(childCount);
|
||||
|
||||
for (int idx = 0; idx < childCount; idx++) {
|
||||
this.append(pagesList.get(idx), depth + 1);
|
||||
this.append(pagesList.get(idx), depth + 1, requestedType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.eu.habbo.messages.outgoing.catalog;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.ClubOffer;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
@@ -22,12 +23,15 @@ public class ClubDataComposer extends MessageComposer {
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.ClubDataComposer);
|
||||
|
||||
List<ClubOffer> offers = Emulator.getGameEnvironment().getCatalogManager().getClubOffers();
|
||||
List<ClubOffer> offers = Emulator.getGameEnvironment().getCatalogManager().getClubOffers(this.windowId);
|
||||
this.response.appendInt(offers.size());
|
||||
|
||||
//TODO Change this to a seperate table.
|
||||
for (ClubOffer offer : offers) {
|
||||
offer.serialize(this.response, this.habbo.getHabboStats().getClubExpireTimestamp());
|
||||
int expireTimestamp = offer.isBuildersClubSubscription()
|
||||
? this.habbo.getHabboStats().getSubscriptionExpireTimestamp(Subscription.BUILDERS_CLUB)
|
||||
: (offer.isBuildersClubAddon() ? Emulator.getIntUnixTimestamp() : this.habbo.getHabboStats().getClubExpireTimestamp());
|
||||
|
||||
offer.serialize(this.response, expireTimestamp);
|
||||
}
|
||||
|
||||
this.response.appendInt(this.windowId);
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.eu.habbo.messages.outgoing.generic.alerts;
|
||||
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
|
||||
public class SimpleAlertComposer extends MessageComposer {
|
||||
private final String alertMessage;
|
||||
private final String titleMessage;
|
||||
|
||||
public SimpleAlertComposer(String alertMessage) {
|
||||
this(alertMessage, null);
|
||||
}
|
||||
|
||||
public SimpleAlertComposer(String alertMessage, String titleMessage) {
|
||||
this.alertMessage = alertMessage;
|
||||
this.titleMessage = titleMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.SimpleAlertComposer);
|
||||
this.response.appendString(this.alertMessage);
|
||||
|
||||
if (this.titleMessage != null && !this.titleMessage.isEmpty()) {
|
||||
this.response.appendString(this.titleMessage);
|
||||
}
|
||||
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user