Move getOnlinePlayers() from Utils to BukkitService; delete Wrapper
This commit is contained in:
@@ -19,6 +19,7 @@ import fr.xephi.authme.util.ValidationService;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -231,4 +232,12 @@ public class CommandService {
|
||||
return bukkitService.getPlayerExact(name);
|
||||
}
|
||||
|
||||
public Collection<? extends Player> getOnlinePlayers() {
|
||||
return bukkitService.getOnlinePlayers();
|
||||
}
|
||||
|
||||
public BukkitService getBukkitService() {
|
||||
return bukkitService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,10 +63,9 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setTimeoutTask(id);
|
||||
}
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTask(
|
||||
scheduler.runTask(
|
||||
plugin, new MessageTask(plugin, playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)
|
||||
)
|
||||
);
|
||||
scheduler.runTask(plugin, new MessageTask(commandService.getBukkitService(), plugin.getMessages(),
|
||||
playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)));
|
||||
|
||||
if (commandService.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.properties.PluginSettings.HELP_HEADER;
|
||||
@@ -22,11 +22,12 @@ public class VersionCommand implements ExecutableCommand {
|
||||
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName()
|
||||
+ " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")");
|
||||
sender.sendMessage(ChatColor.GOLD + "Developers:");
|
||||
printDeveloper(sender, "Xephi", "xephi59", "Lead Developer");
|
||||
printDeveloper(sender, "DNx5", "DNx5", "Developer");
|
||||
printDeveloper(sender, "games647", "games647", "Developer");
|
||||
printDeveloper(sender, "Tim Visee", "timvisee", "Developer");
|
||||
printDeveloper(sender, "Sgdc3", "sgdc3", "Project manager, Contributor");
|
||||
Collection<? extends Player> onlinePlayers = commandService.getOnlinePlayers();
|
||||
printDeveloper(sender, "Xephi", "xephi59", "Lead Developer", onlinePlayers);
|
||||
printDeveloper(sender, "DNx5", "DNx5", "Developer", onlinePlayers);
|
||||
printDeveloper(sender, "games647", "games647", "Developer", onlinePlayers);
|
||||
printDeveloper(sender, "Tim Visee", "timvisee", "Developer", onlinePlayers);
|
||||
printDeveloper(sender, "Sgdc3", "sgdc3", "Project manager, Contributor", onlinePlayers);
|
||||
sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.WHITE +
|
||||
"http://dev.bukkit.org/bukkit-plugins/authme-reloaded/");
|
||||
sender.sendMessage(ChatColor.GOLD + "License: " + ChatColor.WHITE + "GNU GPL v3.0"
|
||||
@@ -38,12 +39,14 @@ public class VersionCommand implements ExecutableCommand {
|
||||
/**
|
||||
* Print a developer with proper styling.
|
||||
*
|
||||
* @param sender The command sender.
|
||||
* @param name The display name of the developer.
|
||||
* @param minecraftName The Minecraft username of the developer, if available.
|
||||
* @param function The function of the developer.
|
||||
* @param sender The command sender
|
||||
* @param name The display name of the developer
|
||||
* @param minecraftName The Minecraft username of the developer, if available
|
||||
* @param function The function of the developer
|
||||
* @param onlinePlayers The list of online players
|
||||
*/
|
||||
private static void printDeveloper(CommandSender sender, String name, String minecraftName, String function) {
|
||||
private static void printDeveloper(CommandSender sender, String name, String minecraftName, String function,
|
||||
Collection<? extends Player> onlinePlayers) {
|
||||
// Print the name
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(" ")
|
||||
@@ -55,7 +58,7 @@ public class VersionCommand implements ExecutableCommand {
|
||||
msg.append(ChatColor.GRAY).append(ChatColor.ITALIC).append(" (").append(function).append(")");
|
||||
|
||||
// Show the online status
|
||||
if (isPlayerOnline(minecraftName)) {
|
||||
if (isPlayerOnline(minecraftName, onlinePlayers)) {
|
||||
msg.append(ChatColor.GREEN).append(ChatColor.ITALIC).append(" (In-Game)");
|
||||
}
|
||||
|
||||
@@ -66,12 +69,13 @@ public class VersionCommand implements ExecutableCommand {
|
||||
/**
|
||||
* Check whether a player is online.
|
||||
*
|
||||
* @param minecraftName The Minecraft player name.
|
||||
* @param minecraftName The Minecraft player name
|
||||
* @param onlinePlayers List of online players
|
||||
*
|
||||
* @return True if the player is online, false otherwise.
|
||||
* @return True if the player is online, false otherwise
|
||||
*/
|
||||
private static boolean isPlayerOnline(String minecraftName) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
private static boolean isPlayerOnline(String minecraftName, Collection<? extends Player> onlinePlayers) {
|
||||
for (Player player : onlinePlayers) {
|
||||
if (player.getName().equalsIgnoreCase(minecraftName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user