Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c25908a04 | |||
| 84a8137955 | |||
| 038d4c1850 | |||
| 0ffe2c2fc9 | |||
| 401933038d | |||
| 5cf88f308a | |||
| 29df796c48 | |||
| 79af85667e | |||
| 57237f6dfa | |||
| fc86e3ef78 | |||
| 846b7f67e5 | |||
| ffe3f5d24a | |||
| 2db1a15c72 | |||
| 95342ae054 | |||
| 6800356f10 | |||
| 95b5d88197 | |||
| 9f6f55d8e8 | |||
| d1ebcfeef0 | |||
| 5305bf0bfd | |||
| 78c5ab5d8a | |||
| 836c568fef | |||
| 7cbd1ebae7 | |||
| a35a277b32 | |||
| 971f0f7683 | |||
| d2718c1934 | |||
| 0cdd2b20d6 | |||
| 66b2bf8436 | |||
| cf01767ad3 | |||
| fdefdb88cc | |||
| 4bcc992b7f | |||
| 35aba2207b | |||
| ce2ee9e0fb | |||
| 9093ad2d9f | |||
| 08ed6504f2 | |||
| 9f70748b55 | |||
| 3f6a7ce48f | |||
| ed320196fe | |||
| 62f27f8231 | |||
| c3485903c5 | |||
| 5f3089b61b | |||
| e8f42ab669 | |||
| e3ff584bf4 | |||
| a9116a2f28 | |||
| ddd8c44396 | |||
| 6edcfa993e | |||
| e63764e2cf | |||
| 63540088c9 | |||
| 8e760e504e | |||
| bf3553df68 | |||
| 44e4937d16 | |||
| 280bb2bdcc | |||
| c0da109dea | |||
| b455d0a200 | |||
| 2f9d11e1d5 | |||
| ab85429b4c | |||
| 145dbd46f0 | |||
| 8e451b0642 | |||
| b12070a517 | |||
| 3950b3034c | |||
| 47ae657c80 | |||
| 87ef1ab8ed | |||
| a6bd4f59cb | |||
| ac610ad552 | |||
| d9204afdc9 | |||
| 69abbc308a | |||
| 06f2b0c49e | |||
| 47b0e6e744 |
@@ -1 +1 @@
|
||||
blank_issues_enabled: false
|
||||
blank_issues_enabled: false
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
|
||||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
|
||||
|
||||
name: Maven Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Publish to GitHub Packages Apache Maven
|
||||
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -20,5 +20,4 @@ jobs:
|
||||
java-version: ${{ matrix.jdkversion }}
|
||||
cache: 'maven'
|
||||
- name: 使用Maven构建
|
||||
run: mvn -V -B clean package --file pom.xml
|
||||
|
||||
run: mvn -V -B clean package --file pom.xml
|
||||
+1
-1
@@ -24,7 +24,7 @@ hs_err_pid*
|
||||
|
||||
# Include the project's code style settings file
|
||||
!.idea/codeStyleSettings.xml
|
||||
/target/class/
|
||||
|
||||
# File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@@ -2,3 +2,16 @@
|
||||
**"A fork of the best authentication plugin for the Bukkit modding API!"**
|
||||
|
||||

