2018-07-06 15:30:00 +02:00
|
|
|
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.rooms.Room;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|
|
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
|
|
import com.eu.habbo.messages.ServerMessage;
|
|
|
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
2018-09-28 21:25:00 +02:00
|
|
|
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class InteractionMannequin extends HabboItem {
|
|
|
|
public InteractionMannequin(ResultSet set, Item baseItem) throws SQLException {
|
2018-07-06 15:30:00 +02:00
|
|
|
super(set, baseItem);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public InteractionMannequin(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
2018-07-06 15:30:00 +02:00
|
|
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void serializeExtradata(ServerMessage serverMessage) {
|
2018-07-06 15:30:00 +02:00
|
|
|
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
|
|
|
|
serverMessage.appendInt(3);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (this.getExtradata().split(":").length >= 2) {
|
2018-07-06 15:30:00 +02:00
|
|
|
String[] data = this.getExtradata().split(":");
|
|
|
|
serverMessage.appendString("GENDER");
|
|
|
|
serverMessage.appendString(data[0].toLowerCase());
|
|
|
|
serverMessage.appendString("FIGURE");
|
|
|
|
serverMessage.appendString(data[1]);
|
|
|
|
serverMessage.appendString("OUTFIT_NAME");
|
2019-05-26 20:14:53 +02:00
|
|
|
serverMessage.appendString((data.length >= 3 ? data[2] : ""));
|
|
|
|
} else {
|
2018-07-06 15:30:00 +02:00
|
|
|
serverMessage.appendString("GENDER");
|
|
|
|
serverMessage.appendString("m");
|
|
|
|
serverMessage.appendString("FIGURE");
|
|
|
|
serverMessage.appendString("");
|
|
|
|
serverMessage.appendString("OUTFIT_NAME");
|
|
|
|
serverMessage.appendString("My Look");
|
|
|
|
this.setExtradata("m: :My look");
|
|
|
|
this.needsUpdate(true);
|
|
|
|
Emulator.getThreading().run(this);
|
|
|
|
}
|
|
|
|
super.serializeExtradata(serverMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isWalkable() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
2020-09-25 04:41:16 +02:00
|
|
|
String lookCode = this.getExtradata().split(":")[1];
|
|
|
|
String newFigure = "";
|
|
|
|
|
|
|
|
for (String playerFigurePart : client.getHabbo().getHabboInfo().getLook().split("\\.")) {
|
|
|
|
if (!playerFigurePart.startsWith("ch") && !playerFigurePart.startsWith("lg"))
|
|
|
|
newFigure += playerFigurePart + ".";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lookCode.isEmpty()) return;
|
|
|
|
String newFigureParts = lookCode;
|
|
|
|
|
|
|
|
for (String newFigurePart : newFigureParts.split("\\.")) {
|
|
|
|
if (newFigurePart.startsWith("hd"))
|
|
|
|
newFigureParts = newFigureParts.replace(newFigurePart, "");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2020-09-25 04:41:16 +02:00
|
|
|
if (newFigureParts.equals("")) return;
|
|
|
|
|
|
|
|
final String figure = newFigure + newFigureParts;
|
|
|
|
|
|
|
|
if (figure.length() > 512)
|
|
|
|
return;
|
|
|
|
|
|
|
|
client.getHabbo().getHabboInfo().setLook(figure);
|
2018-07-06 15:30:00 +02:00
|
|
|
room.sendComposer(new RoomUserDataComposer(client.getHabbo()).compose());
|
|
|
|
client.sendResponse(new UserDataComposer(client.getHabbo()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|