2018-10-07 00:28:00 +02:00
|
|
|
package com.eu.habbo.messages.rcon;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class IgnoreUser extends RCONMessage<IgnoreUser.JSONIgnoreUser> {
|
|
|
|
public IgnoreUser() {
|
2018-10-07 00:28:00 +02:00
|
|
|
super(JSONIgnoreUser.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void handle(Gson gson, JSONIgnoreUser object) {
|
2018-10-07 00:28:00 +02:00
|
|
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
2018-10-07 00:28:00 +02:00
|
|
|
habbo.getHabboStats().ignoreUser(object.target_id);
|
2019-05-26 20:14:53 +02:00
|
|
|
} else {
|
2018-10-07 00:28:00 +02:00
|
|
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
2019-05-26 20:14:53 +02:00
|
|
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {
|
2018-10-07 00:28:00 +02:00
|
|
|
statement.setInt(1, object.user_id);
|
|
|
|
statement.setInt(2, object.target_id);
|
|
|
|
statement.execute();
|
2019-05-26 20:14:53 +02:00
|
|
|
} catch (SQLException e) {
|
2020-05-03 01:46:07 +02:00
|
|
|
logger.error("Caught SQL exception", e);
|
2018-10-07 00:28:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.message = "offline";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
static class JSONIgnoreUser {
|
2018-10-07 00:28:00 +02:00
|
|
|
|
|
|
|
public int user_id;
|
|
|
|
|
|
|
|
public int target_id;
|
|
|
|
}
|
|
|
|
}
|