use of io.xol.chunkstories.api.events.player.PlayerLogoutEvent in project chunkstories by Hugobros3.
the class Ingame method destroy.
@Override
public void destroy() {
// Logout sequence: Save the player entity
if (world instanceof WorldMaster) {
Player player = getPlayer();
PlayerLogoutEvent playerDisconnectionEvent = new PlayerLogoutEvent(player);
world.getPluginManager().fireEvent(playerDisconnectionEvent);
if (this.playerEntity != null) {
SerializedEntityFile playerEntityFile = new SerializedEntityFile(world.getFolderPath() + "/players/" + getPlayer().getName().toLowerCase() + ".csf");
playerEntityFile.write(this.playerEntity);
}
}
// Stop the game logic and save
if (world instanceof WorldMaster) {
// TODO: Stop simulation
Fence fence = ((WorldMaster) world).stopLogic();
// exitButton.text = "#{world.saving}";
fence.traverse();
fence = world.saveEverything();
// exitButton.text = "#{world.saving}";
fence.traverse();
}
// Disables plugins
world.getPluginManager().disablePlugins();
this.world.getWorldRenderer().destroy();
}
use of io.xol.chunkstories.api.events.player.PlayerLogoutEvent in project chunkstories by Hugobros3.
the class ClientConnection method close.
@Override
public boolean close() {
clientsManager.removeClient(this);
if (player != null) {
PlayerLogoutEvent playerDisconnectionEvent = new PlayerLogoutEvent(player);
clientsManager.getServer().getPluginManager().fireEvent(playerDisconnectionEvent);
clientsManager.getServer().broadcastMessage(playerDisconnectionEvent.getLogoutMessage());
player.destroy();
}
return true;
}
Aggregations