Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java

102 lines
3.5 KiB
Java
Raw Normal View History

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 {
2018-07-06 15:30:00 +02:00
String[] lookCode = this.getExtradata().split(":")[1].split("\\.");
2019-03-18 02:22:00 +01:00
StringBuilder look = new StringBuilder();
2019-05-26 20:14:53 +02:00
for (String part : client.getHabbo().getHabboInfo().getLook().split("\\.")) {
2018-07-06 15:30:00 +02:00
String type = part.split("-")[0];
boolean found = false;
2019-05-26 20:14:53 +02:00
for (String s : lookCode) {
if (s.contains(type)) {
2018-07-06 15:30:00 +02:00
found = true;
2019-03-18 02:22:00 +01:00
look.append(s).append(".");
2018-07-06 15:30:00 +02:00
}
}
2019-05-26 20:14:53 +02:00
if (!found) {
2019-03-18 02:22:00 +01:00
look.append(part).append(".");
2018-07-06 15:30:00 +02:00
}
}
2019-05-20 17:34:44 +02:00
client.getHabbo().getHabboInfo().setLook(look.substring(0, look.length() - 1));
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
}
}