예제 #1
0
파일: SmtpGate.java 프로젝트: ulfjack/cqs
  @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);
              }
            }
          }
        });
  }
예제 #2
0
 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);
 }
예제 #3
0
 public <T extends Service> T findService(Class<T> type) {
   return frontEnd.findService(type);
 }
예제 #4
0
 public int countOnlinePlayers() {
   return frontEnd.online();
 }
예제 #5
0
 public boolean isOnline(Player p) {
   return frontEnd.isOnline(p);
 }
예제 #6
0
 public String getSupportEmail() {
   return frontEnd.getSupportEmail();
 }
예제 #7
0
 public String getVersion() {
   return frontEnd.version();
 }
예제 #8
0
 public boolean debug() {
   return frontEnd.debug();
 }
예제 #9
0
 public ObserverReport getObserverReport(String id) {
   return ObserverReport.getObserverReportCopy(frontEnd.getStorageManager(), id);
 }
예제 #10
0
 public String getUrl() {
   return frontEnd.url();
 }
예제 #11
0
 public AgentReport getAgentReport(String id) {
   return AgentReport.getAgentReportCopy(frontEnd.getStorageManager(), id);
 }
예제 #12
0
 public BattleReport getBattleReport(String id) {
   return BattleReport.getBattleReportCopy(frontEnd.getStorageManager(), id);
 }
예제 #13
0
 public MoneyData getMoneyReport(Player player) {
   return MoneyData.getMoneyDataCopy(frontEnd.getStorageManager(), player.getPid());
 }
예제 #14
0
 public List<Locale> getSupportedLocales() {
   return frontEnd.getLocaleProvider().getAvailableLocales();
 }
예제 #15
0
 public long getRandomLong() {
   return frontEnd.getGalaxy().getRandomLong();
 }