forked from Minecraft/QoL
/list totals and welcome message
Added totals to each group in /list Added a welcome message for new players, and a message to other players to welcome themmaster
parent
6ef47e7804
commit
36b1482700
|
@ -14,6 +14,7 @@ import xyz.etztech.qol.other.TPSRunnable;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class QoL extends JavaPlugin {
|
||||
|
@ -52,6 +53,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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue