mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
InteractionMuteArea implemented
This commit is contained in:
parent
7cffb391ea
commit
e817431176
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
@ -78,4 +79,8 @@ public abstract class InteractionCustomValues extends HabboItem {
|
|||||||
|
|
||||||
super.serializeExtradata(serverMessage);
|
super.serializeExtradata(serverMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCustomValuesSaved(Room room, GameClient client) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.items.ItemExtraDataComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.items.RoomFloorItemsComposer;
|
||||||
|
import gnu.trove.TCollections;
|
||||||
|
import gnu.trove.map.TIntObjectMap;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -25,25 +38,122 @@ public class InteractionMuteArea extends InteractionCustomValues {
|
|||||||
{
|
{
|
||||||
this.put("tilesBack", "0");
|
this.put("tilesBack", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
this.put("state", "0");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private THashSet<RoomTile> tiles;
|
||||||
|
|
||||||
public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem, defaultValues);
|
super(set, baseItem, defaultValues);
|
||||||
|
tiles = new THashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
|
super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
|
||||||
|
tiles = new THashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
|
super.onClick(client, room, objects);
|
||||||
|
|
||||||
|
if((objects.length >= 2 && objects[1] instanceof WiredEffectType) || (client != null && room.hasRights(client.getHabbo()))) {
|
||||||
|
this.values.put("state", this.values.get("state").equals("0") ? "1" : "0");
|
||||||
|
room.sendComposer(new ItemExtraDataComposer(this).compose());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlace(Room room) {
|
||||||
|
super.onPlace(room);
|
||||||
|
this.regenAffectedTiles(room);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPickUp(Room room) {
|
||||||
|
super.onPickUp(room);
|
||||||
|
this.tiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||||
|
super.onMove(room, oldLocation, newLocation);
|
||||||
|
this.regenAffectedTiles(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inSquare(RoomTile location) {
|
public boolean inSquare(RoomTile location) {
|
||||||
try {
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||||
|
|
||||||
|
if(!this.values.get("state").equals("1"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(room != null && this.tiles.size() == 0) {
|
||||||
|
regenAffectedTiles(room);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.tiles.contains(location);
|
||||||
|
|
||||||
|
/*try {
|
||||||
return new Rectangle(
|
return new Rectangle(
|
||||||
this.getX() - Integer.valueOf(this.values.get("tilesBack")),
|
this.getX() - Integer.parseInt(this.values.get("tilesBack")),
|
||||||
this.getY() + Integer.valueOf(this.values.get("tilesLeft")) - (Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight"))),
|
this.getY() + Integer.valueOf(this.values.get("tilesLeft")) - (Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight"))),
|
||||||
Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight")) + 1,
|
Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight")) + 1,
|
||||||
Integer.valueOf(this.values.get("tilesFront")) + Integer.valueOf(this.values.get("tilesBack")) + 1).contains(location.x, location.y);
|
Integer.valueOf(this.values.get("tilesFront")) + Integer.valueOf(this.values.get("tilesBack")) + 1).contains(location.x, location.y);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regenAffectedTiles(Room room) {
|
||||||
|
int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack")));
|
||||||
|
int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight")));
|
||||||
|
int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront")));
|
||||||
|
int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft")));
|
||||||
|
|
||||||
|
this.tiles.clear();
|
||||||
|
|
||||||
|
for(int x = minX; x <= maxX; x++) {
|
||||||
|
for(int y = minY; y <= maxY; y++) {
|
||||||
|
RoomTile tile = room.getLayout().getTile((short)x, (short)y);
|
||||||
|
if(tile != null && tile.state != RoomTileState.INVALID)
|
||||||
|
this.tiles.add(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCustomValuesSaved(Room room, GameClient client) {
|
||||||
|
super.onCustomValuesSaved(room, client);
|
||||||
|
|
||||||
|
this.regenAffectedTiles(room);
|
||||||
|
|
||||||
|
// show the effect
|
||||||
|
Item effectItem = Emulator.getGameEnvironment().getItemManager().getItem("mutearea_sign2");
|
||||||
|
|
||||||
|
if(effectItem != null) {
|
||||||
|
TIntObjectMap<String> ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
|
||||||
|
ownerNames.put(-1, "System");
|
||||||
|
THashSet<HabboItem> items = new THashSet<>();
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
for(RoomTile tile : this.tiles) {
|
||||||
|
id--;
|
||||||
|
HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0);
|
||||||
|
item.setX(tile.x);
|
||||||
|
item.setY(tile.y);
|
||||||
|
item.setZ(tile.relativeHeight());
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
client.sendResponse(new RoomFloorItemsComposer(ownerNames, items));
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
for(HabboItem item : items) {
|
||||||
|
client.sendResponse(new RemoveFloorItemComposer(item, true));
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
public static int IDLE_CYCLES_KICK = 480;
|
public static int IDLE_CYCLES_KICK = 480;
|
||||||
public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] ";
|
public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] ";
|
||||||
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
|
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
|
||||||
|
public static boolean MUTEAREA_CAN_WHISPER = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i <= 3; i++) {
|
||||||
@ -3083,11 +3084,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().equals(""))
|
if (roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().equals(""))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(!habbo.hasPermission(Permission.ACC_NOMUTE) && (!MUTEAREA_CAN_WHISPER || chatType != RoomChatType.WHISPER)) {
|
||||||
for (HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) {
|
for (HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) {
|
||||||
if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentLocation())) {
|
if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentLocation())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.wordFilterWords.isEmpty()) {
|
if (!this.wordFilterWords.isEmpty()) {
|
||||||
if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) {
|
if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) {
|
||||||
|
@ -42,6 +42,7 @@ public class AdvertisingSaveEvent extends MessageHandler {
|
|||||||
item.needsUpdate(true);
|
item.needsUpdate(true);
|
||||||
Emulator.getThreading().run(item);
|
Emulator.getThreading().run(item);
|
||||||
room.updateItem(item);
|
room.updateItem(item);
|
||||||
|
((InteractionCustomValues) item).onCustomValuesSaved(room, this.client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ public class PluginManager {
|
|||||||
PacketManager.DEBUG_SHOW_PACKETS = Emulator.getConfig().getBoolean("debug.show.packets");
|
PacketManager.DEBUG_SHOW_PACKETS = Emulator.getConfig().getBoolean("debug.show.packets");
|
||||||
PacketManager.MULTI_THREADED_PACKET_HANDLING = Emulator.getConfig().getBoolean("io.client.multithreaded.handler");
|
PacketManager.MULTI_THREADED_PACKET_HANDLING = Emulator.getConfig().getBoolean("io.client.multithreaded.handler");
|
||||||
Room.HABBO_CHAT_DELAY = Emulator.getConfig().getBoolean("room.chat.delay", false);
|
Room.HABBO_CHAT_DELAY = Emulator.getConfig().getBoolean("room.chat.delay", false);
|
||||||
|
Room.MUTEAREA_CAN_WHISPER = Emulator.getConfig().getBoolean("room.chat.mutearea.allow_whisper", false);
|
||||||
RoomChatMessage.SAVE_ROOM_CHATS = Emulator.getConfig().getBoolean("save.room.chats", false);
|
RoomChatMessage.SAVE_ROOM_CHATS = Emulator.getConfig().getBoolean("save.room.chats", false);
|
||||||
RoomLayout.MAXIMUM_STEP_HEIGHT = Emulator.getConfig().getDouble("pathfinder.step.maximum.height", 1.1);
|
RoomLayout.MAXIMUM_STEP_HEIGHT = Emulator.getConfig().getDouble("pathfinder.step.maximum.height", 1.1);
|
||||||
RoomLayout.ALLOW_FALLING = Emulator.getConfig().getBoolean("pathfinder.step.allow.falling", true);
|
RoomLayout.ALLOW_FALLING = Emulator.getConfig().getBoolean("pathfinder.step.allow.falling", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user