@@ -0,0 +1,2293 @@
+/*%0A * EmergentMUD - A modern MUD with a procedurally generated world.%0A * Copyright (C) 2016 Peter Keeler%0A *%0A * This file is part of EmergentMUD.%0A *%0A * EmergentMUD is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * EmergentMUD is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage com.emergentmud.core.event;%0A%0Aimport com.emergentmud.core.model.Entity;%0Aimport com.emergentmud.core.model.stomp.GameOutput;%0Aimport com.emergentmud.core.repository.EntityRepository;%0Aimport com.emergentmud.core.util.EntityUtil;%0Aimport org.springframework.context.ApplicationListener;%0Aimport org.springframework.context.event.ApplicationContextEvent;%0Aimport org.springframework.context.event.ContextClosedEvent;%0Aimport org.springframework.context.event.ContextStoppedEvent;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport javax.inject.Inject;%0Aimport java.util.List;%0A%0A@Component%0Apublic class GameShutdownListener implements ApplicationListener%3CApplicationContextEvent%3E %7B%0A    private EntityRepository entityRepository;%0A    private EntityUtil entityUtil;%0A%0A    @Inject%0A    public GameShutdownListener(EntityRepository entityRepository, EntityUtil entityUtil) %7B%0A        this.entityRepository = entityRepository;%0A        this.entityUtil = entityUtil;%0A    %7D%0A%0A    @Override%0A    public void onApplicationEvent(ApplicationContextEvent event) %7B%0A        if (event instanceof ContextClosedEvent %7C%7C event instanceof ContextStoppedEvent) %7B%0A            List%3CEntity%3E everyone = entityRepository.findByRoomIsNotNull();%0A            GameOutput output = new GameOutput(%22%5Bred%5DEmergentMUD is shutting down. Please check back later!%22)%0A                    .append(%22%22)%0A                    .append(%22%3E %22);%0A%0A            entityUtil.sendMessageToListeners(everyone, output);%0A        %7D%0A    %7D%0A%7D%0A

Add a shutdown listener to print a quick message right before the game disconnects everyone.