Compare commits
40 Commits
b50
...
feat/minimessage
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a40c2be36 | |||
| a4312fdb51 | |||
| cadd5ddb24 | |||
| 2d10e77b6c | |||
| 3b6160c91f | |||
| 8df6a008c8 | |||
| 2b8450f27e | |||
| 58f8176dae | |||
| e02659d850 | |||
| c95f96572c | |||
| 1c1356a4d1 | |||
| f206deb8ed | |||
| 9bf6aae8e9 | |||
| 63bfc7a5c1 | |||
| 731c6477a5 | |||
| e0bf35284c | |||
| 02ebb0b0ab | |||
| 92741daaa8 | |||
| 18ce05d07d | |||
| 37e6e9feb6 | |||
| 655c5ca42c | |||
| c99fc5c389 | |||
| 9b0a4a003e | |||
| f25610c90b | |||
| 7130d3989c | |||
| 900d2bd2e9 | |||
| 7d255dfa30 | |||
| 0cce930260 | |||
| 0671a54b20 | |||
| 4df4a1fa4b | |||
| 5b52a0ff00 | |||
| 5186d09116 | |||
| a5b06bbd07 | |||
| 9b74cb5a00 | |||
| be97e7faa0 | |||
| 253822a056 | |||
| 0fcc45039d | |||
| 4700e2ae90 | |||
| d9c89e1dc6 | |||
| b513fd37cb |
@@ -25,7 +25,7 @@ jobs:
|
|||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Download
|
name: Download
|
||||||
path: ./target/AuthMe-5.6.0-FORK-Universal.jar
|
path: ./target/AuthMe-*-FORK-Universal.jar
|
||||||
runtime-test:
|
runtime-test:
|
||||||
name: Plugin Runtime Test
|
name: Plugin Runtime Test
|
||||||
needs: [Build]
|
needs: [Build]
|
||||||
@@ -41,6 +41,8 @@ jobs:
|
|||||||
javaVersion: '17'
|
javaVersion: '17'
|
||||||
- mcVersion: '1.20.4'
|
- mcVersion: '1.20.4'
|
||||||
javaVersion: '21'
|
javaVersion: '21'
|
||||||
|
- mcVersion: '1.21'
|
||||||
|
javaVersion: '21'
|
||||||
steps:
|
steps:
|
||||||
- uses: HaHaWTH/minecraft-plugin-runtime-test@paper
|
- uses: HaHaWTH/minecraft-plugin-runtime-test@paper
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
[Releases](https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest)
|
[Releases](https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest)
|
||||||
[Actions(Dev builds, use at your own risk!)](https://github.com/HaHaWTH/AuthMeReReloaded/actions/workflows/maven.yml)
|
[Actions(Dev builds, use at your own risk!)](https://github.com/HaHaWTH/AuthMeReReloaded/actions/workflows/maven.yml)
|
||||||
|
|
||||||
If you are using FRP(内网穿透) for your server, this plugin may help [HAProxy-Detector](https://github.com/HaHaWTH/HAProxy-Detector)
|
|
||||||
|
|
||||||
**Pull Requests and suggestions are welcome!**
|
**Pull Requests and suggestions are welcome!**
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>fr.xephi</groupId>
|
<groupId>fr.xephi</groupId>
|
||||||
<artifactId>authme</artifactId>
|
<artifactId>authme</artifactId>
|
||||||
<version>5.6.0-FORK</version>
|
<version>5.7.0-FORK</version>
|
||||||
|
|
||||||
<name>AuthMeReReloaded</name>
|
<name>AuthMeReReloaded</name>
|
||||||
<description>Fork of the first authentication plugin for the Bukkit API!</description>
|
<description>Fork of the first authentication plugin for the Bukkit API!</description>
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.7.0</version>
|
<version>3.8.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnError>false</failOnError>
|
<failOnError>false</failOnError>
|
||||||
<failOnWarnings>false</failOnWarnings>
|
<failOnWarnings>false</failOnWarnings>
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>3.4.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Include resource files -->
|
<!-- Include resource files -->
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.4.1</version>
|
<version>3.4.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
@@ -454,18 +454,6 @@
|
|||||||
<pattern>com.alessiodp.libby</pattern>
|
<pattern>com.alessiodp.libby</pattern>
|
||||||
<shadedPattern>fr.xephi.authme.libs.com.alessiodp.libby</shadedPattern>
|
<shadedPattern>fr.xephi.authme.libs.com.alessiodp.libby</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
|
||||||
<pattern>net.kyori.adventure</pattern>
|
|
||||||
<shadedPattern>fr.xephi.authme.libs.net.kyori.adventure</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>net.kyori.examination</pattern>
|
|
||||||
<shadedPattern>fr.xephi.authme.libs.net.kyori.examination</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>net.kyori.option</pattern>
|
|
||||||
<shadedPattern>fr.xephi.authme.libs.net.kyori.option</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
</relocations>
|
||||||
|
|
||||||
<filters>
|
<filters>
|
||||||
@@ -623,6 +611,12 @@
|
|||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- Placeholder API Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi-repo</id>
|
||||||
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<!-- Multiverse Repo -->
|
<!-- Multiverse Repo -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>onarandombox-repo-releases</id>
|
<id>onarandombox-repo-releases</id>
|
||||||
@@ -699,7 +693,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- MaxMind GEO IP with our modifications to use GSON in replacement of the big Jackson dependency -->
|
<!-- MaxMind GEO IP with our modifications to use GSON in replacement of the big Jackson dependency -->
|
||||||
<!-- GSON is already included and therefore it reduces the file size in comparison to the original version -->
|
<!-- GSON is already included, and therefore it reduces the file size in comparison to the original version -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.maxmind.db</groupId>
|
<groupId>com.maxmind.db</groupId>
|
||||||
<artifactId>maxmind-db-gson</artifactId>
|
<artifactId>maxmind-db-gson</artifactId>
|
||||||
@@ -895,12 +889,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<version>4.3.2</version>
|
<version>4.3.3</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
|
||||||
<version>4.17.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- LuckPerms plugin -->
|
<!-- LuckPerms plugin -->
|
||||||
@@ -1038,6 +1027,14 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Placeholder API -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.11.6</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- EssentialsX plugin -->
|
<!-- EssentialsX plugin -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.essentialsx</groupId>
|
<groupId>net.essentialsx</groupId>
|
||||||
@@ -1128,7 +1125,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.checkerframework</groupId>
|
<groupId>org.checkerframework</groupId>
|
||||||
<artifactId>checker-qual</artifactId>
|
<artifactId>checker-qual</artifactId>
|
||||||
<version>3.40.0</version>
|
<version>3.45.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ 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;
|
||||||
import fr.xephi.authme.security.crypts.Sha256;
|
import fr.xephi.authme.security.crypts.Sha256;
|
||||||
|
import fr.xephi.authme.service.AdventureService;
|
||||||
import fr.xephi.authme.service.BackupService;
|
import fr.xephi.authme.service.BackupService;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.service.MigrationService;
|
import fr.xephi.authme.service.MigrationService;
|
||||||
@@ -74,13 +75,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-Fork";
|
private static String pluginVersion = "5.7.0-Fork";
|
||||||
private static final String pluginBuild = "b";
|
private static final String pluginBuild = "b";
|
||||||
private static String pluginBuildNumber = "50";
|
private static String pluginBuildNumber = "52";
|
||||||
// Private instances
|
// Private instances
|
||||||
private EmailService emailService;
|
private EmailService emailService;
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
private static TaskScheduler scheduler;
|
private static TaskScheduler scheduler;
|
||||||
|
private static AdventureService adventureService;
|
||||||
@Inject
|
@Inject
|
||||||
public static Settings settings;
|
public static Settings settings;
|
||||||
private DataSource database;
|
private DataSource database;
|
||||||
@@ -139,6 +141,13 @@ public class AuthMe extends JavaPlugin {
|
|||||||
return scheduler;
|
return scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AdventureService
|
||||||
|
*/
|
||||||
|
public static AdventureService getAdventureService() {
|
||||||
|
return adventureService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The library manager
|
* The library manager
|
||||||
*/
|
*/
|
||||||
@@ -153,6 +162,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
loadPluginInfo(getDescription().getVersion());
|
loadPluginInfo(getDescription().getVersion());
|
||||||
scheduler = UniversalScheduler.getScheduler(this);
|
scheduler = UniversalScheduler.getScheduler(this);
|
||||||
libraryManager = new BukkitLibraryManager(this);
|
libraryManager = new BukkitLibraryManager(this);
|
||||||
|
adventureService = new AdventureService(this);
|
||||||
|
adventureService.init();
|
||||||
|
|
||||||
// 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));
|
||||||
@@ -403,6 +414,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Wait for tasks and close data source
|
// Wait for tasks and close data source
|
||||||
new TaskCloser(database).run();
|
new TaskCloser(database).run();
|
||||||
|
|
||||||
|
// Close AdventureService
|
||||||
|
if (adventureService != null) {
|
||||||
|
adventureService.close();
|
||||||
|
}
|
||||||
|
|
||||||
// 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() + " is unloaded successfully!");
|
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " is unloaded successfully!");
|
||||||
@@ -416,7 +432,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
if (updater.isUpdateAvailable()) {
|
if (updater.isUpdateAvailable()) {
|
||||||
String message = "New version available! Latest:" + updater.getLatestVersion() + " Current:" + pluginBuild + pluginBuildNumber;
|
String message = "New version available! Latest:" + updater.getLatestVersion() + " Current:" + pluginBuild + pluginBuildNumber;
|
||||||
logger.warning(message);
|
logger.warning(message);
|
||||||
logger.warning("Download from here: https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest");
|
logger.warning("Download from here: https://modrinth.com/plugin/authmerereloaded");
|
||||||
} else {
|
} else {
|
||||||
logger.info("You are running the latest version.");
|
logger.info("You are running the latest version.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import fr.xephi.authme.util.PlayerUtils;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -24,6 +26,8 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.listener.PlayerListener.PENDING_INVENTORIES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current API of AuthMe.
|
* The current API of AuthMe.
|
||||||
*
|
*
|
||||||
@@ -32,6 +36,7 @@ import java.util.Optional;
|
|||||||
* AuthMeApi authmeApi = AuthMeApi.getInstance();
|
* AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class AuthMeApi {
|
public class AuthMeApi {
|
||||||
|
|
||||||
private static AuthMeApi singleton;
|
private static AuthMeApi singleton;
|
||||||
@@ -256,6 +261,18 @@ public class AuthMeApi {
|
|||||||
return dataSource.saveAuth(auth);
|
return dataSource.saveAuth(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open an inventory for the given player at any time.
|
||||||
|
*
|
||||||
|
* @param player The player to open the inventory for
|
||||||
|
* @param inventory The inventory to open
|
||||||
|
* @return The inventory view
|
||||||
|
*/
|
||||||
|
public InventoryView openInventory(Player player, Inventory inventory) {
|
||||||
|
PENDING_INVENTORIES.add(inventory);
|
||||||
|
return player.openInventory(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force a player to login, i.e. the player is logged in without needing his password.
|
* Force a player to login, i.e. the player is logged in without needing his password.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import fr.xephi.authme.service.BukkitService;
|
|||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() ->
|
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() ->
|
||||||
// AuthMeReReloaded - Folia compatibility
|
// AuthMeReReloaded - Folia compatibility
|
||||||
bukkitService.runTaskIfFolia(player, () -> player.kickPlayer(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER))));
|
bukkitService.runTaskIfFolia(player, () -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER)))));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.PlayerUtils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import fr.xephi.authme.util.expiring.TimedCounter;
|
import fr.xephi.authme.util.expiring.TimedCounter;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -106,7 +107,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
|
|||||||
bukkitService.runTask(player,() -> { // AuthMeReReloaded - Folia compatibility
|
bukkitService.runTask(player,() -> { // AuthMeReReloaded - Folia compatibility
|
||||||
if (customCommand.isEmpty()) {
|
if (customCommand.isEmpty()) {
|
||||||
bukkitService.banIp(ip, reason, expires, "AuthMe");
|
bukkitService.banIp(ip, reason, expires, "AuthMe");
|
||||||
player.kickPlayer(reason);
|
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(reason));
|
||||||
} else {
|
} else {
|
||||||
String command = customCommand
|
String command = customCommand
|
||||||
.replace("%player%", name)
|
.replace("%player%", name)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import java.util.Locale;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.AuthMe.getScheduler;
|
||||||
|
|
||||||
public class VerificationCodeManager implements SettingsDependent, HasCleanup {
|
public class VerificationCodeManager implements SettingsDependent, HasCleanup {
|
||||||
|
|
||||||
private final EmailService emailService;
|
private final EmailService emailService;
|
||||||
@@ -133,17 +135,19 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup {
|
|||||||
* @param name the name of the player to generate a code for
|
* @param name the name of the player to generate a code for
|
||||||
*/
|
*/
|
||||||
private void generateCode(String name) {
|
private void generateCode(String name) {
|
||||||
DataSourceValue<String> emailResult = dataSource.getEmail(name);
|
getScheduler().runTaskAsynchronously(() -> {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'年'MM'月'dd'日' HH:mm:ss");
|
DataSourceValue<String> emailResult = dataSource.getEmail(name);
|
||||||
Date date = new Date(System.currentTimeMillis());
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'-'MM'-'dd'-' HH:mm:ss");
|
||||||
if (emailResult.rowExists()) {
|
Date date = new Date(System.currentTimeMillis());
|
||||||
final String email = emailResult.getValue();
|
if (emailResult.rowExists()) {
|
||||||
if (!Utils.isEmailEmpty(email)) {
|
final String email = emailResult.getValue();
|
||||||
String code = RandomStringUtils.generateNum(6); // 6 digits code
|
if (!Utils.isEmailEmpty(email)) {
|
||||||
verificationCodes.put(name.toLowerCase(Locale.ROOT), code);
|
String code = RandomStringUtils.generateNum(6); // 6 digits code
|
||||||
emailService.sendVerificationMail(name, email, code, dateFormat.format(date));
|
verificationCodes.put(name.toLowerCase(Locale.ROOT), code);
|
||||||
|
emailService.sendVerificationMail(name, email, code, dateFormat.format(date));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.listener;
|
|||||||
|
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -26,7 +27,7 @@ public class DoubleLoginFixListener implements Listener {
|
|||||||
HashSet<String> PlayerSet = new HashSet<String>();
|
HashSet<String> PlayerSet = new HashSet<String>();
|
||||||
for (Player ep : PlayerList) {
|
for (Player ep : PlayerList) {
|
||||||
if (PlayerSet.contains(ep.getName().toLowerCase())) {
|
if (PlayerSet.contains(ep.getName().toLowerCase())) {
|
||||||
ep.kickPlayer(service.retrieveSingleMessage(ep.getPlayer(), MessageKey.DOUBLE_LOGIN_FIX));
|
MiniMessageUtils.kickPlayer(ep, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(ep.getPlayer(), MessageKey.DOUBLE_LOGIN_FIX)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PlayerSet.add(ep.getName().toLowerCase());
|
PlayerSet.add(ep.getName().toLowerCase());
|
||||||
|
|||||||
@@ -75,9 +75,7 @@ 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);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ 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.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
@@ -140,7 +141,7 @@ public class OnJoinVerifier implements Reloadable {
|
|||||||
Player nonVipPlayer = generateKickPlayer(onlinePlayers);
|
Player nonVipPlayer = generateKickPlayer(onlinePlayers);
|
||||||
if (nonVipPlayer != null) {
|
if (nonVipPlayer != null) {
|
||||||
// AuthMeReReloaded - Folia compatibility
|
// AuthMeReReloaded - Folia compatibility
|
||||||
bukkitService.runTaskIfFolia(nonVipPlayer, () -> nonVipPlayer.kickPlayer(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP)));
|
bukkitService.runTaskIfFolia(nonVipPlayer, () -> MiniMessageUtils.kickPlayer(nonVipPlayer, MiniMessageUtils.parseMiniMessage(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP))));
|
||||||
event.allow();
|
event.allow();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,9 +16,11 @@ import fr.xephi.authme.service.ValidationService;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
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.PluginSettings;
|
||||||
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.util.TeleportUtils;
|
import fr.xephi.authme.util.TeleportUtils;
|
||||||
|
import fr.xephi.authme.util.message.I18NUtils;
|
||||||
import fr.xephi.authme.util.message.MiniMessageUtils;
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -50,9 +52,12 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
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.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -93,6 +98,7 @@ public class PlayerListener implements Listener {
|
|||||||
@Inject
|
@Inject
|
||||||
private QuickCommandsProtectionManager quickCommandsProtectionManager;
|
private QuickCommandsProtectionManager quickCommandsProtectionManager;
|
||||||
|
|
||||||
|
public static List<Inventory> PENDING_INVENTORIES = new ArrayList<>();
|
||||||
|
|
||||||
// Lowest priority to apply fast protection checks
|
// Lowest priority to apply fast protection checks
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@@ -213,7 +219,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
String customJoinMessage = settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE);
|
String customJoinMessage = settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE);
|
||||||
if (!customJoinMessage.isEmpty()) {
|
if (!customJoinMessage.isEmpty()) {
|
||||||
customJoinMessage = ChatColor.translateAlternateColorCodes('&', MiniMessageUtils.parseMiniMessageToLegacy(customJoinMessage));
|
customJoinMessage = ChatColor.translateAlternateColorCodes('&', customJoinMessage);
|
||||||
event.setJoinMessage(customJoinMessage
|
event.setJoinMessage(customJoinMessage
|
||||||
.replace("{PLAYERNAME}", player.getName())
|
.replace("{PLAYERNAME}", player.getName())
|
||||||
.replace("{DISPLAYNAME}", player.getDisplayName())
|
.replace("{DISPLAYNAME}", player.getDisplayName())
|
||||||
@@ -248,6 +254,11 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove data from locale map when player quit
|
||||||
|
if (settings.getProperty(PluginSettings.I18N_MESSAGES)) {
|
||||||
|
I18NUtils.removeLocale(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
if (antiBotService.wasPlayerKicked(player.getName())) {
|
if (antiBotService.wasPlayerKicked(player.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -313,7 +324,7 @@ public class PlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!quickCommandsProtectionManager.isAllowed(player.getName())) {
|
if (!quickCommandsProtectionManager.isAllowed(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
bukkitService.runTaskIfFolia(player, () -> player.kickPlayer(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK)));
|
bukkitService.runTaskIfFolia(player, () -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK))));
|
||||||
// AuthMeReReloaded - Folia compatibility
|
// AuthMeReReloaded - Folia compatibility
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -489,6 +500,17 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isInventoryOpenedByApi(Inventory inventory) {
|
||||||
|
if (inventory == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (PENDING_INVENTORIES.contains(inventory)) {
|
||||||
|
PENDING_INVENTORIES.remove(inventory);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private boolean isInventoryWhitelisted(InventoryView inventory) {
|
private boolean isInventoryWhitelisted(InventoryView inventory) {
|
||||||
if (inventory == null) {
|
if (inventory == null) {
|
||||||
@@ -515,7 +537,8 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
||||||
final HumanEntity player = event.getPlayer();
|
final HumanEntity player = event.getPlayer();
|
||||||
if (listenerService.shouldCancelEvent(player)
|
if (listenerService.shouldCancelEvent(player)
|
||||||
&& !isInventoryWhitelisted(event.getView())) {
|
&& !isInventoryWhitelisted(event.getView())
|
||||||
|
&& !isInventoryOpenedByApi(event.getInventory())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ public class ServerListener implements Listener {
|
|||||||
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
||||||
protocolLibService.disable();
|
protocolLibService.disable();
|
||||||
logger.warning("ProtocolLib has been disabled, unhooking packet adapters!");
|
logger.warning("ProtocolLib has been disabled, unhooking packet adapters!");
|
||||||
|
} else if ("PlaceholderAPI".equalsIgnoreCase(pluginName)) {
|
||||||
|
pluginHookService.unhookPlaceholderApi();
|
||||||
|
logger.info("PlaceholderAPI has been disabled: unhooking placeholders");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +77,8 @@ public class ServerListener implements Listener {
|
|||||||
spawnLoader.loadCmiSpawn();
|
spawnLoader.loadCmiSpawn();
|
||||||
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
||||||
protocolLibService.setup();
|
protocolLibService.setup();
|
||||||
|
} else if ("PlaceholderAPI".equalsIgnoreCase(pluginName)) {
|
||||||
|
pluginHookService.tryHookToPlaceholderApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package fr.xephi.authme.message;
|
package fr.xephi.authme.message;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.mail.EmailService;
|
import fr.xephi.authme.mail.EmailService;
|
||||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||||
|
import fr.xephi.authme.service.AdventureService;
|
||||||
import fr.xephi.authme.util.expiring.Duration;
|
import fr.xephi.authme.util.expiring.Duration;
|
||||||
import fr.xephi.authme.util.message.I18NUtils;
|
import fr.xephi.authme.util.message.I18NUtils;
|
||||||
import fr.xephi.authme.util.message.MiniMessageUtils;
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
@@ -44,6 +46,7 @@ public class Messages {
|
|||||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(EmailService.class);
|
private final ConsoleLogger logger = ConsoleLoggerFactory.get(EmailService.class);
|
||||||
|
|
||||||
private MessagesFileHandler messagesFileHandler;
|
private MessagesFileHandler messagesFileHandler;
|
||||||
|
private static final AdventureService adventureService = AuthMe.getAdventureService();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -62,7 +65,7 @@ public class Messages {
|
|||||||
public void send(CommandSender sender, MessageKey key) {
|
public void send(CommandSender sender, MessageKey key) {
|
||||||
String[] lines = retrieve(key, sender);
|
String[] lines = retrieve(key, sender);
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
sender.sendMessage(line);
|
adventureService.send(sender, MiniMessageUtils.parseMiniMessage(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +81,7 @@ public class Messages {
|
|||||||
public void send(CommandSender sender, MessageKey key, String... replacements) {
|
public void send(CommandSender sender, MessageKey key, String... replacements) {
|
||||||
String message = retrieveSingle(sender, key, replacements);
|
String message = retrieveSingle(sender, key, replacements);
|
||||||
for (String line : message.split("\n")) {
|
for (String line : message.split("\n")) {
|
||||||
sender.sendMessage(line);
|
adventureService.send(sender, MiniMessageUtils.parseMiniMessage(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +134,7 @@ public class Messages {
|
|||||||
displayName = ((Player) sender).getDisplayName();
|
displayName = ((Player) sender).getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', MiniMessageUtils.parseMiniMessageToLegacy(message))
|
return ChatColor.translateAlternateColorCodes('&', message)
|
||||||
.replace(NEWLINE_TAG, "\n")
|
.replace(NEWLINE_TAG, "\n")
|
||||||
.replace(USERNAME_TAG, sender.getName())
|
.replace(USERNAME_TAG, sender.getName())
|
||||||
.replace(DISPLAYNAME_TAG, displayName);
|
.replace(DISPLAYNAME_TAG, displayName);
|
||||||
@@ -147,7 +150,7 @@ public class Messages {
|
|||||||
private String retrieveMessage(MessageKey key, String name) {
|
private String retrieveMessage(MessageKey key, String name) {
|
||||||
String message = messagesFileHandler.getMessage(key.getKey());
|
String message = messagesFileHandler.getMessage(key.getKey());
|
||||||
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', MiniMessageUtils.parseMiniMessageToLegacy(message))
|
return ChatColor.translateAlternateColorCodes('&', message)
|
||||||
.replace(NEWLINE_TAG, "\n")
|
.replace(NEWLINE_TAG, "\n")
|
||||||
.replace(USERNAME_TAG, name)
|
.replace(USERNAME_TAG, name)
|
||||||
.replace(DISPLAYNAME_TAG, name);
|
.replace(DISPLAYNAME_TAG, name);
|
||||||
|
|||||||
@@ -26,11 +26,10 @@ 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.util.InternetProtocolUtils;
|
import fr.xephi.authme.util.InternetProtocolUtils;
|
||||||
import fr.xephi.authme.util.PlayerUtils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -179,7 +178,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
|
|
||||||
private void handlePlayerWithUnmetNameRestriction(Player player, String ip) {
|
private void handlePlayerWithUnmetNameRestriction(Player player, String ip) {
|
||||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
||||||
player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.NOT_OWNER_ERROR));
|
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.NOT_OWNER_ERROR)));
|
||||||
if (service.getProperty(RestrictionSettings.BAN_UNKNOWN_IP)) {
|
if (service.getProperty(RestrictionSettings.BAN_UNKNOWN_IP)) {
|
||||||
server.banIP(ip);
|
server.banIP(ip);
|
||||||
}
|
}
|
||||||
@@ -208,7 +207,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout;
|
int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout;
|
||||||
|
|
||||||
// AuthMeReReloaded - Fix potion apply on Folia
|
// AuthMeReReloaded - Fix potion apply on Folia
|
||||||
bukkitService.runTaskIfFolia(player,() -> player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)));
|
bukkitService.runTaskIfFolia(player, () -> player.addPotionEffect(bukkitService.createBlindnessEffect(blindTimeOut)));
|
||||||
}
|
}
|
||||||
commandManager.runCommandsOnJoin(player);
|
commandManager.runCommandsOnJoin(player);
|
||||||
});
|
});
|
||||||
@@ -230,7 +229,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
&& countOnlinePlayersByIp(ip) > service.getProperty(RestrictionSettings.MAX_JOIN_PER_IP)) {
|
&& countOnlinePlayersByIp(ip) > service.getProperty(RestrictionSettings.MAX_JOIN_PER_IP)) {
|
||||||
|
|
||||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
|
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
|
||||||
() -> player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.SAME_IP_ONLINE)));
|
() -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.SAME_IP_ONLINE))));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import fr.xephi.authme.settings.properties.RestrictionSettings;
|
|||||||
import fr.xephi.authme.util.InternetProtocolUtils;
|
import fr.xephi.authme.util.InternetProtocolUtils;
|
||||||
import fr.xephi.authme.util.PlayerUtils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -249,7 +250,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
tempbanManager.tempbanPlayer(player);
|
tempbanManager.tempbanPlayer(player);
|
||||||
} else if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
|
} else if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
|
||||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
|
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
|
||||||
() -> player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.WRONG_PASSWORD)));
|
() -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.WRONG_PASSWORD))));
|
||||||
} else {
|
} else {
|
||||||
service.send(player, MessageKey.WRONG_PASSWORD);
|
service.send(player, MessageKey.WRONG_PASSWORD);
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import fr.xephi.authme.settings.commandconfig.CommandManager;
|
|||||||
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 org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -75,7 +73,7 @@ public class ProcessSyncPlayerLogout implements SynchronousProcess {
|
|||||||
// Apply Blindness effect
|
// Apply Blindness effect
|
||||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
player.addPotionEffect(bukkitService.createBlindnessEffect(timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set player's data to unauthenticated
|
// Set player's data to unauthenticated
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import fr.xephi.authme.settings.commandconfig.CommandManager;
|
|||||||
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.RegistrationSettings;
|
||||||
import fr.xephi.authme.util.PlayerUtils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -77,7 +78,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
|
|
||||||
// Kick Player after Registration is enabled, kick the player
|
// Kick Player after Registration is enabled, kick the player
|
||||||
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {
|
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {
|
||||||
player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.REGISTER_SUCCESS));
|
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.REGISTER_SUCCESS)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import fr.xephi.authme.settings.properties.RegistrationSettings;
|
|||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -150,7 +148,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
private void applyBlindEffect(Player player) {
|
private void applyBlindEffect(Player player) {
|
||||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
bukkitService.runTaskIfFolia(player, () -> player.addPotionEffect(bukkitService.createBlindnessEffect(timeout)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class AdventureService {
|
||||||
|
private final AuthMe plugin;
|
||||||
|
public BukkitAudiences adventure;
|
||||||
|
public AdventureService(AuthMe plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
adventure = BukkitAudiences.create(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (adventure != null) {
|
||||||
|
adventure.close();
|
||||||
|
adventure = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(CommandSender sender, Component component) {
|
||||||
|
adventure.sender(sender).sendMessage(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(Player player, Component component) {
|
||||||
|
adventure.player(player).sendMessage(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,6 +18,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -327,6 +329,16 @@ public class BukkitService implements SettingsDependent {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a PotionEffect with blindness for the given duration in ticks.
|
||||||
|
*
|
||||||
|
* @param timeoutInTicks duration of the effect in ticks
|
||||||
|
* @return blindness potion effect
|
||||||
|
*/
|
||||||
|
public PotionEffect createBlindnessEffect(int timeoutInTicks) {
|
||||||
|
return new PotionEffect(PotionEffectType.BLINDNESS, timeoutInTicks, 2);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the world with the given name.
|
* Gets the world with the given name.
|
||||||
*
|
*
|
||||||
@@ -380,7 +392,11 @@ public class BukkitService implements SettingsDependent {
|
|||||||
* @param bytes the message
|
* @param bytes the message
|
||||||
*/
|
*/
|
||||||
public void sendVelocityMessage(Player player, byte[] bytes) {
|
public void sendVelocityMessage(Player player, byte[] bytes) {
|
||||||
player.sendPluginMessage(authMe, "authmevelocity:main", bytes);
|
if (player != null) {
|
||||||
|
player.sendPluginMessage(authMe, "authmevelocity:main", bytes);
|
||||||
|
} else {
|
||||||
|
Bukkit.getServer().sendPluginMessage(authMe, "authmevelocity:main", bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class GeoIpService {
|
|||||||
private volatile boolean downloading;
|
private volatile boolean downloading;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GeoIpService(@DataFolder File dataFolder){
|
GeoIpService(@DataFolder File dataFolder) {
|
||||||
this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE);
|
this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE);
|
||||||
|
|
||||||
// Fires download of recent data or the initialization of the look up service
|
// Fires download of recent data or the initialization of the look up service
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
|||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||||
|
import fr.xephi.authme.service.hook.papi.AuthMeExpansion;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -26,6 +28,8 @@ public class PluginHookService {
|
|||||||
private Essentials essentials;
|
private Essentials essentials;
|
||||||
private Plugin cmi;
|
private Plugin cmi;
|
||||||
private MultiverseCore multiverse;
|
private MultiverseCore multiverse;
|
||||||
|
private PlaceholderAPIPlugin placeholderApi;
|
||||||
|
private AuthMeExpansion authMeExpansion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -38,6 +42,7 @@ public class PluginHookService {
|
|||||||
tryHookToEssentials();
|
tryHookToEssentials();
|
||||||
tryHookToCmi();
|
tryHookToCmi();
|
||||||
tryHookToMultiverse();
|
tryHookToMultiverse();
|
||||||
|
tryHookToPlaceholderApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,6 +138,20 @@ public class PluginHookService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to create a hook into PlaceholderAPI.
|
||||||
|
*/
|
||||||
|
public void tryHookToPlaceholderApi() {
|
||||||
|
try {
|
||||||
|
placeholderApi = getPlugin(pluginManager, "PlaceholderAPI", PlaceholderAPIPlugin.class);
|
||||||
|
authMeExpansion = new AuthMeExpansion();
|
||||||
|
authMeExpansion.register();
|
||||||
|
} catch (Exception | NoClassDefFoundError ignored) {
|
||||||
|
placeholderApi = null;
|
||||||
|
authMeExpansion = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create a hook into CMI.
|
* Attempts to create a hook into CMI.
|
||||||
*/
|
*/
|
||||||
@@ -180,6 +199,16 @@ public class PluginHookService {
|
|||||||
multiverse = null;
|
multiverse = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unhooks from PlaceholderAPI.
|
||||||
|
*/
|
||||||
|
public void unhookPlaceholderApi() {
|
||||||
|
if (placeholderApi != null) {
|
||||||
|
authMeExpansion.unregister();
|
||||||
|
placeholderApi = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------
|
// ------
|
||||||
// Helpers
|
// Helpers
|
||||||
// ------
|
// ------
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class TeleportationService implements Reloadable {
|
|||||||
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
||||||
Location location = buildLocationFromAuth(player, auth);
|
Location location = buildLocationFromAuth(player, auth);
|
||||||
Location playerLoc = player.getLocation();
|
Location playerLoc = player.getLocation();
|
||||||
if (location.getX() == playerLoc.getX() && location.getY() == location.getY() && location.getZ() == playerLoc.getZ()
|
if (location.getX() == playerLoc.getX() && location.getY() == playerLoc.getY() && location.getZ() == playerLoc.getZ()
|
||||||
&& location.getWorld() == playerLoc.getWorld()) return;
|
&& location.getWorld() == playerLoc.getWorld()) return;
|
||||||
logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName());
|
logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName());
|
||||||
teleportBackFromSpawn(player, location);
|
teleportBackFromSpawn(player, location);
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package fr.xephi.authme.service.hook.papi;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AuthMe PlaceholderAPI expansion class.
|
||||||
|
* @author Kobe 8
|
||||||
|
*/
|
||||||
|
public class AuthMeExpansion extends PlaceholderExpansion {
|
||||||
|
private final Settings settings = AuthMe.settings;
|
||||||
|
private final AuthMeApi authMeApi = AuthMeApi.getInstance();
|
||||||
|
@Override
|
||||||
|
public @NotNull String getIdentifier() {
|
||||||
|
return "authme";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getAuthor() {
|
||||||
|
return "HaHaWTH";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getVersion() {
|
||||||
|
return AuthMe.getPluginVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean persist() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||||
|
if (!settings.getProperty(HooksSettings.PLACEHOLDER_API)) return null;
|
||||||
|
if (params.equalsIgnoreCase("version")) {
|
||||||
|
return getVersion();
|
||||||
|
}
|
||||||
|
if (params.equalsIgnoreCase("is_registered")) {
|
||||||
|
if (player != null) {
|
||||||
|
Player onlinePlayer = player.getPlayer();
|
||||||
|
if (onlinePlayer != null) {
|
||||||
|
return String.valueOf(authMeApi.isRegistered(onlinePlayer.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (params.equalsIgnoreCase("is_authenticated")) {
|
||||||
|
if (player != null) {
|
||||||
|
Player onlinePlayer = player.getPlayer();
|
||||||
|
if (onlinePlayer != null) {
|
||||||
|
return String.valueOf(authMeApi.isAuthenticated(onlinePlayer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (params.equalsIgnoreCase("last_login_time")) {
|
||||||
|
if (player != null) {
|
||||||
|
Player onlinePlayer = player.getPlayer();
|
||||||
|
if (onlinePlayer != null) {
|
||||||
|
return authMeApi.getLastLoginTime(onlinePlayer.getName()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,9 +129,9 @@ public class CommandManager implements Reloadable {
|
|||||||
if (predicate.test(cmd)) {
|
if (predicate.test(cmd)) {
|
||||||
long delay = cmd.getDelay();
|
long delay = cmd.getDelay();
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
bukkitService.scheduleSyncDelayedTask(() -> dispatchCommand(player, cmd), delay);
|
bukkitService.runTaskLater(player, () -> dispatchCommand(player, cmd), delay);
|
||||||
} else {
|
} else {
|
||||||
dispatchCommand(player, cmd);
|
bukkitService.runTaskIfFolia(player, () -> dispatchCommand(player, cmd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ public final class HooksSettings implements SettingsHolder {
|
|||||||
public static final Property<Boolean> MULTIVERSE =
|
public static final Property<Boolean> MULTIVERSE =
|
||||||
newProperty("Hooks.multiverse", true);
|
newProperty("Hooks.multiverse", true);
|
||||||
|
|
||||||
|
@Comment("Do we need to hook with PlaceholderAPI for AuthMe placeholders?")
|
||||||
|
public static final Property<Boolean> PLACEHOLDER_API =
|
||||||
|
newProperty("Hooks.placeholderapi", true);
|
||||||
|
|
||||||
@Comment("Do we need to hook with BungeeCord?")
|
@Comment("Do we need to hook with BungeeCord?")
|
||||||
public static final Property<Boolean> BUNGEECORD =
|
public static final Property<Boolean> BUNGEECORD =
|
||||||
newProperty("Hooks.bungeecord", false);
|
newProperty("Hooks.bungeecord", false);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public final class PluginSettings implements SettingsHolder {
|
|||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Send i18n messages to player based on their client settings, this option will override `settings.messagesLanguage`",
|
"Send i18n messages to player based on their client settings, this option will override `settings.messagesLanguage`",
|
||||||
"(Requires Protocollib or Packetevents)",
|
"(Requires ProtocolLib)",
|
||||||
"This will not affect language of AuthMe help command."
|
"This will not affect language of AuthMe help command."
|
||||||
})
|
})
|
||||||
public static final Property<Boolean> I18N_MESSAGES =
|
public static final Property<Boolean> I18N_MESSAGES =
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package fr.xephi.authme.task;
|
package fr.xephi.authme.task;
|
||||||
|
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
|
import fr.xephi.authme.util.message.MiniMessageUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +29,7 @@ public class TimeoutTask implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!playerCache.isAuthenticated(player.getName())) {
|
if (!playerCache.isAuthenticated(player.getName())) {
|
||||||
player.kickPlayer(message);
|
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ public class I18NUtils {
|
|||||||
PLAYER_LOCALE.put(uuid, locale);
|
PLAYER_LOCALE.put(uuid, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeLocale(UUID uuid) {
|
||||||
|
PLAYER_LOCALE.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the AuthMe messages file language code, by given locale and settings.
|
* Returns the AuthMe messages file language code, by given locale and settings.
|
||||||
* Dreeam - Hard mapping, based on mc1.20.6, 5/29/2024
|
* Dreeam - Hard mapping, based on mc1.20.6, 5/29/2024
|
||||||
|
|||||||
@@ -1,14 +1,36 @@
|
|||||||
package fr.xephi.authme.util.message;
|
package fr.xephi.authme.util.message;
|
||||||
|
|
||||||
|
import fr.xephi.authme.util.Utils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class MiniMessageUtils {
|
public class MiniMessageUtils {
|
||||||
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
|
private static final char SECTION_CHAR = '§';
|
||||||
|
private static final char AMPERSAND_CHAR = '&';
|
||||||
|
private static final boolean HEX_SUPPORTED = Utils.MAJOR_VERSION >= 16;
|
||||||
|
private static Method methodDisallow;
|
||||||
|
private static Method methodKick;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
methodDisallow = AsyncPlayerPreLoginEvent.class.getMethod("disallow", AsyncPlayerPreLoginEvent.Result.class, Component.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
methodDisallow = null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
methodKick = Player.class.getMethod("kick", Component.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
methodKick = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Parse a MiniMessage string into a legacy string.
|
* Parse a MiniMessage string into a legacy string.
|
||||||
*
|
*
|
||||||
@@ -21,16 +43,96 @@ public class MiniMessageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a MiniMessage string into a BaseComponent.
|
* Parse a MiniMessage string into a component.
|
||||||
*
|
*
|
||||||
* @param message The message to parse.
|
* @param message The message to parse.
|
||||||
* @return The parsed message.
|
* @return The parsed message.
|
||||||
*/
|
*/
|
||||||
public static BaseComponent[] parseMiniMessageToBaseComponent(String message) {
|
public static Component parseMiniMessage(String message) {
|
||||||
Component component = miniMessage.deserialize(message);
|
return miniMessage.deserialize(convertLegacyToMiniMessage(message, false, SECTION_CHAR, HEX_SUPPORTED));
|
||||||
return BungeeComponentSerializer.legacy().serialize(component);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kicks a player with the given message.
|
||||||
|
*
|
||||||
|
* @param player the player to kick
|
||||||
|
* @param message the message to send
|
||||||
|
*/
|
||||||
|
public static void kickPlayer(Player player, Component message) {
|
||||||
|
if (methodKick != null) {
|
||||||
|
try {
|
||||||
|
methodKick.invoke(player, message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.kickPlayer(LegacyComponentSerializer.legacySection().serialize(message));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.kickPlayer(LegacyComponentSerializer.legacySection().serialize(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disallows the login event with the given result and reason.
|
||||||
|
*
|
||||||
|
* @param event the event
|
||||||
|
* @param result the event result to set
|
||||||
|
* @param message the denial message
|
||||||
|
*/
|
||||||
|
public static void disallowPreLoginEvent(AsyncPlayerPreLoginEvent event,
|
||||||
|
AsyncPlayerPreLoginEvent.Result result, Component message) {
|
||||||
|
if (methodDisallow != null) {
|
||||||
|
try {
|
||||||
|
methodDisallow.invoke(event, result, message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
event.disallow(result, LegacyComponentSerializer.legacySection().serialize(message));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.disallow(result, LegacyComponentSerializer.legacySection().serialize(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
private static String convertLegacyToMiniMessage(String legacy, boolean concise, char charCode, boolean rgb) {
|
||||||
|
String miniMessage = legacy.replaceAll(Pattern.quote(String.valueOf(charCode)) + "0", "<black>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "1", "<dark_blue>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "2", "<dark_green>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "3", "<dark_aqua>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "4", "<dark_red>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "5", "<dark_purple>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "6", "<gold>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "7", "<gray>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "8", "<dark_gray>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "9", "<blue>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "a", "<green>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "b", "<aqua>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "c", "<red>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "d", "<light_purple>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "e", "<yellow>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "f", "<white>");
|
||||||
|
|
||||||
|
if (concise) {
|
||||||
|
miniMessage = miniMessage.replaceAll(Pattern.quote(String.valueOf(charCode)) + "n", "<u>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "m", "<st>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "k", "<obf>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "o", "<i>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "l", "<b>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "r", "<r>");
|
||||||
|
} else {
|
||||||
|
miniMessage = miniMessage.replaceAll(Pattern.quote(String.valueOf(charCode)) + "n", "<underlined>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "m", "<strikethrough>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "k", "<obfuscated>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "o", "<italic>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "l", "<bold>")
|
||||||
|
.replaceAll(Pattern.quote(String.valueOf(charCode)) + "r", "<reset>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rgb) {
|
||||||
|
Pattern pattern = Pattern.compile(Pattern.quote(String.valueOf(charCode)) + "#([0-9a-fA-F]{6})");
|
||||||
|
Matcher matcher = pattern.matcher(miniMessage);
|
||||||
|
miniMessage = matcher.replaceAll("<#$1>");
|
||||||
|
}
|
||||||
|
|
||||||
|
return miniMessage;
|
||||||
|
}
|
||||||
private MiniMessageUtils() {
|
private MiniMessageUtils() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
# noinspection YAMLSchemaValidation
|
||||||
name: ${pluginDescription.name}
|
name: ${pluginDescription.name}
|
||||||
|
# noinspection YAMLSchemaValidation
|
||||||
authors: [${pluginDescription.authors}]
|
authors: [${pluginDescription.authors}]
|
||||||
website: https://github.com/HaHaWTH/AuthMeReReloaded/
|
website: https://github.com/HaHaWTH/AuthMeReReloaded/
|
||||||
description: A fork of AuthMeReloaded that contains bug fixes
|
description: A fork of AuthMeReloaded that contains bug fixes
|
||||||
|
# noinspection YAMLSchemaValidation
|
||||||
main: ${pluginDescription.main}
|
main: ${pluginDescription.main}
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
version: 5.6.0-FORK-b50
|
version: 5.7.0-FORK-b52
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend:
|
softdepend:
|
||||||
- Vault
|
- Vault
|
||||||
@@ -17,6 +20,7 @@ softdepend:
|
|||||||
- EssentialsSpawn
|
- EssentialsSpawn
|
||||||
- ProtocolLib
|
- ProtocolLib
|
||||||
- floodgate
|
- floodgate
|
||||||
|
- PlaceholderAPI
|
||||||
commands:
|
commands:
|
||||||
authme:
|
authme:
|
||||||
description: AuthMe op commands
|
description: AuthMe op commands
|
||||||
|
|||||||
Reference in New Issue
Block a user