Arcturus-Community/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeNameDescEvent.java

46 lines
1.6 KiB
Java
Raw Normal View History

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;
public class GuildChangeNameDescEvent extends MessageHandler
{
@Override
public void handle() throws Exception
{
int guildId = this.packet.readInt();
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
if(guild != null)
{
if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin"))
{
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());
if (room != null && !room.getCurrentHabbos().isEmpty())
{
room.refreshGuild(guild);
}
}
}
}
}