mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
Fix Interaction Water
This commit is contained in:
parent
0fb8dad0ea
commit
9f9bbf1a37
@ -59,6 +59,7 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -72,6 +73,8 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
|
|
||||||
|
roomUnit.isSwimming = true;
|
||||||
|
|
||||||
Pet pet = room.getPet(roomUnit);
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
|
||||||
if (pet == null)
|
if (pet == null)
|
||||||
@ -79,19 +82,23 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
|
|
||||||
if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) {
|
if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) {
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, "");
|
pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
|
roomUnit.isSwimming = false;
|
||||||
|
|
||||||
super.onWalkOff(roomUnit, room, objects);
|
super.onWalkOff(roomUnit, room, objects);
|
||||||
|
|
||||||
|
if ( roomUnit.getRoomUnitType() != RoomUnitType.PET) return;
|
||||||
Pet pet = room.getPet(roomUnit);
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
|
||||||
if(pet == null)
|
if (pet == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM);
|
roomUnit.removeStatus(RoomUnitStatus.SWIM);
|
||||||
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,11 +115,10 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation) {
|
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation) {
|
||||||
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation) {
|
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation) {
|
||||||
for (HabboItem item : set.getValue()) {
|
for (HabboItem item : set.getValue()) {
|
||||||
if (!(item instanceof InteractionWater)) {
|
if(item != this)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.canStackAt(room, itemsAtLocation);
|
return super.canStackAt(room, itemsAtLocation);
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -2968,8 +2968,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
list.add(bot.getRoomUnit());
|
list.add(bot.getRoomUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Habbo habbo : this.getHabbosAt(tile))
|
for (Habbo habbo : this.getHabbosAt(tile)) {
|
||||||
{
|
|
||||||
list.add(habbo.getRoomUnit());
|
list.add(habbo.getRoomUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3356,6 +3355,7 @@ 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
|
* 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 receivingHabbo The receiving Habbo
|
||||||
* @param roomChatMessage The message to receive
|
* @param roomChatMessage The message to receive
|
||||||
* @param tentRectangle The whole tent area from where the sending Habbo is saying something
|
* @param tentRectangle The whole tent area from where the sending Habbo is saying something
|
||||||
@ -3472,8 +3472,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (item.getRotation() != 2 && item.getRotation() != 6) {
|
if (item.getRotation() != 2 && item.getRotation() != 6) {
|
||||||
width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
|
width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
|
||||||
length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
|
length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
|
width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
|
||||||
length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
|
length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
|
||||||
}
|
}
|
||||||
@ -4137,7 +4136,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
duration += Emulator.getIntUnixTimestamp();
|
duration += Emulator.getIntUnixTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.allowEffects) {
|
if (this.allowEffects && !roomUnit.isSwimming) {
|
||||||
roomUnit.setEffectId(effectId, duration);
|
roomUnit.setEffectId(effectId, duration);
|
||||||
this.sendComposer(new RoomUserEffectComposer(roomUnit).compose());
|
this.sendComposer(new RoomUserEffectComposer(roomUnit).compose());
|
||||||
}
|
}
|
||||||
@ -4520,6 +4519,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
|
|
||||||
if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
|
if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
|
||||||
|
|
||||||
|
|
||||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||||
for (RoomTile t : occupiedTiles) {
|
for (RoomTile t : occupiedTiles) {
|
||||||
if(t.state == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE;
|
if(t.state == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE;
|
||||||
@ -4530,6 +4530,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<HabboItem> stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny();
|
||||||
|
|
||||||
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
||||||
for (RoomTile t : occupiedTiles) {
|
for (RoomTile t : occupiedTiles) {
|
||||||
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
|
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
|
||||||
@ -4538,6 +4540,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
|
if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
|
||||||
return FurnitureMovementError.CANT_STACK;
|
return FurnitureMovementError.CANT_STACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) || topItem != null && (topItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() == InteractionWater.class || item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class))) {
|
||||||
|
return FurnitureMovementError.CANT_STACK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.canStackAt(this, tileFurniList)) {
|
if (!item.canStackAt(this, tileFurniList)) {
|
||||||
@ -4663,14 +4669,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
|
|
||||||
HabboItem topItem = this.getTopItemAt(occupiedTiles, null);
|
HabboItem topItem = this.getTopItemAt(occupiedTiles, null);
|
||||||
|
|
||||||
if (!stackHelper.isPresent() && !pluginHelper) {
|
if ((!stackHelper.isPresent() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
|
||||||
if (oldLocation != tile) {
|
if (oldLocation != tile) {
|
||||||
for (RoomTile t : occupiedTiles) {
|
for (RoomTile t : occupiedTiles) {
|
||||||
HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
|
HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
|
||||||
if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
|
if ((!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && item.getBaseItem().getInteractionType().getType() == InteractionWater.class || item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class)) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class))
|
||||||
return FurnitureMovementError.CANT_STACK;
|
return FurnitureMovementError.CANT_STACK;
|
||||||
|
|
||||||
if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) {
|
if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) {
|
||||||
if (checkForUnits) {
|
if (checkForUnits) {
|
||||||
if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||||
if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
|
if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
|
||||||
@ -4706,8 +4712,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((!stackHelper.isPresent() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack())|| (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT))
|
if ((!stackHelper.isPresent() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT)) {
|
||||||
{
|
|
||||||
item.setRotation(oldRotation);
|
item.setRotation(oldRotation);
|
||||||
return FurnitureMovementError.CANT_STACK;
|
return FurnitureMovementError.CANT_STACK;
|
||||||
}
|
}
|
||||||
@ -4742,6 +4747,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK;
|
||||||
|
if(height < this.getLayout().getHeightAtSquare(tile.x, tile.y)) return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor
|
||||||
|
|
||||||
item.setX(tile.x);
|
item.setX(tile.x);
|
||||||
item.setY(tile.y);
|
item.setY(tile.y);
|
||||||
item.setZ(height);
|
item.setZ(height);
|
||||||
@ -4785,8 +4793,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
for (Habbo h : this.getHabbosAt(t.x, t.y)) {
|
for (Habbo h : this.getHabbosAt(t.x, t.y)) {
|
||||||
try {
|
try {
|
||||||
item.onWalkOn(h.getRoomUnit(), this, null);
|
item.onWalkOn(h.getRoomUnit(), this, null);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user