use of com.earth2me.essentials.textreader.SimpleTextPager in project Essentials by drtshock.
the class EssentialsSpawnPlayerListener method delayedJoin.
public void delayedJoin(final Player player) {
if (player.hasPlayedBefore()) {
LOGGER.log(Level.FINE, "Old player join");
List<String> spawnOnJoinGroups = ess.getSettings().getSpawnOnJoinGroups();
if (!spawnOnJoinGroups.isEmpty()) {
final User user = ess.getUser(player);
if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) {
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
Location spawn = spawns.getSpawn(user.getGroup());
try {
// We don't use user.getTeleport() because it stores last location, which is unwanted in this case.
user.getBase().teleport(spawn, TeleportCause.PLUGIN);
} catch (Exception e) {
ess.showError(user.getSource(), e, "spawn-on-join");
}
}
});
}
}
return;
}
final User user = ess.getUser(player);
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn())) {
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
}
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
if (!user.getBase().isOnline()) {
return;
}
//This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg
if (ess.getSettings().getAnnounceNewPlayers()) {
final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getSource(), ess);
final SimpleTextPager pager = new SimpleTextPager(output);
for (String line : pager.getLines()) {
ess.broadcastMessage(user, line);
}
}
final String kitName = ess.getSettings().getNewPlayerKit();
if (!kitName.isEmpty()) {
try {
final Kit kit = new Kit(kitName.toLowerCase(Locale.ENGLISH), ess);
kit.expandItems(user);
} catch (Exception ex) {
LOGGER.log(Level.WARNING, ex.getMessage());
}
}
LOGGER.log(Level.FINE, "New player join");
}
}, 2L);
}
Aggregations