Merge branch 'master' of git.etztech.xyz:Etzelia/QoL

master
Joey Hines 2018-09-26 15:48:47 -05:00
commit a46c7a6e56
4 changed files with 45 additions and 13 deletions

View File

@ -15,6 +15,7 @@ import org.dynmap.DynmapAPI;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
public class QoL extends JavaPlugin {
@ -60,6 +61,8 @@ public class QoL extends JavaPlugin {
getServer().getPluginManager().registerEvents(asyncPlayerChatListener, this);
LoginListener loginListener = new LoginListener(this);
getServer().getPluginManager().registerEvents(loginListener, this);
JoinListener joinListener = new JoinListener(this);
getServer().getPluginManager().registerEvents(joinListener, this);
BlockIgniteListener blockIgniteListener = new BlockIgniteListener(this);
getServer().getPluginManager().registerEvents(blockIgniteListener, this);
CommandPreprocessListener commandPreprocessListener = new CommandPreprocessListener(this);

View File

@ -49,7 +49,7 @@ public class ListCommand implements CommandExecutor {
parts.set(i, StringUtils.capitalize(parts.get(i)));
}
List<String> names = list.get(key);
message.append(ChatColor.GOLD)
message.append("\n").append(ChatColor.GOLD)
.append(StringUtils.join(parts, " "))
.append(" (")
@ -59,8 +59,7 @@ public class ListCommand implements CommandExecutor {
.append("): ")
.append(ChatColor.YELLOW)
.append(StringUtils.join(names, ", "))
.append("\n");
.append(StringUtils.join(names, ", "));
}
commandSender.sendMessage(message.toString());

View File

@ -0,0 +1,40 @@
package xyz.etztech.qol.listeners;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import xyz.etztech.qol.QoL;
public class JoinListener implements Listener {
private QoL plugin;
public JoinListener(QoL plugin) {
this.plugin = plugin;
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
// First login
final Player player = event.getPlayer();
if (!player.hasPlayedBefore()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (player != p) {
p.sendMessage(ChatColor.GREEN + player.getName() + " is new here! Be sure to welcome them!");
} else {
p.sendMessage(ChatColor.GREEN + "Welcome, " + player.getName() + "! Check out /rules and then /apply!");
}
}
}, 30); // ~1.5 seconds
}
}
}

View File

@ -34,16 +34,6 @@ public class LoginListener implements Listener {
}
}
// First login
if (!player.hasPlayedBefore()) {
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (p != player) {
p.sendMessage(ChatColor.YELLOW + player.getName() + " is new here!");
} else {
p.sendMessage(ChatColor.YELLOW + "Welcome, " + p.getName() + "! Check out /rules and then /apply!");
}
}
}
}
}