mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-26 18:47:37 +01:00
change all usage of getOnlinePlayers
This commit is contained in:
parent
8701733b30
commit
7c56dec476
@ -731,7 +731,7 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.isOnline()) {
|
||||
String name = player.getName().toLowerCase();
|
||||
if (database.isAuthAvailable(name))
|
||||
@ -776,7 +776,7 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
public boolean isLoggedIp(String name, String ip) {
|
||||
int count = 0;
|
||||
for (Player player : this.getServer().getOnlinePlayers()) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (ip.equalsIgnoreCase(getIP(player)) && database.isLogged(player.getName().toLowerCase()) && !player.getName().equalsIgnoreCase(name))
|
||||
count++;
|
||||
}
|
||||
@ -785,7 +785,7 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
public boolean hasJoinedIp(String name, String ip) {
|
||||
int count = 0;
|
||||
for (Player player : this.getServer().getOnlinePlayers()) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (ip.equalsIgnoreCase(getIP(player)) && !player.getName().equalsIgnoreCase(name))
|
||||
count++;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class DataManager {
|
||||
public synchronized Boolean call() throws Exception {
|
||||
Boolean result = null;
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOnlinePlayers())
|
||||
for (OfflinePlayer op : Utils.getOnlinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
result = true;
|
||||
break;
|
||||
|
@ -62,7 +62,7 @@ public class JsonCache {
|
||||
|
||||
try {
|
||||
String data = gson.toJson(playerData);
|
||||
Files.write(Paths.get(file.getPath()), data.getBytes());
|
||||
Files.write(file.toPath(), data.getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class JsonCache {
|
||||
|
||||
File file = new File(cacheDir, path + File.separator + "cache.json");
|
||||
try {
|
||||
byte[] bytes = Files.readAllBytes(Paths.get(file.getPath()));
|
||||
byte[] bytes = Files.readAllBytes(file.toPath());
|
||||
String str = new String(bytes);
|
||||
return gson.fromJson(str, DataFileCache.class);
|
||||
} catch (Exception e) {
|
||||
|
@ -3,6 +3,7 @@ package fr.xephi.authme.datasource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import fr.xephi.authme.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
@ -140,7 +141,7 @@ public class CacheDataSource implements DataSource {
|
||||
public void reload() {
|
||||
cache.clear();
|
||||
source.reload();
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
String user = player.getName().toLowerCase();
|
||||
if (PlayerCache.getInstance().isAuthenticated(user)) {
|
||||
try {
|
||||
|
@ -553,7 +553,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (playersOnline > plugin.getServer().getMaxPlayers()) {
|
||||
event.allow();
|
||||
} else {
|
||||
final Player pl = plugin.generateKickPlayer(plugin.getServer().getOnlinePlayers());
|
||||
final Player pl = plugin.generateKickPlayer(Utils.getOnlinePlayers());
|
||||
if (pl != null) {
|
||||
pl.kickPlayer(m.send("kick_forvip")[0]);
|
||||
event.allow();
|
||||
|
@ -3,6 +3,7 @@ package fr.xephi.authme.process.login;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -239,7 +240,7 @@ public class AsyncronousLogin {
|
||||
* uuidaccounts = uuidaccounts + ", "; } else { uuidaccounts =
|
||||
* uuidaccounts + "."; } }
|
||||
*/
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
||||
player.sendMessage(message);
|
||||
|
@ -177,7 +177,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
// We can now display the join message
|
||||
if (AuthMePlayerListener.joinMessage.containsKey(name) && AuthMePlayerListener.joinMessage.get(name) != null && !AuthMePlayerListener.joinMessage.get(name).isEmpty()) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
for (Player p : Utils.getOnlinePlayers()) {
|
||||
if (p.isOnline())
|
||||
p.sendMessage(AuthMePlayerListener.joinMessage.get(name));
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.Resources;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -9,7 +7,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public class CustomConfiguration extends YamlConfiguration {
|
||||
|
||||
@ -62,15 +62,11 @@ public class CustomConfiguration extends YamlConfiguration {
|
||||
if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
|
||||
return false;
|
||||
}
|
||||
if (!file.exists() && !file.createNewFile()) {
|
||||
return false;
|
||||
}
|
||||
int i = file.getPath().indexOf("AuthMe");
|
||||
if (i > -1) {
|
||||
String path = file.getPath().substring(i + 6).replace('\\', '/');
|
||||
URL url = Resources.getResource(getClass(), path);
|
||||
byte[] bytes = Resources.toByteArray(url);
|
||||
Files.write(bytes, file);
|
||||
InputStream is = getClass().getResourceAsStream(path);
|
||||
Files.copy(is, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package fr.xephi.authme.task;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class MessageTask implements Runnable {
|
||||
|
||||
@ -15,7 +15,7 @@ public class MessageTask implements Runnable {
|
||||
private int interval;
|
||||
|
||||
public MessageTask(AuthMe plugin, String name, String[] strings,
|
||||
int interval) {
|
||||
int interval) {
|
||||
this.plugin = plugin;
|
||||
this.name = name;
|
||||
this.msg = strings;
|
||||
@ -27,7 +27,7 @@ public class MessageTask implements Runnable {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
for (String ms : msg) {
|
||||
player.sendMessage(ms);
|
||||
|
Loading…
Reference in New Issue
Block a user