2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.messages.incoming.guilds;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.Room;
|
|
|
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
|
|
|
import com.eu.habbo.plugin.events.guilds.GuildChangedNameEvent;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class GuildChangeNameDescEvent extends MessageHandler {
|
2018-07-06 15:30:00 +02:00
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void handle() throws Exception {
|
2018-07-06 15:30:00 +02:00
|
|
|
int guildId = this.packet.readInt();
|
|
|
|
|
|
|
|
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (guild != null) {
|
|
|
|
if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) {
|
2018-07-06 15:30:00 +02:00
|
|
|
GuildChangedNameEvent nameEvent = new GuildChangedNameEvent(guild, this.packet.readString(), this.packet.readString());
|
|
|
|
Emulator.getPluginManager().fireEvent(nameEvent);
|
|
|
|
|
|
|
|
if (nameEvent.isCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (guild.getName().equals(nameEvent.name) && guild.getDescription().equals(nameEvent.description))
|
|
|
|
return;
|
|
|
|
|
|
|
|
guild.setName(nameEvent.name);
|
|
|
|
guild.setDescription(nameEvent.description);
|
|
|
|
guild.needsUpdate = true;
|
|
|
|
guild.run();
|
|
|
|
|
|
|
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (room != null && !room.getCurrentHabbos().isEmpty()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
room.refreshGuild(guild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|