diff --git a/sqlupdates/3_5_0 to 4_0_0.sql b/sqlupdates/3_5_0 to 4_0_0.sql new file mode 100644 index 00000000..c04dbb5d --- /dev/null +++ b/sqlupdates/3_5_0 to 4_0_0.sql @@ -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.'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java index 213842bc..da17cc8f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java @@ -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; } }