|
||||
|
||||
**Detailed Changes:**
|
||||
1. Improved mail sending logic & support more emails
|
||||
2. Shutdown mail sending(When server is closed, email you)
|
||||
3. Old bug fixes
|
||||
4. Anti Ghost Player(Doubled login bug)
|
||||
5. Use the best performance method by server brand
|
||||
6. Bedrock Compatibility(Floodgate needed)
|
||||
7. Update checker
|
||||
8. Integrated GUI Captcha feature(Bedrock compatibility & ProtocolLib needed)(70% Asynchronous)
|
||||
9. Improved listeners
|
||||
10. Player login logic improvement to reduce lag
|
||||
11. More......
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<maven.minimumVersion>3.6.3</maven.minimumVersion>
|
||||
|
||||
<!-- Dependencies versions -->
|
||||
<spigot.version>1.19.2-R0.1-SNAPSHOT</spigot.version>
|
||||
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version>
|
||||
|
||||
<!-- Versioning properties -->
|
||||
<project.outputName>AuthMe</project.outputName>
|
||||
@@ -616,7 +616,7 @@
|
||||
<groupId>org.geysermc.floodgate</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Jalu Injector -->
|
||||
<dependency>
|
||||
@@ -780,7 +780,7 @@
|
||||
<dependency>
|
||||
<groupId>ch.jalu</groupId>
|
||||
<artifactId>configme</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -802,7 +802,7 @@
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<version>5.1.0</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -945,7 +945,7 @@
|
||||
<dependency>
|
||||
<groupId>net.essentialsx</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.19.7</version>
|
||||
<version>2.20.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
||||
@@ -2,9 +2,7 @@ package fr.xephi.authme;
|
||||
|
||||
import ch.jalu.injector.Injector;
|
||||
import ch.jalu.injector.InjectorBuilder;
|
||||
import com.google.gson.annotations.Since;
|
||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||
import fr.xephi.authme.command.CommandArgumentDescription;
|
||||
import fr.xephi.authme.command.CommandHandler;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
@@ -12,17 +10,10 @@ import fr.xephi.authme.initialization.DataSourceProvider;
|
||||
import fr.xephi.authme.initialization.OnShutdownPlayerSaver;
|
||||
import fr.xephi.authme.initialization.OnStartupTasks;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.initialization.SettingsProvider;
|
||||
import fr.xephi.authme.initialization.TaskCloser;
|
||||
import fr.xephi.authme.listener.BlockListener;
|
||||
@@ -31,8 +22,8 @@ import fr.xephi.authme.listener.PlayerListener;
|
||||
import fr.xephi.authme.listener.PlayerListener111;
|
||||
import fr.xephi.authme.listener.PlayerListener19;
|
||||
import fr.xephi.authme.listener.PlayerListener19Spigot;
|
||||
import fr.xephi.authme.listener.PlayerQuitListener;
|
||||
import fr.xephi.authme.listener.RegisterListener;
|
||||
import fr.xephi.authme.listener.DoubleLoginFixListener;
|
||||
import fr.xephi.authme.listener.GuiCaptchaHandler;
|
||||
import fr.xephi.authme.listener.ServerListener;
|
||||
import fr.xephi.authme.mail.EmailService;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
@@ -45,13 +36,10 @@ import fr.xephi.authme.service.yaml.YamlParseException;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.SettingsWarner;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.task.CleanupTask;
|
||||
import fr.xephi.authme.task.purge.PurgeService;
|
||||
import fr.xephi.authme.util.ExceptionUtils;
|
||||
import fr.xephi.authme.util.TeleportUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -61,24 +49,17 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import fr.xephi.authme.listener.PlayerQuitListener;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
|
||||
import static fr.xephi.authme.util.Utils.isClassLoaded;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
import static org.bukkit.Bukkit.isHardcore;
|
||||
|
||||
/**
|
||||
* The AuthMe main class.
|
||||
@@ -93,26 +74,25 @@ public class AuthMe extends JavaPlugin {
|
||||
// Version and build number values
|
||||
private static String pluginVersion = "5.6.0-Fork";
|
||||
private static final String pluginBuild = "b";
|
||||
private static String pluginBuildNumber = "17";
|
||||
private static String pluginBuildNumber = "23";
|
||||
protected final Boolean SHAEnabled = false;
|
||||
// Private instances
|
||||
private EmailService emailService;
|
||||
private CommandHandler commandHandler;
|
||||
@Inject
|
||||
private Settings settings;
|
||||
public static Settings settings;
|
||||
private DataSource database;
|
||||
private BukkitService bukkitService;
|
||||
private Injector injector;
|
||||
private BackupService backupService;
|
||||
private ConsoleLogger logger;
|
||||
|
||||
public static ConsoleLogger logger;
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public AuthMe() {
|
||||
}
|
||||
public static Boolean SATEnabled = false;
|
||||
public static Boolean GUIEnabled = false;
|
||||
|
||||
|
||||
/**
|
||||
* Get the plugin's name.
|
||||
*
|
||||
@@ -146,28 +126,28 @@ public class AuthMe extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
AuthMe.GUIEnabled = false;
|
||||
AuthMe.SATEnabled = false;
|
||||
// Load the plugin version data from the plugin description file
|
||||
loadPluginInfo(getDescription().getVersion());
|
||||
|
||||
// Set the Logger instance and log file path
|
||||
ConsoleLogger.initialize(getLogger(), new File(getDataFolder(), LOG_FILENAME));
|
||||
logger = ConsoleLoggerFactory.get(AuthMe.class);
|
||||
logger.info("您正在加载的是由第三方Fork并修复众多错误的 AuthMeReReloaded!");
|
||||
logger.info("You are running an unofficial fork version of AuthMe!");
|
||||
|
||||
|
||||
// Check server version
|
||||
if (!isClassLoaded("org.spigotmc.event.player.PlayerSpawnLocationEvent")
|
||||
|| !isClassLoaded("org.bukkit.event.player.PlayerInteractAtEntityEvent")) {
|
||||
logger.warning("你正在运行不受支持的服务器版本 (" + getServerNameVersionSafe() + "). "
|
||||
+ "AuthMe 仅支持Spigot 1.9及之后的版本!");
|
||||
logger.warning("You are running an unsupported server version (" + getServerNameVersionSafe() + "). "
|
||||
+ "AuthMe requires Spigot 1.8.X or later!");
|
||||
stopOrUnload();
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent running AuthMeBridge due to major exploit issues
|
||||
if (getServer().getPluginManager().isPluginEnabled("AuthMeBridge")) {
|
||||
logger.warning("检测到 AuthMeBridge被加载, 对AuthMeBridge的支持已经停止 "
|
||||
+ "且可能会造成严重漏洞! 已中止加载!");
|
||||
logger.warning("Detected AuthMeBridge, support for it has been dropped as it was "
|
||||
+ "causing exploit issues, please use AuthMeBungee instead! Aborting!");
|
||||
stopOrUnload();
|
||||
return;
|
||||
}
|
||||
@@ -178,11 +158,11 @@ public class AuthMe extends JavaPlugin {
|
||||
} catch (Throwable th) {
|
||||
YamlParseException yamlParseException = ExceptionUtils.findThrowableInCause(YamlParseException.class, th);
|
||||
if (yamlParseException == null) {
|
||||
logger.logException("已中止AuthMeReReloaded的初始化,原因:", th);
|
||||
logger.logException("Aborting initialization of AuthMe:", th);
|
||||
th.printStackTrace();
|
||||
} else {
|
||||
logger.logException("文件 '" + yamlParseException.getFile() + "' 包含YAML语法错误. "
|
||||
+ "请尝试在 https://yamllint.com 中运行文件内容", yamlParseException);
|
||||
logger.logException("File '" + yamlParseException.getFile() + "' contains invalid YAML. "
|
||||
+ "Please run its contents through http://yamllint.com", yamlParseException);
|
||||
}
|
||||
stopOrUnload();
|
||||
return;
|
||||
@@ -199,34 +179,49 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
// Set up Metrics
|
||||
OnStartupTasks.sendMetrics(this, settings);
|
||||
|
||||
if(settings.getProperty(SecuritySettings.SHOW_STARTUP_BANNER)) {
|
||||
String loadColorConfig = settings.getProperty(SecuritySettings.STARTUP_BANNER_COLOR);
|
||||
if (loadColorConfig.startsWith("§")) {
|
||||
logger.info("\n" + loadColorConfig + " ___ __ __ __ ___ \n" +
|
||||
loadColorConfig + " / | __ __/ /_/ /_ / |/ /__ \n" +
|
||||
loadColorConfig + " / /| |/ / / / __/ __ \\/ /|_/ / _ \\\n" +
|
||||
loadColorConfig + " / ___ / /_/ / /_/ / / / / / / __/\n" +
|
||||
loadColorConfig + "/_/ |_\\__,_/\\__/_/ /_/_/ /_/\\___/ \n" +
|
||||
loadColorConfig + " ");
|
||||
}else {
|
||||
logger.info("\n"+" ___ __ __ __ ___ \n" +
|
||||
" / | __ __/ /_/ /_ / |/ /__ \n" +
|
||||
" / /| |/ / / / __/ __ \\/ /|_/ / _ \\\n" +
|
||||
" / ___ / /_/ / /_/ / / / / / / __/\n" +
|
||||
"/_/ |_\\__,_/\\__/_/ /_/_/ /_/\\___/ \n" +
|
||||
" ");
|
||||
}
|
||||
}
|
||||
// Successful message
|
||||
logger.info("AuthMeReReloaded 已成功启动!");
|
||||
//detect server brand with classloader
|
||||
checkServerType();
|
||||
logger.info("AuthMeReReloaded is enabled successfully!");
|
||||
// Purge on start if enabled
|
||||
PurgeService purgeService = injector.getSingleton(PurgeService.class);
|
||||
purgeService.runAutoPurge();
|
||||
// 注册玩家退出事件监听
|
||||
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS) || settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)/* || settings.getProperty(SecuritySettings.GUI_CAPTCHA)*/) {
|
||||
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
|
||||
getServer().getPluginManager().registerEvents(new PlayerQuitListener((Plugin) this), this);
|
||||
}
|
||||
if (settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
|
||||
logger.info("(RC2)SmartAsyncTeleport功能已注册");
|
||||
AuthMe.SATEnabled = true;
|
||||
}
|
||||
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||
getServer().getPluginManager().registerEvents(new RegisterListener((Plugin) this), this);
|
||||
logger.info("(RC2)GUI验证码功能已注册");
|
||||
AuthMe.GUIEnabled = true;
|
||||
} else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && !getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||
logger.warning("ProtocolLib未加载,GUI验证码功能无法使用");
|
||||
}
|
||||
logger.info("以上功能尚在测试中,如有问题请反馈,如需关闭请前往config.yml修改");
|
||||
logger.info("反馈地址: github.com/HaHaWTH/AuthMeReReloaded/issues");
|
||||
// 注册玩家加入事件监听
|
||||
// if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS) || settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)/* || settings.getProperty(SecuritySettings.GUI_CAPTCHA)*/) {
|
||||
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
|
||||
getServer().getPluginManager().registerEvents(new DoubleLoginFixListener((Plugin) this), this);
|
||||
}
|
||||
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||
getServer().getPluginManager().registerEvents(new GuiCaptchaHandler((Plugin) this), this);
|
||||
logger.info("(Alpha4)GUICaptcha Feature is enabled successfully!");
|
||||
logger.info("These features are still in development, if you encountered any problem, please report.");
|
||||
} else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && !getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||
logger.warning("ProtocolLib is not loaded, we can't enable GUI Captcha.");
|
||||
}
|
||||
logger.info("GitHub: https://github.com/HaHaWTH/AuthMeReReloaded/");
|
||||
|
||||
if (settings.getProperty(SecuritySettings.CHECK_FOR_UPDATES)) {
|
||||
checkForUpdates();
|
||||
}
|
||||
|
||||
if (SHAEnabled){
|
||||
//shaChecker();
|
||||
}
|
||||
@@ -365,7 +360,7 @@ public class AuthMe extends JavaPlugin {
|
||||
onShutdownPlayerSaver.saveAllPlayers();
|
||||
}
|
||||
if (settings.getProperty(EmailSettings.SHUTDOWN_MAIL)){
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'年'MM'月'dd'日' HH:mm:ss");
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'.'MM'.'dd'.' HH:mm:ss");
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
emailService.sendShutDown(settings.getProperty(EmailSettings.SHUTDOWN_MAIL_ADDRESS),dateFormat.format(date));
|
||||
}
|
||||
@@ -380,17 +375,17 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
// Disabled correctly
|
||||
Consumer<String> infoLogMethod = logger == null ? getLogger()::info : logger::info;
|
||||
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " 已卸载!");
|
||||
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " is unloaded successfully!");
|
||||
ConsoleLogger.closeFileWriter();
|
||||
}
|
||||
private static final String owner = "HaHaWTH";
|
||||
private static final String owner_gitee = "Shixuehan114514";
|
||||
private static final String repo = "AuthMeReReloaded";
|
||||
private void checkForUpdates() {
|
||||
logger.info("正在检查更新...");
|
||||
logger.info("Checking for updates...");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||
try {
|
||||
// Get the latest version number from GitHub
|
||||
// 从南通集线器获取最新版本号
|
||||
|
||||
URL url = new URL("https://api.github.com/repos/" + owner + "/" + repo + "/releases/latest");
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
@@ -400,23 +395,41 @@ public class AuthMe extends JavaPlugin {
|
||||
String response = scanner.useDelimiter("\\Z").next();
|
||||
scanner.close();
|
||||
|
||||
// Parse JSON response and extract version number
|
||||
// 处理JSON响应
|
||||
String latestVersion = response.substring(response.indexOf("tag_name") + 11);
|
||||
latestVersion = latestVersion.substring(0, latestVersion.indexOf("\""));
|
||||
if ((pluginBuild + pluginBuildNumber).equals(latestVersion)) {
|
||||
getLogger().log(Level.INFO,"当前为最新版本");
|
||||
getLogger().log(Level.INFO,"You are running the latest version.");
|
||||
}
|
||||
if (!(pluginBuild + pluginBuildNumber).equals(latestVersion)) {
|
||||
// Display update message to users
|
||||
String message = "有新版本可用! 最新版本:" + latestVersion + " 当前版本:" + pluginBuild + pluginBuildNumber;
|
||||
// Display update message
|
||||
String message = "New version available! Latest:" + latestVersion + " Current:" + pluginBuild + pluginBuildNumber;
|
||||
getLogger().log(Level.INFO, message);
|
||||
getLogger().log(Level.INFO,"下载地址:github.com/HaHaWTH/AuthMeReReloaded/releases/latest");
|
||||
getLogger().log(Level.INFO,"Download from here:github.com/HaHaWTH/AuthMeReReloaded/releases/latest");
|
||||
}
|
||||
}catch (IOException e) {
|
||||
getLogger().log(Level.WARNING,"从GitHub检查更新时出现错误,原因: " + e.getMessage());
|
||||
getLogger().log(Level.WARNING,"Error occurred while checking updates from GitHub. Reason: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkServerType() {
|
||||
if (isClassLoaded("com.destroystokyo.paper.PaperConfig")) {
|
||||
logger.info("AuthMeReReloaded is running on Paper");
|
||||
}else if (isClassLoaded("catserver.server.CatServerConfig")) {
|
||||
logger.info("AuthMeReReloaded is running on CatServer");
|
||||
} else if (isClassLoaded("org.spigotmc.SpigotConfig")) {
|
||||
logger.info("AuthMeReReloaded is running on Spigot");
|
||||
} else if (isClassLoaded("org.bukkit.craftbukkit.CraftServer")) {
|
||||
logger.info("AuthMeReReloaded is running on Bukkit");
|
||||
} else {
|
||||
logger.info("AuthMeReReloaded is running on Unknown*");
|
||||
}
|
||||
}
|
||||
// 其他方法和事件处理
|
||||
|
||||
|
||||
// 其他方法和事件处理
|
||||
private static final String SHA_URL = "https://raw.githubusercontent.com/"+ owner +"/"+ repo + "/master/"+pluginBuild +pluginBuildNumber+ ".sha";
|
||||
private static final String ALGORITHM = "SHA-256";
|
||||
private static final String PROXY_URL = "https://ghproxy.com/";
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class ConsoleLogger {
|
||||
*/
|
||||
public void warning(String message) {
|
||||
logger.warning(message);
|
||||
writeLog("[警告] " + message);
|
||||
writeLog("[WARN] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public final class ConsoleLogger {
|
||||
*/
|
||||
public void info(String message) {
|
||||
logger.info(message);
|
||||
writeLog("[信息] " + message);
|
||||
writeLog("[INFO] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ public final class ConsoleLogger {
|
||||
public void fine(String message) {
|
||||
if (logLevel.includes(LogLevel.FINE)) {
|
||||
logger.info(message);
|
||||
writeLog("[信息:调试] " + message);
|
||||
writeLog("[INFO:FINE] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public final class ConsoleLogger {
|
||||
}
|
||||
|
||||
private void logAndWriteWithDebugPrefix(String message) {
|
||||
String debugMessage = "[信息:调试] " + message;
|
||||
String debugMessage = "[INFO:DEBUG] " + message;
|
||||
logger.info(debugMessage);
|
||||
writeLog(debugMessage);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FirstSpawnCommand extends PlayerCommand {
|
||||
player.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn");
|
||||
} else {
|
||||
//String name= player.getName();
|
||||
if(AuthMe.SATEnabled) {
|
||||
if(settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
|
||||
TeleportUtils.teleport(player, spawnLoader.getFirstSpawn());
|
||||
} else {
|
||||
player.teleport(spawnLoader.getFirstSpawn());
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package fr.xephi.authme.listener;
|
||||
//Prevent Ghost Players
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class DoubleLoginFixListener implements Listener {
|
||||
private final Plugin plugin;
|
||||
|
||||
|
||||
|
||||
public DoubleLoginFixListener(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Collection<? extends Player> PlayerList = Bukkit.getServer().getOnlinePlayers();
|
||||
HashSet<String> PlayerSet = new HashSet<String>();
|
||||
for (Player ep : PlayerList) {
|
||||
if (PlayerSet.contains(ep.getName().toLowerCase())) {
|
||||
ep.kickPlayer("You have been disconnected due to doubled login.");
|
||||
break;
|
||||
}
|
||||
PlayerSet.add(ep.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package fr.xephi.authme.listener;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
public class GuiCaptchaHandler implements Listener {
|
||||
//define AuthMeApi
|
||||
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||
private final Plugin plugin;
|
||||
|
||||
|
||||
//define timesLeft
|
||||
public int timesLeft = 3;
|
||||
//Use ConcurrentHashMap to store player and their close reason
|
||||
/* We used many async tasks so there is concurrent**/
|
||||
protected static ConcurrentHashMap<Player, String> closeReasonMap = new ConcurrentHashMap<>();
|
||||
//define randomStringSet
|
||||
String randomSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@#%&*()_+";
|
||||
String randomString = "";
|
||||
Random randomItemSet = new Random();
|
||||
Random howManyRandom = new Random();
|
||||
|
||||
|
||||
int howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
||||
|
||||
public GuiCaptchaHandler(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
// 获取点击事件的容器
|
||||
if (!authmeApi.isRegistered(player.getName()) && !closeReasonMap.containsKey(player)) {
|
||||
if (AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getWhoClicked().getUniqueId()) && (getServer().getPluginManager().isPluginEnabled("floodgate") || getServer().getPluginManager().getPlugin("floodgate") != null)) {
|
||||
if (!closeReasonMap.containsKey(player)) {
|
||||
closeReasonMap.put(player,"verified");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Objects.requireNonNull(event.getCurrentItem()).getType().equals(Material.REDSTONE_BLOCK)) {
|
||||
event.setCancelled(true);
|
||||
closeReasonMap.put(player, "verified");
|
||||
player.closeInventory();
|
||||
player.sendMessage("§a验证完成");
|
||||
} else {
|
||||
player.sendMessage("§c验证失败,你还有" + timesLeft + "§c次机会");
|
||||
timesLeft--;
|
||||
}
|
||||
//force to string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
randomString = "";
|
||||
Player playerunreg = event.getPlayer();
|
||||
String name = playerunreg.getName();
|
||||
if (!authmeApi.isRegistered(name)) {
|
||||
if (AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getPlayer().getUniqueId()) && (getServer().getPluginManager().isPluginEnabled("floodgate") || getServer().getPluginManager().getPlugin("floodgate") != null)) {
|
||||
closeReasonMap.put(playerunreg, "verified");
|
||||
playerunreg.sendMessage("§a基岩版自动验证完成");
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
||||
for (int i = 0; i < howLongIsRandomString; i++) {
|
||||
//生成随机索引号
|
||||
int index = randomItemSet.nextInt(randomSet.length());
|
||||
|
||||
// 从字符串中获取由索引 index 指定的字符
|
||||
char randomChar = randomSet.charAt(index);
|
||||
|
||||
// 将字符追加到字符串生成器
|
||||
sb.append(randomChar);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
randomString = sb.toString();
|
||||
Random random_blockpos = new Random();
|
||||
AtomicInteger random_num = new AtomicInteger(random_blockpos.nextInt(26));
|
||||
Inventory menu = Bukkit.createInventory(null, 27, randomString + "请验证你是真人");
|
||||
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
try {
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§a我是真人");
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
getLogger().log(Level.WARNING, "Unexpected error occurred while setting item meta.");
|
||||
}
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
menu.setItem(random_num.get(), item);
|
||||
});
|
||||
menu.setItem(random_num.get(), item);
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
playerunreg.openInventory(menu);
|
||||
});
|
||||
if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) {
|
||||
long timeOut = AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT);
|
||||
if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT)) {
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
Bukkit.getLogger().warning("AuthMe detected that your GUI captcha timeout seconds(" + AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) + ") is bigger than the Login timeout seconds(" +
|
||||
AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT) + "). To prevent issues, we will let the GUI captcha follow the Login timeout seconds, please check and modify your config.");
|
||||
});
|
||||
timeOut = AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT);
|
||||
}
|
||||
long finalTimeOut = timeOut;
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
||||
playerunreg.kickPlayer("§c验证超时");
|
||||
timesLeft = 3; // Reset the attempt counter
|
||||
}
|
||||
}, finalTimeOut * 20L);
|
||||
});
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
||||
if (timesLeft <= 0) {
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
playerunreg.kickPlayer("§c请先完成人机验证!");
|
||||
});
|
||||
timesLeft = 3;
|
||||
return;
|
||||
} else {
|
||||
timesLeft--;
|
||||
playerunreg.sendMessage("§c请先完成验证!,你还有" + timesLeft + "次机会");
|
||||
|
||||
}
|
||||
event.setCancelled(true);
|
||||
random_num.set(random_blockpos.nextInt(26));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
menu.clear();
|
||||
menu.setItem(random_num.get(), item);
|
||||
});
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
playerunreg.openInventory(menu);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
||||
playerunreg.sendMessage("§c请先完成验证!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void deletePlayerData(UUID playerUUID) {
|
||||
// 获取服务器的存储文件夹路径
|
||||
File serverFolder = Bukkit.getServer().getWorldContainer();
|
||||
String worldFolderName = AuthMe.settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
|
||||
// 构建playerdata文件夹路径
|
||||
File playerDataFolder = new File(serverFolder, File.separator+worldFolderName+File.separator+"playerdata");
|
||||
|
||||
// 构建玩家数据文件路径
|
||||
File playerDataFile = new File(playerDataFolder, File.separator+playerUUID + ".dat");
|
||||
|
||||
// 删除玩家数据文件
|
||||
if (playerDataFile.exists()) {
|
||||
playerDataFile.delete();
|
||||
}
|
||||
}
|
||||
private void deletePlayerStats(UUID playerUUID) {
|
||||
// 获取服务器的存储文件夹路径
|
||||
File serverFolder = Bukkit.getServer().getWorldContainer();
|
||||
String worldFolderName = AuthMe.settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
|
||||
// 构建stats文件夹路径
|
||||
File statsFolder = new File(serverFolder, File.separator+worldFolderName+File.separator+"stats");
|
||||
// 构建玩家统计数据文件路径
|
||||
File statsFile = new File(statsFolder, File.separator+playerUUID + ".json");
|
||||
// 删除玩家统计数据文件
|
||||
|
||||
if (statsFile.exists()) {
|
||||
statsFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName();
|
||||
UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
if (!authmeApi.isRegistered(name)) {
|
||||
if(AuthMe.settings.getProperty(SecuritySettings.DELETE_UNVERIFIED_PLAYER_DATA) && !closeReasonMap.containsKey(player)){
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin,() -> {
|
||||
deletePlayerData(playerUUID);
|
||||
deletePlayerStats(playerUUID);
|
||||
},100L);
|
||||
return;
|
||||
}
|
||||
closeReasonMap.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,19 +10,12 @@ import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Service class for the AuthMe listeners to determine whether an event should be canceled.
|
||||
@@ -93,7 +86,7 @@ class ListenerService implements SettingsDependent {
|
||||
}
|
||||
public boolean shouldCancelInvEvent(Player player) {
|
||||
try {
|
||||
return !AuthMe.GUIEnabled || authmeApi.isRegistered(player.getName()) || RegisterListener.closeReasonMap.containsKey(player)/* || !player.getOpenInventory().getTitle().equals("请验证你是真人")*/;
|
||||
return !AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA) || authmeApi.isRegistered(player.getName()) || GuiCaptchaHandler.closeReasonMap.containsKey(player)/* || !player.getOpenInventory().getTitle().equals("请验证你是真人")*/;
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.listener.RegisterListener;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||
import fr.xephi.authme.data.QuickCommandsProtectionManager;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
@@ -31,7 +25,6 @@ import fr.xephi.authme.util.TeleportUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -62,15 +55,12 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_MOVEMENT_RADIUS;
|
||||
@@ -134,8 +124,10 @@ public class PlayerListener implements Listener{
|
||||
if (validationService.isUnrestricted(name)) {
|
||||
return;
|
||||
}
|
||||
if (settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getUniqueId())){
|
||||
return;
|
||||
if (settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER)) {
|
||||
if (getServer().getPluginManager().getPlugin("floodgate") != null) {
|
||||
if (org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getUniqueId())) return;
|
||||
}
|
||||
}
|
||||
// Non-blocking checks
|
||||
try {
|
||||
@@ -387,13 +379,13 @@ public class PlayerListener implements Listener{
|
||||
Location spawn = spawnLoader.getSpawnLocation(player);
|
||||
if (spawn != null && spawn.getWorld() != null) {
|
||||
if (!player.getWorld().equals(spawn.getWorld())) {
|
||||
if(AuthMe.SATEnabled) {
|
||||
if(settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
|
||||
TeleportUtils.teleport(player,spawn);
|
||||
} else {
|
||||
player.teleport(spawn);
|
||||
}
|
||||
} else if (spawn.distance(player.getLocation()) > settings.getProperty(ALLOWED_MOVEMENT_RADIUS)) {
|
||||
if(AuthMe.SATEnabled) {
|
||||
if(settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
|
||||
TeleportUtils.teleport(player,spawn);
|
||||
} else {
|
||||
player.teleport(spawn);
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package fr.xephi.authme.listener;
|
||||
//Prevent Ghost Players
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerQuitListener implements Listener {
|
||||
private final Plugin plugin;
|
||||
public PlayerQuitListener(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String LastAddr = Objects.requireNonNull(player.getAddress()).getAddress().getHostAddress();
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.isOnline()) {
|
||||
player.kickPlayer("You have been disconnected.");
|
||||
}
|
||||
}
|
||||
}, 20L); // 20 ticks = 1 second
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
|
||||
public class RegisterListener implements Listener {
|
||||
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||
private final Plugin plugin;
|
||||
public static boolean enabled=true;
|
||||
// 创建一个储存玩家关闭箱子GUI的原因的HashMap
|
||||
public static HashMap<Player, String> closeReasonMap = new HashMap<>();
|
||||
// Add a timer to kick the player if they don't verify in time
|
||||
|
||||
|
||||
public RegisterListener(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack item = event.getCurrentItem();
|
||||
// 获取点击事件的容器
|
||||
Inventory inventory = event.getInventory();
|
||||
if (event.getView().getTitle().equals("请验证你是真人")&&!authmeApi.isRegistered(player.getName())) {
|
||||
if (Objects.requireNonNull(event.getCurrentItem()).getType().equals(Material.REDSTONE_BLOCK)) {
|
||||
event.setCancelled(true);
|
||||
closeReasonMap.put(player, "verified");
|
||||
player.closeInventory();
|
||||
player.sendMessage("§a验证完成");
|
||||
//force to string
|
||||
|
||||
// ProtocolLibrary.getProtocolManager().removePacketListeners(this.plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Random random_blockpos = new Random();
|
||||
int random_num = random_blockpos.nextInt(26);
|
||||
Inventory menu = Bukkit.createInventory(null, 27, "请验证你是真人");
|
||||
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§a我是真人");
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
menu.setItem(random_num, item);
|
||||
Player playerunreg = event.getPlayer();
|
||||
String name = playerunreg.getName();
|
||||
if (!authmeApi.isRegistered(name)) {
|
||||
// getLogger().log(Level.INFO, "TESTTEST");
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
playerunreg.openInventory(menu);
|
||||
}, 1L);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg)) {
|
||||
playerunreg.sendMessage("§c请先完成验证!");
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
playerunreg.openInventory(menu);
|
||||
//playerunreg.kickPlayer("§c请先完成人机验证!");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg)) {
|
||||
playerunreg.sendMessage("§c请先完成验证!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
// chatListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
||||
// @Override
|
||||
// public void onPacketReceiving(PacketEvent event) {
|
||||
// if (event.getPlayer() == player) {
|
||||
// event.setCancelled(true);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event){
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName();
|
||||
if (!authmeApi.isRegistered(name)){closeReasonMap.remove(player);}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ package fr.xephi.authme.message;
|
||||
* Keys for translatable messages managed by {@link Messages}.
|
||||
*/
|
||||
public enum MessageKey {
|
||||
|
||||
/** In order to use this command you must be authenticated! */
|
||||
DENIED_COMMAND("error.denied_command"),
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ public final class RestrictionSettings implements SettingsHolder {
|
||||
|
||||
@Comment("Regex syntax for allowed chars in email.")
|
||||
public static final Property<String> ALLOWED_EMAIL_REGEX =
|
||||
newProperty("settings.restrictions.allowedEmailCharacters", "^[A-Za-z0-9]{4,15}@(qq|outlook|163|gmail|icloud).com$");
|
||||
newProperty("settings.restrictions.allowedEmailCharacters", "^[A-Za-z0-9_]{4,15}@(qq|outlook|163|gmail|icloud)\\.com$");
|
||||
|
||||
|
||||
@Comment("Force survival gamemode when player joins?")
|
||||
|
||||
@@ -2,12 +2,12 @@ package fr.xephi.authme.settings.properties;
|
||||
|
||||
import ch.jalu.configme.Comment;
|
||||
import ch.jalu.configme.SettingsHolder;
|
||||
import ch.jalu.configme.properties.BooleanProperty;
|
||||
|
||||
import ch.jalu.configme.properties.Property;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.settings.EnumSetProperty;
|
||||
import java.util.Set;
|
||||
import fr.xephi.authme.listener.PlayerQuitListener;
|
||||
|
||||
import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty;
|
||||
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
||||
|
||||
@@ -17,21 +17,37 @@ public final class SecuritySettings implements SettingsHolder {
|
||||
"Take care with this, if you set this to false,",
|
||||
"AuthMe will automatically disable and the server won't be protected!"})
|
||||
public static final Property<Boolean> STOP_SERVER_ON_PROBLEM =
|
||||
newProperty("Security.SQLProblem.stopServer", true);
|
||||
newProperty("Security.SQLProblem.stopServer", false);
|
||||
|
||||
@Comment("Enable the new feature to prevent ghost players?")
|
||||
public static final Property<Boolean> ANTI_GHOST_PLAYERS = newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false);
|
||||
|
||||
@Comment({"(BETA Feature)Choose the best teleport method by server brand?",
|
||||
@Comment({"Choose the best teleport method by server brand?",
|
||||
"(Enable this if you are using Paper)"})
|
||||
public static final Property<Boolean> SMART_ASYNC_TELEPORT = newProperty("3rdPartyFeature.optimizes.smartAsyncTeleport",false);
|
||||
|
||||
@Comment("(BETA Feature)Send a GUI captcha to unregistered players?")
|
||||
@Comment("Send a GUI captcha to unregistered players?(Requires ProtocolLib)")
|
||||
public static final Property<Boolean> GUI_CAPTCHA = newProperty("3rdPartyFeature.captcha.guiCaptcha",false);
|
||||
|
||||
// @Comment({"Kick the players when they didn't finish the gui captcha in time? " ,
|
||||
// "(0 is disabled)"})
|
||||
// public static final Property<Integer> CAPTCHA_TIMEOUT = newProperty("3rdPartyFeature.captcha.timeout",0);
|
||||
@Comment({"Should we kick the players when they don't finish the GUI captcha in seconds?",
|
||||
"(less than or equals 0 is disabled)"})
|
||||
public static final Property<Integer> GUI_CAPTCHA_TIMEOUT = newProperty("3rdPartyFeature.captcha.timeOut",0);
|
||||
|
||||
@Comment({"Should we ignore floodgate players when sending GUI captcha?",
|
||||
"(Requires floodgate and hookFloodgate: true)"})
|
||||
public static final Property<Boolean> GUI_CAPTCHA_BE_COMPATIBILITY = newProperty("3rdPartyFeature.captcha.ignoreBedrock",false);
|
||||
|
||||
@Comment("Should we delete player data and stats when they didn't finish the captcha?")
|
||||
public static final Property<Boolean> DELETE_UNVERIFIED_PLAYER_DATA = newProperty("3rdPartyFeature.captcha.purgePlayerData",false);
|
||||
|
||||
@Comment("Which world's player data should be deleted?(Enter the world *FOLDER* name where your players first logged in)")
|
||||
public static final Property<String> DELETE_PLAYER_DATA_WORLD = newProperty("3rdPartyFeature.captcha.purgeWorldFolderName","world");
|
||||
|
||||
// @Comment({"Should we kick the players when they failed captcha too many times?",
|
||||
// "(Minimum value is 1)(Default: 3)"})
|
||||
// public static final Property<Integer> GUI_CAPTCHA_MAX_TRY = newProperty("3rdPartyFeature.captcha.maxTryTimes",3);
|
||||
|
||||
|
||||
//@Comment({"Using which API to get hash data?",
|
||||
//"Available options: github, gitee, ghproxy (if your server is in China, please use gitee or ghproxy.)"})
|
||||
//public static final Property<String> SHA_CHECK_METHOD = newProperty("Plugin.hashing.hashApi","github");
|
||||
@@ -63,6 +79,14 @@ public final class SecuritySettings implements SettingsHolder {
|
||||
public static final Property<Boolean> CHECK_FOR_UPDATES =
|
||||
newProperty("Plugin.updates.checkForUpdates", true);
|
||||
|
||||
@Comment("Should we show the AuthMe banner on startup?")
|
||||
public static final Property<Boolean> SHOW_STARTUP_BANNER =
|
||||
newProperty("Plugin.banners.showBanners", true);
|
||||
|
||||
@Comment("Change the banner colors here (Default: §r)")
|
||||
public static final Property<String> STARTUP_BANNER_COLOR =
|
||||
newProperty("Plugin.banners.bannerColor", "§r");
|
||||
|
||||
@Comment("Max allowed tries before a captcha is required")
|
||||
public static final Property<Integer> MAX_LOGIN_TRIES_BEFORE_CAPTCHA =
|
||||
newProperty("Security.captcha.maxLoginTry", 8);
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package fr.xephi.authme.util;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
//
|
||||
//public class TeleportUtils {
|
||||
|
||||
Binary file not shown.
@@ -3,7 +3,7 @@ authors: [${pluginDescription.authors}]
|
||||
website: http://github.com/HaHaWTH/AuthMeReReloaded/
|
||||
description: A fork of AuthMeReloaded that contains bug fixes
|
||||
main: ${pluginDescription.main}
|
||||
version: 5.6.0-FORK-b17
|
||||
version: 5.6.0-FORK-b23
|
||||
api-version: 1.13
|
||||
softdepend:
|
||||
- Vault
|
||||
|
||||
Reference in New Issue
Block a user