Search in sources :

Example 1 with GuildDeleteEvent

use of io.discloader.discloader.common.event.guild.GuildDeleteEvent in project DiscLoader by R3alCl0ud.

the class GuildDelete method handle.

@Override
public void handle(SocketPacket packet) {
    String d = this.gson.toJson(packet.d);
    GuildJSON data = this.gson.fromJson(d, GuildJSON.class);
    IGuild guild = null;
    if (EntityRegistry.guildExists(data.id)) {
        guild = EntityRegistry.getGuildByID(data.id);
        guild.setup(data);
    } else {
        guild = EntityRegistry.addGuild(data);
    }
    if (!guild.isAvailable()) {
        EntityRegistry.removeGuild(guild);
        if (socket.status == Status.READY && loader.ready) {
            GuildDeleteEvent event = new GuildDeleteEvent(guild);
            loader.emit(Events.GUILD_DELETE, event);
            for (IEventListener e : loader.handlers) {
                e.GuildDelete(event);
            }
        }
    }
}
Also used : GuildDeleteEvent(io.discloader.discloader.common.event.guild.GuildDeleteEvent) IEventListener(io.discloader.discloader.common.event.IEventListener) GuildJSON(io.discloader.discloader.network.json.GuildJSON) IGuild(io.discloader.discloader.entity.guild.IGuild)

Aggregations

IEventListener (io.discloader.discloader.common.event.IEventListener)1 GuildDeleteEvent (io.discloader.discloader.common.event.guild.GuildDeleteEvent)1 IGuild (io.discloader.discloader.entity.guild.IGuild)1 GuildJSON (io.discloader.discloader.network.json.GuildJSON)1