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
Merge pull request #179 from simoleo89/fix/rooms-self-moderation-scope
fix(rooms): scope room actions and bound rights removal
This commit is contained in:
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.polls;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.polls.Poll;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer;
|
||||
@@ -31,12 +32,20 @@ public class AnswerPollEvent extends MessageHandler {
|
||||
if(answer.length() <= 0) return;
|
||||
|
||||
if (pollId == 0 && questionId <= 0) {
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().handleWordQuiz(this.client.getHabbo(), answer.toString());
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room != null) {
|
||||
room.handleWordQuiz(this.client.getHabbo(), answer.toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
answer = new StringBuilder(answer.substring(1));
|
||||
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room == null || room.getPollId() != pollId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(pollId);
|
||||
|
||||
if (poll != null) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.polls;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.polls.Poll;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -17,6 +18,10 @@ public class CancelPollEvent extends MessageHandler {
|
||||
public void handle() throws Exception {
|
||||
int pollId = this.packet.readInt();
|
||||
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room == null || room.getPollId() != pollId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(pollId);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.polls;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.polls.Poll;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.polls.PollQuestionsComposer;
|
||||
|
||||
@@ -10,6 +11,11 @@ public class GetPollDataEvent extends MessageHandler {
|
||||
public void handle() throws Exception {
|
||||
int pollId = this.packet.readInt();
|
||||
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room == null || room.getPollId() != pollId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(pollId);
|
||||
|
||||
if (poll != null) {
|
||||
|
||||
+15
-2
@@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.users;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomManager;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
|
||||
public class RoomUserBanEvent extends MessageHandler {
|
||||
@@ -11,6 +12,18 @@ public class RoomUserBanEvent extends MessageHandler {
|
||||
int roomId = this.packet.readInt();
|
||||
String banName = this.packet.readString();
|
||||
|
||||
Emulator.getGameEnvironment().getRoomManager().banUserFromRoom(this.client.getHabbo(), userId, roomId, RoomManager.RoomBanTypes.valueOf(banName));
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room == null || room.getId() != roomId) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomManager.RoomBanTypes banType;
|
||||
try {
|
||||
banType = RoomManager.RoomBanTypes.valueOf(banName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
Emulator.getGameEnvironment().getRoomManager().banUserFromRoom(this.client.getHabbo(), userId, roomId, banType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-9
@@ -15,17 +15,18 @@ public class RoomUserMuteEvent extends MessageHandler {
|
||||
int roomId = this.packet.readInt();
|
||||
int minutes = this.packet.readInt();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room == null || room.getId() != roomId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (room != null) {
|
||||
if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("cmd_mute") || this.client.getHabbo().hasPermission(Permission.ACC_AMBASSADOR)) {
|
||||
Habbo habbo = room.getHabbo(userId);
|
||||
if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("cmd_mute") || this.client.getHabbo().hasPermission(Permission.ACC_AMBASSADOR)) {
|
||||
Habbo habbo = room.getHabbo(userId);
|
||||
|
||||
if (habbo != null) {
|
||||
room.muteHabbo(habbo, minutes);
|
||||
habbo.getClient().sendResponse(new MutedWhisperComposer(minutes * 60));
|
||||
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModMuteSeen"));
|
||||
}
|
||||
if (habbo != null) {
|
||||
room.muteHabbo(habbo, minutes);
|
||||
habbo.getClient().sendResponse(new MutedWhisperComposer(minutes * 60));
|
||||
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModMuteSeen"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -3,8 +3,12 @@ package com.eu.habbo.messages.incoming.rooms.users;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.util.PacketGuard;
|
||||
|
||||
public class RoomUserRemoveRightsEvent extends MessageHandler {
|
||||
private static final int MAX_RIGHTS_REMOVALS = 100;
|
||||
private static final int BYTES_PER_USER_ID = 4;
|
||||
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
int amount = this.packet.readInt();
|
||||
@@ -15,6 +19,11 @@ public class RoomUserRemoveRightsEvent extends MessageHandler {
|
||||
return;
|
||||
|
||||
if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) {
|
||||
if (!PacketGuard.isCountInRange(amount, 1, MAX_RIGHTS_REMOVALS)
|
||||
|| !PacketGuard.hasFixedWidthEntries(this.packet, amount, BYTES_PER_USER_ID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
int userId = this.packet.readInt();
|
||||
|
||||
|
||||
+6
-6
@@ -10,13 +10,13 @@ public class UnbanRoomUserEvent extends MessageHandler {
|
||||
int userId = this.packet.readInt();
|
||||
int roomId = this.packet.readInt();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
|
||||
|
||||
if (room != null) {
|
||||
if (room.isOwner(this.client.getHabbo())) {
|
||||
room.unbanHabbo(userId);
|
||||
}
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room == null || room.getId() != roomId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.isOwner(this.client.getHabbo())) {
|
||||
room.unbanHabbo(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user