Added Sticky Limits to rooms (default 200 like habbo)

This commit is contained in:
KrewsOrg 2020-04-23 22:17:04 +01:00
parent df2641f215
commit 78905c2a05
5 changed files with 59 additions and 29 deletions

View File

@ -0,0 +1 @@
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.stickies.max', '200');

View File

@ -13,7 +13,9 @@ public enum FurnitureMovementError {
TILE_HAS_BOTS("${room.error.cant_set_item}"), TILE_HAS_BOTS("${room.error.cant_set_item}"),
MAX_DIMMERS("${room.error.max_dimmers}"), MAX_DIMMERS("${room.error.max_dimmers}"),
MAX_SOUNDFURNI("${room.errors.max_soundfurni}"), MAX_SOUNDFURNI("${room.errors.max_soundfurni}"),
MAX_ITEMS("${room.error.max_furniture}"); MAX_ITEMS("${room.error.max_furniture}"),
MAX_STICKIES("${room.error.max_stickies}");
public final String errorCode; public final String errorCode;

View File

@ -86,25 +86,19 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class Room implements Comparable<Room>, ISerialize, Runnable { public class Room implements Comparable<Room>, ISerialize, Runnable {
public static final Comparator SORT_SCORE = new Comparator() { public static final Comparator SORT_SCORE = (o1, o2) -> {
@Override
public int compare(Object o1, Object o2) {
if (!(o1 instanceof Room && o2 instanceof Room)) if (!(o1 instanceof Room && o2 instanceof Room))
return 0; return 0;
return ((Room) o2).getScore() - ((Room) o1).getScore(); return ((Room) o2).getScore() - ((Room) o1).getScore();
}
}; };
public static final Comparator SORT_ID = new Comparator() { public static final Comparator SORT_ID = (o1, o2) -> {
@Override
public int compare(Object o1, Object o2) {
if (!(o1 instanceof Room && o2 instanceof Room)) if (!(o1 instanceof Room && o2 instanceof Room))
return 0; return 0;
return ((Room) o2).getId() - ((Room) o1).getId(); return ((Room) o2).getId() - ((Room) o1).getId();
}
}; };
private static final TIntObjectHashMap<RoomMoodlightData> defaultMoodData = new TIntObjectHashMap<>(); private static final TIntObjectHashMap<RoomMoodlightData> defaultMoodData = new TIntObjectHashMap<>();
//Configuration. Loaded from database & updated accordingly. //Configuration. Loaded from database & updated accordingly.
@ -112,6 +106,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public static int MAXIMUM_BOTS = 10; public static int MAXIMUM_BOTS = 10;
public static int MAXIMUM_PETS = 10; public static int MAXIMUM_PETS = 10;
public static int MAXIMUM_FURNI = 2500; public static int MAXIMUM_FURNI = 2500;
public static int MAXIMUM_POSTITNOTES = 200;
public static int HAND_ITEM_TIME = 10; public static int HAND_ITEM_TIME = 10;
public static int IDLE_CYCLES = 240; public static int IDLE_CYCLES = 240;
public static int IDLE_CYCLES_KICK = 480; public static int IDLE_CYCLES_KICK = 480;
@ -427,6 +422,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (this.itemCount() > Room.MAXIMUM_FURNI) { if (this.itemCount() > Room.MAXIMUM_FURNI) {
Emulator.getLogging().logErrorLine("Room ID: " + this.getId() + " has exceeded the furniture limit (" + this.itemCount() + " > " + Room.MAXIMUM_FURNI + ")."); Emulator.getLogging().logErrorLine("Room ID: " + this.getId() + " has exceeded the furniture limit (" + this.itemCount() + " > " + Room.MAXIMUM_FURNI + ").");
} }
} }
private synchronized void loadWiredData(Connection connection) { private synchronized void loadWiredData(Connection connection) {
@ -2556,6 +2552,25 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public THashSet<HabboItem> getPostItNotes() {
THashSet<HabboItem> items = new THashSet<>();
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
for (int i = this.roomItems.size(); i-- > 0; ) {
try {
iterator.advance();
} catch (Exception e) {
break;
}
if (iterator.value().getBaseItem().getInteractionType().getType() == InteractionPostIt.class)
items.add(iterator.value());
}
return items;
}
public void addHabbo(Habbo habbo) { public void addHabbo(Habbo habbo) {
synchronized (this.roomUnitLock) { synchronized (this.roomUnitLock) {
habbo.getRoomUnit().setId(this.unitCounter); habbo.getRoomUnit().setId(this.unitCounter);
@ -4340,6 +4355,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return FurnitureMovementError.MAX_ITEMS; return FurnitureMovementError.MAX_ITEMS;
} }
rotation %= 8; rotation %= 8;
if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) { if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) {
return FurnitureMovementError.NONE; return FurnitureMovementError.NONE;

View File

@ -4,9 +4,12 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt;
import com.eu.habbo.habbohotel.items.interactions.InteractionStickyPole; import com.eu.habbo.habbohotel.items.interactions.InteractionStickyPole;
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler; 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 com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer;
import com.eu.habbo.messages.outgoing.rooms.items.AddWallItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.AddWallItemComposer;
@ -23,6 +26,7 @@ public class PostItPlaceEvent extends MessageHandler {
HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId);
if (item instanceof InteractionPostIt) { if (item instanceof InteractionPostIt) {
if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) {
room.addHabboItem(item); room.addHabboItem(item);
item.setExtradata("FFFF33"); item.setExtradata("FFFF33");
item.setRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()); item.setRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId());
@ -40,6 +44,11 @@ public class PostItPlaceEvent extends MessageHandler {
AchievementManager.progressAchievement(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesLeft")); AchievementManager.progressAchievement(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesLeft"));
} }
}
else {
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.MAX_STICKIES.errorCode));
}
//this.client.sendResponse(new PostItStickyPoleOpenComposer(item)); //this.client.sendResponse(new PostItStickyPoleOpenComposer(item));
} }
} }

View File

@ -91,6 +91,7 @@ public class PluginManager {
Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room"); Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room");
Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room"); Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room");
Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500); Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500);
Room.MAXIMUM_POSTITNOTES = Emulator.getConfig().getInt("hotel.room.stickies.max", 200);
Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time"); Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time");
Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240); Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240);
Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480); Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480);