Compare commits

...

28 Commits

Author SHA1 Message Date
HaHaWTH 82fade61d5 B29 update 2023-10-20 21:52:54 +08:00
HaHaWTH fc5009bf0d Use TeleportUtils 2023-10-20 21:40:16 +08:00
HaHaWTH 9fe91fe22c Use TeleportUtils 2023-10-20 21:30:36 +08:00
HaHaWTH 37d327bcb6 Merge remote-tracking branch 'origin/master' 2023-10-19 23:41:04 +08:00
HaHaWTH 217b411095 GUICaptcha is now beta 2023-10-19 23:40:50 +08:00
DGun Otto 9239f3a90d [ci skip] Update README.md 2023-10-19 22:17:01 +08:00
HaHaWTH ae9d9ea159 Merge remote-tracking branch 'origin/master' 2023-10-19 22:10:13 +08:00
HaHaWTH 12cfd243f6 Prepare for B29 2023-10-19 22:09:56 +08:00
DGun Otto 059c00c2ad Update sqlite-jdbc
Bump org.xerial:sqlite-jdbc from 3.40.1.0 to 3.43.2.1
2023-10-19 22:07:34 +08:00
HaHaWTH 3dab24c142 Delete useless options & make code more readable 2023-10-19 22:03:23 +08:00
dependabot[bot] 4de55f9cf6 Bump org.xerial:sqlite-jdbc from 3.40.1.0 to 3.43.2.1
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.40.1.0 to 3.43.2.1.
- [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.40.1.0...3.43.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-19 04:18:04 +00:00
HaHaWTH 07d9bbbf7c LoginLocationFixListener logic improvement 2023-10-18 22:11:16 +08:00
HaHaWTH c182510a46 Small clean up 2023-10-18 01:44:28 +08:00
HaHaWTH aec1277ab3 Update build 2023-10-17 00:50:10 +08:00
HaHaWTH 32b694cbb0 Infinity bug fix 2023-10-15 15:11:08 +08:00
HaHaWTH 932368f2d6 Massive bug fixes 2023-10-15 14:57:37 +08:00
HaHaWTH 7a33fc8928 Bug fix 2023-10-15 14:01:40 +08:00
HaHaWTH d048db44ba Fix 2023-10-15 12:36:31 +08:00
HaHaWTH 76b92bacd9 Prepare for B28 2023-10-15 10:25:26 +08:00
HaHaWTH dadae42992 Improve GUI captcha performance 2023-10-15 10:12:08 +08:00
HaHaWTH 1e9058a5cb Clean up 2023-10-15 09:08:48 +08:00
HaHaWTH b307911896 Small tweaks 2023-10-15 09:06:12 +08:00
HaHaWTH 11a1547242 Rewrite the update checker 2023-10-14 21:52:05 +08:00
HaHaWTH 17ee5dc97b Prepare for B27 2023-10-14 20:37:23 +08:00
HaHaWTH ac89630f5d Improve version compatibility 2023-10-14 19:24:12 +08:00
HaHaWTH 94028484cf Revert changes 2023-10-14 19:15:49 +08:00
HaHaWTH 1b1fd77470 Merge remote-tracking branch 'origin/master' 2023-10-14 19:09:54 +08:00
HaHaWTH 7a7b148a7d Logic Improvement 2023-10-14 19:09:35 +08:00
7 changed files with 146 additions and 113 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471
3. Old bug fixes 3. Old bug fixes
4. Anti Ghost Player(Doubled login bug) 4. Anti Ghost Player(Doubled login bug)
5. Use the best performance method by server brand 5. Use the best performance method by server brand
6. Bedrock Compatibility(Floodgate needed) 6. Bedrock Compatibility(Floodgate needed)(based on UUID)
7. Update checker 7. Update checker
8. Integrated GUI Captcha feature(Bedrock compatibility & ProtocolLib needed)(70% Asynchronous) 8. Integrated GUI Captcha feature(Bedrock compatibility & ProtocolLib needed)(70% Asynchronous)
9. Improved listeners 9. Improved listeners
+2 -2
View File
@@ -71,7 +71,7 @@
<!-- Versioning properties --> <!-- Versioning properties -->
<project.outputName>AuthMe</project.outputName> <project.outputName>AuthMe</project.outputName>
<project.buildNumber>CUSTOM</project.buildNumber> <project.buildNumber>28</project.buildNumber>
<project.versionCode>${project.version}-b${project.buildNumber}</project.versionCode> <project.versionCode>${project.version}-b${project.buildNumber}</project.versionCode>
<project.finalNameBase>${project.outputName}-${project.version}</project.finalNameBase> <project.finalNameBase>${project.outputName}-${project.version}</project.finalNameBase>
@@ -1078,7 +1078,7 @@
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.40.1.0</version> <version>3.43.2.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
+36 -20
View File
@@ -9,22 +9,17 @@ import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.initialization.DataSourceProvider; import fr.xephi.authme.initialization.DataSourceProvider;
import fr.xephi.authme.initialization.OnShutdownPlayerSaver; import fr.xephi.authme.initialization.OnShutdownPlayerSaver;
import fr.xephi.authme.initialization.OnStartupTasks; import fr.xephi.authme.initialization.OnStartupTasks;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
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.BlockListener; import fr.xephi.authme.listener.BlockListener;
import fr.xephi.authme.listener.DoubleLoginFixListener;
import fr.xephi.authme.listener.EntityListener; import fr.xephi.authme.listener.EntityListener;
import fr.xephi.authme.listener.GuiCaptchaHandler;
import fr.xephi.authme.listener.LoginLocationFixListener; import fr.xephi.authme.listener.LoginLocationFixListener;
import fr.xephi.authme.listener.PlayerListener; import fr.xephi.authme.listener.PlayerListener;
import fr.xephi.authme.listener.PlayerListener111; import fr.xephi.authme.listener.PlayerListener111;
import fr.xephi.authme.listener.PlayerListener19; import fr.xephi.authme.listener.PlayerListener19;
import fr.xephi.authme.listener.PlayerListener19Spigot; import fr.xephi.authme.listener.PlayerListener19Spigot;
import fr.xephi.authme.listener.DoubleLoginFixListener;
import fr.xephi.authme.listener.GuiCaptchaHandler;
import fr.xephi.authme.listener.PlayerListenerHigherThan18; import fr.xephi.authme.listener.PlayerListenerHigherThan18;
import fr.xephi.authme.listener.ServerListener; import fr.xephi.authme.listener.ServerListener;
import fr.xephi.authme.mail.EmailService; import fr.xephi.authme.mail.EmailService;
@@ -53,6 +48,9 @@ import org.bukkit.scheduler.BukkitScheduler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@@ -76,7 +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 = "26"; private static String pluginBuildNumber = "29";
protected final Boolean SHAEnabled = false; protected final Boolean SHAEnabled = false;
// Private instances // Private instances
private EmailService emailService; private EmailService emailService;
@@ -211,13 +209,13 @@ public class AuthMe extends JavaPlugin {
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) { if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
getServer().getPluginManager().registerEvents(new DoubleLoginFixListener((Plugin) this), this); getServer().getPluginManager().registerEvents(new DoubleLoginFixListener((Plugin) this), this);
} }
if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX)) { 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); getServer().getPluginManager().registerEvents(new LoginLocationFixListener((Plugin) this), this);
} }
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().isPluginEnabled("ProtocolLib")) { if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
getServer().getPluginManager().registerEvents(new GuiCaptchaHandler((Plugin) this), this); getServer().getPluginManager().registerEvents(new GuiCaptchaHandler((Plugin) this), this);
logger.info("(Alpha4)GUICaptcha Feature is enabled successfully!"); logger.info("(Beta)GUICaptcha is enabled successfully!");
logger.info("These features are still in development, if you encountered any problem, please report."); 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")) { } else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && !getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
logger.warning("ProtocolLib is not loaded, we can't enable GUI Captcha."); logger.warning("ProtocolLib is not loaded, we can't enable GUI Captcha.");
} }
@@ -390,15 +388,16 @@ public class AuthMe extends JavaPlugin {
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " is unloaded successfully!"); infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " is unloaded successfully!");
ConsoleLogger.closeFileWriter(); ConsoleLogger.closeFileWriter();
} }
private static final String owner = "HaHaWTH"; private static final String owner = "HaHaWTH";
private static final String owner_gitee = "Shixuehan114514"; private static final String owner_gitee = "Shixuehan114514";
private static final String repo = "AuthMeReReloaded"; private static final String repo = "AuthMeReReloaded";
private void checkForUpdates() { private void checkForUpdates() {
logger.info("Checking for updates..."); logger.info("Checking for updates...");
Bukkit.getScheduler().runTaskAsynchronously(this, () -> { Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
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");
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(10000); // 设置连接超时为10秒 conn.setConnectTimeout(10000); // 设置连接超时为10秒
@@ -410,20 +409,37 @@ public class AuthMe extends JavaPlugin {
// 处理JSON响应 // 处理JSON响应
String latestVersion = response.substring(response.indexOf("tag_name") + 11); String latestVersion = response.substring(response.indexOf("tag_name") + 11);
latestVersion = latestVersion.substring(0, latestVersion.indexOf("\"")); latestVersion = latestVersion.substring(0, latestVersion.indexOf("\""));
if ((pluginBuild + pluginBuildNumber).equals(latestVersion)) { if (isUpdateAvailable(latestVersion)) {
getLogger().log(Level.INFO,"You are running the latest version.");
}
if (!(pluginBuild + pluginBuildNumber).equals(latestVersion)) {
// Display update message
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.INFO, message);
getLogger().log(Level.INFO,"Download from here:github.com/HaHaWTH/AuthMeReReloaded/releases/latest"); getLogger().log(Level.INFO, "Download from here: github.com/HaHaWTH/AuthMeReReloaded/releases/latest");
} else {
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()); getLogger().log(Level.WARNING, "Error occurred while checking updates from GitHub. Reason: " + e.getMessage());
} }
}); });
} }
private boolean isUpdateAvailable(String latestVersion) {
// Extract the first character and the remaining digits from the version string
char latestChar = latestVersion.charAt(0);
int latestNumber = Integer.parseInt(latestVersion.substring(1));
char currentChar = pluginBuild.charAt(0);
int currentNumber = Integer.parseInt(pluginBuildNumber);
// Compare the characters first
if (latestChar > currentChar) {
return true;
} else if (latestChar < currentChar) {
return false;
} else {
// If the characters are the same, compare the numbers
return latestNumber > currentNumber;
}
}
private void checkServerType() { private void checkServerType() {
if (isClassLoaded("com.destroystokyo.paper.PaperConfig")) { if (isClassLoaded("com.destroystokyo.paper.PaperConfig")) {
@@ -1,10 +1,10 @@
package fr.xephi.authme.listener; package fr.xephi.authme.listener;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.earth2me.essentials.libs.checkerframework.checker.nullness.qual.NonNull;
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.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.HooksSettings;
@@ -23,26 +23,28 @@ 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 org.bukkit.plugin.Plugin;
import java.io.File; import java.io.File;
import java.util.Objects;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; 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 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; private final Plugin plugin;
private PacketAdapter chatPacketListener;
private PacketAdapter windowPacketListener;
//define timesLeft //define timesLeft
public int timesLeft = 3; public 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**/
protected static ConcurrentHashMap<Player, String> closeReasonMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<Player, String> closeReasonMap = new ConcurrentHashMap<>();
//define randomStringSet //define randomStringSet
String randomSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@#%&*()_+"; String randomSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@#%&*()_+";
String randomString = ""; String randomString = "";
@@ -63,21 +65,14 @@ 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().isPluginEnabled("floodgate") || getServer().getPluginManager().getPlugin("floodgate") != null)) { 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 (!closeReasonMap.containsKey(player)) {
closeReasonMap.put(player,"verified");
return; 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验证完成"); player.sendMessage("§a验证完成");
} else {
player.sendMessage("§c验证失败,你还有" + timesLeft + "§c次机会");
timesLeft--;
} }
//force to string //force to string
} }
@@ -91,7 +86,7 @@ public class GuiCaptchaHandler implements Listener {
Player playerunreg = event.getPlayer(); Player playerunreg = event.getPlayer();
String name = playerunreg.getName(); String name = playerunreg.getName();
if (!authmeApi.isRegistered(name)) { 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)) { 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) {
closeReasonMap.put(playerunreg, "verified"); closeReasonMap.put(playerunreg, "verified");
playerunreg.sendMessage("§a基岩版自动验证完成"); playerunreg.sendMessage("§a基岩版自动验证完成");
return; return;
@@ -114,7 +109,7 @@ public class GuiCaptchaHandler implements Listener {
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(null, 27, randomString + "请验证你是真人"); Inventory menu = Bukkit.createInventory(playerunreg, 27, 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 {
@@ -136,7 +131,7 @@ public class GuiCaptchaHandler implements Listener {
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, () -> { 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(" + 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);
@@ -153,7 +148,7 @@ public class GuiCaptchaHandler implements Listener {
} }
Bukkit.getScheduler().runTask(this.plugin, () -> { Bukkit.getScheduler().runTask(this.plugin, () -> {
ProtocolLibrary.getProtocolManager().addPacketListener(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())) {
@@ -162,31 +157,31 @@ public class GuiCaptchaHandler implements Listener {
playerunreg.kickPlayer("§c请先完成人机验证!"); playerunreg.kickPlayer("§c请先完成人机验证!");
}); });
timesLeft = 3; timesLeft = 3;
return;
} else { } else {
timesLeft--; --timesLeft;
playerunreg.sendMessage("§c请先完成验证!,你还有" + timesLeft + "次机会"); if (timesLeft <= 0) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
playerunreg.kickPlayer("§c请先完成人机验证!");
});
timesLeft = 3;
return;
} }
playerunreg.sendMessage("§c请先完成验证!,你还有" + timesLeft + "次机会");
event.setCancelled(true); event.setCancelled(true);
random_num.set(random_blockpos.nextInt(26)); random_num.set(random_blockpos.nextInt(26));
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
Bukkit.getScheduler().runTask(plugin, () -> { Bukkit.getScheduler().runTask(plugin, () -> {
menu.clear(); menu.clear();
menu.setItem(random_num.get(), item); menu.setItem(random_num.get(), item);
});
Bukkit.getScheduler().runTask(plugin, () -> {
playerunreg.openInventory(menu); playerunreg.openInventory(menu);
}); });
});
} }
} }
}); }
};
ProtocolLibrary.getProtocolManager().addPacketListener(windowPacketListener);
}); });
Bukkit.getScheduler().runTask(this.plugin, () -> { Bukkit.getScheduler().runTask(this.plugin, () -> {
chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
ProtocolLibrary.getProtocolManager().addPacketListener(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())) {
@@ -194,7 +189,8 @@ public class GuiCaptchaHandler implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
}); };
ProtocolLibrary.getProtocolManager().addPacketListener(chatPacketListener);
}); });
}); });
}); });
@@ -225,7 +221,6 @@ public class GuiCaptchaHandler implements Listener {
// 构建玩家统计数据文件路径 // 构建玩家统计数据文件路径
File statsFile = new File(statsFolder, File.separator + playerUUID + ".json"); File statsFile = new File(statsFolder, File.separator + playerUUID + ".json");
// 删除玩家统计数据文件 // 删除玩家统计数据文件
if (statsFile.exists()) { if (statsFile.exists()) {
statsFile.delete(); statsFile.delete();
} }
@@ -237,15 +232,18 @@ public class GuiCaptchaHandler implements Listener {
String name = player.getName(); String name = player.getName();
UUID playerUUID = event.getPlayer().getUniqueId(); UUID playerUUID = event.getPlayer().getUniqueId();
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)) {
Bukkit.getScheduler().runTaskLater(this.plugin , () -> { closeReasonMap.remove(player);
if(!player.isOnline()) { Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
if (!player.isOnline()) {
deletePlayerData(playerUUID); deletePlayerData(playerUUID);
deletePlayerStats(playerUUID); deletePlayerStats(playerUUID);
} }
},100L); }, 100L);
return; return;
} }
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener);
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
closeReasonMap.remove(player); closeReasonMap.remove(player);
} }
} }
@@ -1,39 +1,50 @@
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.events.LoginEvent;
import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.TeleportUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
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 org.bukkit.plugin.Plugin;
public class LoginLocationFixListener implements Listener{
public class LoginLocationFixListener implements Listener {
private final Plugin plugin; private final Plugin plugin;
private final AuthMeApi authmeApi = AuthMeApi.getInstance(); private final AuthMeApi authmeApi = AuthMeApi.getInstance();
public LoginLocationFixListener(Plugin plugin) { public LoginLocationFixListener(Plugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
private static Material material = Material.matchMaterial("PORTAL");
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 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 {
if (material == null) {
material = Material.matchMaterial("PORTAL_BLOCK");
if (material == null) {
material = Material.matchMaterial("NETHER_PORTAL");
}
}
}
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (authmeApi.isRegistered(player.getName())) {
Material material = Material.matchMaterial("PORTAL");
if (material == null) {
material = Material.matchMaterial("PORTAL_BLOCK");
} else {
material = Material.matchMaterial("NETHER_PORTAL");
}
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 (AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL)) { if (isFixPortalStuck) {
if (!JoinLocation.getBlock().getType().equals(material) && !JoinLocation.getBlock().getRelative(BlockFace.UP).getType().equals(material)) { if (!JoinLocation.getBlock().getType().equals(material) && !JoinLocation.getBlock().getRelative(BlockFace.UP).getType().equals(material)) {
return; return;
} }
@@ -41,7 +52,11 @@ public class LoginLocationFixListener implements Listener{
boolean solved = false; boolean solved = false;
for (BlockFace face : faces) { for (BlockFace face : faces) {
if (JoinBlock.getRelative(face).getType().equals(Material.AIR) && JoinBlock.getRelative(face).getRelative(BlockFace.UP).getType().equals(Material.AIR)) { if (JoinBlock.getRelative(face).getType().equals(Material.AIR) && JoinBlock.getRelative(face).getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
if (isSmartAsyncTeleport) {
TeleportUtils.teleport(player, JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5));
} else {
player.teleport(JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5)); player.teleport(JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5));
}
solved = true; solved = true;
break; break;
} }
@@ -51,7 +66,7 @@ public class LoginLocationFixListener implements Listener{
JoinBlock.breakNaturally(); JoinBlock.breakNaturally();
} }
player.sendMessage("§a你在登录时卡在了地狱门, 现已修正"); player.sendMessage("§a你在登录时卡在了地狱门, 现已修正");
} else if (AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND)) { } 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();
int MaxHeight = world.getMaxHeight(); int MaxHeight = world.getMaxHeight();
@@ -68,16 +83,23 @@ public class LoginLocationFixListener implements Listener{
if (JoinBlock.getRelative(BlockFace.DOWN).getType().equals(Material.LAVA)) { if (JoinBlock.getRelative(BlockFace.DOWN).getType().equals(Material.LAVA)) {
JoinBlock.getRelative(BlockFace.DOWN).setType(Material.DIRT); JoinBlock.getRelative(BlockFace.DOWN).setType(Material.DIRT);
} }
if (isSmartAsyncTeleport) {
TeleportUtils.teleport(player, JoinBlock.getLocation().add(0.5, 0.1, 0.5));
} 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你被埋住了, 坐标已修正, 下次下线之前请小心!"); player.sendMessage("§a你被埋住了, 坐标已修正, 下次下线之前请小心!");
break; break;
} }
if (i == MaxHeight) { if (i == MaxHeight) {
if (isSmartAsyncTeleport) {
TeleportUtils.teleport(player, JoinBlock.getLocation().add(0.5, 1.1, 0.5));
} 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你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~"); player.sendMessage("§a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~");
} }
} }
} }
} }
}
} }
@@ -2,10 +2,10 @@ package fr.xephi.authme.settings.properties;
import ch.jalu.configme.Comment; import ch.jalu.configme.Comment;
import ch.jalu.configme.SettingsHolder; import ch.jalu.configme.SettingsHolder;
import ch.jalu.configme.properties.Property; import ch.jalu.configme.properties.Property;
import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.settings.EnumSetProperty; import fr.xephi.authme.settings.EnumSetProperty;
import java.util.Set; import java.util.Set;
import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty; import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty;
@@ -43,9 +43,6 @@ public final class SecuritySettings implements SettingsHolder {
@Comment("Which world's player data should be deleted?(Enter the world *FOLDER* name where your players first logged in)") @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"); public static final Property<String> DELETE_PLAYER_DATA_WORLD = newProperty("3rdPartyFeature.captcha.purgeWorldFolderName","world");
@Comment("Should we enable the new LoginLocationFix feature?")
public static final Property<Boolean> LOGIN_LOC_FIX = newProperty("3rdPartyFeature.fixes.loginLocationFix.enabled", false);
@Comment("Should we fix the location when players logged in the portal?") @Comment("Should we fix the location when players logged in the portal?")
public static final Property<Boolean> LOGIN_LOC_FIX_SUB_PORTAL = newProperty("3rdPartyFeature.fixes.loginLocationFix.fixPortalStuck", false); public static final Property<Boolean> LOGIN_LOC_FIX_SUB_PORTAL = newProperty("3rdPartyFeature.fixes.loginLocationFix.fixPortalStuck", false);
+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-b26 version: 5.6.0-FORK-b29
api-version: 1.13 api-version: 1.13
softdepend: softdepend:
- Vault - Vault