mirror of
https://github.com/darverdevs/Uranium.git
synced 2024-12-21 22:54:10 -08:00
feat: add IP/domain detection task
This commit is contained in:
parent
98ee42ad48
commit
80f7df8eb4
|
@ -1,6 +1,11 @@
|
|||
package uranium.tasks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import uranium.Main;
|
||||
import uranium.user.UserManager;
|
||||
import uranium.util.Util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IPCheck implements Runnable {
|
||||
|
||||
|
@ -11,7 +16,30 @@ public class IPCheck implements Runnable {
|
|||
}
|
||||
|
||||
public void run() {
|
||||
UserManager.getUsers().forEach((user) -> {
|
||||
if (user.getIP() == null || user.getDomain() == null) {
|
||||
Player player = user.getPlayer();
|
||||
user.onJoin();
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
if (UserManager.getUser(player) == null) return;
|
||||
if (!plugin.getConfig().getBoolean("suspicious-domains.enabled")) return;
|
||||
List<String> trustedDomains = plugin.getConfig().getStringList("suspicious-domains.trusted-domains");
|
||||
String prefix = plugin.getConfig().getString("prefix");
|
||||
boolean offlineDownload = plugin.getConfig().getBoolean("suspicious-domains.offline-download");
|
||||
boolean debugRuntime = plugin.getConfig().getBoolean("suspicious-domains.debug-runtime");
|
||||
if (user.getDomain() == null) return;
|
||||
if (trustedDomains.contains(user.getDomain())) return;
|
||||
|
||||
if (offlineDownload && user.getDomain().equalsIgnoreCase("null"))
|
||||
Util.sendStaff(prefix + "&c" + user.getName() + "&7 joined using an offline download.");
|
||||
else if (debugRuntime && user.getDomain().equalsIgnoreCase(""))
|
||||
Util.sendStaff(prefix + "&c" + user.getName() + "&7 joined using the debug runtime.");
|
||||
else
|
||||
Util.sendStaff(prefix + "&c" + user.getName() + "&7 joined using a strange domain: &c" + user.getDomain());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -20,4 +20,18 @@ public class Util {
|
|||
Bukkit.getConsoleSender().sendMessage(StringUtil.cc(message));
|
||||
}
|
||||
|
||||
public static void sendStaff(String message) {
|
||||
UserManager.getUsers().forEach((user) -> {
|
||||
if (user.hasPermission("uranium.notify")) user.sendMessage(message);
|
||||
});
|
||||
Bukkit.getConsoleSender().sendMessage(StringUtil.cc(message));
|
||||
}
|
||||
|
||||
public static void sendStaff(String message, String permission) {
|
||||
UserManager.getUsers().forEach((user) -> {
|
||||
if (user.hasPermission(permission)) user.sendMessage(message);
|
||||
});
|
||||
Bukkit.getConsoleSender().sendMessage(StringUtil.cc(message));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user