Compare commits

..

20 Commits

Author SHA1 Message Date
HaHaWTH 007e01156b B53 release 2024-08-20 23:52:40 +08:00
Kobe ⑧ d2ec62ac7f Merge pull request #203 from HaHaWTH/dependabot/maven/org.apache.maven.plugins-maven-deploy-plugin-3.1.3
Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.2 to 3.1.3
2024-08-20 18:46:24 +08:00
Kobe ⑧ da32bdec94 Merge pull request #204 from HaHaWTH/dependabot/maven/org.apache.maven.plugins-maven-install-plugin-3.1.3
Bump org.apache.maven.plugins:maven-install-plugin from 3.1.2 to 3.1.3
2024-08-20 18:46:14 +08:00
Kobe ⑧ 7d58e90557 Merge pull request #202 from HaHaWTH/dependabot/maven/org.xerial-sqlite-jdbc-3.46.1.0
Bump org.xerial:sqlite-jdbc from 3.46.0.1 to 3.46.1.0
2024-08-20 18:45:54 +08:00
dependabot[bot] 08dabda7c7 Bump org.apache.maven.plugins:maven-install-plugin from 3.1.2 to 3.1.3
Bumps [org.apache.maven.plugins:maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/apache/maven-install-plugin/releases)
- [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.1.2...maven-install-plugin-3.1.3)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-install-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-20 04:34:00 +00:00
dependabot[bot] feea348ec3 Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.2 to 3.1.3
Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/apache/maven-deploy-plugin/releases)
- [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.2...maven-deploy-plugin-3.1.3)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-deploy-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-20 04:32:17 +00:00
dependabot[bot] 67eb7dee0f Bump org.xerial:sqlite-jdbc from 3.46.0.1 to 3.46.1.0
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.46.0.1 to 3.46.1.0.
- [Release notes](https://github.com/xerial/sqlite-jdbc/releases)
- [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG)
- [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.46.0.1...3.46.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-19 04:42:25 +00:00
Kobe ⑧ 6fb1d2855e Merge pull request #196 from HaHaWTH/dependabot/maven/net.kyori-adventure-platform-bukkit-4.3.4
Bump net.kyori:adventure-platform-bukkit from 4.3.3 to 4.3.4
2024-08-16 19:40:48 +08:00
dependabot[bot] faa3d9320c Bump net.kyori:adventure-platform-bukkit from 4.3.3 to 4.3.4
Bumps [net.kyori:adventure-platform-bukkit](https://github.com/KyoriPowered/adventure-platform) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/KyoriPowered/adventure-platform/releases)
- [Commits](https://github.com/KyoriPowered/adventure-platform/compare/v4.3.3...v4.3.4)

---
updated-dependencies:
- dependency-name: net.kyori:adventure-platform-bukkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-13 05:06:28 +00:00
Kobe ⑧ 497cd543fd Merge pull request #194 from HaHaWTH/dependabot/maven/org.checkerframework-checker-qual-3.46.0
Bump org.checkerframework:checker-qual from 3.45.0 to 3.46.0
2024-08-02 12:38:37 +08:00
Kobe ⑧ 71d5205df0 Merge pull request #192 from HaHaWTH/dependabot/maven/org.xerial-sqlite-jdbc-3.46.0.1
Bump org.xerial:sqlite-jdbc from 3.46.0.0 to 3.46.0.1
2024-08-02 12:38:26 +08:00
dependabot[bot] bba90d93f1 Bump org.checkerframework:checker-qual from 3.45.0 to 3.46.0
Bumps [org.checkerframework:checker-qual](https://github.com/typetools/checker-framework) from 3.45.0 to 3.46.0.
- [Release notes](https://github.com/typetools/checker-framework/releases)
- [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.45.0...checker-framework-3.46.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-02 04:33:38 +00:00
HaHaWTH ab40b1b82d fix papi NPE 2024-07-31 23:48:32 +08:00
HaHaWTH 22a6cefbdc Merge remote-tracking branch 'origin/master' 2024-07-31 13:54:34 +08:00
HaHaWTH 9ca3a24862 Temporarily fix inventory loss 2024-07-31 13:53:54 +08:00
dependabot[bot] 91f0dfa5c5 Bump org.xerial:sqlite-jdbc from 3.46.0.0 to 3.46.0.1
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.46.0.0 to 3.46.0.1.
- [Release notes](https://github.com/xerial/sqlite-jdbc/releases)
- [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG)
- [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.46.0.0...3.46.0.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-31 04:21:56 +00:00
Kobe ⑧ f0e935a5d8 Merge pull request #186 from luketeam5/patch-1
Better Regex e-mail
2024-07-23 09:39:45 +08:00
luketeam5 f0fae0fce0 Update RestrictionSettings.java 2024-07-23 03:34:10 +02:00
luketeam5 4c40ba36a6 Better regex 2024-07-23 00:07:34 +02:00
HaHaWTH bd7a25560f Added config to disable changepassword email verification 2024-07-23 03:52:01 +08:00
20 changed files with 51 additions and 212 deletions
+16 -9
View File
@@ -454,6 +454,18 @@
<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>
@@ -485,13 +497,13 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version> <version>3.1.3</version>
</plugin> </plugin>
<!-- Deploy the jars as artifacts into the remote repository --> <!-- Deploy the jars as artifacts into the remote repository -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId> <artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version> <version>3.1.3</version>
</plugin> </plugin>
<!-- Handle documentation generation, required by other plugins --> <!-- Handle documentation generation, required by other plugins -->
<plugin> <plugin>
@@ -886,11 +898,6 @@
<artifactId>adventure-text-minimessage</artifactId> <artifactId>adventure-text-minimessage</artifactId>
<version>4.17.0</version> <version>4.17.0</version>
</dependency> </dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.3</version>
</dependency>
<!-- LuckPerms plugin --> <!-- LuckPerms plugin -->
<dependency> <dependency>
@@ -1125,7 +1132,7 @@
<dependency> <dependency>
<groupId>org.checkerframework</groupId> <groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId> <artifactId>checker-qual</artifactId>
<version>3.45.0</version> <version>3.46.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@@ -1141,7 +1148,7 @@
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.46.0.0</version> <version>3.46.1.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
+1 -17
View File
@@ -31,7 +31,6 @@ 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;
@@ -77,12 +76,11 @@ public class AuthMe extends JavaPlugin {
// Version and build number values // Version and build number values
private static String pluginVersion = "5.7.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 = "52"; private static String pluginBuildNumber = "53";
// 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;
@@ -141,13 +139,6 @@ public class AuthMe extends JavaPlugin {
return scheduler; return scheduler;
} }
/**
* Get the AdventureService
*/
public static AdventureService getAdventureService() {
return adventureService;
}
/** /**
* The library manager * The library manager
*/ */
@@ -162,8 +153,6 @@ 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));
@@ -414,11 +403,6 @@ 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!");
@@ -12,7 +12,6 @@ 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;
@@ -80,7 +79,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, () -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER))))); bukkitService.runTaskIfFolia(player, () -> player.kickPlayer(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER))));
} }
}); });
} }
@@ -8,6 +8,7 @@ import fr.xephi.authme.process.Management;
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.settings.properties.SecuritySettings;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import javax.inject.Inject; import javax.inject.Inject;
@@ -42,11 +43,14 @@ 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)) { if (commonService.getProperty(SecuritySettings.CHANGE_PASSWORD_EMAIL_VERIFICATION_REQUIRED)) {
codeManager.codeExistOrGenerateNew(name); // Check if the user has been verified or not
commonService.send(player, MessageKey.VERIFICATION_CODE_REQUIRED); if (codeManager.isVerificationRequired(player)) {
return; codeManager.codeExistOrGenerateNew(name);
commonService.send(player, MessageKey.VERIFICATION_CODE_REQUIRED);
return;
}
} }
String oldPassword = arguments.get(0); String oldPassword = arguments.get(0);
@@ -9,7 +9,6 @@ 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;
@@ -107,7 +106,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");
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(reason)); player.kickPlayer(reason);
} else { } else {
String command = customCommand String command = customCommand
.replace("%player%", name) .replace("%player%", name)
@@ -3,7 +3,6 @@ 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;
@@ -27,7 +26,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())) {
MiniMessageUtils.kickPlayer(ep, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(ep.getPlayer(), MessageKey.DOUBLE_LOGIN_FIX))); ep.kickPlayer(service.retrieveSingleMessage(ep.getPlayer(), MessageKey.DOUBLE_LOGIN_FIX));
break; break;
} }
PlayerSet.add(ep.getName().toLowerCase()); PlayerSet.add(ep.getName().toLowerCase());
@@ -18,7 +18,6 @@ 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;
@@ -141,7 +140,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, () -> MiniMessageUtils.kickPlayer(nonVipPlayer, MiniMessageUtils.parseMiniMessage(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP)))); bukkitService.runTaskIfFolia(nonVipPlayer, () -> nonVipPlayer.kickPlayer(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP)));
event.allow(); event.allow();
return false; return false;
} else { } else {
@@ -219,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('&', customJoinMessage); customJoinMessage = ChatColor.translateAlternateColorCodes('&', MiniMessageUtils.parseMiniMessageToLegacy(customJoinMessage));
event.setJoinMessage(customJoinMessage event.setJoinMessage(customJoinMessage
.replace("{PLAYERNAME}", player.getName()) .replace("{PLAYERNAME}", player.getName())
.replace("{DISPLAYNAME}", player.getDisplayName()) .replace("{DISPLAYNAME}", player.getDisplayName())
@@ -324,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, () -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK)))); bukkitService.runTaskIfFolia(player, () -> player.kickPlayer(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK)));
// AuthMeReReloaded - Folia compatibility // AuthMeReReloaded - Folia compatibility
return; return;
} }
@@ -1,11 +1,9 @@
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;
@@ -46,7 +44,6 @@ 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.
@@ -65,7 +62,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) {
adventureService.send(sender, MiniMessageUtils.parseMiniMessage(line)); sender.sendMessage(line);
} }
} }
@@ -81,7 +78,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")) {
adventureService.send(sender, MiniMessageUtils.parseMiniMessage(line)); sender.sendMessage(line);
} }
} }
@@ -134,7 +131,7 @@ public class Messages {
displayName = ((Player) sender).getDisplayName(); displayName = ((Player) sender).getDisplayName();
} }
return ChatColor.translateAlternateColorCodes('&', message) return ChatColor.translateAlternateColorCodes('&', MiniMessageUtils.parseMiniMessageToLegacy(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);
@@ -150,7 +147,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('&', message) return ChatColor.translateAlternateColorCodes('&', MiniMessageUtils.parseMiniMessageToLegacy(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,7 +26,6 @@ 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;
@@ -178,7 +177,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
private void handlePlayerWithUnmetNameRestriction(Player player, String ip) { private void handlePlayerWithUnmetNameRestriction(Player player, String ip) {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> { bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.NOT_OWNER_ERROR))); player.kickPlayer(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);
} }
@@ -229,7 +228,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(
() -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.SAME_IP_ONLINE)))); () -> player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.SAME_IP_ONLINE)));
return false; return false;
} }
return true; return true;
@@ -36,7 +36,6 @@ 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;
@@ -250,7 +249,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(
() -> MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.WRONG_PASSWORD)))); () -> player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.WRONG_PASSWORD)));
} else { } else {
service.send(player, MessageKey.WRONG_PASSWORD); service.send(player, MessageKey.WRONG_PASSWORD);
@@ -29,7 +29,7 @@ public class ProcessSyncPlayerQuit implements SynchronousProcess {
} else { } else {
limboService.restoreData(player); limboService.restoreData(player);
if (!UniversalScheduler.isFolia) { // AuthMeReReloaded - Fix #146 (Very stupid solution, but works) if (!UniversalScheduler.isFolia) { // AuthMeReReloaded - Fix #146 (Very stupid solution, but works)
player.saveData(); // #1238: Speed is sometimes not restored properly // player.saveData(); // #1238: Speed is sometimes not restored properly
} }
} }
player.leaveVehicle(); player.leaveVehicle();
@@ -15,7 +15,6 @@ 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;
@@ -78,7 +77,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)) {
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(service.retrieveSingleMessage(player, MessageKey.REGISTER_SUCCESS))); player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.REGISTER_SUCCESS));
return; return;
} }
@@ -1,35 +0,0 @@
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);
}
}
@@ -15,7 +15,6 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class AuthMeExpansion extends PlaceholderExpansion { public class AuthMeExpansion extends PlaceholderExpansion {
private final Settings settings = AuthMe.settings; private final Settings settings = AuthMe.settings;
private final AuthMeApi authMeApi = AuthMeApi.getInstance();
@Override @Override
public @NotNull String getIdentifier() { public @NotNull String getIdentifier() {
return "authme"; return "authme";
@@ -39,6 +38,8 @@ public class AuthMeExpansion extends PlaceholderExpansion {
@Override @Override
public String onRequest(OfflinePlayer player, @NotNull String params) { public String onRequest(OfflinePlayer player, @NotNull String params) {
if (!settings.getProperty(HooksSettings.PLACEHOLDER_API)) return null; if (!settings.getProperty(HooksSettings.PLACEHOLDER_API)) return null;
AuthMeApi authMeApi = AuthMeApi.getInstance();
if (authMeApi == null) return null;
if (params.equalsIgnoreCase("version")) { if (params.equalsIgnoreCase("version")) {
return getVersion(); return getVersion();
} }
@@ -173,7 +173,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_.]{3,20}@(qq|outlook|163|gmail|icloud)\\.com$"); newProperty("settings.restrictions.allowedEmailCharacters", "^([a-zA-Z0-9_.+-]+)@([a-zA-Z0-9-]+)\\.([a-zA-Z]{2,})$");
@Comment("Force survival gamemode when player joins?") @Comment("Force survival gamemode when player joins?")
@@ -62,6 +62,11 @@ public final class SecuritySettings implements SettingsHolder {
public static final Property<Integer> HAVE_I_BEEN_PWNED_LIMIT = public static final Property<Integer> HAVE_I_BEEN_PWNED_LIMIT =
newProperty("Security.account.haveIBeenPwned.limit", 0); newProperty("Security.account.haveIBeenPwned.limit", 0);
@Comment({"Require email verification when changing password if email feature enabled.",
"Original behavior is true"})
public static final Property<Boolean> CHANGE_PASSWORD_EMAIL_VERIFICATION_REQUIRED =
newProperty("Security.account.emailVerification.required", true);
@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);
@@ -1,7 +1,6 @@
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;
/** /**
@@ -29,7 +28,7 @@ public class TimeoutTask implements Runnable {
@Override @Override
public void run() { public void run() {
if (!playerCache.isAuthenticated(player.getName())) { if (!playerCache.isAuthenticated(player.getName())) {
MiniMessageUtils.kickPlayer(player, MiniMessageUtils.parseMiniMessage(message)); player.kickPlayer(message);
} }
} }
} }
@@ -1,36 +1,12 @@
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.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
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.
* *
@@ -41,98 +17,6 @@ public class MiniMessageUtils {
Component component = miniMessage.deserialize(message); Component component = miniMessage.deserialize(message);
return LegacyComponentSerializer.legacyAmpersand().serialize(component); return LegacyComponentSerializer.legacyAmpersand().serialize(component);
} }
/**
* Parse a MiniMessage string into a component.
*
* @param message The message to parse.
* @return The parsed message.
*/
public static Component parseMiniMessage(String message) {
return miniMessage.deserialize(convertLegacyToMiniMessage(message, false, SECTION_CHAR, HEX_SUPPORTED));
}
/**
* 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 -1
View File
@@ -7,7 +7,7 @@ description: A fork of AuthMeReloaded that contains bug fixes
# noinspection YAMLSchemaValidation # noinspection YAMLSchemaValidation
main: ${pluginDescription.main} main: ${pluginDescription.main}
folia-supported: true folia-supported: true
version: 5.7.0-FORK-b52 version: 5.7.0-FORK-b53
api-version: 1.13 api-version: 1.13
softdepend: softdepend:
- Vault - Vault