58 lines
2.1 KiB
Java
Raw Normal View History

2018-07-06 13:30:00 +00:00
package com.eu.habbo.messages.rcon;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
import com.google.gson.Gson;
2019-05-26 21:14:53 +03:00
public class StalkUser extends RCONMessage<StalkUser.StalkUserJSON> {
public StalkUser() {
2018-07-06 13:30:00 +00:00
super(StalkUserJSON.class);
}
@Override
2019-05-26 21:14:53 +03:00
public void handle(Gson gson, StalkUserJSON json) {
2018-07-06 13:30:00 +00:00
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id);
2019-05-26 21:14:53 +03:00
if (habbo != null) {
2018-07-06 13:30:00 +00:00
Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.follow_id);
2019-05-26 21:14:53 +03:00
if (target == null) {
2018-07-06 13:30:00 +00:00
this.message = Emulator.getTexts().getValue("commands.error.cmd_stalk.not_found").replace("%user%", json.user_id + "");
this.status = STATUS_ERROR;
2019-03-18 01:22:00 +00:00
return;
2018-07-06 13:30:00 +00:00
}
2019-05-26 21:14:53 +03:00
if (target.getHabboInfo().getCurrentRoom() == null) {
2018-07-06 13:30:00 +00:00
this.message = Emulator.getTexts().getValue("commands.error.cmd_stalk.not_room").replace("%user%", json.user_id + "");
this.status = STATUS_ERROR;
2019-03-18 01:22:00 +00:00
return;
2018-07-06 13:30:00 +00:00
}
2019-05-26 21:14:53 +03:00
if (target.getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) {
2018-07-06 13:30:00 +00:00
this.message = Emulator.getTexts().getValue("commands.generic.cmd_stalk.self").replace("%user%", json.user_id + "");
this.status = STATUS_ERROR;
2019-03-18 01:22:00 +00:00
return;
2018-07-06 13:30:00 +00:00
}
2019-05-26 21:14:53 +03:00
if (target.getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) {
2018-07-06 13:30:00 +00:00
this.message = Emulator.getTexts().getValue("commands.generic.cmd_stalk.same_room").replace("%user%", json.user_id + "");
this.status = STATUS_ERROR;
2019-03-18 01:22:00 +00:00
return;
2018-07-06 13:30:00 +00:00
}
2019-05-26 21:14:53 +03:00
if (this.status == 0) {
2018-07-06 13:30:00 +00:00
habbo.getClient().sendResponse(new ForwardToRoomComposer(target.getHabboInfo().getCurrentRoom().getId()));
}
}
}
2019-05-26 21:14:53 +03:00
static class StalkUserJSON {
2018-10-06 22:28:00 +00:00
2018-07-06 13:30:00 +00:00
public int user_id;
2018-10-06 22:28:00 +00:00
2018-07-06 13:30:00 +00:00
public int follow_id;
}
}