Compare commits

..

17 Commits

Author SHA1 Message Date
HaHaWTH f25610c90b Fix workflow 2024-06-27 12:10:57 +08:00
HaHaWTH 7130d3989c Bump version number 2024-06-27 12:02:24 +08:00
HaHaWTH 900d2bd2e9 Merge remote-tracking branch 'origin/master' 2024-06-27 11:57:55 +08:00
HaHaWTH 7d255dfa30 Sync with upstream & Bump version number 2024-06-27 11:57:17 +08:00
DGun Otto 0cce930260 Merge pull request #172 from HaHaWTH/dependabot/maven/org.apache.maven.plugins-maven-jar-plugin-3.4.2
Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2
2024-06-20 14:37:48 +08:00
DGun Otto 0671a54b20 Merge pull request #171 from HaHaWTH/dependabot/maven/org.apache.maven.plugins-maven-clean-plugin-3.4.0
Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0
2024-06-20 14:37:37 +08:00
dependabot[bot] 4df4a1fa4b Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2
Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.4.1 to 3.4.2.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.1...maven-jar-plugin-3.4.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-20 04:48:58 +00:00
dependabot[bot] 5b52a0ff00 Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0
Bumps [org.apache.maven.plugins:maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.3.2 to 3.4.0.
- [Release notes](https://github.com/apache/maven-clean-plugin/releases)
- [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.3.2...maven-clean-plugin-3.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-20 04:48:06 +00:00
HaHaWTH 5186d09116 Revert some changes 2024-06-18 16:17:03 +08:00
HaHaWTH a5b06bbd07 Merge remote-tracking branch 'origin/master' 2024-06-12 01:46:32 +08:00
HaHaWTH 9b74cb5a00 Fix Folia join commands 2024-06-12 01:45:57 +08:00
DGun Otto be97e7faa0 Update maven.yml 2024-06-11 21:43:35 +08:00
HaHaWTH 253822a056 Merge remote-tracking branch 'origin/master' 2024-06-11 07:28:59 +08:00
HaHaWTH 0fcc45039d Add openInventory method to API 2024-06-11 07:28:13 +08:00
DGun Otto 4700e2ae90 Merge pull request #169 from Dreeam-qwq/fix/i18n-opt
Remove locale data from locale map when player quit to save ram
2024-06-10 06:51:49 +08:00
Dreeam d9c89e1dc6 Remove locale data from locale map when player quit to save mem 2024-06-10 06:15:48 +08:00
DGun Otto b513fd37cb [ci skip] Update link 2024-06-06 03:20:54 +08:00
13 changed files with 82 additions and 37 deletions
+3 -1
View File
@@ -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.20.6'
javaVersion: '21'
steps: steps:
- uses: HaHaWTH/minecraft-plugin-runtime-test@paper - uses: HaHaWTH/minecraft-plugin-runtime-test@paper
with: with:
+4 -4
View File
@@ -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.6.1-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>
@@ -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>
@@ -699,7 +699,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>
+3 -3
View File
@@ -74,9 +74,9 @@ 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.6.1-Fork";
private static final String pluginBuild = "b"; private static final String pluginBuild = "b";
private static String pluginBuildNumber = "50"; private static String pluginBuildNumber = "51";
// Private instances // Private instances
private EmailService emailService; private EmailService emailService;
private CommandHandler commandHandler; private CommandHandler commandHandler;
@@ -416,7 +416,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.
* *
@@ -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)
@@ -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;
} }
@@ -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);
/* /*
@@ -29,8 +29,6 @@ import fr.xephi.authme.util.PlayerUtils;
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;
@@ -208,7 +206,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);
}); });
@@ -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
@@ -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)));
} }
} }
@@ -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) {
if (player != null) {
player.sendPluginMessage(authMe, "authmevelocity:main", bytes); player.sendPluginMessage(authMe, "authmevelocity:main", bytes);
} else {
Bukkit.getServer().sendPluginMessage(authMe, "authmevelocity:main", bytes);
}
} }
@@ -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));
} }
} }
} }
@@ -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
@@ -2,9 +2,7 @@ package fr.xephi.authme.util.message;
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;
public class MiniMessageUtils { public class MiniMessageUtils {
private static final MiniMessage miniMessage = MiniMessage.miniMessage(); private static final MiniMessage miniMessage = MiniMessage.miniMessage();
@@ -19,18 +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 BaseComponent.
*
* @param message The message to parse.
* @return The parsed message.
*/
public static BaseComponent[] parseMiniMessageToBaseComponent(String message) {
Component component = miniMessage.deserialize(message);
return BungeeComponentSerializer.legacy().serialize(component);
}
private MiniMessageUtils() { private MiniMessageUtils() {
} }
} }
+4 -1
View File
@@ -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.6.1-FORK-b51
api-version: 1.13 api-version: 1.13
softdepend: softdepend:
- Vault - Vault