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

46 lines
1.4 KiB
Java
Raw Normal View History

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;
2020-05-04 22:24:09 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2018-10-07 00:28:00 +02:00
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> {
2020-05-04 22:24:09 +02:00
private static final Logger LOGGER = LoggerFactory.getLogger(IgnoreUser.class);
2019-05-26 20:14:53 +02:00
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) {
habbo.getHabboStats().ignoreUser(habbo.getClient(), 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-04 22:24:09 +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;
}
}