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.google.gson.Gson;
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
public class MuteUser extends RCONMessage<MuteUser.JSON>
|
|
|
|
{
|
2018-12-22 10:39:00 +00:00
|
|
|
public MuteUser()
|
2018-07-06 13:30:00 +00:00
|
|
|
{
|
2018-12-22 10:39:00 +00:00
|
|
|
super(MuteUser.JSON.class);
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handle(Gson gson, JSON json)
|
|
|
|
{
|
|
|
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id);
|
|
|
|
|
|
|
|
if (habbo != null)
|
|
|
|
{
|
|
|
|
if (json.duration == 0)
|
|
|
|
{
|
|
|
|
habbo.unMute();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
habbo.mute(json.duration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET mute_end_timestamp = ? WHERE user_id = ? LIMIT 1"))
|
|
|
|
{
|
|
|
|
statement.setInt(1, Emulator.getIntUnixTimestamp() + json.duration);
|
|
|
|
statement.setInt(2, json.user_id);
|
|
|
|
if (statement.executeUpdate() == 0)
|
|
|
|
{
|
|
|
|
this.status = HABBO_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (SQLException e)
|
|
|
|
{
|
2019-03-18 01:22:00 +00:00
|
|
|
Emulator.getLogging().logSQLException(e);
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 01:22:00 +00:00
|
|
|
static class JSON
|
2018-07-06 13:30:00 +00:00
|
|
|
{
|
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 duration;
|
|
|
|
}
|
|
|
|
}
|