@SubscribeEvent public void serverStopping(FEModuleServerStopEvent e) { try { votifier.shutdown(); } catch (Exception e1) { FMLLog.severe("Error closing Votifier compat thread."); FMLLog.severe(e.toString()); e1.printStackTrace(); } try { log.close(); } catch (Exception e1) { e1.printStackTrace(); } try { File file = new File(moduleDir, "offlineVoteList.txt"); if (!file.exists()) { file.createNewFile(); } PrintWriter pw = new PrintWriter(file); for (VoteEvent vote : offlineList.values()) { pw.println(vote.toString()); } pw.close(); } catch (Exception e1) { e1.printStackTrace(); } }
@SubscribeEvent public void serverStarting(FEModuleServerInitEvent e) { try { votifier = new VoteReceiver(ConfigServerVote.hostname, ConfigServerVote.port); votifier.start(); } catch (Exception e1) { FMLLog.severe("Error initializing Votifier compat."); FMLLog.severe(e.toString()); e1.printStackTrace(); } try { File logFile = new File(moduleDir, "vote.log"); if (!logFile.exists()) { logFile.createNewFile(); } log = new PrintWriter(logFile); } catch (Exception e1) { e1.printStackTrace(); } try { File file = new File(moduleDir, "offlineVoteList.txt"); if (file.exists()) { BufferedReader br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) { if (!(line.startsWith("#") || line.isEmpty())) { VoteEvent vote = new VoteEvent(line.trim()); offlineList.put(vote.player, vote); } } br.close(); } } catch (Exception e1) { e1.printStackTrace(); } }