Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82fade61d5 | |||
| fc5009bf0d | |||
| 9fe91fe22c | |||
| 37d327bcb6 | |||
| 217b411095 | |||
| 9239f3a90d | |||
| ae9d9ea159 | |||
| 12cfd243f6 | |||
| 059c00c2ad | |||
| 3dab24c142 | |||
| 4de55f9cf6 | |||
| 07d9bbbf7c | |||
| c182510a46 | |||
| aec1277ab3 | |||
| 32b694cbb0 | |||
| 932368f2d6 | |||
| 7a33fc8928 | |||
| d048db44ba | |||
| 76b92bacd9 | |||
| dadae42992 |
@@ -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
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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 = "27";
|
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.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
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;
|
||||||
@@ -22,19 +23,23 @@ 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.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
|
||||||
@@ -60,11 +65,7 @@ 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)) {
|
||||||
@@ -72,9 +73,6 @@ public class GuiCaptchaHandler implements Listener{
|
|||||||
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
|
||||||
}
|
}
|
||||||
@@ -88,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;
|
||||||
@@ -111,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 {
|
||||||
@@ -150,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())) {
|
||||||
@@ -159,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())) {
|
||||||
@@ -191,7 +189,8 @@ public class GuiCaptchaHandler implements Listener{
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(chatPacketListener);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -222,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();
|
||||||
}
|
}
|
||||||
@@ -235,6 +233,7 @@ public class GuiCaptchaHandler implements Listener{
|
|||||||
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)) {
|
||||||
|
closeReasonMap.remove(player);
|
||||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||||
if (!player.isOnline()) {
|
if (!player.isOnline()) {
|
||||||
deletePlayerData(playerUUID);
|
deletePlayerData(playerUUID);
|
||||||
@@ -243,6 +242,8 @@ public class GuiCaptchaHandler implements Listener{
|
|||||||
}, 100L);
|
}, 100L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener);
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
|
||||||
closeReasonMap.remove(player);
|
closeReasonMap.remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ 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.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;
|
||||||
@@ -17,22 +18,33 @@ 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};
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event){
|
static {
|
||||||
Player player = event.getPlayer();
|
|
||||||
Material material = Material.matchMaterial("PORTAL");
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
material = Material.matchMaterial("PORTAL_BLOCK");
|
material = Material.matchMaterial("PORTAL_BLOCK");
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
material = Material.matchMaterial("NETHER_PORTAL");
|
material = Material.matchMaterial("NETHER_PORTAL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
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 (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;
|
||||||
}
|
}
|
||||||
@@ -40,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;
|
||||||
}
|
}
|
||||||
@@ -50,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();
|
||||||
@@ -67,12 +83,20 @@ 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);
|
||||||
|
|
||||||
|
|||||||
@@ -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-b27
|
version: 5.6.0-FORK-b29
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend:
|
softdepend:
|
||||||
- Vault
|
- Vault
|
||||||
|
|||||||
Reference in New Issue
Block a user