Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4533f52016 | |||
| ae36036874 | |||
| 6f19a5442f | |||
| 3019e33945 | |||
| 7e49e26735 | |||
| b014da245d | |||
| 912e607144 | |||
| af71f9f5fe | |||
| 53d4206271 | |||
| 110fc7266d | |||
| b1bee0967c | |||
| e9481db633 | |||
| 82f29af1ae | |||
| 7e5d9ed1e8 | |||
| 55152a62c4 | |||
| 1b12d1b7d5 | |||
| 527f7f21c7 | |||
| 0205f585df | |||
| d44792baa5 | |||
| 68ac58686d | |||
| 25caa602fd | |||
| b36590c827 |
@@ -1,144 +1,4 @@
|
|||||||
# AuthMeReReloaded
|
# AuthMeReReloaded
|
||||||
**"A Fork of Authme that contains many bug fixes!"**
|
**"A fork of the best authentication plugin for the Bukkit modding API!"**
|
||||||
**请前往Releases下载最新版本**
|
|
||||||
<img src="wallpaper.png?raw=true" alt="AuthMeLogo"/>
|
|
||||||
|
|
||||||
| Type | Badges |
|

|
||||||
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| **General:** |   |
|
|
||||||
| **代码质量:** | [](https://codeclimate.com/github/AuthMe/AuthMeReloaded) [](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master) |
|
|
||||||
| **Jenkins CI:** | [](https://ci.codemc.org/) [](https://ci.codemc.org/job/AuthMe/job/AuthMeReloaded)  |
|
|
||||||
| **Other CIs:** | [](https://www.travis-ci.com/AuthMe/AuthMeReloaded) |
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
Prevent username stealing on your server!<br>
|
|
||||||
Use it to secure your Offline mode server or to increase your Online mode server's protection!
|
|
||||||
|
|
||||||
AuthMeReloaded disallows players who aren't authenticated to do actions like placing blocks, moving,<br>
|
|
||||||
typing commands or using the inventory. It can also kick players with uncommonly long or short player names or kick players from banned countries.
|
|
||||||
|
|
||||||
With the Session Login feature you don't have to execute the authentication command every time you connect to the server!
|
|
||||||
Each command and every feature can be enabled or disabled from our well structured configuration file.
|
|
||||||
|
|
||||||
You can also create your own translation file and, if you want, you can share it with us! :)
|
|
||||||
|
|
||||||
#### Features:
|
|
||||||
<ul>
|
|
||||||
<li><strong>E-Mail Recovery System!</strong></li>
|
|
||||||
<li>Username spoofing protection.</li>
|
|
||||||
<li>Countries Whitelist/Blacklist! <a href="https://dev.maxmind.com/geoip/legacy/codes/iso3166/">(country codes)</a></li>
|
|
||||||
<li><strong>Built-in AntiBot System!</strong></li>
|
|
||||||
<li><strong>ForceLogin Feature: Admins can login with all account via console command!</strong></li>
|
|
||||||
<li><strong>Avoid the "Logged in from another location" message!</strong></li>
|
|
||||||
<li>Two-factor (2FA) support!</li>
|
|
||||||
<li>Session Login!</li>
|
|
||||||
<li>Editable translations and messages!</li>
|
|
||||||
<li><strong>MySQL and SQLite Backend support!</strong></li>
|
|
||||||
<li>Supported password encryption algorithms: SHA256, ARGON2, BCRYPT, PBKDF2, <a href="https://github.com/CypherX/xAuth/wiki/Password-Hashing">xAuth</a></li>
|
|
||||||
<li>Supported alternative registration methods:<br>
|
|
||||||
<ul>
|
|
||||||
<li>PHPBB, VBulletin: PHPBB - MD5VB</li>
|
|
||||||
<li>Xenforo: XFBCRYPT</li>
|
|
||||||
<li>MyBB: MYBB</li>
|
|
||||||
<li>IPB3: IPB3</li>
|
|
||||||
<li>IPB4: IPB4</li>
|
|
||||||
<li>PhpFusion: PHPFUSION</li>
|
|
||||||
<li>Joomla: JOOMLA</li>
|
|
||||||
<li>WBB3: WBB3*</li>
|
|
||||||
<li>SHA512: SALTEDSHA512</li>
|
|
||||||
<li>DoubleSaltedMD5: SALTED2MD5</li>
|
|
||||||
<li>WordPress: WORDPRESS</li>
|
|
||||||
<li><a href="https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/hash_algorithms.md">List of all supported hashes</a></li>
|
|
||||||
</ul></li>
|
|
||||||
<li>Custom MySQL tables/columns names (useful with forum databases)</li>
|
|
||||||
<li><strong>Cached database queries!</strong></li>
|
|
||||||
<li><strong>Fully compatible with Citizens2, CombatTag, CombatTagPlus!</strong></li>
|
|
||||||
<li>Compatible with Minecraft mods like <strong>BuildCraft or RedstoneCraft</strong></li>
|
|
||||||
<li>Restricted users (associate a username with an IP)</li>
|
|
||||||
<li>Protect player's inventory until correct authentication (requires ProtocolLib)</li>
|
|
||||||
<li>Saves the quit location of the player</li>
|
|
||||||
<li>Automatic database backup</li>
|
|
||||||
<li>Available languages: <a href="https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md">translations</a></li>
|
|
||||||
<li>Built-in Deprecated FlatFile (auths.db) to SQL (authme.sql) converter!</li>
|
|
||||||
<li><strong>Import your old database from other plugins like Rakamak, xAuth, CrazyLogin, RoyalAuth and vAuth!</strong></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
#### Configuration
|
|
||||||
[How to configure AuthMe](https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/config.md)
|
|
||||||
#### Commands
|
|
||||||
[Command list and usage](https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/commands.md)
|
|
||||||
#### Permissions
|
|
||||||
- authme.player.* - for all user commands
|
|
||||||
- authme.admin.* - for all admin commands
|
|
||||||
- [List of all permission nodes](http://github.com/AuthMe/AuthMeReloaded/blob/master/docs/permission_nodes.md)
|
|
||||||
|
|
||||||
#### How To
|
|
||||||
- [How to use the converter](https://github.com/AuthMe/AuthMeReloaded/wiki/Converters)
|
|
||||||
- [How to import database from xAuth](https://dev.bukkit.org/projects/authme-reloaded/pages/how-to-import-database-from-xauth)
|
|
||||||
- [Website integration](https://github.com/AuthMe/AuthMeReloaded/tree/master/samples/website_integration)
|
|
||||||
- [How to convert from Rakamak](https://dev.bukkit.org/projects/authme-reloaded/pages/how-to-import-database-from-rakamak)
|
|
||||||
- Convert between database types (e.g. SQLite to MySQL): /authme converter
|
|
||||||
|
|
||||||
|
|
||||||
## Links and Contacts
|
|
||||||
|
|
||||||
- **Support:**
|
|
||||||
- [GitHub issue tracker](https://github.com/AuthMe/AuthMeReloaded/issues)
|
|
||||||
- [Discord](https://discord.gg/Vn9eCyE)
|
|
||||||
- [BukkitDev page](https://dev.bukkit.org/projects/authme-reloaded)
|
|
||||||
- [Spigot page](https://www.spigotmc.org/resources/authmereloaded.6269/)
|
|
||||||
|
|
||||||
- **Dev resources:**
|
|
||||||
- <a href="https://ci.codemc.org/job/AuthMe/job/AuthMeReloaded/javadoc/">JavaDocs</a>
|
|
||||||
- <a href="http://repo.codemc.org/repository/maven-public/">Maven Repository</a>
|
|
||||||
```xml
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>codemc-repo</id>
|
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>fr.xephi</groupId>
|
|
||||||
<artifactId>authme</artifactId>
|
|
||||||
<version>5.6.0-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Statistics:**
|
|
||||||

|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
##### Compiling requirements:
|
|
||||||
>- JDK 11 (JDK 17 is recommended)
|
|
||||||
>- Maven
|
|
||||||
>- Git/Github (Optional)
|
|
||||||
|
|
||||||
##### How to compile the project:
|
|
||||||
>- Clone the project with Git/GitHub
|
|
||||||
>- Execute command "mvn clean package"
|
|
||||||
|
|
||||||
##### Running requirements:
|
|
||||||
>- Java 8 (Java 17 is recommended)
|
|
||||||
>- Paper or Spigot (1.8.X and up)<br>
|
|
||||||
(In case you use Thermos, Cauldron or similar, you have to update the SpecialSource library to support Java 8 plugins.
|
|
||||||
HowTo: https://github.com/games647/FastLogin/issues/111#issuecomment-272331347)
|
|
||||||
>- ProtocolLib (optional, required by some features)
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
##### Contributors:
|
|
||||||
Team members: <a href="https://github.com/AuthMe/AuthMeReloaded/wiki/Development-team">developers</a>, <a href="https://github.com/AuthMe/AuthMeReloaded/wiki/Translators">translators</a>
|
|
||||||
|
|
||||||
Credits for the old version of the plugin: d4rkwarriors, fabe1337, Whoami2 and pomo4ka
|
|
||||||
|
|
||||||
Thanks also to: AS1LV3RN1NJA, Hoeze and eprimex
|
|
||||||
|
|
||||||
##### GeoIP License:
|
|
||||||
This product uses data from the GeoLite API created by MaxMind, available at https://www.maxmind.com
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
<groupId>fr.xephi</groupId>
|
<groupId>fr.xephi</groupId>
|
||||||
<artifactId>authme</artifactId>
|
<artifactId>authme</artifactId>
|
||||||
<version>5.6.0-SNAPSHOT</version>
|
<version>5.6.0-FORK</version>
|
||||||
|
|
||||||
<name>AuthMeReloaded</name>
|
<name>AuthMeReReloaded</name>
|
||||||
<description>The first authentication plugin for the Bukkit API!</description>
|
<description>Fork of the first authentication plugin for the Bukkit API!</description>
|
||||||
<inceptionYear>2013</inceptionYear>
|
<inceptionYear>2013</inceptionYear>
|
||||||
<url>https://github.com/AuthMe/AuthMeReloaded</url>
|
<url>https://github.com/AuthMe/AuthMeReloaded</url>
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@
|
|||||||
<goal>shade</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${project.finalNameBase}-legacy</finalName>
|
<finalName>${project.finalNameBase}-Spigot-Universal</finalName>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>com.google.common</pattern>
|
<pattern>com.google.common</pattern>
|
||||||
@@ -616,7 +616,7 @@
|
|||||||
<groupId>org.geysermc.floodgate</groupId>
|
<groupId>org.geysermc.floodgate</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.2.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Jalu Injector -->
|
<!-- Jalu Injector -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -706,7 +706,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
<version>8.0.32</version>
|
<version>8.0.33</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -757,7 +757,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>31.0.1-jre</version>
|
<version>31.1-jre</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@@ -770,7 +770,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.9</version>
|
<version>2.10.1</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.1</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -802,7 +802,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>4.8.0</version>
|
<version>5.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@@ -1068,7 +1068,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xerial</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
<version>3.39.3.0</version>
|
<version>3.40.1.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -2,13 +2,27 @@ package fr.xephi.authme;
|
|||||||
|
|
||||||
import ch.jalu.injector.Injector;
|
import ch.jalu.injector.Injector;
|
||||||
import ch.jalu.injector.InjectorBuilder;
|
import ch.jalu.injector.InjectorBuilder;
|
||||||
|
import com.google.gson.annotations.Since;
|
||||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
|
import fr.xephi.authme.command.CommandArgumentDescription;
|
||||||
import fr.xephi.authme.command.CommandHandler;
|
import fr.xephi.authme.command.CommandHandler;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
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.BufferedReader;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import fr.xephi.authme.initialization.SettingsProvider;
|
import fr.xephi.authme.initialization.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;
|
||||||
@@ -17,6 +31,8 @@ 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.PlayerQuitListener;
|
||||||
|
import fr.xephi.authme.listener.RegisterListener;
|
||||||
import fr.xephi.authme.listener.ServerListener;
|
import fr.xephi.authme.listener.ServerListener;
|
||||||
import fr.xephi.authme.mail.EmailService;
|
import fr.xephi.authme.mail.EmailService;
|
||||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||||
@@ -29,26 +45,40 @@ 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.RegistrationSettings;
|
||||||
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 fr.xephi.authme.util.TeleportUtils;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
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;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import fr.xephi.authme.listener.PlayerQuitListener;
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Scanner;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
|
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
|
||||||
import static fr.xephi.authme.util.Utils.isClassLoaded;
|
import static fr.xephi.authme.util.Utils.isClassLoaded;
|
||||||
|
import static org.bukkit.Bukkit.getServer;
|
||||||
|
import static org.bukkit.Bukkit.isHardcore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AuthMe main class.
|
* The AuthMe main class.
|
||||||
@@ -61,12 +91,14 @@ public class AuthMe extends JavaPlugin {
|
|||||||
private static final int CLEANUP_INTERVAL = 5 * TICKS_PER_MINUTE;
|
private static final int CLEANUP_INTERVAL = 5 * TICKS_PER_MINUTE;
|
||||||
|
|
||||||
// Version and build number values
|
// Version and build number values
|
||||||
private static String pluginVersion = "5.6.0";
|
private static String pluginVersion = "5.6.0-Fork";
|
||||||
private static String pluginBuildNumber = "Custom";
|
private static final String pluginBuild = "b";
|
||||||
|
private static String pluginBuildNumber = "17";
|
||||||
|
protected final Boolean SHAEnabled = false;
|
||||||
// Private instances
|
// Private instances
|
||||||
private EmailService emailService;
|
private EmailService emailService;
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
|
@Inject
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
private DataSource database;
|
private DataSource database;
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
@@ -79,7 +111,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public AuthMe() {
|
public AuthMe() {
|
||||||
}
|
}
|
||||||
|
public static Boolean SATEnabled = false;
|
||||||
|
public static Boolean GUIEnabled = false;
|
||||||
/**
|
/**
|
||||||
* Get the plugin's name.
|
* Get the plugin's name.
|
||||||
*
|
*
|
||||||
@@ -107,31 +140,34 @@ public class AuthMe extends JavaPlugin {
|
|||||||
return pluginBuildNumber;
|
return pluginBuildNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called when the server enables the plugin.
|
* Method called when the server enables the plugin.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
AuthMe.GUIEnabled = false;
|
||||||
|
AuthMe.SATEnabled = false;
|
||||||
// Load the plugin version data from the plugin description file
|
// Load the plugin version data from the plugin description file
|
||||||
loadPluginInfo(getDescription().getVersion());
|
loadPluginInfo(getDescription().getVersion());
|
||||||
|
|
||||||
// Set the Logger instance and log file path
|
// Set the Logger instance and log file path
|
||||||
ConsoleLogger.initialize(getLogger(), new File(getDataFolder(), LOG_FILENAME));
|
ConsoleLogger.initialize(getLogger(), new File(getDataFolder(), LOG_FILENAME));
|
||||||
logger = ConsoleLoggerFactory.get(AuthMe.class);
|
logger = ConsoleLoggerFactory.get(AuthMe.class);
|
||||||
|
logger.info("您正在加载的是由第三方Fork并修复众多错误的 AuthMeReReloaded!");
|
||||||
|
|
||||||
// Check server version
|
// Check server version
|
||||||
if (!isClassLoaded("org.spigotmc.event.player.PlayerSpawnLocationEvent")
|
if (!isClassLoaded("org.spigotmc.event.player.PlayerSpawnLocationEvent")
|
||||||
|| !isClassLoaded("org.bukkit.event.player.PlayerInteractAtEntityEvent")) {
|
|| !isClassLoaded("org.bukkit.event.player.PlayerInteractAtEntityEvent")) {
|
||||||
logger.warning("You are running an unsupported server version (" + getServerNameVersionSafe() + "). "
|
logger.warning("你正在运行不受支持的服务器版本 (" + getServerNameVersionSafe() + "). "
|
||||||
+ "AuthMe requires Spigot 1.8.X or later!");
|
+ "AuthMe 仅支持Spigot 1.9及之后的版本!");
|
||||||
stopOrUnload();
|
stopOrUnload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent running AuthMeBridge due to major exploit issues
|
// Prevent running AuthMeBridge due to major exploit issues
|
||||||
if (getServer().getPluginManager().isPluginEnabled("AuthMeBridge")) {
|
if (getServer().getPluginManager().isPluginEnabled("AuthMeBridge")) {
|
||||||
logger.warning("Detected AuthMeBridge, support for it has been dropped as it was "
|
logger.warning("检测到 AuthMeBridge被加载, 对AuthMeBridge的支持已经停止 "
|
||||||
+ "causing exploit issues, please use AuthMeBungee instead! Aborting!");
|
+ "且可能会造成严重漏洞! 已中止加载!");
|
||||||
stopOrUnload();
|
stopOrUnload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -142,11 +178,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
YamlParseException yamlParseException = ExceptionUtils.findThrowableInCause(YamlParseException.class, th);
|
YamlParseException yamlParseException = ExceptionUtils.findThrowableInCause(YamlParseException.class, th);
|
||||||
if (yamlParseException == null) {
|
if (yamlParseException == null) {
|
||||||
logger.logException("Aborting initialization of AuthMe:", th);
|
logger.logException("已中止AuthMeReReloaded的初始化,原因:", th);
|
||||||
th.printStackTrace();
|
th.printStackTrace();
|
||||||
} else {
|
} else {
|
||||||
logger.logException("File '" + yamlParseException.getFile() + "' contains invalid YAML. "
|
logger.logException("文件 '" + yamlParseException.getFile() + "' 包含YAML语法错误. "
|
||||||
+ "Please run its contents through https://yamllint.com", yamlParseException);
|
+ "请尝试在 https://yamllint.com 中运行文件内容", yamlParseException);
|
||||||
}
|
}
|
||||||
stopOrUnload();
|
stopOrUnload();
|
||||||
return;
|
return;
|
||||||
@@ -158,7 +194,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Schedule clean up task
|
// Schedule clean up task
|
||||||
CleanupTask cleanupTask = injector.getSingleton(CleanupTask.class);
|
CleanupTask cleanupTask = injector.getSingleton(CleanupTask.class);
|
||||||
cleanupTask.runTaskTimerAsynchronously(this, CLEANUP_INTERVAL, CLEANUP_INTERVAL);
|
cleanupTask.runTaskTimerAsynchronously(this, CLEANUP_INTERVAL, CLEANUP_INTERVAL);
|
||||||
|
|
||||||
// Do a backup on start
|
// Do a backup on start
|
||||||
backupService.doBackup(BackupService.BackupCause.START);
|
backupService.doBackup(BackupService.BackupCause.START);
|
||||||
|
|
||||||
@@ -166,18 +201,43 @@ public class AuthMe extends JavaPlugin {
|
|||||||
OnStartupTasks.sendMetrics(this, settings);
|
OnStartupTasks.sendMetrics(this, settings);
|
||||||
|
|
||||||
// Successful message
|
// Successful message
|
||||||
logger.info("AuthMeReloaded successfully enabled!");
|
logger.info("AuthMeReReloaded 已成功启动!");
|
||||||
|
|
||||||
// Purge on start if enabled
|
// Purge on start if enabled
|
||||||
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)*/) {
|
||||||
|
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerQuitListener((Plugin) this), this);
|
||||||
}
|
}
|
||||||
|
if (settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
|
||||||
|
logger.info("(RC2)SmartAsyncTeleport功能已注册");
|
||||||
|
AuthMe.SATEnabled = true;
|
||||||
|
}
|
||||||
|
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||||
|
getServer().getPluginManager().registerEvents(new RegisterListener((Plugin) this), this);
|
||||||
|
logger.info("(RC2)GUI验证码功能已注册");
|
||||||
|
AuthMe.GUIEnabled = true;
|
||||||
|
} else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && !getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||||
|
logger.warning("ProtocolLib未加载,GUI验证码功能无法使用");
|
||||||
|
}
|
||||||
|
logger.info("以上功能尚在测试中,如有问题请反馈,如需关闭请前往config.yml修改");
|
||||||
|
logger.info("反馈地址: github.com/HaHaWTH/AuthMeReReloaded/issues");
|
||||||
|
}
|
||||||
|
if (settings.getProperty(SecuritySettings.CHECK_FOR_UPDATES)) {
|
||||||
|
checkForUpdates();
|
||||||
|
}
|
||||||
|
if (SHAEnabled){
|
||||||
|
//shaChecker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public File pluginfile = getFile();
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* @param versionRaw the version as given by the plugin description file
|
* @param versionRaw the version as given by the plugin description file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static void loadPluginInfo(String versionRaw) {
|
private static void loadPluginInfo(String versionRaw) {
|
||||||
int index = versionRaw.lastIndexOf("-");
|
int index = versionRaw.lastIndexOf("-");
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
@@ -320,9 +380,106 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Disabled correctly
|
// Disabled correctly
|
||||||
Consumer<String> infoLogMethod = logger == null ? getLogger()::info : logger::info;
|
Consumer<String> infoLogMethod = logger == null ? getLogger()::info : logger::info;
|
||||||
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " 已卸载!");
|
||||||
ConsoleLogger.closeFileWriter();
|
ConsoleLogger.closeFileWriter();
|
||||||
}
|
}
|
||||||
|
private static final String owner = "HaHaWTH";
|
||||||
|
private static final String owner_gitee = "Shixuehan114514";
|
||||||
|
private static final String repo = "AuthMeReReloaded";
|
||||||
|
private void checkForUpdates() {
|
||||||
|
logger.info("正在检查更新...");
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
|
try {
|
||||||
|
// Get the latest version number from GitHub
|
||||||
|
|
||||||
|
URL url = new URL("https://api.github.com/repos/" + owner + "/" + repo + "/releases/latest");
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setConnectTimeout(10000); // 设置连接超时为10秒
|
||||||
|
conn.setReadTimeout(10000); // 设置读取超时为10秒
|
||||||
|
Scanner scanner = new Scanner(conn.getInputStream());
|
||||||
|
String response = scanner.useDelimiter("\\Z").next();
|
||||||
|
scanner.close();
|
||||||
|
|
||||||
|
// Parse JSON response and extract version number
|
||||||
|
String latestVersion = response.substring(response.indexOf("tag_name") + 11);
|
||||||
|
latestVersion = latestVersion.substring(0, latestVersion.indexOf("\""));
|
||||||
|
if ((pluginBuild + pluginBuildNumber).equals(latestVersion)) {
|
||||||
|
getLogger().log(Level.INFO,"当前为最新版本");
|
||||||
|
}
|
||||||
|
if (!(pluginBuild + pluginBuildNumber).equals(latestVersion)) {
|
||||||
|
// Display update message to users
|
||||||
|
String message = "有新版本可用! 最新版本:" + latestVersion + " 当前版本:" + pluginBuild + pluginBuildNumber;
|
||||||
|
getLogger().log(Level.INFO, message);
|
||||||
|
getLogger().log(Level.INFO,"下载地址:github.com/HaHaWTH/AuthMeReReloaded/releases/latest");
|
||||||
|
}
|
||||||
|
}catch (IOException e) {
|
||||||
|
getLogger().log(Level.WARNING,"从GitHub检查更新时出现错误,原因: " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle Bukkit commands.
|
* Handle Bukkit commands.
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public final class ConsoleLogger {
|
|||||||
*/
|
*/
|
||||||
public void warning(String message) {
|
public void warning(String message) {
|
||||||
logger.warning(message);
|
logger.warning(message);
|
||||||
writeLog("[WARN] " + message);
|
writeLog("[警告] " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,7 +128,7 @@ public final class ConsoleLogger {
|
|||||||
*/
|
*/
|
||||||
public void info(String message) {
|
public void info(String message) {
|
||||||
logger.info(message);
|
logger.info(message);
|
||||||
writeLog("[INFO] " + message);
|
writeLog("[信息] " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +142,7 @@ public final class ConsoleLogger {
|
|||||||
public void fine(String message) {
|
public void fine(String message) {
|
||||||
if (logLevel.includes(LogLevel.FINE)) {
|
if (logLevel.includes(LogLevel.FINE)) {
|
||||||
logger.info(message);
|
logger.info(message);
|
||||||
writeLog("[FINE] " + message);
|
writeLog("[信息:调试] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ public final class ConsoleLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logAndWriteWithDebugPrefix(String message) {
|
private void logAndWriteWithDebugPrefix(String message) {
|
||||||
String debugMessage = "[DEBUG] " + message;
|
String debugMessage = "[信息:调试] " + message;
|
||||||
logger.info(debugMessage);
|
logger.info(debugMessage);
|
||||||
writeLog(debugMessage);
|
writeLog(debugMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ public abstract class PlayerCommand implements ExecutableCommand {
|
|||||||
} else {
|
} else {
|
||||||
String alternative = getAlternativeCommand();
|
String alternative = getAlternativeCommand();
|
||||||
if (alternative != null) {
|
if (alternative != null) {
|
||||||
sender.sendMessage("Player only! Please use " + alternative + " instead.");
|
sender.sendMessage("此命令仅限玩家使用!请使用 " + alternative + " .");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("This command is only for players.");
|
sender.sendMessage("此命令只能被玩家执行.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
import fr.xephi.authme.command.PlayerCommand;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
import fr.xephi.authme.util.TeleportUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -11,16 +15,22 @@ import java.util.List;
|
|||||||
* Teleports the player to the first spawn.
|
* Teleports the player to the first spawn.
|
||||||
*/
|
*/
|
||||||
public class FirstSpawnCommand extends PlayerCommand {
|
public class FirstSpawnCommand extends PlayerCommand {
|
||||||
|
@Inject
|
||||||
|
private Settings settings;
|
||||||
@Inject
|
@Inject
|
||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runCommand(Player player, List<String> arguments) {
|
public void runCommand(Player player, List<String> arguments) {
|
||||||
if (spawnLoader.getFirstSpawn() == null) {
|
if (spawnLoader.getFirstSpawn() == null) {
|
||||||
player.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn");
|
player.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn");
|
||||||
|
} else {
|
||||||
|
//String name= player.getName();
|
||||||
|
if(AuthMe.SATEnabled) {
|
||||||
|
TeleportUtils.teleport(player, spawnLoader.getFirstSpawn());
|
||||||
} else {
|
} else {
|
||||||
player.teleport(spawnLoader.getFirstSpawn());
|
player.teleport(spawnLoader.getFirstSpawn());
|
||||||
}
|
}
|
||||||
|
//player.teleport(spawnLoader.getFirstSpawn());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -42,6 +42,12 @@ public class ChangePasswordCommand extends PlayerCommand {
|
|||||||
commonService.send(player, MessageKey.NOT_LOGGED_IN);
|
commonService.send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Check if the user has been verified or not
|
||||||
|
if (codeManager.isVerificationRequired(player)) {
|
||||||
|
codeManager.codeExistOrGenerateNew(name);
|
||||||
|
commonService.send(player, MessageKey.VERIFICATION_CODE_REQUIRED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String oldPassword = arguments.get(0);
|
String oldPassword = arguments.get(0);
|
||||||
String newPassword = arguments.get(1);
|
String newPassword = arguments.get(1);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class OnStartupTasks {
|
|||||||
* @param settings the settings
|
* @param settings the settings
|
||||||
*/
|
*/
|
||||||
public static void sendMetrics(AuthMe plugin, Settings settings) {
|
public static void sendMetrics(AuthMe plugin, Settings settings) {
|
||||||
final Metrics metrics = new Metrics(plugin, 164);
|
final Metrics metrics = new Metrics(plugin, 18479);
|
||||||
|
|
||||||
metrics.addCustomChart(new SimplePie("messages_language",
|
metrics.addCustomChart(new SimplePie("messages_language",
|
||||||
() -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)));
|
() -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)));
|
||||||
|
|||||||
@@ -1,30 +1,40 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.PlayerUtils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityEvent;
|
import org.bukkit.event.entity.EntityEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service class for the AuthMe listeners to determine whether an event should be canceled.
|
* Service class for the AuthMe listeners to determine whether an event should be canceled.
|
||||||
*/
|
*/
|
||||||
class ListenerService implements SettingsDependent {
|
class ListenerService implements SettingsDependent {
|
||||||
|
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final PlayerCache playerCache;
|
private final PlayerCache playerCache;
|
||||||
private final ValidationService validationService;
|
private final ValidationService validationService;
|
||||||
|
|
||||||
private boolean isRegistrationForced;
|
private boolean isRegistrationForced;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ListenerService(Settings settings, DataSource dataSource, PlayerCache playerCache,
|
ListenerService(Settings settings, DataSource dataSource, PlayerCache playerCache,
|
||||||
ValidationService validationService) {
|
ValidationService validationService) {
|
||||||
@@ -76,9 +86,18 @@ class ListenerService implements SettingsDependent {
|
|||||||
* @param player the player to verify
|
* @param player the player to verify
|
||||||
* @return true if the associated event should be canceled, false otherwise
|
* @return true if the associated event should be canceled, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean shouldCancelEvent(Player player) {
|
public boolean shouldCancelEvent(Player player) {
|
||||||
|
|
||||||
return player != null && !checkAuth(player.getName()) && !PlayerUtils.isNpc(player);
|
return player != null && !checkAuth(player.getName()) && !PlayerUtils.isNpc(player);
|
||||||
}
|
}
|
||||||
|
public boolean shouldCancelInvEvent(Player player) {
|
||||||
|
try {
|
||||||
|
return !AuthMe.GUIEnabled || authmeApi.isRegistered(player.getName()) || RegisterListener.closeReasonMap.containsKey(player)/* || !player.getOpenInventory().getTitle().equals("请验证你是真人")*/;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(Settings settings) {
|
public void reload(Settings settings) {
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.listener.RegisterListener;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
import fr.xephi.authme.data.QuickCommandsProtectionManager;
|
import fr.xephi.authme.data.QuickCommandsProtectionManager;
|
||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
@@ -18,9 +26,12 @@ import fr.xephi.authme.settings.SpawnLoader;
|
|||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
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.util.TeleportUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -51,10 +62,15 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_MOVEMENT_RADIUS;
|
import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_MOVEMENT_RADIUS;
|
||||||
@@ -64,6 +80,10 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOW_UNAU
|
|||||||
* Listener class for player events.
|
* Listener class for player events.
|
||||||
*/
|
*/
|
||||||
public class PlayerListener implements Listener{
|
public class PlayerListener implements Listener{
|
||||||
|
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
@@ -93,9 +113,12 @@ public class PlayerListener implements Listener {
|
|||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
@Inject
|
@Inject
|
||||||
private QuickCommandsProtectionManager quickCommandsProtectionManager;
|
private QuickCommandsProtectionManager quickCommandsProtectionManager;
|
||||||
|
|
||||||
|
|
||||||
// Lowest priority to apply fast protection checks
|
// Lowest priority to apply fast protection checks
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onAsyncPlayerPreLoginEventLowest(AsyncPlayerPreLoginEvent event) {
|
public void onAsyncPlayerPreLoginEventLowest(AsyncPlayerPreLoginEvent event) {
|
||||||
|
|
||||||
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -111,8 +134,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (validationService.isUnrestricted(name)) {
|
if (validationService.isUnrestricted(name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getUniqueId())){
|
||||||
if (settings.getProperty(RestrictionSettings.HOOK_FLOODGATE_PLAYER) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getUniqueId())){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Non-blocking checks
|
// Non-blocking checks
|
||||||
@@ -121,9 +143,9 @@ public class PlayerListener implements Listener {
|
|||||||
} catch (FailedVerificationException e) {
|
} catch (FailedVerificationException e) {
|
||||||
event.setKickMessage(messages.retrieveSingle(name, e.getReason(), e.getArgs()));
|
event.setKickMessage(messages.retrieveSingle(name, e.getReason(), e.getArgs()));
|
||||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Login/join/leave events
|
* Login/join/leave events
|
||||||
@@ -184,7 +206,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||||
if (!PlayerListener19Spigot.isPlayerSpawnLocationEventCalled()) {
|
if (!PlayerListener19Spigot.isPlayerSpawnLocationEventCalled()) {
|
||||||
teleportationService.teleportOnJoin(player);
|
teleportationService.teleportOnJoin(player);
|
||||||
}
|
}
|
||||||
@@ -194,12 +216,15 @@ public class PlayerListener implements Listener {
|
|||||||
management.performJoin(player);
|
management.performJoin(player);
|
||||||
|
|
||||||
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH) // HIGH as EssentialsX listens at HIGHEST
|
@EventHandler(priority = EventPriority.HIGH) // HIGH as EssentialsX listens at HIGHEST
|
||||||
public void onJoinMessage(PlayerJoinEvent event) {
|
public void onJoinMessage(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
|
||||||
// Note: join message can be null, despite api documentation says not
|
// Note: join message can be null, despite api documentation says not
|
||||||
if (settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)) {
|
if (settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)) {
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
@@ -334,12 +359,12 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Limit player X and Z movements to 1 block
|
* Limit player X and Z movements
|
||||||
* Deny player Y+ movements (allows falling)
|
* Deny player Y+ movements (allows falling)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (from.getBlockX() == to.getBlockX()
|
if (from.getX() == to.getX()
|
||||||
&& from.getBlockZ() == to.getBlockZ()
|
&& from.getZ() == to.getZ()
|
||||||
&& from.getY() - to.getY() >= 0) {
|
&& from.getY() - to.getY() >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -362,12 +387,20 @@ public class PlayerListener implements Listener {
|
|||||||
Location spawn = spawnLoader.getSpawnLocation(player);
|
Location spawn = spawnLoader.getSpawnLocation(player);
|
||||||
if (spawn != null && spawn.getWorld() != null) {
|
if (spawn != null && spawn.getWorld() != null) {
|
||||||
if (!player.getWorld().equals(spawn.getWorld())) {
|
if (!player.getWorld().equals(spawn.getWorld())) {
|
||||||
|
if(AuthMe.SATEnabled) {
|
||||||
|
TeleportUtils.teleport(player,spawn);
|
||||||
|
} else {
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
|
}
|
||||||
} else if (spawn.distance(player.getLocation()) > settings.getProperty(ALLOWED_MOVEMENT_RADIUS)) {
|
} else if (spawn.distance(player.getLocation()) > settings.getProperty(ALLOWED_MOVEMENT_RADIUS)) {
|
||||||
|
if(AuthMe.SATEnabled) {
|
||||||
|
TeleportUtils.teleport(player,spawn);
|
||||||
|
} else {
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
@@ -488,15 +521,16 @@ public class PlayerListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<String> whitelist = settings.getProperty(RestrictionSettings.UNRESTRICTED_INVENTORIES);
|
Set<String> whitelist = settings.getProperty(RestrictionSettings.UNRESTRICTED_INVENTORIES);
|
||||||
|
//append a string for String whitelist
|
||||||
return whitelist.contains(ChatColor.stripColor(inventory.getTitle()).toLowerCase(Locale.ROOT));
|
return whitelist.contains(ChatColor.stripColor(inventory.getTitle()).toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
||||||
final HumanEntity player = event.getPlayer();
|
final HumanEntity player = event.getPlayer();
|
||||||
|
Player ply = (Player) event.getPlayer();
|
||||||
if (listenerService.shouldCancelEvent(player)
|
if (listenerService.shouldCancelEvent(player)
|
||||||
&& !isInventoryWhitelisted(event.getView())) {
|
&& !isInventoryWhitelisted(event.getView()) && listenerService.shouldCancelInvEvent(ply)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package fr.xephi.authme.listener;
|
||||||
|
//Prevent Ghost Players
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class PlayerQuitListener implements Listener {
|
||||||
|
private final Plugin plugin;
|
||||||
|
public PlayerQuitListener(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
String LastAddr = Objects.requireNonNull(player.getAddress()).getAddress().getHostAddress();
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (player.isOnline()) {
|
||||||
|
player.kickPlayer("You have been disconnected.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 20L); // 20 ticks = 1 second
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static org.bukkit.Bukkit.getLogger;
|
||||||
|
|
||||||
|
public class RegisterListener implements Listener {
|
||||||
|
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||||
|
private final Plugin plugin;
|
||||||
|
public static boolean enabled=true;
|
||||||
|
// 创建一个储存玩家关闭箱子GUI的原因的HashMap
|
||||||
|
public static HashMap<Player, String> closeReasonMap = new HashMap<>();
|
||||||
|
// Add a timer to kick the player if they don't verify in time
|
||||||
|
|
||||||
|
|
||||||
|
public RegisterListener(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if (event.getWhoClicked() instanceof Player) {
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
ItemStack item = event.getCurrentItem();
|
||||||
|
// 获取点击事件的容器
|
||||||
|
Inventory inventory = event.getInventory();
|
||||||
|
if (event.getView().getTitle().equals("请验证你是真人")&&!authmeApi.isRegistered(player.getName())) {
|
||||||
|
if (Objects.requireNonNull(event.getCurrentItem()).getType().equals(Material.REDSTONE_BLOCK)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
closeReasonMap.put(player, "verified");
|
||||||
|
player.closeInventory();
|
||||||
|
player.sendMessage("§a验证完成");
|
||||||
|
//force to string
|
||||||
|
|
||||||
|
// ProtocolLibrary.getProtocolManager().removePacketListeners(this.plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Random random_blockpos = new Random();
|
||||||
|
int random_num = random_blockpos.nextInt(26);
|
||||||
|
Inventory menu = Bukkit.createInventory(null, 27, "请验证你是真人");
|
||||||
|
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.setDisplayName("§a我是真人");
|
||||||
|
}
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
menu.setItem(random_num, item);
|
||||||
|
Player playerunreg = event.getPlayer();
|
||||||
|
String name = playerunreg.getName();
|
||||||
|
if (!authmeApi.isRegistered(name)) {
|
||||||
|
// getLogger().log(Level.INFO, "TESTTEST");
|
||||||
|
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||||
|
playerunreg.openInventory(menu);
|
||||||
|
}, 1L);
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg)) {
|
||||||
|
playerunreg.sendMessage("§c请先完成验证!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
playerunreg.openInventory(menu);
|
||||||
|
//playerunreg.kickPlayer("§c请先完成人机验证!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg)) {
|
||||||
|
playerunreg.sendMessage("§c请先完成验证!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// chatListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
||||||
|
// @Override
|
||||||
|
// public void onPacketReceiving(PacketEvent event) {
|
||||||
|
// if (event.getPlayer() == player) {
|
||||||
|
// event.setCancelled(true);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
String name = player.getName();
|
||||||
|
if (!authmeApi.isRegistered(name)){closeReasonMap.remove(player);}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -114,10 +114,6 @@ class InventoryPacketAdapter extends PacketAdapter {
|
|||||||
itemListModifier.write(0, Arrays.asList(blankInventory));
|
itemListModifier.write(0, Arrays.asList(blankInventory));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
protocolManager.sendServerPacket(player, inventoryPacket, false);
|
protocolManager.sendServerPacket(player, inventoryPacket, false);
|
||||||
} catch (InvocationTargetException invocationExc) {
|
|
||||||
logger.logException("Error during sending blank inventory", invocationExc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ public enum MessageKey {
|
|||||||
/** The chosen password isn't safe, please choose another one... */
|
/** The chosen password isn't safe, please choose another one... */
|
||||||
PASSWORD_UNSAFE_ERROR("password.unsafe_password"),
|
PASSWORD_UNSAFE_ERROR("password.unsafe_password"),
|
||||||
|
|
||||||
|
/** Your chosen password is not secure. It was used %pwned_count times already! Please use a stronger password... */
|
||||||
|
PASSWORD_PWNED_ERROR("password.pwned_password", "%pwned_count"),
|
||||||
|
|
||||||
/** Your password contains illegal characters. Allowed chars: %valid_chars */
|
/** Your password contains illegal characters. Allowed chars: %valid_chars */
|
||||||
PASSWORD_CHARACTERS_ERROR("password.forbidden_characters", "%valid_chars"),
|
PASSWORD_CHARACTERS_ERROR("password.forbidden_characters", "%valid_chars"),
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,16 @@ import java.util.zip.GZIPInputStream;
|
|||||||
|
|
||||||
public class GeoIpService {
|
public class GeoIpService {
|
||||||
|
|
||||||
private static final String LICENSE =
|
//private static final String LICENSE =
|
||||||
"[LICENSE] This product includes GeoLite2 data created by MaxMind, available at https://www.maxmind.com";
|
//"[LICENSE] This product includes GeoLite2 data created by MaxMind, available at https://www.maxmind.com";
|
||||||
|
|
||||||
private static final String DATABASE_NAME = "GeoLite2-Country";
|
private static final String DATABASE_NAME = "GeoLite2-Country";
|
||||||
private static final String DATABASE_FILE = DATABASE_NAME + ".mmdb";
|
private static final String DATABASE_FILE = DATABASE_NAME + ".mmdb";
|
||||||
|
|
||||||
|
|
||||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(GeoIpService.class);
|
private final ConsoleLogger logger = ConsoleLoggerFactory.get(GeoIpService.class);
|
||||||
private final Path dataFile;
|
private final Path dataFile;
|
||||||
|
|
||||||
private GeoIp2Provider databaseReader;
|
private GeoIp2Provider databaseReader;
|
||||||
private volatile boolean downloading;
|
private volatile boolean downloading;
|
||||||
|
|
||||||
@@ -86,27 +89,63 @@ public class GeoIpService {
|
|||||||
if (Files.exists(dataFile)) {
|
if (Files.exists(dataFile)) {
|
||||||
try {
|
try {
|
||||||
startReading();
|
startReading();
|
||||||
// don't fire the update task - we are up to date
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException ioEx) {
|
} catch (IOException ioEx) {
|
||||||
logger.logException("Failed to load GeoLiteAPI database", ioEx);
|
logger.logException("Failed to load GeoLiteAPI database", ioEx);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// File is outdated or doesn't exist - let's try to download the data file!
|
// File is outdated or doesn't exist - let's try to download the data file!
|
||||||
// use bukkit's cached threads
|
// use bukkit's cached threads
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
private void startReading() throws IOException {
|
private void startReading() throws IOException {
|
||||||
databaseReader = new Reader(dataFile.toFile(), FileMode.MEMORY, new CHMCache());
|
databaseReader = new Reader(dataFile.toFile(), FileMode.MEMORY, new CHMCache());
|
||||||
logger.info(LICENSE);
|
|
||||||
|
|
||||||
// clear downloading flag, because we now have working reader instance
|
// clear downloading flag, because we now have working reader instance
|
||||||
downloading = false;
|
downloading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the archive to the destination file if it's newer than the locally version.
|
||||||
|
*
|
||||||
|
* @param lastModified modification timestamp of the already present file
|
||||||
|
* @param destination save file
|
||||||
|
* @return null if no updates were found, the MD5 hash of the downloaded archive if successful
|
||||||
|
* @throws IOException if failed during downloading and writing to destination file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the archive to the destination file if it's newer than the locally version.
|
||||||
|
*
|
||||||
|
* @param destination save file
|
||||||
|
* @return null if no updates were found, the MD5 hash of the downloaded archive if successful
|
||||||
|
* @throws IOException if failed during downloading and writing to destination file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if the expected checksum is equal to the checksum of the given file.
|
||||||
|
*
|
||||||
|
* @param function the checksum function like MD5, SHA256 used to generate the checksum from the file
|
||||||
|
* @param file the file we want to calculate the checksum from
|
||||||
|
* @param expectedChecksum the expected checksum
|
||||||
|
* @throws IOException on I/O error reading the file or the checksum verification failed
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the database from gzipped data. Existing outputFile will be replaced if it already exists.
|
||||||
|
*
|
||||||
|
* @param inputFile gzipped database input file
|
||||||
|
* @param outputFile destination file for the database
|
||||||
|
* @throws IOException on I/O error reading the archive, or writing the output
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the country code of the given IP address.
|
* Get the country code of the given IP address.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import fr.xephi.authme.message.MessageKey;
|
|||||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
|
import fr.xephi.authme.security.HashUtils;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.ProtectionSettings;
|
import fr.xephi.authme.settings.properties.ProtectionSettings;
|
||||||
@@ -21,6 +22,11 @@ import fr.xephi.authme.util.Utils;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.ProtocolException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@@ -28,6 +34,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static fr.xephi.authme.util.StringUtils.isInsideString;
|
import static fr.xephi.authme.util.StringUtils.isInsideString;
|
||||||
@@ -84,7 +91,15 @@ public class ValidationService implements Reloadable {
|
|||||||
return new ValidationResult(MessageKey.INVALID_PASSWORD_LENGTH);
|
return new ValidationResult(MessageKey.INVALID_PASSWORD_LENGTH);
|
||||||
} else if (settings.getProperty(SecuritySettings.UNSAFE_PASSWORDS).contains(passLow)) {
|
} else if (settings.getProperty(SecuritySettings.UNSAFE_PASSWORDS).contains(passLow)) {
|
||||||
return new ValidationResult(MessageKey.PASSWORD_UNSAFE_ERROR);
|
return new ValidationResult(MessageKey.PASSWORD_UNSAFE_ERROR);
|
||||||
|
} else if (settings.getProperty(SecuritySettings.HAVE_I_BEEN_PWNED_CHECK)) {
|
||||||
|
HaveIBeenPwnedResults results = validatePasswordHaveIBeenPwned(password);
|
||||||
|
if (results != null
|
||||||
|
&& results.isPwned()
|
||||||
|
&& results.getPwnCount() > settings.getProperty(SecuritySettings.HAVE_I_BEEN_PWNED_LIMIT)) {
|
||||||
|
return new ValidationResult(MessageKey.PASSWORD_PWNED_ERROR, String.valueOf(results.getPwnCount()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new ValidationResult();
|
return new ValidationResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,6 +240,47 @@ public class ValidationService implements Reloadable {
|
|||||||
}
|
}
|
||||||
return restrictions;
|
return restrictions;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Check haveibeenpwned.com for the given password.
|
||||||
|
*
|
||||||
|
* @param password password to check for
|
||||||
|
* @return Results of the check
|
||||||
|
*/
|
||||||
|
public HaveIBeenPwnedResults validatePasswordHaveIBeenPwned(String password) {
|
||||||
|
String hash = HashUtils.sha1(password);
|
||||||
|
|
||||||
|
String hashPrefix = hash.substring(0, 5);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String url = String.format("https://api.pwnedpasswords.com/range/%s", hashPrefix);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setRequestProperty("User-Agent", "AuthMeReloaded");
|
||||||
|
connection.setConnectTimeout(5000);
|
||||||
|
connection.setReadTimeout(5000);
|
||||||
|
connection.setDoInput(true);
|
||||||
|
StringBuilder outStr = new StringBuilder();
|
||||||
|
|
||||||
|
try (DataInputStream input = new DataInputStream(connection.getInputStream())) {
|
||||||
|
for (int c = input.read(); c != -1; c = input.read())
|
||||||
|
outStr.append((char) c);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] hashes = outStr.toString().split("\n");
|
||||||
|
for (String hashSuffix : hashes) {
|
||||||
|
String[] hashSuffixParts = hashSuffix.trim().split(":");
|
||||||
|
if (hashSuffixParts[0].equalsIgnoreCase(hash.substring(5))) {
|
||||||
|
return new HaveIBeenPwnedResults(true, Integer.parseInt(hashSuffixParts[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new HaveIBeenPwnedResults(false, 0);
|
||||||
|
} catch (java.io.IOException e) {
|
||||||
|
logger.warning("验证密码时出现错误,这可能是由于网络问题,如果无法解决,请关闭HaveIBeenPwned检查");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final class ValidationResult {
|
public static final class ValidationResult {
|
||||||
private final MessageKey messageKey;
|
private final MessageKey messageKey;
|
||||||
@@ -266,4 +322,22 @@ public class ValidationService implements Reloadable {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class HaveIBeenPwnedResults {
|
||||||
|
private final boolean isPwned;
|
||||||
|
private final int pwnCount;
|
||||||
|
|
||||||
|
public HaveIBeenPwnedResults(boolean isPwned, int pwnCount) {
|
||||||
|
this.isPwned = isPwned;
|
||||||
|
this.pwnCount = pwnCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPwned() {
|
||||||
|
return isPwned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPwnCount() {
|
||||||
|
return pwnCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public final class HooksSettings implements SettingsHolder {
|
|||||||
public static final Property<Boolean> BUNGEECORD =
|
public static final Property<Boolean> BUNGEECORD =
|
||||||
newProperty("Hooks.bungeecord", false);
|
newProperty("Hooks.bungeecord", false);
|
||||||
|
|
||||||
|
@Comment("Allow FloodGatePlayer Join Without checkIsValidName()")
|
||||||
|
public static final Property<Boolean> HOOK_FLOODGATE_PLAYER =
|
||||||
|
newProperty("Hooks.floodgate", false);
|
||||||
|
|
||||||
|
|
||||||
@Comment("Send player to this BungeeCord server after register/login")
|
@Comment("Send player to this BungeeCord server after register/login")
|
||||||
public static final Property<String> BUNGEECORD_SERVER =
|
public static final Property<String> BUNGEECORD_SERVER =
|
||||||
newProperty("Hooks.sendPlayerTo", "");
|
newProperty("Hooks.sendPlayerTo", "");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public final class RegistrationSettings implements SettingsHolder {
|
|||||||
"Send every X seconds a message to a player to",
|
"Send every X seconds a message to a player to",
|
||||||
"remind him that he has to login/register"})
|
"remind him that he has to login/register"})
|
||||||
public static final Property<Integer> MESSAGE_INTERVAL =
|
public static final Property<Integer> MESSAGE_INTERVAL =
|
||||||
newProperty("settings.registration.messageInterval", 600);
|
newProperty("settings.registration.messageInterval", 5);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Only registered and logged in players can play.",
|
"Only registered and logged in players can play.",
|
||||||
@@ -33,7 +33,7 @@ public final class RegistrationSettings implements SettingsHolder {
|
|||||||
"More info at https://github.com/AuthMe/AuthMeReloaded/wiki/Registration"
|
"More info at https://github.com/AuthMe/AuthMeReloaded/wiki/Registration"
|
||||||
})
|
})
|
||||||
public static final Property<RegistrationType> REGISTRATION_TYPE =
|
public static final Property<RegistrationType> REGISTRATION_TYPE =
|
||||||
newProperty(RegistrationType.class, "settings.registration.type", RegistrationType.EMAIL);
|
newProperty(RegistrationType.class, "settings.registration.type", RegistrationType.PASSWORD);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Second argument the /register command should take: ",
|
"Second argument the /register command should take: ",
|
||||||
@@ -44,7 +44,7 @@ public final class RegistrationSettings implements SettingsHolder {
|
|||||||
})
|
})
|
||||||
public static final Property<RegisterSecondaryArgument> REGISTER_SECOND_ARGUMENT =
|
public static final Property<RegisterSecondaryArgument> REGISTER_SECOND_ARGUMENT =
|
||||||
newProperty(RegisterSecondaryArgument.class, "settings.registration.secondArg",
|
newProperty(RegisterSecondaryArgument.class, "settings.registration.secondArg",
|
||||||
RegisterSecondaryArgument.NONE);
|
RegisterSecondaryArgument.CONFIRMATION);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Do we force kick a player after a successful registration?",
|
"Do we force kick a player after a successful registration?",
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ 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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -113,21 +115,19 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||||||
|
|
||||||
@Comment("Can unregistered players walk around?")
|
@Comment("Can unregistered players walk around?")
|
||||||
public static final Property<Boolean> ALLOW_UNAUTHED_MOVEMENT =
|
public static final Property<Boolean> ALLOW_UNAUTHED_MOVEMENT =
|
||||||
newProperty("settings.restrictions.allowMovement", true);
|
newProperty("settings.restrictions.allowMovement", false);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"After how many seconds should players who fail to login or register",
|
"After how many seconds should players who fail to login or register",
|
||||||
"be kicked? Set to 0 to disable."})
|
"be kicked? Set to 0 to disable."})
|
||||||
public static final Property<Integer> TIMEOUT =
|
public static final Property<Integer> TIMEOUT =
|
||||||
newProperty("settings.restrictions.timeout", 0);
|
newProperty("settings.restrictions.timeout", 120);
|
||||||
|
|
||||||
@Comment("Regex pattern of allowed characters in the player name.")
|
@Comment("Regex pattern of allowed characters in the player name.")
|
||||||
public static final Property<String> ALLOWED_NICKNAME_CHARACTERS =
|
public static final Property<String> ALLOWED_NICKNAME_CHARACTERS =
|
||||||
newProperty("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
|
newProperty("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
|
||||||
|
|
||||||
@Comment("Allow FloodGatePlayer Join Without checkIsValidName()")
|
|
||||||
public static final Property<Boolean> HOOK_FLOODGATE_PLAYER =
|
|
||||||
newProperty("settings.restrictions.hookFloodGatePlayer", false);
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"How far can unregistered players walk?",
|
"How far can unregistered players walk?",
|
||||||
"Set to 0 for unlimited radius"
|
"Set to 0 for unlimited radius"
|
||||||
@@ -163,7 +163,7 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||||||
|
|
||||||
@Comment("AuthMe will NEVER teleport players if set to true!")
|
@Comment("AuthMe will NEVER teleport players if set to true!")
|
||||||
public static final Property<Boolean> NO_TELEPORT =
|
public static final Property<Boolean> NO_TELEPORT =
|
||||||
newProperty("settings.restrictions.noTeleport", true);
|
newProperty("settings.restrictions.noTeleport", false);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Regex syntax for allowed chars in passwords. The default [!-~] allows all visible ASCII",
|
"Regex syntax for allowed chars in passwords. The default [!-~] allows all visible ASCII",
|
||||||
@@ -175,7 +175,7 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||||||
|
|
||||||
@Comment("Regex syntax for allowed chars in email.")
|
@Comment("Regex syntax for allowed chars in email.")
|
||||||
public static final Property<String> ALLOWED_EMAIL_REGEX =
|
public static final Property<String> ALLOWED_EMAIL_REGEX =
|
||||||
newProperty("settings.restrictions.allowedEmailCharacters", "^[A-Za-z0-9]{4,15}@(outlook|163|gmail|icloud).com$");
|
newProperty("settings.restrictions.allowedEmailCharacters", "^[A-Za-z0-9]{4,15}@(qq|outlook|163|gmail|icloud).com$");
|
||||||
|
|
||||||
|
|
||||||
@Comment("Force survival gamemode when player joins?")
|
@Comment("Force survival gamemode when player joins?")
|
||||||
@@ -194,6 +194,7 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||||||
public static final Property<Set<String>> UNRESTRICTED_NAMES =
|
public static final Property<Set<String>> UNRESTRICTED_NAMES =
|
||||||
newLowercaseStringSetProperty("settings.unrestrictions.UnrestrictedName");
|
newLowercaseStringSetProperty("settings.unrestrictions.UnrestrictedName");
|
||||||
|
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Below you can list all inventories names that AuthMe will ignore",
|
"Below you can list all inventories names that AuthMe will ignore",
|
||||||
"for registration or login. Configure it at your own risk!!",
|
"for registration or login. Configure it at your own risk!!",
|
||||||
@@ -206,7 +207,9 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||||||
public static final Property<Set<String>> UNRESTRICTED_INVENTORIES =
|
public static final Property<Set<String>> UNRESTRICTED_INVENTORIES =
|
||||||
newLowercaseStringSetProperty("settings.unrestrictions.UnrestrictedInventories");
|
newLowercaseStringSetProperty("settings.unrestrictions.UnrestrictedInventories");
|
||||||
|
|
||||||
|
|
||||||
private RestrictionSettings() {
|
private RestrictionSettings() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ 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.BooleanProperty;
|
||||||
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 fr.xephi.authme.listener.PlayerQuitListener;
|
||||||
import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty;
|
import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty;
|
||||||
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
||||||
|
|
||||||
@@ -19,14 +19,50 @@ 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", true);
|
newProperty("Security.SQLProblem.stopServer", true);
|
||||||
|
|
||||||
|
@Comment("Enable the new feature to prevent ghost players?")
|
||||||
|
public static final Property<Boolean> ANTI_GHOST_PLAYERS = newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false);
|
||||||
|
|
||||||
|
@Comment({"(BETA Feature)Choose the best teleport method by server brand?",
|
||||||
|
"(Enable this if you are using Paper)"})
|
||||||
|
public static final Property<Boolean> SMART_ASYNC_TELEPORT = newProperty("3rdPartyFeature.optimizes.smartAsyncTeleport",false);
|
||||||
|
|
||||||
|
@Comment("(BETA Feature)Send a GUI captcha to unregistered players?")
|
||||||
|
public static final Property<Boolean> GUI_CAPTCHA = newProperty("3rdPartyFeature.captcha.guiCaptcha",false);
|
||||||
|
|
||||||
|
// @Comment({"Kick the players when they didn't finish the gui captcha in time? " ,
|
||||||
|
// "(0 is disabled)"})
|
||||||
|
// public static final Property<Integer> CAPTCHA_TIMEOUT = newProperty("3rdPartyFeature.captcha.timeout",0);
|
||||||
|
//@Comment({"Using which API to get hash data?",
|
||||||
|
//"Available options: github, gitee, ghproxy (if your server is in China, please use gitee or ghproxy.)"})
|
||||||
|
//public static final Property<String> SHA_CHECK_METHOD = newProperty("Plugin.hashing.hashApi","github");
|
||||||
|
|
||||||
|
//@Comment("Should we use the local cache sometimes instead of requesting API?")
|
||||||
|
//public static final Property<Boolean> USE_LOCAL_CACHE = newProperty("Plugin.hashing.useLocalCache",false);
|
||||||
|
|
||||||
|
//@Comment("DON'T TOUCH!!!")
|
||||||
|
//public static final Property<String> SHA_CHECK_CACHE = newProperty("Plugin.hashing.hashCached","");
|
||||||
|
|
||||||
@Comment("Copy AuthMe log output in a separate file as well?")
|
@Comment("Copy AuthMe log output in a separate file as well?")
|
||||||
public static final Property<Boolean> USE_LOGGING =
|
public static final Property<Boolean> USE_LOGGING =
|
||||||
newProperty("Security.console.logConsole", true);
|
newProperty("Security.console.logConsole", true);
|
||||||
|
|
||||||
|
@Comment({"Query haveibeenpwned.com with a hashed version of the password.",
|
||||||
|
"This is used to check whether it is safe."})
|
||||||
|
public static final Property<Boolean> HAVE_I_BEEN_PWNED_CHECK =
|
||||||
|
newProperty("Security.account.haveIBeenPwned.check", false);
|
||||||
|
|
||||||
|
@Comment({"If the password is used more than this number of times, it is considered unsafe."})
|
||||||
|
public static final Property<Integer> HAVE_I_BEEN_PWNED_LIMIT =
|
||||||
|
newProperty("Security.account.haveIBeenPwned.limit", 0);
|
||||||
|
|
||||||
@Comment("Enable captcha when a player uses wrong password too many times")
|
@Comment("Enable captcha when a player uses wrong password too many times")
|
||||||
public static final Property<Boolean> ENABLE_LOGIN_FAILURE_CAPTCHA =
|
public static final Property<Boolean> ENABLE_LOGIN_FAILURE_CAPTCHA =
|
||||||
newProperty("Security.captcha.useCaptcha", false);
|
newProperty("Security.captcha.useCaptcha", false);
|
||||||
|
|
||||||
|
@Comment("Check for updates on enabled from GitHub?")
|
||||||
|
public static final Property<Boolean> CHECK_FOR_UPDATES =
|
||||||
|
newProperty("Plugin.updates.checkForUpdates", true);
|
||||||
|
|
||||||
@Comment("Max allowed tries before a captcha is required")
|
@Comment("Max allowed tries before a captcha is required")
|
||||||
public static final Property<Integer> MAX_LOGIN_TRIES_BEFORE_CAPTCHA =
|
public static final Property<Integer> MAX_LOGIN_TRIES_BEFORE_CAPTCHA =
|
||||||
newProperty("Security.captcha.maxLoginTry", 8);
|
newProperty("Security.captcha.maxLoginTry", 8);
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package fr.xephi.authme.util;
|
||||||
|
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
//
|
||||||
|
//public class TeleportUtils {
|
||||||
|
// public static void teleport(Player player, Location location) {
|
||||||
|
// try {
|
||||||
|
// Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||||
|
// // Paper API is loaded, use teleportAsync
|
||||||
|
// Method teleportAsyncMethod = player.getClass().getMethod("teleportAsync", Location.class);
|
||||||
|
// teleportAsyncMethod.setAccessible(true);
|
||||||
|
// teleportAsyncMethod.invoke(player, location);
|
||||||
|
// } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
|
||||||
|
// // Paper API is not loaded, use normal teleport
|
||||||
|
// player.teleport(location);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
public class TeleportUtils {
|
||||||
|
private static Method teleportAsyncMethod;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {//Detect Paper class
|
||||||
|
Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||||
|
teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class);
|
||||||
|
// if detected,use teleportAsync()
|
||||||
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
|
teleportAsyncMethod = null;
|
||||||
|
//if not, set method to null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void teleport(Player player, Location location) {
|
||||||
|
if (teleportAsyncMethod != null) {
|
||||||
|
try {
|
||||||
|
teleportAsyncMethod.setAccessible(true);
|
||||||
|
teleportAsyncMethod.invoke(player, location);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
player.teleport(location);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.teleport(location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,10 +41,7 @@
|
|||||||
# executor: CONSOLE
|
# executor: CONSOLE
|
||||||
# ifNumberOfAccountsAtLeast: 5
|
# ifNumberOfAccountsAtLeast: 5
|
||||||
# Commands to run for players logging in whose 'last login date' was empty
|
# Commands to run for players logging in whose 'last login date' was empty
|
||||||
onFirstLogin:
|
onFirstLogin: {}
|
||||||
broadcast:
|
|
||||||
command: 'cmi broadcast &b欢迎 &r%p &7( %ip ) &b光临服务器,请大家多多关照!'
|
|
||||||
executor: CONSOLE
|
|
||||||
onJoin: {}
|
onJoin: {}
|
||||||
onLogin: {}
|
onLogin: {}
|
||||||
# These commands are called whenever a logged in player uses /logout or quits.
|
# These commands are called whenever a logged in player uses /logout or quits.
|
||||||
|
|||||||
@@ -102,8 +102,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 IrisCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="https://www.mcbbs.net/thread-1263385-1-1.html" target="_blank" style="text-decoration: none; font-size: 16px">iriscraft.work</a>
|
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ password:
|
|||||||
unsafe_password: '&cThe chosen password isn''t safe, please choose another one...'
|
unsafe_password: '&cThe chosen password isn''t safe, please choose another one...'
|
||||||
forbidden_characters: '&4Your password contains illegal characters. Allowed chars: %valid_chars'
|
forbidden_characters: '&4Your password contains illegal characters. Allowed chars: %valid_chars'
|
||||||
wrong_length: '&cYour password is too short or too long! Please try with another one!'
|
wrong_length: '&cYour password is too short or too long! Please try with another one!'
|
||||||
|
pwned_password: '&cYour chosen password is not secure. It was used %pwned_count times already! Please use a strong password...'
|
||||||
|
|
||||||
# Login
|
# Login
|
||||||
login:
|
login:
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
registration:
|
registration:
|
||||||
disabled: '&c注册已被禁止'
|
disabled: '&c注册已被禁止'
|
||||||
name_taken: '&c此用户已经在此服务器注册过'
|
name_taken: '&c此用户已经在此服务器注册过'
|
||||||
register_request: '&7请输入“/register <邮箱>”以注册'
|
register_request: '&b请输入“&a/reg <密码> <重复密码>&b”以注册'
|
||||||
command_usage: '&c正确用法:“/register <邮箱>”'
|
command_usage: '&c正确用法:“/reg <密码> <重复密码>”'
|
||||||
reg_only: '&c只允许注册过的玩家进服!'
|
reg_only: '&c只允许注册过的玩家进服!'
|
||||||
success: '&a*** 已成功注册 ***'
|
success: '&a*** 已成功注册 ***'
|
||||||
|
|
||||||
@@ -19,13 +19,14 @@ password:
|
|||||||
unsafe_password: '&c您不能使用安全性过低的密码。 '
|
unsafe_password: '&c您不能使用安全性过低的密码。 '
|
||||||
forbidden_characters: '&4您的密码包含了非法字符.可使用的字符: %valid_chars'
|
forbidden_characters: '&4您的密码包含了非法字符.可使用的字符: %valid_chars'
|
||||||
wrong_length: '&4您的密码没有达到要求!'
|
wrong_length: '&4您的密码没有达到要求!'
|
||||||
|
pwned_password: '&c你使用的密码并不安全。它已经被使用了 %pwned_count 次! 请使用一个更强大的密码...'
|
||||||
|
|
||||||
# Login
|
# Login
|
||||||
login:
|
login:
|
||||||
command_usage: '&c正确用法:“/login <密码>”'
|
command_usage: '&c正确用法:“/l <密码>”'
|
||||||
wrong_password: '&c*** 密码错误 ***'
|
wrong_password: '&c*** 密码错误 ***'
|
||||||
success: '&a*** 已成功登录 ***'
|
success: '&a*** 已成功登录 ***'
|
||||||
login_request: '&c请输入“/login <密码>”以登录'
|
login_request: '&c请输入“/l <密码>”以登录'
|
||||||
timeout_error: '给您登录的时间已经过了'
|
timeout_error: '给您登录的时间已经过了'
|
||||||
|
|
||||||
# Errors
|
# Errors
|
||||||
|
|||||||
@@ -108,8 +108,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 IrisCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="https://www.mcbbs.net/thread-1263385-1-1.html" target="_blank" style="text-decoration: none; font-size: 16px">iriscraft.work</a>
|
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
name: ${pluginDescription.name}
|
name: ${pluginDescription.name}
|
||||||
authors: [${pluginDescription.authors}]
|
authors: [${pluginDescription.authors}]
|
||||||
website: ${project.url}
|
website: http://github.com/HaHaWTH/AuthMeReReloaded/
|
||||||
description: ${project.description}
|
description: A fork of AuthMeReloaded that contains bug fixes
|
||||||
main: ${pluginDescription.main}
|
main: ${pluginDescription.main}
|
||||||
version: ${pluginDescription.version}
|
version: 5.6.0-FORK-b17
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend:
|
softdepend:
|
||||||
- Vault
|
- Vault
|
||||||
@@ -28,7 +28,6 @@ commands:
|
|||||||
usage: /login <password>
|
usage: /login <password>
|
||||||
aliases:
|
aliases:
|
||||||
- l
|
- l
|
||||||
- log
|
|
||||||
logout:
|
logout:
|
||||||
description: Logout command
|
description: Logout command
|
||||||
usage: /logout
|
usage: /logout
|
||||||
|
|||||||
@@ -101,8 +101,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 IrisCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="https://www.mcbbs.net/thread-1263385-1-1.html" target="_blank" style="text-decoration: none; font-size: 16px">iriscraft.work</a>
|
<a href="191980.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -99,8 +99,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 IrisCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="https://www.mcbbs.net/thread-1263385-1-1.html" target="_blank" style="text-decoration: none; font-size: 16px">iriscraft.work</a>
|
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -101,8 +101,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 IrisCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="https://www.mcbbs.net/thread-1263385-1-1.html" target="_blank" style="text-decoration: none; font-size: 16px">iriscraft.work</a>
|
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user