Merge branch 'feature/permissions-see-tent-chat' into 'dev'

Added permission to view the chat of users in the tent

See merge request morningstar/Arcturus-Community!298
This commit is contained in:
skeletor 2020-11-29 00:07:20 -05:00
commit 7c05abb226
5 changed files with 32 additions and 6 deletions

View File

@ -1,2 +1,2 @@
-- Recycler value fix
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('recycler.value', '8');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('recycler.value', '8');

View File

@ -0,0 +1,3 @@
-- Permissions to see tent chat
ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`;
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent');

View File

@ -81,7 +81,6 @@ public class InteractionOneWayGate extends HabboItem {
if (unit == null)
return;
if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY()) {
if (!currentLocation.hasUnits()) {
List<Runnable> onSuccess = new ArrayList<Runnable>();

View File

@ -6,6 +6,7 @@ public class Permission {
public static String ACC_EMPTY_OTHERS = "acc_empty_others";
public static String ACC_ENABLE_OTHERS = "acc_enable_others";
public static String ACC_SEE_WHISPERS = "acc_see_whispers";
public static String ACC_SEE_TENTCHAT = "acc_see_tentchat";
public static String ACC_SUPERWIRED = "acc_superwired";
public static String ACC_SUPPORTTOOL = "acc_supporttool";
public static String ACC_UNKICKABLE = "acc_unkickable";

View File

@ -3193,7 +3193,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null;
Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation());
Rectangle tentRectangle = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation());
String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$","");
@ -3239,7 +3239,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance ||
h.equals(habbo) ||
this.hasRights(h) ||
noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) {
noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
if (prefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(prefixMessage);
@ -3249,13 +3249,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
h.getClient().sendResponse(clearPrefixMessage);
}
}
continue;
}
// Staff should be able to see the tent chat anyhow
showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle);
}
} else if (chatType == RoomChatType.SHOUT) {
ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose();
for (Habbo h : this.getHabbos()) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) {
// Show the message
// If the receiving Habbo has not ignored the sending Habbo
// AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) {
if (prefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(prefixMessage);
}
@ -3263,7 +3269,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(clearPrefixMessage);
}
continue;
}
// Staff should be able to see the tent chat anyhow, even when not in the same tent
showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle);
}
}
@ -3315,11 +3324,25 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
}
}
}
}
/**
* Sends the given message to the receiving Habbo if the Habbo has the ACC_SEE_TENTCHAT permission and is not within the tent
* @param receivingHabbo The receiving Habbo
* @param roomChatMessage The message to receive
* @param tentRectangle The whole tent area from where the sending Habbo is saying something
*/
private void showTentChatMessageOutsideTentIfPermitted(Habbo receivingHabbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle) {
if (receivingHabbo != null && receivingHabbo.hasPermission(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentLocation())) {
RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage);
staffChatMessage.setMessage("[" + Emulator.getTexts().getValue("hotel.room.tent.prefix") + "] " + staffChatMessage.getMessage());
final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose();
receivingHabbo.getClient().sendResponse(staffMessage);
}
}
public THashSet<RoomTile> getLockedTiles() {
THashSet<RoomTile> lockedTiles = new THashSet<>();