You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 06:56:19 +00:00
🆙 Navigator Group Filter
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
-- Navigator search filters - companion to the gameserver fix for the catalog
|
||||||
|
-- 'Find groups to join!' button (navigator/search/hotel_view/group:).
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `navigator_filter` (`key`, `field`, `compare`, `database_query`) VALUES
|
||||||
|
('anything', 'getName', 'contains', 'SELECT rooms.* FROM rooms WHERE rooms.name LIKE ?'),
|
||||||
|
('roomname', 'getName', 'contains', 'SELECT rooms.* FROM rooms WHERE rooms.name LIKE ?'),
|
||||||
|
('owner', 'getOwnerName', 'equals_ignore_case', 'SELECT rooms.* FROM rooms WHERE rooms.owner_name LIKE ?'),
|
||||||
|
('tag', 'getTags', 'contains', 'SELECT rooms.* FROM rooms WHERE rooms.tags LIKE ?'),
|
||||||
|
('group', 'getGuildName', 'contains', 'SELECT rooms.* FROM rooms INNER JOIN guilds ON guilds.room_id = rooms.id WHERE guilds.name LIKE ?');
|
||||||
@@ -158,12 +158,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
private String tags;
|
private String tags;
|
||||||
private boolean publicRoom;
|
private boolean publicRoom;
|
||||||
private boolean staffPromotedRoom;
|
private boolean staffPromotedRoom;
|
||||||
// Read every room cycle (processBots/processPets) but written from settings/
|
private boolean allowPets;
|
||||||
// admin packet handlers on another thread — volatile for cross-thread visibility.
|
private boolean allowPetsEat;
|
||||||
private volatile boolean allowPets;
|
|
||||||
private volatile boolean allowPetsEat;
|
|
||||||
private boolean allowWalkthrough;
|
private boolean allowWalkthrough;
|
||||||
private volatile boolean allowBotsWalk;
|
private boolean allowBotsWalk;
|
||||||
private boolean allowEffects;
|
private boolean allowEffects;
|
||||||
private boolean hideWall;
|
private boolean hideWall;
|
||||||
private int chatMode;
|
private int chatMode;
|
||||||
@@ -1028,10 +1026,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
com.eu.habbo.habbohotel.wired.core.WiredManager.getEngine().clearRoomDiagnostics(this.id);
|
com.eu.habbo.habbohotel.wired.core.WiredManager.getEngine().clearRoomDiagnostics(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop this room's shared wired-variable assignment caches (otherwise
|
|
||||||
// they accrue per (room, item, user) for the JVM lifetime).
|
|
||||||
com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredVariableReferenceSupport.invalidateRoom(this.id);
|
|
||||||
|
|
||||||
this.itemManager.clear();
|
this.itemManager.clear();
|
||||||
|
|
||||||
this.unitManager.clearQueue();
|
this.unitManager.clearQueue();
|
||||||
@@ -1499,6 +1493,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return this.getGuildId() != 0;
|
return this.getGuildId() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean belongsToGuild() {
|
||||||
|
return this.guild > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void setGuild(int guild) {
|
public void setGuild(int guild) {
|
||||||
this.guild = guild;
|
this.guild = guild;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -5,6 +5,13 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer;
|
import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer;
|
||||||
|
|
||||||
public class AddSavedSearchEvent extends MessageHandler {
|
public class AddSavedSearchEvent extends MessageHandler {
|
||||||
|
private static final int MAX_SAVED_SEARCHES = 50;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
String searchCode = this.packet.readString();
|
String searchCode = this.packet.readString();
|
||||||
@@ -13,6 +20,11 @@ public class AddSavedSearchEvent extends MessageHandler {
|
|||||||
if (searchCode.length() > 255) searchCode = searchCode.substring(0, 255);
|
if (searchCode.length() > 255) searchCode = searchCode.substring(0, 255);
|
||||||
if (filter.length() > 255) filter = filter.substring(0, 255);
|
if (filter.length() > 255) filter = filter.substring(0, 255);
|
||||||
|
|
||||||
|
if (this.client.getHabbo().getHabboInfo().getSavedSearches().size() >= MAX_SAVED_SEARCHES) {
|
||||||
|
this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.client.getHabbo().getHabboInfo().addSavedSearch(new NavigatorSavedSearch(searchCode, filter));
|
this.client.getHabbo().getHabboInfo().addSavedSearch(new NavigatorSavedSearch(searchCode, filter));
|
||||||
|
|
||||||
this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches()));
|
this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches()));
|
||||||
|
|||||||
+5
@@ -5,6 +5,11 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer;
|
import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer;
|
||||||
|
|
||||||
public class DeleteSavedSearchEvent extends MessageHandler {
|
public class DeleteSavedSearchEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
int searchId = this.packet.readInt();
|
int searchId = this.packet.readInt();
|
||||||
|
|||||||
+18
-18
@@ -15,12 +15,20 @@ import java.util.*;
|
|||||||
|
|
||||||
public class RequestNewNavigatorRoomsEvent extends MessageHandler {
|
public class RequestNewNavigatorRoomsEvent extends MessageHandler {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RequestNewNavigatorRoomsEvent.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(RequestNewNavigatorRoomsEvent.class);
|
||||||
|
private static final int MAX_VIEW_LENGTH = 32;
|
||||||
|
private static final int MAX_QUERY_LENGTH = 64;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
String view = this.packet.readString();
|
String view = this.packet.readString();
|
||||||
String query = this.packet.readString();
|
String query = this.packet.readString();
|
||||||
|
if (view.length() > MAX_VIEW_LENGTH) return;
|
||||||
|
if (query.length() > MAX_QUERY_LENGTH) query = query.substring(0, MAX_QUERY_LENGTH);
|
||||||
if (view.equals("query")) view = "hotel_view";
|
if (view.equals("query")) view = "hotel_view";
|
||||||
if (view.equals("groups")) view = "hotel_view";
|
if (view.equals("groups")) view = "hotel_view";
|
||||||
|
|
||||||
@@ -43,7 +51,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler {
|
|||||||
NavigatorFilterField field = Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField);
|
NavigatorFilterField field = Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField);
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
if (query.contains(":")) {
|
if (query.contains(":")) {
|
||||||
String[] parts = query.split(":");
|
String[] parts = query.split(":", 2);
|
||||||
|
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
filterField = parts[0];
|
filterField = parts[0];
|
||||||
@@ -53,6 +61,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler {
|
|||||||
if (!Emulator.getGameEnvironment().getNavigatorManager().filterSettings.containsKey(filterField)) {
|
if (!Emulator.getGameEnvironment().getNavigatorManager().filterSettings.containsKey(filterField)) {
|
||||||
filterField = "anything";
|
filterField = "anything";
|
||||||
}
|
}
|
||||||
|
part = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,28 +104,19 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler {
|
|||||||
rooms.addAll(searchResultList.rooms);
|
rooms.addAll(searchResultList.rooms);
|
||||||
resultLists.add(new SearchResultList(searchResultList.order, searchResultList.code, searchResultList.query, searchResultList.action, searchResultList.mode, searchResultList.hidden, rooms, searchResultList.filter, searchResultList.showInvisible, searchResultList.displayOrder, searchResultList.categoryOrder));
|
resultLists.add(new SearchResultList(searchResultList.order, searchResultList.code, searchResultList.query, searchResultList.action, searchResultList.mode, searchResultList.hidden, rooms, searchResultList.filter, searchResultList.showInvisible, searchResultList.displayOrder, searchResultList.categoryOrder));
|
||||||
}
|
}
|
||||||
|
if ("group".equals(filterField)) {
|
||||||
|
final String needle = part.toLowerCase();
|
||||||
|
for (SearchResultList list : resultLists) {
|
||||||
|
list.rooms.removeIf(room -> !room.belongsToGuild()
|
||||||
|
|| (!needle.isEmpty() && !room.getGuildName().toLowerCase().contains(needle)));
|
||||||
|
}
|
||||||
|
}
|
||||||
filter.filter(field.field, part, resultLists);
|
filter.filter(field.field, part, resultLists);
|
||||||
resultLists = toQueryResults(resultLists);
|
resultLists = toQueryResults(resultLists);
|
||||||
this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists));
|
this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Caught exception", e);
|
LOGGER.error("Caught exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
List<SearchResultList> resultLists = new ArrayList<>(filter.getResult(this.client.getHabbo(), field, part, category != null ? category.getId() : -1));
|
|
||||||
filter.filter(field.field, part, resultLists);
|
|
||||||
|
|
||||||
Collections.sort(resultLists);
|
|
||||||
this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.error("Caught exception", e);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<SearchResultList> toQueryResults(List<SearchResultList> resultLists) {
|
private ArrayList<SearchResultList> toQueryResults(List<SearchResultList> resultLists) {
|
||||||
|
|||||||
Reference in New Issue
Block a user