Compare commits

..

57 Commits

Author SHA1 Message Date
DGun Otto a31c2f45b1 Update README.md 2023-11-12 14:57:34 +08:00
DGun Otto 06d9e71ae8 [ci skip] Update README.md 2023-11-12 14:56:13 +08:00
HaHaWTH 441e020192 Localized DoubleLoginFix 2023-11-12 14:19:01 +08:00
HaHaWTH f153867d85 Merge remote-tracking branch 'origin/master' 2023-11-12 14:12:39 +08:00
HaHaWTH eed5ce1b7b Localized LoginLocationFix 2023-11-12 14:12:11 +08:00
DGun Otto 00b4bcb6a3 [ci skip] Update README 2023-11-12 13:24:35 +08:00
HaHaWTH e69ba501da Localized BedrockAutoLogin 2023-11-12 11:31:47 +08:00
HaHaWTH f2ccbf72a8 Another method 2023-11-12 00:54:52 +08:00
HaHaWTH c29aec210b Prepare for B32 2023-11-11 22:13:44 +08:00
HaHaWTH 78b5102692 Prepare for B32 2023-11-11 21:41:08 +08:00
HaHaWTH 9fd671db85 Use bukkitService 2023-11-11 21:18:42 +08:00
HaHaWTH beb99418d4 switch to warning 2023-11-11 21:16:17 +08:00
HaHaWTH 0f70de9a5a patch 2023-11-11 21:04:35 +08:00
HaHaWTH 08ad55c742 typo 2023-11-11 21:03:36 +08:00
HaHaWTH a70c1e0102 Migration 2023-11-11 20:49:53 +08:00
HaHaWTH efec997128 Add tips 2023-11-11 20:47:32 +08:00
HaHaWTH 413c2a39d7 Add tips 2023-11-11 20:45:27 +08:00
HaHaWTH 5a9b9ce619 Unified code style 2023-11-11 20:32:01 +08:00
HaHaWTH ee58da2b39 SQL support for Java8 2023-11-11 14:43:59 +08:00
DGun Otto 7475cd8ea4 Update maven.yml 2023-11-11 12:59:21 +08:00
HaHaWTH 8b8f6c0e2e fix 2023-11-11 12:57:09 +08:00
HaHaWTH 69b170b754 11&8 2023-11-11 12:55:42 +08:00
HaHaWTH 702b6aae32 Code Cleanup 2023-11-11 12:20:40 +08:00
HaHaWTH 010874586a Localized GUI Captcha 2023-11-11 11:12:48 +08:00
HaHaWTH fcc34c28aa Migrate to @Inject 2023-11-11 10:00:27 +08:00
HaHaWTH ecbc11cf0b Useless 2023-11-10 22:28:46 +08:00
HaHaWTH bfd3a8f439 Merge remote-tracking branch 'origin/master' 2023-11-10 22:18:02 +08:00
HaHaWTH f8dd410d96 Improved code style 2023-11-10 22:17:35 +08:00
DGun Otto 2459aec4b6 Merge pull request #46 from HaHaWTH/dependabot/maven/org.xerial-sqlite-jdbc-3.43.2.2
Bump org.xerial:sqlite-jdbc from 3.43.2.1 to 3.43.2.2
2023-11-10 00:49:53 +08:00
DGun Otto d623337a15 Merge pull request #47 from HaHaWTH/dependabot/maven/org.checkerframework-checker-qual-3.40.0
Bump org.checkerframework:checker-qual from 3.39.0 to 3.40.0
2023-11-10 00:49:28 +08:00
HaHaWTH 73c3cea778 Optimises 2023-11-05 12:17:21 +08:00
HaHaWTH 11a4cff10a Revert changes 2023-11-04 18:42:55 +08:00
HaHaWTH 628d5adcb5 MapUtils 2023-11-04 18:31:36 +08:00
HaHaWTH 8681cd0733 MapCaptchaHandler 2023-11-04 18:29:44 +08:00
HaHaWTH bb2fdbfb40 why r there so many runTask 2023-11-04 18:04:28 +08:00
HaHaWTH 4dedc30d94 Format 2023-11-04 18:01:39 +08:00
dependabot[bot] fa995eea53 Bump org.checkerframework:checker-qual from 3.39.0 to 3.40.0
Bumps [org.checkerframework:checker-qual](https://github.com/typetools/checker-framework) from 3.39.0 to 3.40.0.
- [Release notes](https://github.com/typetools/checker-framework/releases)
- [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.39.0...checker-framework-3.40.0)

---
updated-dependencies:
- dependency-name: org.checkerframework:checker-qual
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-02 05:04:26 +00:00
dependabot[bot] e819be918b Bump org.xerial:sqlite-jdbc from 3.43.2.1 to 3.43.2.2
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.43.2.1 to 3.43.2.2.
- [Release notes](https://github.com/xerial/sqlite-jdbc/releases)
- [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG)
- [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.43.2.1...3.43.2.2)

---
updated-dependencies:
- dependency-name: org.xerial:sqlite-jdbc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-31 04:16:08 +00:00
HaHaWTH 1e3e625c1a Update: fake player compatibility(UNTESTED) 2023-10-28 20:32:38 +08:00
HaHaWTH b747a4bdff Update: untested 2023-10-28 20:21:10 +08:00
HaHaWTH 03443104be Prepare for PacketPlayerListener 2023-10-27 20:54:13 +08:00
HaHaWTH 819e55e235 Prepare for PacketPlayerListener 2023-10-25 01:07:44 +08:00
HaHaWTH 80b06f3bc7 Now prepare for B31 2023-10-25 01:05:36 +08:00
HaHaWTH d90e87896c [ci skip] 2023-10-22 19:07:31 +08:00
HaHaWTH 72073b80f0 debug & update 2023-10-22 14:13:28 +08:00
HaHaWTH 19866bc4a4 Add thanks 2023-10-22 10:18:24 +08:00
HaHaWTH cf4037614a Patch 2023-10-22 10:15:04 +08:00
HaHaWTH 5c22601c52 Add Bedrock player auto login feature 2023-10-22 10:13:08 +08:00
HaHaWTH 1bb3bb1fa7 Prepare for B30 2023-10-21 19:50:35 +08:00
HaHaWTH 11959ca794 Rename material to materialPortal 2023-10-21 19:46:46 +08:00
HaHaWTH 9ba9af6369 Logic improvement 2023-10-21 19:29:30 +08:00
HaHaWTH 584f2074fd Bump Spigot API to 1.20.2 2023-10-21 18:59:07 +08:00
HaHaWTH 2971a0a202 Revert ProtocolPacketListener update 2023-10-21 18:21:44 +08:00
HaHaWTH 3cc8128faa ProtocolPacketListener update 2023-10-21 18:16:24 +08:00
HaHaWTH 1ef7ed4b3f Random string for click verify 2023-10-21 18:12:33 +08:00
HaHaWTH 59eabe38c6 Code readability update 2023-10-21 18:01:01 +08:00
HaHaWTH 1c090a5a65 Update TeleportUtils 2023-10-21 00:11:56 +08:00
16 changed files with 359 additions and 196 deletions
+9 -9
View File
@@ -10,14 +10,14 @@ jobs:
Build: Build:
strategy: strategy:
matrix: matrix:
jdkversion: [11] jdkversion: [ 11 ]
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: ${{ matrix.jdkversion }} java-version: ${{ matrix.jdkversion }}
cache: 'maven' cache: 'maven'
- name: 使用Maven构建 - name: Build
run: mvn -V -B clean package --file pom.xml run: mvn -V -B clean package --file pom.xml
+5
View File
@@ -2,6 +2,10 @@
**"A fork of the best authentication plugin for the Bukkit modding API!"** **"A fork of the best authentication plugin for the Bukkit modding API!"**
MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471495) MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471495)
![Graph](https://bstats.org/signatures/bukkit/AuthMeReloaded-Fork.svg) ![Graph](https://bstats.org/signatures/bukkit/AuthMeReloaded-Fork.svg)
<p align="center">
<img src="https://img.shields.io/github/languages/code-size/HaHaWTH/AuthMeReReloaded.svg" alt="Code size"/>
<img src="https://img.shields.io/github/repo-size/HaHaWTH/AuthMeReReloaded.svg" alt="GitHub repo size"/>
</p>
**Detailed Changes:** **Detailed Changes:**
1. Improved mail sending logic & support more emails 1. Improved mail sending logic & support more emails
@@ -19,3 +23,4 @@ MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471
13. Offhand Menu compatibility(Thats amazing) 13. Offhand Menu compatibility(Thats amazing)
14. Automatically fix portal stuck issue 14. Automatically fix portal stuck issue
15. More...... 15. More......
**Pull Requests and suggestions are welcome!**
+7 -9
View File
@@ -67,7 +67,7 @@
<maven.minimumVersion>3.6.3</maven.minimumVersion> <maven.minimumVersion>3.6.3</maven.minimumVersion>
<!-- Dependencies versions --> <!-- Dependencies versions -->
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version> <spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version>
<!-- Versioning properties --> <!-- Versioning properties -->
<project.outputName>AuthMe</project.outputName> <project.outputName>AuthMe</project.outputName>
@@ -687,7 +687,7 @@
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>5.0.1</version> <!-- Latest java 8 release --> <version>4.0.3</version> <!-- Latest java 8 release -->
<optional>true</optional> <optional>true</optional>
<exclusions> <exclusions>
<exclusion> <exclusion>
@@ -700,7 +700,7 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
<version>2.0.5</version> <!-- We can't update to 2.x as long as we use HikariCP for java 8 --> <version>1.7.36</version> <!-- We can't update to 2.x as long as we use HikariCP for java 8 -->
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
@@ -784,8 +784,6 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- Bukkit Libraries -->
<!-- ConfigMe --> <!-- ConfigMe -->
<dependency> <dependency>
<groupId>ch.jalu</groupId> <groupId>ch.jalu</groupId>
@@ -800,7 +798,7 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- bStats metrics --> <!-- bStats metrics -->
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
@@ -1070,7 +1068,7 @@
<dependency> <dependency>
<groupId>org.checkerframework</groupId> <groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId> <artifactId>checker-qual</artifactId>
<version>3.39.0</version> <version>3.40.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@@ -1078,13 +1076,13 @@
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.43.2.1</version> <version>3.43.2.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>2.1.214</version> <version>2.2.224</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
+37 -96
View File
@@ -11,6 +11,7 @@ import fr.xephi.authme.initialization.OnShutdownPlayerSaver;
import fr.xephi.authme.initialization.OnStartupTasks; import fr.xephi.authme.initialization.OnStartupTasks;
import fr.xephi.authme.initialization.SettingsProvider; import fr.xephi.authme.initialization.SettingsProvider;
import fr.xephi.authme.initialization.TaskCloser; import fr.xephi.authme.initialization.TaskCloser;
import fr.xephi.authme.listener.BedrockAutoLoginListener;
import fr.xephi.authme.listener.BlockListener; import fr.xephi.authme.listener.BlockListener;
import fr.xephi.authme.listener.DoubleLoginFixListener; import fr.xephi.authme.listener.DoubleLoginFixListener;
import fr.xephi.authme.listener.EntityListener; import fr.xephi.authme.listener.EntityListener;
@@ -33,15 +34,14 @@ import fr.xephi.authme.service.yaml.YamlParseException;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SettingsWarner; import fr.xephi.authme.settings.SettingsWarner;
import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.task.CleanupTask; import fr.xephi.authme.task.CleanupTask;
import fr.xephi.authme.task.purge.PurgeService; import fr.xephi.authme.task.purge.PurgeService;
import fr.xephi.authme.util.ExceptionUtils; import fr.xephi.authme.util.ExceptionUtils;
import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
@@ -74,8 +74,7 @@ public class AuthMe extends JavaPlugin {
// Version and build number values // Version and build number values
private static String pluginVersion = "5.6.0-Fork"; private static String pluginVersion = "5.6.0-Fork";
private static final String pluginBuild = "b"; private static final String pluginBuild = "b";
private static String pluginBuildNumber = "29"; private static String pluginBuildNumber = "32";
protected final Boolean SHAEnabled = false;
// Private instances // Private instances
private EmailService emailService; private EmailService emailService;
private CommandHandler commandHandler; private CommandHandler commandHandler;
@@ -121,6 +120,7 @@ public class AuthMe extends JavaPlugin {
} }
/** /**
* Method called when the server enables the plugin. * Method called when the server enables the plugin.
*/ */
@@ -205,31 +205,17 @@ public class AuthMe extends JavaPlugin {
PurgeService purgeService = injector.getSingleton(PurgeService.class); PurgeService purgeService = injector.getSingleton(PurgeService.class);
purgeService.runAutoPurge(); purgeService.runAutoPurge();
// 注册玩家加入事件监听 // 注册玩家加入事件监听
// if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS) || settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)/* || settings.getProperty(SecuritySettings.GUI_CAPTCHA)*/) { // register3rdPartyListeners();
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
getServer().getPluginManager().registerEvents(new DoubleLoginFixListener((Plugin) this), this);
}
if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND) || settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL)) {
getServer().getPluginManager().registerEvents(new LoginLocationFixListener((Plugin) this), this);
}
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
getServer().getPluginManager().registerEvents(new GuiCaptchaHandler((Plugin) this), this);
logger.info("(Beta)GUICaptcha is enabled successfully!");
logger.info("These features are still in early 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/"); logger.info("GitHub: https://github.com/HaHaWTH/AuthMeReReloaded/");
if (settings.getProperty(SecuritySettings.CHECK_FOR_UPDATES)) { if (settings.getProperty(SecuritySettings.CHECK_FOR_UPDATES)) {
checkForUpdates(); checkForUpdates();
} }
if (SHAEnabled){
//shaChecker();
}
} }
public File pluginfile = getFile();
//Migrated
/** /**
* Load the version and build number of the plugin from the description file. * Load the version and build number of the plugin from the description file.
* *
@@ -324,14 +310,14 @@ public class AuthMe extends JavaPlugin {
pluginManager.registerEvents(injector.getSingleton(EntityListener.class), this); pluginManager.registerEvents(injector.getSingleton(EntityListener.class), this);
pluginManager.registerEvents(injector.getSingleton(ServerListener.class), this); pluginManager.registerEvents(injector.getSingleton(ServerListener.class), this);
// Try to register 1.8+ player listeners // Try to register 1.8+ player listeners
if (isClassLoaded("org.bukkit.event.entity.EntityPickupItemEvent") && isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")){ if (isClassLoaded("org.bukkit.event.entity.EntityPickupItemEvent") && isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
pluginManager.registerEvents(injector.getSingleton(PlayerListenerHigherThan18.class), this); pluginManager.registerEvents(injector.getSingleton(PlayerListenerHigherThan18.class), this);
} else if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) { } else if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this); pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this);
} }
// Try to register 1.9 player listeners(Moved to else-if)
// Try to register 1.9 player listeners(Moved to else-if)
// if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) { // if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
// pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this); // pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this);
// } // }
@@ -345,6 +331,26 @@ public class AuthMe extends JavaPlugin {
if (isClassLoaded("org.bukkit.event.entity.EntityAirChangeEvent")) { if (isClassLoaded("org.bukkit.event.entity.EntityAirChangeEvent")) {
pluginManager.registerEvents(injector.getSingleton(PlayerListener111.class), this); pluginManager.registerEvents(injector.getSingleton(PlayerListener111.class), this);
} }
//Register 3rd party listeners
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
pluginManager.registerEvents(injector.getSingleton(GuiCaptchaHandler.class), this);
logger.info("(Beta)GUICaptcha is enabled successfully!");
logger.info("These features are still in early development, if you encountered any problem, please report.");
} else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().getPlugin("ProtocolLib") == null) {
logger.warning("ProtocolLib is not loaded, can't enable GUI Captcha.");
}
if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
pluginManager.registerEvents(injector.getSingleton(BedrockAutoLoginListener.class), this);
} else if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && (!settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) || getServer().getPluginManager().getPlugin("floodgate") == null)) {
logger.warning("Failed to enable BedrockAutoLogin, ensure hookFloodgate: true and floodgate is loaded.");
}
if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND) || settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL)) {
pluginManager.registerEvents(injector.getSingleton(LoginLocationFixListener.class), this);
}
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
pluginManager.registerEvents(injector.getSingleton(DoubleLoginFixListener.class), this);
}
} }
/** /**
@@ -395,7 +401,7 @@ public class AuthMe extends JavaPlugin {
private void checkForUpdates() { private void checkForUpdates() {
logger.info("Checking for updates..."); logger.info("Checking for updates...");
Bukkit.getScheduler().runTaskAsynchronously(this, () -> { bukkitService.runTaskAsynchronously(() -> {
try { try {
// 从南通集线器获取最新版本号 // 从南通集线器获取最新版本号
URL url = new URL("https://api.github.com/repos/" + owner + "/" + repo + "/releases/latest"); URL url = new URL("https://api.github.com/repos/" + owner + "/" + repo + "/releases/latest");
@@ -411,13 +417,14 @@ public class AuthMe extends JavaPlugin {
latestVersion = latestVersion.substring(0, latestVersion.indexOf("\"")); latestVersion = latestVersion.substring(0, latestVersion.indexOf("\""));
if (isUpdateAvailable(latestVersion)) { if (isUpdateAvailable(latestVersion)) {
String message = "New version available! Latest:" + latestVersion + " Current:" + pluginBuild + pluginBuildNumber; String message = "New version available! Latest:" + latestVersion + " Current:" + pluginBuild + pluginBuildNumber;
getLogger().log(Level.INFO, message); getLogger().log(Level.WARNING, message);
getLogger().log(Level.INFO, "Download from here: github.com/HaHaWTH/AuthMeReReloaded/releases/latest"); getLogger().log(Level.WARNING, "Download from here: github.com/HaHaWTH/AuthMeReReloaded/releases/latest");
} else { } else {
getLogger().log(Level.INFO, "You are running the latest version."); getLogger().log(Level.INFO, "You are running the latest version.");
} }
} catch (IOException e) { } catch (IOException e) {
getLogger().log(Level.WARNING, "Error occurred while checking updates from GitHub. Reason: " + e.getMessage()); String formattedException = ExceptionUtils.formatException(e);
getLogger().log(Level.WARNING, "Error occurred while checking updates from GitHub. Reason: " + formattedException);
} }
}); });
} }
@@ -454,72 +461,6 @@ public class AuthMe extends JavaPlugin {
logger.info("AuthMeReReloaded is running on Unknown*"); 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/";
private static final String SHA_URL_GITEE = "https://gitee.com/"+ owner_gitee +"/"+ repo + "/raw/master/"+pluginBuild+pluginBuildNumber+ ".sha";
// public void shaChecker() {
// // 请求SHA文件
//
// String actualSha;
// try {
// URL url;
// if(settings.getProperty(SecuritySettings.SHA_CHECK_METHOD).equals("github")) {
// url = new URL(SHA_URL);
// logger.info("正在检查文件完整性...(GitHub)");
// } else if(settings.getProperty(SecuritySettings.SHA_CHECK_METHOD).equals("ghproxy")) {
// url = new URL(PROXY_URL + SHA_URL);
// logger.info("正在检查文件完整性...(GhProxy)");
// } else if (settings.getProperty(SecuritySettings.SHA_CHECK_METHOD).equals("gitee")) {
// url = new URL(SHA_URL_GITEE);
// logger.info("正在检查文件完整性...(Gitee)");
// }else {
// logger.warning("未知的SHA检查方法,将从GitHub获取SHA文件");
// url = new URL(SHA_URL);
// }
//
//
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// conn.setConnectTimeout(10000);
// conn.setReadTimeout(9000);
// conn.setRequestMethod("GET");
// InputStream stream = conn.getInputStream();
// ByteArrayOutputStream result = new ByteArrayOutputStream();
// byte[] buffer = new byte[1024];
// int length;
// while ((length = stream.read(buffer)) != -1) {
// result.write(buffer, 0, length);
// }
// String expectedSha = result.toString().trim();
// // 计算插件文件的SHA值
// MessageDigest md = MessageDigest.getInstance(ALGORITHM);
// byte[] fileBytes = Files.readAllBytes(pluginfile.toPath());
// byte[] hashBytes = md.digest(fileBytes);
// StringBuilder sb = new StringBuilder();
// for (byte b : hashBytes) {
// sb.append(String.format("%02x", b));
// }
// actualSha = sb.toString();
//
// // 比较SHA值并加载插件
// if (expectedSha.equals(actualSha)) {
// logger.info("SHA联网安全校验完毕");
// } else {
// // SHA值不匹配,插件可能被篡改
// logger.warning("SHA值不匹配,插件被篡改");
// stopOrUnload();
// }
// }catch (NoSuchAlgorithmException | IOException e){
// logger.warning("SHA校验失败,请尝试切换校验API");
// logger.warning("您当前请求的API为:" + settings.getProperty(SecuritySettings.SHA_CHECK_METHOD));
// stopOrUnload();
// }
// }
/** /**
@@ -0,0 +1,60 @@
package fr.xephi.authme.listener;
/* Inspired by DongShaoNB/BedrockPlayerSupport **/
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import javax.inject.Inject;
import java.util.UUID;
import static org.bukkit.Bukkit.getServer;
public class BedrockAutoLoginListener implements Listener {
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
@Inject
private BukkitService bukkitService;
@Inject
private AuthMe plugin;
@Inject
private Messages messages;
public BedrockAutoLoginListener() {
}
private boolean isBedrockPlayer(UUID uuid) {
return AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
String name = event.getPlayer().getName();
UUID uuid = event.getPlayer().getUniqueId();
if (isBedrockPlayer(uuid) && !authmeApi.isAuthenticated(player) && authmeApi.isRegistered(name)) {
authmeApi.forceLogin(player);
messages.send(player, MessageKey.BEDROCK_AUTO_LOGGED_IN);
}
}
/* prevent sending duplicate messages */
// @EventHandler(priority = EventPriority.HIGHEST)
// public void onPlayerRestoreSession(RestoreSessionEvent event) {
// Player player = event.getPlayer();
// String name = event.getPlayer().getName();
// UUID uuid = event.getPlayer().getUniqueId();
// if (isBedrockPlayer(uuid) && !authmeApi.isAuthenticated(player) && authmeApi.isRegistered(name)) {
// event.setCancelled(true);
// }
// }
}
@@ -1,32 +1,32 @@
package fr.xephi.authme.listener; package fr.xephi.authme.listener;
//Prevent Ghost Players //Prevent Ghost Players
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import javax.inject.Inject;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
public class DoubleLoginFixListener implements Listener { public class DoubleLoginFixListener implements Listener {
private final Plugin plugin; @Inject
private CommonService service;
public DoubleLoginFixListener(Plugin plugin) {
this.plugin = plugin;
public DoubleLoginFixListener() {
} }
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Collection<? extends Player> PlayerList = Bukkit.getServer().getOnlinePlayers(); Collection<? extends Player> PlayerList = Bukkit.getServer().getOnlinePlayers();
HashSet<String> PlayerSet = new HashSet<String>(); HashSet<String> PlayerSet = new HashSet<String>();
for (Player ep : PlayerList) { for (Player ep : PlayerList) {
if (PlayerSet.contains(ep.getName().toLowerCase())) { if (PlayerSet.contains(ep.getName().toLowerCase())) {
ep.kickPlayer("You have been disconnected due to doubled login."); ep.kickPlayer(service.retrieveSingleMessage(ep.getPlayer(), MessageKey.DOUBLE_LOGIN_FIX));
break; break;
} }
PlayerSet.add(ep.getName().toLowerCase()); PlayerSet.add(ep.getName().toLowerCase());
@@ -7,6 +7,10 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.settings.properties.SecuritySettings;
@@ -22,8 +26,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import javax.inject.Inject;
import java.io.File; import java.io.File;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@@ -31,17 +35,26 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level; import java.util.logging.Level;
import static fr.xephi.authme.util.PlayerUtils.isNpc;
import static org.bukkit.Bukkit.getLogger; import static org.bukkit.Bukkit.getLogger;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
public class GuiCaptchaHandler implements Listener{
public class GuiCaptchaHandler implements Listener {
//define AuthMeApi //define AuthMeApi
private final AuthMeApi authmeApi = AuthMeApi.getInstance(); private final AuthMeApi authmeApi = AuthMeApi.getInstance();
private final Plugin plugin; @Inject
private PacketAdapter chatPacketListener; private BukkitService bukkitService;
@Inject
private AuthMe plugin;
@Inject
private Messages messages;
@Inject
private CommonService service;
private PacketAdapter chatPacketListener;
private PacketAdapter windowPacketListener; private PacketAdapter windowPacketListener;
//define timesLeft //define timesLeft
public int timesLeft = 3; private int timesLeft = 3;
//Use ConcurrentHashMap to store player and their close reason //Use ConcurrentHashMap to store player and their close reason
/* We used many async tasks so there is concurrent**/ /* We used many async tasks so there is concurrent**/
public static ConcurrentHashMap<Player, String> closeReasonMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<Player, String> closeReasonMap = new ConcurrentHashMap<>();
@@ -54,10 +67,17 @@ public class GuiCaptchaHandler implements Listener{
int howLongIsRandomString = (howManyRandom.nextInt(3) + 1); int howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
public GuiCaptchaHandler(Plugin plugin) { public GuiCaptchaHandler() {
this.plugin = plugin;
} }
private boolean isBedrockPlayer(UUID uuid) {
return AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null;
}
private void removePacketListeners() {
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener);
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
}
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
@@ -65,33 +85,31 @@ public class GuiCaptchaHandler implements Listener{
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
ItemStack currentItem = event.getCurrentItem(); ItemStack currentItem = event.getCurrentItem();
if (!authmeApi.isRegistered(player.getName()) && !closeReasonMap.containsKey(player)) { 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().getPlugin("floodgate") != null) { if (isBedrockPlayer(player.getUniqueId())) {
return; return;
} }
if (currentItem != null && currentItem.getType().equals(Material.REDSTONE_BLOCK)) { if (currentItem != null && currentItem.getType().equals(Material.REDSTONE_BLOCK)) {
event.setCancelled(true); event.setCancelled(true);
closeReasonMap.put(player, "verified"); closeReasonMap.put(player, "verified");
player.closeInventory(); player.closeInventory();
player.sendMessage("§a验证完成"); messages.send(player, MessageKey.GUI_CAPTCHA_VERIFIED);
} }
//force to string
} }
} }
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
randomString = ""; randomString = "";
Player playerunreg = event.getPlayer(); Player playerunreg = event.getPlayer();
String name = playerunreg.getName(); String name = playerunreg.getName();
if (!authmeApi.isRegistered(name)) { if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) {
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().getPlugin("floodgate") != null) { if (isBedrockPlayer(playerunreg.getUniqueId())) {
closeReasonMap.put(playerunreg, "verified"); closeReasonMap.put(playerunreg, "verified");
playerunreg.sendMessage("§a基岩版自动验证完成"); messages.send(playerunreg, MessageKey.GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK);
return; return;
} }
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { bukkitService.runTaskAsynchronously(() -> {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
howLongIsRandomString = (howManyRandom.nextInt(3) + 1); howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
for (int i = 0; i < howLongIsRandomString; i++) { for (int i = 0; i < howLongIsRandomString; i++) {
@@ -105,71 +123,66 @@ public class GuiCaptchaHandler implements Listener{
sb.append(randomChar); sb.append(randomChar);
} }
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
randomString = sb.toString(); randomString = sb.toString();
Random random_blockpos = new Random(); Random random_blockpos = new Random();
AtomicInteger random_num = new AtomicInteger(random_blockpos.nextInt(26)); AtomicInteger random_num = new AtomicInteger(random_blockpos.nextInt(26));
Inventory menu = Bukkit.createInventory(playerunreg, 27, randomString + "请验证你是真人"); Inventory menu = Bukkit.createInventory(playerunreg, 27, messages.retrieveSingle(playerunreg, MessageKey.GUI_CAPTCHA_WINDOW_NAME, randomString));
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK); ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
try { try {
if (meta != null) { if (meta != null) {
meta.setDisplayName("§a我是真人"); meta.setDisplayName(messages.retrieveSingle(playerunreg, MessageKey.GUI_CAPTCHA_CLICKABLE_NAME, randomString));
item.setItemMeta(meta); item.setItemMeta(meta);
} }
} catch (NullPointerException e) { } catch (NullPointerException e) {
getLogger().log(Level.WARNING, "Unexpected error occurred while setting item meta."); 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); menu.setItem(random_num.get(), item);
Bukkit.getScheduler().runTask(this.plugin, () -> { playerunreg.openInventory(menu);
playerunreg.openInventory(menu);
});
if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) { if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) {
long timeOut = AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT); long timeOut = AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT);
if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT)) { if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT)) {
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
getLogger().warning("AuthMe detected that your GUI captcha timeout seconds(" + AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) + ") is bigger than the Login timeout seconds(" + 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."); 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); timeOut = AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT);
} }
long finalTimeOut = timeOut; long finalTimeOut = timeOut;
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
Bukkit.getScheduler().runTaskLater(this.plugin, () -> { bukkitService.runTaskLater(() -> {
if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) { if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
playerunreg.kickPlayer("§c验证超时"); playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_TIMEOUT));
timesLeft = 3; // Reset the attempt counter timesLeft = 3; // Reset the attempt counter
} }
}, finalTimeOut * 20L); }, finalTimeOut * 20L);
}); });
} }
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
windowPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) { windowPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
@Override @Override
public void onPacketReceiving(PacketEvent event) { public void onPacketReceiving(PacketEvent event) {
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) { if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
if (timesLeft <= 0) { if (timesLeft <= 0) {
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
playerunreg.kickPlayer("§c请先完成人机验证!"); playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_FAILED));
}); });
timesLeft = 3; timesLeft = 3;
} else { } else {
--timesLeft; --timesLeft;
if (timesLeft <= 0) { if (timesLeft <= 0) {
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
playerunreg.kickPlayer("§c请先完成人机验证!"); playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_FAILED));
}); });
timesLeft = 3; timesLeft = 3;
return; return;
} }
playerunreg.sendMessage("§c请先完成验证!,你还有" + timesLeft + "次机会"); messages.send(playerunreg, MessageKey.GUI_CAPTCHA_RETRY_MESSAGE, String.valueOf(timesLeft));
event.setCancelled(true); event.setCancelled(true);
random_num.set(random_blockpos.nextInt(26)); random_num.set(random_blockpos.nextInt(26));
Bukkit.getScheduler().runTask(plugin, () -> { bukkitService.runTask(() -> {
menu.clear(); menu.clear();
menu.setItem(random_num.get(), item); menu.setItem(random_num.get(), item);
playerunreg.openInventory(menu); playerunreg.openInventory(menu);
@@ -180,12 +193,12 @@ public class GuiCaptchaHandler implements Listener{
}; };
ProtocolLibrary.getProtocolManager().addPacketListener(windowPacketListener); ProtocolLibrary.getProtocolManager().addPacketListener(windowPacketListener);
}); });
Bukkit.getScheduler().runTask(this.plugin, () -> { bukkitService.runTask(() -> {
chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) { chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
@Override @Override
public void onPacketReceiving(PacketEvent event) { public void onPacketReceiving(PacketEvent event) {
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) { if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
playerunreg.sendMessage("§c请先完成验证!"); messages.send(playerunreg, MessageKey.GUI_CAPTCHA_DENIED_MESSAGE);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@@ -226,6 +239,16 @@ public class GuiCaptchaHandler implements Listener{
} }
} }
private void deleteAuthMePlayerData(UUID playerUUID) {
File pluginFolder = plugin.getDataFolder();
File path = new File(pluginFolder, File.separator + "playerdata" + File.separator + playerUUID);
File dataFile = new File(path, File.separator + "data.json");
if (dataFile.exists()) {
dataFile.delete();
path.delete();
}
}
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@@ -234,16 +257,17 @@ public class GuiCaptchaHandler implements Listener{
if (!authmeApi.isRegistered(name)) { if (!authmeApi.isRegistered(name)) {
if (AuthMe.settings.getProperty(SecuritySettings.DELETE_UNVERIFIED_PLAYER_DATA) && !closeReasonMap.containsKey(player)) { if (AuthMe.settings.getProperty(SecuritySettings.DELETE_UNVERIFIED_PLAYER_DATA) && !closeReasonMap.containsKey(player)) {
closeReasonMap.remove(player); closeReasonMap.remove(player);
Bukkit.getScheduler().runTaskLater(this.plugin, () -> { bukkitService.runTaskLater(() -> {
if (!player.isOnline()) { if (!player.isOnline()) {
deletePlayerData(playerUUID); deletePlayerData(playerUUID);
deletePlayerStats(playerUUID); deletePlayerStats(playerUUID);
deleteAuthMePlayerData(playerUUID);
} }
}, 100L); }, 100L);
removePacketListeners();
return; return;
} }
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener); removePacketListeners();
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
closeReasonMap.remove(player); closeReasonMap.remove(player);
} }
} }
@@ -1,6 +1,9 @@
package fr.xephi.authme.listener; package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.TeleportUtils; import fr.xephi.authme.util.TeleportUtils;
import org.bukkit.Location; import org.bukkit.Location;
@@ -12,32 +15,33 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import javax.inject.Inject;
public class LoginLocationFixListener implements Listener { public class LoginLocationFixListener implements Listener {
private final Plugin plugin; @Inject
private AuthMe plugin;
@Inject
private Messages messages;
private final AuthMeApi authmeApi = AuthMeApi.getInstance(); private final AuthMeApi authmeApi = AuthMeApi.getInstance();
public LoginLocationFixListener(Plugin plugin) { public LoginLocationFixListener() {
this.plugin = plugin;
} }
private static Material material = Material.matchMaterial("PORTAL"); private static Material materialPortal = Material.matchMaterial("PORTAL");
private final boolean isSmartAsyncTeleport = AuthMe.settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT); private final boolean isSmartAsyncTeleport = AuthMe.settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT);
private final boolean isFixPortalStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL); private final boolean isFixPortalStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL);
private final boolean isFixGroundStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND); private final boolean isFixGroundStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND);
BlockFace[] faces = {BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST}; BlockFace[] faces = {BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST};
static { static {
if (material == null) { if (materialPortal == null) {
material = Material.matchMaterial("PORTAL_BLOCK"); materialPortal = Material.matchMaterial("PORTAL_BLOCK");
if (material == null) { if (materialPortal == null) {
material = Material.matchMaterial("NETHER_PORTAL"); materialPortal = Material.matchMaterial("NETHER_PORTAL");
} }
} }
} }
@EventHandler @EventHandler
@@ -45,7 +49,7 @@ public class LoginLocationFixListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location JoinLocation = player.getLocation().getBlock().getLocation().add(0.5, 0.1, 0.5); Location JoinLocation = player.getLocation().getBlock().getLocation().add(0.5, 0.1, 0.5);
if (isFixPortalStuck) { if (isFixPortalStuck) {
if (!JoinLocation.getBlock().getType().equals(material) && !JoinLocation.getBlock().getRelative(BlockFace.UP).getType().equals(material)) { if (!JoinLocation.getBlock().getType().equals(materialPortal) && !JoinLocation.getBlock().getRelative(BlockFace.UP).getType().equals(materialPortal)) {
return; return;
} }
Block JoinBlock = JoinLocation.getBlock(); Block JoinBlock = JoinLocation.getBlock();
@@ -65,7 +69,7 @@ public class LoginLocationFixListener implements Listener {
JoinBlock.getRelative(BlockFace.UP).breakNaturally(); JoinBlock.getRelative(BlockFace.UP).breakNaturally();
JoinBlock.breakNaturally(); JoinBlock.breakNaturally();
} }
player.sendMessage("§a你在登录时卡在了地狱门, 现已修正"); messages.send(player, MessageKey.LOCATION_FIX_PORTAL);
} else if (isFixGroundStuck) { } else if (isFixGroundStuck) {
Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType(); Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType();
World world = player.getWorld(); World world = player.getWorld();
@@ -88,7 +92,7 @@ public class LoginLocationFixListener implements Listener {
} else { } else {
player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5)); player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5));
} }
player.sendMessage("§a你被埋住了, 坐标已修正, 下次下线之前请小心!"); messages.send(player, MessageKey.LOCATION_FIX_UNDERGROUND);
break; break;
} }
if (i == MaxHeight) { if (i == MaxHeight) {
@@ -97,7 +101,7 @@ public class LoginLocationFixListener implements Listener {
} else { } else {
player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5)); player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5));
} }
player.sendMessage("§a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~"); messages.send(player, MessageKey.LOCATION_FIX_UNDERGROUND_CANT_FIX);
} }
} }
} }
@@ -4,13 +4,84 @@ package fr.xephi.authme.message;
* Keys for translatable messages managed by {@link Messages}. * Keys for translatable messages managed by {@link Messages}.
*/ */
public enum MessageKey { public enum MessageKey {
/** In order to use this command you must be authenticated! */ /**
* You have been disconnected due to doubled login.
*/
DOUBLE_LOGIN_FIX("double_login_fix.fix_message"),
/**
* You are stuck in portal during Login.
*/
LOCATION_FIX_PORTAL("login_location_fix.fix_portal"),
/**
* You are stuck underground during Login.
*/
LOCATION_FIX_UNDERGROUND("login_location_fix.fix_underground"),
/**
* You are stuck underground during Login, but we cant fix it.
*/
LOCATION_FIX_UNDERGROUND_CANT_FIX("login_location_fix.cannot_fix_underground"),
/**
* Bedrock auto login success!
*/
BEDROCK_AUTO_LOGGED_IN("bedrock_auto_login.success"),
/**
* %random Verification
*/
GUI_CAPTCHA_WINDOW_NAME("gui_captcha.captcha_window_name", "%random"),
/**
* %random I am human
*/
GUI_CAPTCHA_CLICKABLE_NAME("gui_captcha.captcha_clickable_name", "%random"),
/**
* Verification failed, you have %times retries left
*/
GUI_CAPTCHA_RETRY_MESSAGE("gui_captcha.message_on_retry", "%times"),
/**
* Bedrock verification success!
*/
GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK("gui_captcha.bedrock_auto_verify_success"),
/**
* Please be verified before chatting!
*/
GUI_CAPTCHA_DENIED_MESSAGE("gui_captcha.denied_message_sending"),
/**
* Verification timed out!
*/
GUI_CAPTCHA_KICK_TIMEOUT("gui_captcha.kick_on_timeout"),
/**
* Please complete the verification!
*/
GUI_CAPTCHA_KICK_FAILED("gui_captcha.kick_on_failed"),
/**
* Verification success!
*/
GUI_CAPTCHA_VERIFIED("gui_captcha.success"),
/**
* In order to use this command you must be authenticated!
*/
DENIED_COMMAND("error.denied_command"), DENIED_COMMAND("error.denied_command"),
/** A player with the same IP is already in game! */ /**
* A player with the same IP is already in game!
*/
SAME_IP_ONLINE("on_join_validation.same_ip_online"), SAME_IP_ONLINE("on_join_validation.same_ip_online"),
/** In order to chat you must be authenticated! */ /**
* In order to chat you must be authenticated!
*/
DENIED_CHAT("error.denied_chat"), DENIED_CHAT("error.denied_chat"),
/** AntiBot protection mode is enabled! You have to wait some minutes before joining the server. */ /** AntiBot protection mode is enabled! You have to wait some minutes before joining the server. */
@@ -149,6 +149,10 @@ public class MessageUpdater {
.put("verification", "Verification code") .put("verification", "Verification code")
.put("time", "Time units") .put("time", "Time units")
.put("two_factor", "Two-factor authentication") .put("two_factor", "Two-factor authentication")
.put("gui_captcha", "3rd party features: GUI Captcha")
.put("bedrock_auto_login", "3rd party features: Bedrock Auto Login")
.put("login_location_fix", "3rd party features: Login Location Fix")
.put("double_login_fix", "3rd party features: Double Login Fix")
.build(); .build();
Set<String> addedKeys = new HashSet<>(); Set<String> addedKeys = new HashSet<>();
@@ -73,7 +73,7 @@ public class AntiBotService implements SettingsDependent {
// Delay the schedule on first start // Delay the schedule on first start
if (startup) { if (startup) {
int delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY); int delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
bukkitService.scheduleSyncDelayedTask(enableTask, delay * TICKS_PER_SECOND); bukkitService.scheduleSyncDelayedTask(enableTask, (long) delay * TICKS_PER_SECOND);
startup = false; startup = false;
} else { } else {
enableTask.run(); enableTask.run();
@@ -91,7 +91,7 @@ public class AntiBotService implements SettingsDependent {
disableTask.cancel(); disableTask.cancel();
} }
// Schedule auto-disable // Schedule auto-disable
disableTask = bukkitService.runTaskLater(this::stopProtection, duration * TICKS_PER_MINUTE); disableTask = bukkitService.runTaskLater(this::stopProtection, (long) duration * TICKS_PER_MINUTE);
antiBotStatus = AntiBotStatus.ACTIVE; antiBotStatus = AntiBotStatus.ACTIVE;
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> { bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
// Inform admins // Inform admins
@@ -19,15 +19,19 @@ public final class SecuritySettings implements SettingsHolder {
public static final Property<Boolean> STOP_SERVER_ON_PROBLEM = public static final Property<Boolean> STOP_SERVER_ON_PROBLEM =
newProperty("Security.SQLProblem.stopServer", false); newProperty("Security.SQLProblem.stopServer", false);
@Comment({"Should we let Bedrock players login automatically?",
"(Requires hookFloodgate to be true & floodgate loaded)"})
public static final Property<Boolean> FORCE_LOGIN_BEDROCK = newProperty("3rdPartyFeature.features.bedrockAutoLogin", false);
@Comment("Enable the new feature to prevent ghost players?") @Comment("Enable the new feature to prevent ghost players?")
public static final Property<Boolean> ANTI_GHOST_PLAYERS = newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false); public static final Property<Boolean> ANTI_GHOST_PLAYERS = newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false);
@Comment({"Choose the best teleport method by server brand?", @Comment({"Choose the best teleport method by server brand?",
"(Enable this if you are using Paper)"}) "(Enable this if you are using Paper)"})
public static final Property<Boolean> SMART_ASYNC_TELEPORT = newProperty("3rdPartyFeature.optimizes.smartAsyncTeleport",false); public static final Property<Boolean> SMART_ASYNC_TELEPORT = newProperty("3rdPartyFeature.optimizes.smartAsyncTeleport", false);
@Comment("Send a GUI captcha to unregistered players?(Requires ProtocolLib)") @Comment("Send a GUI captcha to unregistered players?(Requires ProtocolLib)")
public static final Property<Boolean> GUI_CAPTCHA = newProperty("3rdPartyFeature.captcha.guiCaptcha",false); public static final Property<Boolean> GUI_CAPTCHA = newProperty("3rdPartyFeature.captcha.guiCaptcha", false);
@Comment({"Should we kick the players when they don't finish the GUI captcha in seconds?", @Comment({"Should we kick the players when they don't finish the GUI captcha in seconds?",
"(less than or equals 0 is disabled)"}) "(less than or equals 0 is disabled)"})
@@ -28,6 +28,7 @@ public class TeleportUtils {
try {//Detect Paper class try {//Detect Paper class
Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig"); Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig");
teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class); teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class);
teleportAsyncMethod.setAccessible(true);
// if detected,use teleportAsync() // if detected,use teleportAsync()
} catch (ClassNotFoundException | NoSuchMethodException e) { } catch (ClassNotFoundException | NoSuchMethodException e) {
teleportAsyncMethod = null; teleportAsyncMethod = null;
@@ -38,7 +39,6 @@ public class TeleportUtils {
public static void teleport(Player player, Location location) { public static void teleport(Player player, Location location) {
if (teleportAsyncMethod != null) { if (teleportAsyncMethod != null) {
try { try {
teleportAsyncMethod.setAccessible(true);
teleportAsyncMethod.invoke(player, location); teleportAsyncMethod.invoke(player, location);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
player.teleport(location); player.teleport(location);
@@ -155,3 +155,28 @@ time:
hours: 'hours' hours: 'hours'
day: 'day' day: 'day'
days: 'days' days: 'days'
# 3rd party features: GUI Captcha
gui_captcha:
success: '&aVerification success!'
bedrock_auto_verify_success: '&aBedrock verification success!'
captcha_window_name: '%random Verification'
captcha_clickable_name: '%random I am human'
message_on_retry: '&cVerification failed, you have %times retries left'
denied_message_sending: '&cPlease be verified before chatting!'
kick_on_failed: '&cPlease complete the verification!'
kick_on_timeout: '&cVerification timed out!'
# 3rd party features: Bedrock Auto Login
bedrock_auto_login:
success: '&aBedrock auto login success!'
# 3rd party features: Login Location Fix
login_location_fix:
fix_portal: '&aYou are stuck in portal during Login.'
fix_underground: '&aYou are stuck underground during Login.'
cannot_fix_underground: '&aYou are stuck underground during Login, but we cant fix it.'
# 3rd party features: Double Login Fix
double_login_fix:
fix_message: '&cYou have been disconnected due to doubled login.'
+37 -10
View File
@@ -154,13 +154,40 @@ time:
# Two-factor authentication # Two-factor authentication
two_factor: two_factor:
code_created: '&7您正在激活双重验证, 请打开 &a%url &7扫描二维码' code_created: '&7您正在激活双重验证, 请打开 &a%url &7扫描二维码'
confirmation_required: '&7请输入“/totp confirm <验证码>”来确认激活双重验证' confirmation_required: '&7请输入“/totp confirm <验证码>”来确认激活双重验证'
code_required: '&c请输入“/totp code <验证码>”来提交验证码' code_required: '&c请输入“/totp code <验证码>”来提交验证码'
already_enabled: '&a双重验证已启用' already_enabled: '&a双重验证已启用'
enable_error_no_code: '&c验证码丢失' enable_error_no_code: '&c验证码丢失'
enable_success: '&a已成功启用双重验证' enable_success: '&a已成功启用双重验证'
enable_error_wrong_code: '&c验证码错误或者已经过期,请重新执行“/totp add”' enable_error_wrong_code: '&c验证码错误或者已经过期,请重新执行“/totp add”'
not_enabled_error: '&c双重验证未在您的账号上启用,请使用“/totp add”来启用' not_enabled_error: '&c双重验证未在您的账号上启用,请使用“/totp add”来启用'
removed_success: '&c双重验证已从您的账号上禁用' removed_success: '&c双重验证已从您的账号上禁用'
invalid_code: '&c无效的验证码' invalid_code: '&c无效的验证码'
# 3rd party features: GUI Captcha
gui_captcha:
success: '&a*** 验证完成 ***'
bedrock_auto_verify_success: '&a*** 基岩版自动验证完成 ***'
captcha_window_name: '&k%random&r&n请验证你是真人'
captcha_clickable_name: '&k%random&r&n我是真人'
message_on_retry: '&c验证失败,你还有 %times 次机会'
denied_message_sending: '&c请先完成验证再聊天!'
kick_on_failed: '&c请先完成验证!'
kick_on_timeout: '&c验证超时'
# 3rd party features: Bedrock Auto Login
bedrock_auto_login:
success: "&a基岩版自动登录完成"
# 3rd party features: Login Location Fix
login_location_fix:
fix_portal: '&a你在登录时卡在了地狱门, 现已修正'
fix_underground: '&a你被埋住了, 坐标已修正, 下次下线之前请小心!'
cannot_fix_underground: '&a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~'
# 3rd party features: Double Login Fix
double_login_fix:
fix_message: '&a已修复幽灵玩家, 请重新进入'
+1 -1
View File
@@ -3,7 +3,7 @@ authors: [${pluginDescription.authors}]
website: http://github.com/HaHaWTH/AuthMeReReloaded/ website: http://github.com/HaHaWTH/AuthMeReReloaded/
description: A fork of AuthMeReloaded that contains bug fixes description: A fork of AuthMeReloaded that contains bug fixes
main: ${pluginDescription.main} main: ${pluginDescription.main}
version: 5.6.0-FORK-b29 version: 5.6.0-FORK-b32
api-version: 1.13 api-version: 1.13
softdepend: softdepend:
- Vault - Vault