Merge branch 'ms4-unstable' into 'ms4-unstable'

ChangeNameCommand now allows you to Name Change others.

See merge request morningstar/Arcturus-Community!558
This commit is contained in:
Harmonic 2022-05-05 12:57:40 +00:00
commit eb6bf8f6c6
2 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,3 @@
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_changename.user_not_found', 'The Habbo %user% does not exist or is not online.');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.succes.cmd_changename.done', 'Successfully toggled the name change for the Habbo %user%.');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.succes.cmd_changename.received', 'Hotel staff requests for you to change your name.\n Please click on your Habbo then click on the "Change Your Name" button.');

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands;
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.users.UserObjectComposer;
public class ChangeNameCommand extends Command {
@ -11,8 +12,27 @@ public class ChangeNameCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
gameClient.getHabbo().getHabboStats().allowNameChange = !gameClient.getHabbo().getHabboStats().allowNameChange;
gameClient.sendResponse(new UserObjectComposer(gameClient.getHabbo()));
// check if there are no params
if (params.length < 2) {
gameClient.getHabbo().getHabboStats().allowNameChange = !gameClient.getHabbo().getHabboStats().allowNameChange;
gameClient.sendResponse(new UserObjectComposer(gameClient.getHabbo()));
return true;
}
// check if the habbo exists or is online
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
if ( habbo == null) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_changename.user_not_found").replace("%user%", params[1]));
return true;
}
// this runs if params[1] is a valid habbo
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_changename.done").replace("%user%", params[1]));
habbo.alert(Emulator.getTexts().getValue("commands.succes.cmd_changename.received"));
habbo.getHabboStats().allowNameChange = !habbo.getHabboStats().allowNameChange;
habbo.getClient().sendResponse(new UserObjectComposer(habbo));
return true;
}
}