@Override public void run() { Collection<? extends Player> players = Bukkit.getOnlinePlayers(); long maxAFKTime; SinCityPlayer thisPlayer; for (Player player : players) { if (!player.isOnline() || player.isDead()) continue; thisPlayer = this.playerManager.getPlayer(player); maxAFKTime = this.dataManager.getMaxAFKTime(thisPlayer.getGroup()); // WHEN AFK TIMER IS REACHED AND (PLAYER HAS NOT MOVED OR IS INSIDE // A VEHICLE) (PREVENT ABUSE!) if (maxAFKTime >= 0) { if (player.isInsideVehicle() || thisPlayer.hasMoved(player.getLocation())) { thisPlayer.setLastLocation(player.getLocation()); return; } if (thisPlayer.isTooLongAFK(maxAFKTime)) { ConsoleUtils.printInfo(Core.NAME, "Kicked '" + player.getName() + "' for being AFK!"); player.kickPlayer("Kicked being AFK!"); } } else { thisPlayer.setLastLocation(player.getLocation()); } } }
private void loadSettings(File dataFolder) { File configFile = new File(dataFolder, "mailConfig.yml"); try { YamlConfiguration config = new YamlConfiguration(); config.load(configFile); // Standardized Properties to talk with SMTP Server Properties properties = System.getProperties(); // HOST properties.setProperty("mail.smtp.host", config.getString("smtp.host")); // PORT properties.setProperty("mail.smtp.port", config.getString("smtp.port")); // Has an Authentifaction properties.setProperty("mail.smtp.auth", "true"); // Create session session = Session.getDefaultInstance( properties, new MailAuthenticator( config.getString("smtp.username"), config.getString("smtp.password"))); // Get Addresses from = new InternetAddress(config.getString("smtp.from")); to = new InternetAddress(config.getString("smtp.to")); } catch (Exception e) { ConsoleUtils.printException(e, Core.NAME, "Can't initiate E-Mail settings!"); } }
/** * Compare the version tag from the config with the plugin version. If their differ, an outdate * warning is printed on console * * @param pluginName The name of the plugin using this configuration file * @param pluginVersion The version of the plugin using this configuration file */ private void checkVersion(String pluginName, String pluginVersion) { String confVersion = getString("VERSION"); if (confVersion != null && !confVersion.equals(pluginVersion)) ConsoleUtils.printWarning( pluginName, "The config '" + configFile + "' is out of date! Plugin Version is " + pluginVersion + " but Config Version is " + confVersion + " !"); }
// sending the mail private boolean sendMail(String subject, String message) { MimeMessage msg = new MimeMessage(session); try { msg.setFrom(from); msg.setSubject(subject); msg.setText(message); msg.setRecipient(Message.RecipientType.TO, to); Transport.send(msg); return true; } catch (Exception e) { ConsoleUtils.printException(e, Core.NAME, "Can't send mail!"); return false; } }