Arcturus-Community/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java

58 lines
2.1 KiB
Java
Raw Normal View History

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