You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 15:36:17 +00:00
Fix builders club virtual owner persistence
This commit is contained in:
@@ -27,8 +27,8 @@ public class BuildersClubRoomSupport {
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(BuildersClubRoomSupport.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(BuildersClubRoomSupport.class);
|
||||||
|
|
||||||
public static final int DEFAULT_TRIAL_FURNI_LIMIT = 50;
|
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`,
|
// Runtime-only owner marker used to display Builders Club furni as virtual/non-user-owned in-room.
|
||||||
// while still being treated as virtual / non-user-owned everywhere else in the BC flow.
|
// The actual DB owner for persistence/FK purposes is tracked separately on the item instance.
|
||||||
public static final int VIRTUAL_OWNER_ID = 1;
|
public static final int VIRTUAL_OWNER_ID = 1;
|
||||||
public static final String DISPLAY_OWNER_NAME = "Builders Club";
|
public static final String DISPLAY_OWNER_NAME = "Builders Club";
|
||||||
|
|
||||||
|
|||||||
@@ -628,7 +628,7 @@ public class RoomItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BuildersClubRoomSupport.isTrackedItem(item.getId()) && item.getUserId() != BuildersClubRoomSupport.VIRTUAL_OWNER_ID) {
|
if (BuildersClubRoomSupport.isTrackedItem(item.getId()) && item.getUserId() != BuildersClubRoomSupport.VIRTUAL_OWNER_ID) {
|
||||||
item.setUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
item.setVirtualUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
||||||
item.needsUpdate(true);
|
item.needsUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
|||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private int userId;
|
private int userId;
|
||||||
|
private int databaseUserId;
|
||||||
private int roomId;
|
private int roomId;
|
||||||
private Item baseItem;
|
private Item baseItem;
|
||||||
private String wallPosition;
|
private String wallPosition;
|
||||||
@@ -62,6 +63,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
|||||||
public HabboItem(ResultSet set, Item baseItem) throws SQLException {
|
public HabboItem(ResultSet set, Item baseItem) throws SQLException {
|
||||||
this.id = set.getInt("id");
|
this.id = set.getInt("id");
|
||||||
this.userId = set.getInt("user_id");
|
this.userId = set.getInt("user_id");
|
||||||
|
this.databaseUserId = this.userId;
|
||||||
this.roomId = set.getInt("room_id");
|
this.roomId = set.getInt("room_id");
|
||||||
this.baseItem = baseItem;
|
this.baseItem = baseItem;
|
||||||
this.wallPosition = set.getString("wall_pos");
|
this.wallPosition = set.getString("wall_pos");
|
||||||
@@ -81,6 +83,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
|||||||
public HabboItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
public HabboItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
this.databaseUserId = userId;
|
||||||
this.roomId = 0;
|
this.roomId = 0;
|
||||||
this.baseItem = item;
|
this.baseItem = item;
|
||||||
this.wallPosition = "";
|
this.wallPosition = "";
|
||||||
@@ -169,6 +172,11 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
|||||||
|
|
||||||
public void setUserId(int userId) {
|
public void setUserId(int userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
this.databaseUserId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVirtualUserId(int userId) {
|
||||||
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRoomId() {
|
public int getRoomId() {
|
||||||
@@ -275,7 +283,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
|||||||
}
|
}
|
||||||
} else if (this.needsUpdate) {
|
} else if (this.needsUpdate) {
|
||||||
try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) {
|
try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) {
|
||||||
statement.setInt(1, this.userId);
|
statement.setInt(1, this.databaseUserId);
|
||||||
statement.setInt(2, this.roomId);
|
statement.setInt(2, this.roomId);
|
||||||
statement.setString(3, this.wallPosition);
|
statement.setString(3, this.wallPosition);
|
||||||
statement.setInt(4, this.x);
|
statement.setInt(4, this.x);
|
||||||
|
|||||||
+3
-1
@@ -76,13 +76,15 @@ public class BuildersClubPlaceRoomItemEvent extends MessageHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(BuildersClubRoomSupport.VIRTUAL_OWNER_ID, baseItem, 0, 0, (extraData != null && !extraData.isEmpty()) ? extraData : catalogItem.getExtradata());
|
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(placementUserId, baseItem, 0, 0, (extraData != null && !extraData.isEmpty()) ? extraData : catalogItem.getExtradata());
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item.setVirtualUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
||||||
|
|
||||||
FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation);
|
FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation);
|
||||||
|
|
||||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||||
|
|||||||
+3
-1
@@ -66,13 +66,15 @@ public class BuildersClubPlaceWallItemEvent extends MessageHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(BuildersClubRoomSupport.VIRTUAL_OWNER_ID, baseItem, 0, 0, (extraData != null && !extraData.isEmpty()) ? extraData : catalogItem.getExtradata());
|
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(placementUserId, baseItem, 0, 0, (extraData != null && !extraData.isEmpty()) ? extraData : catalogItem.getExtradata());
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item.setVirtualUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
||||||
|
|
||||||
FurnitureMovementError error = room.placeWallFurniAt(item, wallPosition, this.client.getHabbo());
|
FurnitureMovementError error = room.placeWallFurniAt(item, wallPosition, this.client.getHabbo());
|
||||||
|
|
||||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ public class RoomPlaceItemEvent extends MessageHandler {
|
|||||||
trackedUserId = this.client.getHabbo().getHabboInfo().getId();
|
trackedUserId = this.client.getHabbo().getHabboInfo().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
item.setVirtualUserId(BuildersClubRoomSupport.VIRTUAL_OWNER_ID);
|
||||||
BuildersClubRoomSupport.trackPlacedItem(item.getId(), trackedUserId, room.getId());
|
BuildersClubRoomSupport.trackPlacedItem(item.getId(), trackedUserId, room.getId());
|
||||||
|
|
||||||
BuildersClubRoomSupport.SyncResult syncResult = BuildersClubRoomSupport.syncRoom(room);
|
BuildersClubRoomSupport.SyncResult syncResult = BuildersClubRoomSupport.syncRoom(room);
|
||||||
|
|||||||
Reference in New Issue
Block a user