@Override public void startup() { frontEnd.addMailListener( new PlayerMailListener() { @Override public void notifyMail(Player who, Message m) { if (who.getAttr(Attribute.FORWARD_EMAIL).booleanValue() && (m.getType() == PlayerMessageType.MESSAGE)) { try { AuthService authService = frontEnd.findService(AuthService.class); String email = authService.getEmail(who.getPrimaryIdentity()); if (email == null) { logger.fine("Forwarding to email failed. " + who + " has no email adress."); return; } logger.fine("Forwarding message for " + who + " to email " + email); Player sender = m.getSender(frontEnd.getGalaxy()); String subject = m.getSubject(EMAIL_CONVERTER); String text = m.getText(EMAIL_CONVERTER); Email em = new Email(email); em.setSubject("[Conquer-Space.net] " + subject); em.setBody( sender.getName() + " schreibt an " + who.getName() + ":\n\n" + text + "\n"); frontEnd.findService(SmtpService.class).sendEmail(em); } catch (Exception e) { logger.log(Level.SEVERE, "Exception caught", e); } } } }); }
public boolean hasNewAllianceMessage(Player p) { Alliance a = p.getAlliance(); if (a == null) return false; AllianceData ad = AllianceData.getAllianceDataCopy(frontEnd.getStorageManager(), a.getId()); return (p.getAllianceReadTime() <= ad.getMail().getFolder(0).getLastAddRealTime()) && (ad.getMail().folderSize(0) > 0); }
public <T extends Service> T findService(Class<T> type) { return frontEnd.findService(type); }
public int countOnlinePlayers() { return frontEnd.online(); }
public boolean isOnline(Player p) { return frontEnd.isOnline(p); }
public String getSupportEmail() { return frontEnd.getSupportEmail(); }
public String getVersion() { return frontEnd.version(); }
public boolean debug() { return frontEnd.debug(); }
public ObserverReport getObserverReport(String id) { return ObserverReport.getObserverReportCopy(frontEnd.getStorageManager(), id); }
public String getUrl() { return frontEnd.url(); }
public AgentReport getAgentReport(String id) { return AgentReport.getAgentReportCopy(frontEnd.getStorageManager(), id); }
public BattleReport getBattleReport(String id) { return BattleReport.getBattleReportCopy(frontEnd.getStorageManager(), id); }
public MoneyData getMoneyReport(Player player) { return MoneyData.getMoneyDataCopy(frontEnd.getStorageManager(), player.getPid()); }
public List<Locale> getSupportedLocales() { return frontEnd.getLocaleProvider().getAvailableLocales(); }
public long getRandomLong() { return frontEnd.getGalaxy().getRandomLong(); }