use of com.earth2me.essentials.textreader.TextInput in project Essentials by drtshock.
the class EssentialsPlayerListener method delayedJoin.
public void delayedJoin(final Player player, final String message) {
if (!player.isOnline()) {
return;
}
ess.getBackup().onPlayerJoin();
final User dUser = ess.getUser(player);
dUser.startTransaction();
if (dUser.isNPC()) {
dUser.setNPC(false);
}
final long currentTime = System.currentTimeMillis();
dUser.checkMuteTimeout(currentTime);
dUser.updateActivity(false);
dUser.stopTransaction();
IText tempInput = null;
if (!ess.getSettings().isCommandDisabled("motd")) {
try {
tempInput = new TextInput(dUser.getSource(), "motd", true, ess);
} catch (IOException ex) {
if (ess.getSettings().isDebug()) {
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
} else {
LOGGER.log(Level.WARNING, ex.getMessage());
}
}
}
final IText input = tempInput;
class DelayJoinTask implements Runnable {
@Override
public void run() {
final User user = ess.getUser(player);
if (!user.getBase().isOnline()) {
return;
}
user.startTransaction();
user.setLastAccountName(user.getBase().getName());
user.setLastLogin(currentTime);
user.setDisplayNick();
updateCompass(user);
if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see")) {
for (String p : ess.getVanishedPlayers()) {
Player toVanish = ess.getServer().getPlayerExact(p);
if (toVanish != null && toVanish.isOnline()) {
user.getBase().hidePlayer(toVanish);
}
}
}
if (user.isAuthorized("essentials.sleepingignored")) {
user.getBase().setSleepingIgnored(true);
}
if (ess.getSettings().allowSilentJoinQuit() && (user.isAuthorized("essentials.silentjoin") || user.isAuthorized("essentials.silentjoin.vanish"))) {
if (user.isAuthorized("essentials.silentjoin.vanish")) {
user.setVanished(true);
}
} else if (message == null) {
//NOOP
} else if (ess.getSettings().isCustomJoinMessage()) {
String msg = ess.getSettings().getCustomJoinMessage().replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName()).replace("{UNIQUE}", NumberFormat.getInstance().format(ess.getUserMap().getUniqueUsers()));
ess.getServer().broadcastMessage(msg);
} else if (ess.getSettings().allowSilentJoinQuit()) {
ess.getServer().broadcastMessage(message);
}
if (input != null && user.isAuthorized("essentials.motd")) {
final IText output = new KeywordReplacer(input, user.getSource(), ess);
final TextPager pager = new TextPager(output, true);
pager.showPage("1", null, "motd", user.getSource());
}
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail")) {
final List<String> mail = user.getMails();
if (mail.isEmpty()) {
if (ess.getSettings().isNotifyNoNewMail()) {
// Only notify if they want us to.
user.sendMessage(tl("noNewMail"));
}
} else {
user.sendMessage(tl("youHaveNewMail", mail.size()));
}
}
if (user.isAuthorized("essentials.fly.safelogin")) {
user.getBase().setFallDistance(0);
if (LocationUtil.shouldFly(user.getLocation())) {
user.getBase().setAllowFlight(true);
user.getBase().setFlying(true);
if (ess.getSettings().isSendFlyEnableOnJoin()) {
user.getBase().sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
}
}
}
if (!user.isAuthorized("essentials.speed")) {
user.getBase().setFlySpeed(0.1f);
user.getBase().setWalkSpeed(0.2f);
}
if (user.isSocialSpyEnabled() && !user.isAuthorized("essentials.socialspy")) {
user.setSocialSpyEnabled(false);
ess.getLogger().log(Level.INFO, "Set socialspy to false for {0} because they had it enabled without permission.", user.getName());
}
user.stopTransaction();
}
}
ess.scheduleSyncDelayedTask(new DelayJoinTask());
}
Aggregations