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