Add give user clothing RCON command

This commit is contained in:
Alejandro 2019-05-26 23:59:55 +03:00
parent 35446586e0
commit 1d8b82c4ec
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,47 @@
package com.eu.habbo.messages.rcon;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.users.UserClothesComposer;
import com.google.gson.Gson;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class GiveUserClothing extends RCONMessage<GiveUserClothing.JSONGiveUserClothing> {
public GiveUserClothing() {
super(GiveUserClothing.JSONGiveUserClothing.class);
}
@Override
public void handle(Gson gson, GiveUserClothing.JSONGiveUserClothing object) {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_clothing (user_id, clothing_id) VALUES (?, ?)")) {
statement.setInt(1, object.user_id);
statement.setInt(2, object.clothing_id);
statement.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
if (habbo != null) {
GameClient client = habbo.getClient();
if (client != null) {
habbo.getInventory().getWardrobeComponent().getClothing().add(object.clothing_id);
client.sendResponse(new UserClothesComposer(habbo));
client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FIGURESET_REDEEMED.key));
}
}
}
static class JSONGiveUserClothing {
public int user_id;
public int clothing_id;
}
}

View File

@ -56,6 +56,7 @@ public class RCONServer extends Server {
this.addRCONMessage("giverespect", GiveRespect.class);
this.addRCONMessage("ignoreuser", IgnoreUser.class);
this.addRCONMessage("setmotto", SetMotto.class);
this.addRCONMessage("giveuserclothing", GiveUserClothing.class);
Collections.addAll(this.allowedAdresses, Emulator.getConfig().getValue("rcon.allowed", "127.0.0.1").split(";"));
}