mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-28 02:59:13 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9b1070725 | ||
|
|
5a000add98 | ||
|
|
aec2836d1e | ||
|
|
84e2ea3904 | ||
|
|
4f669170c2 | ||
|
|
8ea8c7b7ba | ||
|
|
acab4ae58a | ||
|
|
ea822b0f4b | ||
|
|
24a9974ff7 | ||
|
|
222a9871e0 | ||
|
|
0ce9d2ce74 | ||
|
|
cde500a123 | ||
|
|
f15790030f | ||
|
|
ce3350c6fa |
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
id 'com.github.johnrengelman.shadow' version '8.1.0'
|
||||||
id 'org.ajoberstar.grgit' version '5.0.0'
|
id 'org.ajoberstar.grgit' version '5.0.0'
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
@@ -40,8 +40,8 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ dependencies {
|
|||||||
implementation 'net.william278:AndJam:1.0.2'
|
implementation 'net.william278:AndJam:1.0.2'
|
||||||
implementation 'me.lucko:commodore:2.2'
|
implementation 'me.lucko:commodore:2.2'
|
||||||
implementation 'net.kyori:adventure-platform-bukkit:4.2.0'
|
implementation 'net.kyori:adventure-platform-bukkit:4.2.0'
|
||||||
implementation 'dev.triumphteam:triumph-gui:3.1.3'
|
implementation 'dev.triumphteam:triumph-gui:3.1.4'
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||||
compileOnly 'commons-io:commons-io:2.11.0'
|
compileOnly 'commons-io:commons-io:2.11.0'
|
||||||
compileOnly 'de.themoep:minedown-adventure:1.7.1-SNAPSHOT'
|
compileOnly 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
|
||||||
compileOnly 'dev.dejvokep:boosted-yaml:1.3'
|
compileOnly 'dev.dejvokep:boosted-yaml:1.3.1'
|
||||||
compileOnly 'com.zaxxer:HikariCP:5.0.1'
|
compileOnly 'com.zaxxer:HikariCP:5.0.1'
|
||||||
compileOnly 'redis.clients:jedis:' + jedis_version
|
compileOnly 'redis.clients:jedis:' + jedis_version
|
||||||
compileOnly 'net.william278:DesertWell:1.1'
|
compileOnly 'net.william278:DesertWell:1.1.1'
|
||||||
compileOnly 'net.william278:Annotaml:2.0.1'
|
compileOnly 'net.william278:Annotaml:2.0.1'
|
||||||
compileOnly 'net.william278:AdvancementAPI:97a9583413'
|
compileOnly 'net.william278:AdvancementAPI:97a9583413'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class BukkitHuskSync extends JavaPlugin implements HuskSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare data adapter
|
// Prepare data adapter
|
||||||
if (settings.compressData) {
|
if (settings.doCompressData()) {
|
||||||
dataAdapter = new CompressedDataAdapter();
|
dataAdapter = new CompressedDataAdapter();
|
||||||
} else {
|
} else {
|
||||||
dataAdapter = new JsonDataAdapter();
|
dataAdapter = new JsonDataAdapter();
|
||||||
@@ -169,7 +169,7 @@ public class BukkitHuskSync extends JavaPlugin implements HuskSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
if (settings.checkForUpdates) {
|
if (settings.doCheckForUpdates()) {
|
||||||
log(Level.INFO, "Checking for updates...");
|
log(Level.INFO, "Checking for updates...");
|
||||||
getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
||||||
newestVersion.ifPresent(newVersion -> log(Level.WARNING,
|
newestVersion.ifPresent(newVersion -> log(Level.WARNING,
|
||||||
@@ -304,8 +304,8 @@ public class BukkitHuskSync extends JavaPlugin implements HuskSync {
|
|||||||
|
|
||||||
// Load locales from language preset default
|
// Load locales from language preset default
|
||||||
final Locales languagePresets = Annotaml.create(Locales.class,
|
final Locales languagePresets = Annotaml.create(Locales.class,
|
||||||
Objects.requireNonNull(getResource("locales/" + settings.language + ".yml"))).get();
|
Objects.requireNonNull(getResource("locales/" + settings.getLanguage() + ".yml"))).get();
|
||||||
this.locales = Annotaml.create(new File(getDataFolder(), "messages_" + settings.language + ".yml"),
|
this.locales = Annotaml.create(new File(getDataFolder(), "messages_" + settings.getLanguage() + ".yml"),
|
||||||
languagePresets).get();
|
languagePresets).get();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException | NullPointerException | InvocationTargetException | IllegalAccessException |
|
} catch (IOException | NullPointerException | InvocationTargetException | IllegalAccessException |
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class BukkitEventListener extends EventListener implements BukkitJoinEven
|
|||||||
|
|
||||||
public BukkitEventListener(@NotNull BukkitHuskSync huskSync) {
|
public BukkitEventListener(@NotNull BukkitHuskSync huskSync) {
|
||||||
super(huskSync);
|
super(huskSync);
|
||||||
this.blacklistedCommands = huskSync.getSettings().blacklistedCommandsWhileLocked;
|
this.blacklistedCommands = huskSync.getSettings().getBlacklistedCommandsWhileLocked();
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(this, huskSync);
|
Bukkit.getServer().getPluginManager().registerEvents(this, huskSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ public class BukkitEventListener extends EventListener implements BukkitJoinEven
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle saving player data snapshots on death
|
// Handle saving player data snapshots on death
|
||||||
if (!plugin.getSettings().saveOnDeath) return;
|
if (!plugin.getSettings().doSaveOnDeath()) return;
|
||||||
|
|
||||||
// Truncate the drops list to the inventory size and save the player's inventory
|
// Truncate the drops list to the inventory size and save the player's inventory
|
||||||
final int maxInventorySize = BukkitInventoryMap.INVENTORY_SLOT_COUNT;
|
final int maxInventorySize = BukkitInventoryMap.INVENTORY_SLOT_COUNT;
|
||||||
@@ -89,7 +89,7 @@ public class BukkitEventListener extends EventListener implements BukkitJoinEven
|
|||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onWorldSave(@NotNull WorldSaveEvent event) {
|
public void onWorldSave(@NotNull WorldSaveEvent event) {
|
||||||
// Handle saving player data snapshots when the world saves
|
// Handle saving player data snapshots when the world saves
|
||||||
if (!plugin.getSettings().saveOnWorldSave) return;
|
if (!plugin.getSettings().doSaveOnWorldSave()) return;
|
||||||
|
|
||||||
CompletableFuture.runAsync(() -> super.saveOnWorldSave(event.getWorld().getPlayers()
|
CompletableFuture.runAsync(() -> super.saveOnWorldSave(event.getWorld().getPlayers()
|
||||||
.stream().map(BukkitPlayer::adapt)
|
.stream().map(BukkitPlayer::adapt)
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ public class LegacyMigrator extends Migrator {
|
|||||||
public LegacyMigrator(@NotNull HuskSync plugin) {
|
public LegacyMigrator(@NotNull HuskSync plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.hslConverter = HSLConverter.getInstance();
|
this.hslConverter = HSLConverter.getInstance();
|
||||||
this.sourceHost = plugin.getSettings().mySqlHost;
|
this.sourceHost = plugin.getSettings().getMySqlHost();
|
||||||
this.sourcePort = plugin.getSettings().mySqlPort;
|
this.sourcePort = plugin.getSettings().getMySqlPort();
|
||||||
this.sourceUsername = plugin.getSettings().mySqlUsername;
|
this.sourceUsername = plugin.getSettings().getMySqlUsername();
|
||||||
this.sourcePassword = plugin.getSettings().mySqlPassword;
|
this.sourcePassword = plugin.getSettings().getMySqlPassword();
|
||||||
this.sourceDatabase = plugin.getSettings().mySqlDatabase;
|
this.sourceDatabase = plugin.getSettings().getMySqlDatabase();
|
||||||
this.sourcePlayersTable = "husksync_players";
|
this.sourcePlayersTable = "husksync_players";
|
||||||
this.sourceDataTable = "husksync_data";
|
this.sourceDataTable = "husksync_data";
|
||||||
this.minecraftVersion = plugin.getMinecraftVersion().toString();
|
this.minecraftVersion = plugin.getMinecraftVersion().toString();
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ public class MpdbMigrator extends Migrator {
|
|||||||
public MpdbMigrator(@NotNull BukkitHuskSync plugin, @NotNull Plugin mySqlPlayerDataBridge) {
|
public MpdbMigrator(@NotNull BukkitHuskSync plugin, @NotNull Plugin mySqlPlayerDataBridge) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.mpdbConverter = MPDBConverter.getInstance(mySqlPlayerDataBridge);
|
this.mpdbConverter = MPDBConverter.getInstance(mySqlPlayerDataBridge);
|
||||||
this.sourceHost = plugin.getSettings().mySqlHost;
|
this.sourceHost = plugin.getSettings().getMySqlHost();
|
||||||
this.sourcePort = plugin.getSettings().mySqlPort;
|
this.sourcePort = plugin.getSettings().getMySqlPort();
|
||||||
this.sourceUsername = plugin.getSettings().mySqlUsername;
|
this.sourceUsername = plugin.getSettings().getMySqlUsername();
|
||||||
this.sourcePassword = plugin.getSettings().mySqlPassword;
|
this.sourcePassword = plugin.getSettings().getMySqlPassword();
|
||||||
this.sourceDatabase = plugin.getSettings().mySqlDatabase;
|
this.sourceDatabase = plugin.getSettings().getMySqlDatabase();
|
||||||
this.sourceInventoryTable = "mpdb_inventory";
|
this.sourceInventoryTable = "mpdb_inventory";
|
||||||
this.sourceEnderChestTable = "mpdb_enderchest";
|
this.sourceEnderChestTable = "mpdb_enderchest";
|
||||||
this.sourceExperienceTable = "mpdb_experience";
|
this.sourceExperienceTable = "mpdb_experience";
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ import org.bukkit.attribute.Attribute;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
@@ -146,7 +148,11 @@ public class BukkitPlayer extends OnlineUser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<ItemData> getInventory() {
|
public CompletableFuture<ItemData> getInventory() {
|
||||||
return BukkitSerializer.serializeItemStackArray(player.getInventory().getContents())
|
final PlayerInventory inventory = player.getInventory();
|
||||||
|
if (inventory.isEmpty()) {
|
||||||
|
return CompletableFuture.completedFuture(ItemData.empty());
|
||||||
|
}
|
||||||
|
return BukkitSerializer.serializeItemStackArray(inventory.getContents())
|
||||||
.thenApply(ItemData::new);
|
.thenApply(ItemData::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +172,11 @@ public class BukkitPlayer extends OnlineUser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<ItemData> getEnderChest() {
|
public CompletableFuture<ItemData> getEnderChest() {
|
||||||
return BukkitSerializer.serializeItemStackArray(player.getEnderChest().getContents())
|
final Inventory enderChest = player.getEnderChest();
|
||||||
|
if (enderChest.isEmpty()) {
|
||||||
|
return CompletableFuture.completedFuture(ItemData.empty());
|
||||||
|
}
|
||||||
|
return BukkitSerializer.serializeItemStackArray(enderChest.getContents())
|
||||||
.thenApply(ItemData::new);
|
.thenApply(ItemData::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,11 +446,9 @@ public class BukkitPlayer extends OnlineUser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<PersistentDataContainerData> getPersistentDataContainer() {
|
public CompletableFuture<PersistentDataContainerData> getPersistentDataContainer() {
|
||||||
final CompletableFuture<PersistentDataContainerData> future = new CompletableFuture<>();
|
|
||||||
final Map<String, PersistentDataTag<?>> persistentDataMap = new HashMap<>();
|
final Map<String, PersistentDataTag<?>> persistentDataMap = new HashMap<>();
|
||||||
|
final PersistentDataContainer container = player.getPersistentDataContainer();
|
||||||
Bukkit.getScheduler().runTask(BukkitHuskSync.getInstance(), () -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
final PersistentDataContainer container = player.getPersistentDataContainer();
|
|
||||||
container.getKeys().forEach(key -> {
|
container.getKeys().forEach(key -> {
|
||||||
BukkitPersistentTypeMapping<?, ?> type = null;
|
BukkitPersistentTypeMapping<?, ?> type = null;
|
||||||
for (BukkitPersistentTypeMapping<?, ?> dataType : BukkitPersistentTypeMapping.PRIMITIVE_TYPE_MAPPINGS) {
|
for (BukkitPersistentTypeMapping<?, ?> dataType : BukkitPersistentTypeMapping.PRIMITIVE_TYPE_MAPPINGS) {
|
||||||
@@ -453,10 +461,8 @@ public class BukkitPlayer extends OnlineUser {
|
|||||||
persistentDataMap.put(key.toString(), type.getContainerValue(container, key));
|
persistentDataMap.put(key.toString(), type.getContainerValue(container, key));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
future.complete(new PersistentDataContainerData(persistentDataMap));
|
return new PersistentDataContainerData(persistentDataMap);
|
||||||
});
|
}).exceptionally(throwable -> {
|
||||||
|
|
||||||
return future.exceptionally(throwable -> {
|
|
||||||
BukkitHuskSync.getInstance().log(Level.WARNING,
|
BukkitHuskSync.getInstance().log(Level.WARNING,
|
||||||
"Could not read " + player.getName() + "'s persistent data map, skipping!");
|
"Could not read " + player.getName() + "'s persistent data map, skipping!");
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
|
|||||||
@@ -1,29 +1,28 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'commons-io:commons-io:2.11.0'
|
implementation 'commons-io:commons-io:2.11.0'
|
||||||
implementation 'de.themoep:minedown-adventure:1.7.1-SNAPSHOT'
|
implementation 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
|
||||||
implementation 'net.kyori:adventure-api:4.11.0'
|
implementation 'net.kyori:adventure-api:4.12.0'
|
||||||
implementation 'com.google.code.gson:gson:2.10.1'
|
implementation 'com.google.code.gson:gson:2.10.1'
|
||||||
implementation 'dev.dejvokep:boosted-yaml:1.3'
|
implementation 'dev.dejvokep:boosted-yaml:1.3.1'
|
||||||
implementation 'net.william278:Annotaml:2.0.1'
|
implementation 'net.william278:Annotaml:2.0.1'
|
||||||
implementation 'net.william278:DesertWell:1.1'
|
implementation 'net.william278:DesertWell:1.1.1'
|
||||||
implementation 'net.william278:PagineDown:1.1'
|
implementation 'net.william278:PagineDown:1.1'
|
||||||
implementation('com.zaxxer:HikariCP:5.0.1') {
|
implementation('com.zaxxer:HikariCP:5.0.1') {
|
||||||
exclude module: 'slf4j-api'
|
exclude module: 'slf4j-api'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOnly 'org.jetbrains:annotations:24.0.0'
|
compileOnly 'org.jetbrains:annotations:24.0.1'
|
||||||
compileOnly 'com.github.plan-player-analytics:Plan:5.4.1690'
|
compileOnly 'com.github.plan-player-analytics:Plan:5.5.2272'
|
||||||
compileOnly 'redis.clients:jedis:' + jedis_version
|
compileOnly 'redis.clients:jedis:' + jedis_version
|
||||||
compileOnly 'org.xerial.snappy:snappy-java:' + snappy_version
|
compileOnly 'org.xerial.snappy:snappy-java:' + snappy_version
|
||||||
compileOnly 'org.apache.commons:commons-text:' + commons_text_version
|
compileOnly 'org.apache.commons:commons-text:' + commons_text_version
|
||||||
|
|
||||||
testImplementation 'org.xerial.snappy:snappy-java:1.1.8.4'
|
testImplementation 'com.github.plan-player-analytics:Plan:5.5.2272'
|
||||||
testImplementation 'com.github.plan-player-analytics:Plan:5.4.1690'
|
|
||||||
testImplementation 'redis.clients:jedis:' + jedis_version
|
testImplementation 'redis.clients:jedis:' + jedis_version
|
||||||
testImplementation 'org.xerial.snappy:snappy-java:' + snappy_version
|
testImplementation 'org.xerial.snappy:snappy-java:' + snappy_version
|
||||||
testImplementation 'org.apache.commons:commons-text:' + commons_text_version
|
testImplementation 'org.apache.commons:commons-text:' + commons_text_version
|
||||||
testCompileOnly 'dev.dejvokep:boosted-yaml:1.3'
|
testCompileOnly 'dev.dejvokep:boosted-yaml:1.3.1'
|
||||||
testCompileOnly 'org.jetbrains:annotations:24.0.0'
|
testCompileOnly 'org.jetbrains:annotations:24.0.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public interface HuskSync {
|
|||||||
* @param throwable a throwable to log
|
* @param throwable a throwable to log
|
||||||
*/
|
*/
|
||||||
default void debug(@NotNull String message, @NotNull Throwable... throwable) {
|
default void debug(@NotNull String message, @NotNull Throwable... throwable) {
|
||||||
if (getSettings().debugLogging) {
|
if (getSettings().doDebugLogging()) {
|
||||||
log(Level.INFO, "[DEBUG] " + message, throwable);
|
log(Level.INFO, "[DEBUG] " + message, throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,117 +20,255 @@ import java.util.Map;
|
|||||||
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||||
┣╸ Information: https://william278.net/project/husksync
|
┣╸ Information: https://william278.net/project/husksync
|
||||||
┗╸ Documentation: https://william278.net/docs/husksync""",
|
┗╸ Documentation: https://william278.net/docs/husksync""",
|
||||||
versionField = "config_version", versionNumber = 3)
|
versionField = "config_version", versionNumber = 4)
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
// Top-level settings
|
// Top-level settings
|
||||||
public String language = "en-gb";
|
@YamlKey("language")
|
||||||
|
private String language = "en-gb";
|
||||||
|
|
||||||
@YamlKey("check_for_updates")
|
@YamlKey("check_for_updates")
|
||||||
public boolean checkForUpdates = true;
|
private boolean checkForUpdates = true;
|
||||||
|
|
||||||
@YamlKey("cluster_id")
|
@YamlKey("cluster_id")
|
||||||
public String clusterId = "";
|
private String clusterId = "";
|
||||||
|
|
||||||
@YamlKey("debug_logging")
|
@YamlKey("debug_logging")
|
||||||
public boolean debugLogging = false;
|
private boolean debugLogging = false;
|
||||||
|
|
||||||
|
|
||||||
// Database settings
|
// Database settings
|
||||||
@YamlComment("Database connection settings")
|
@YamlComment("Database connection settings")
|
||||||
@YamlKey("database.credentials.host")
|
@YamlKey("database.credentials.host")
|
||||||
public String mySqlHost = "localhost";
|
private String mySqlHost = "localhost";
|
||||||
|
|
||||||
@YamlKey("database.credentials.port")
|
@YamlKey("database.credentials.port")
|
||||||
public int mySqlPort = 3306;
|
private int mySqlPort = 3306;
|
||||||
|
|
||||||
@YamlKey("database.credentials.database")
|
@YamlKey("database.credentials.database")
|
||||||
public String mySqlDatabase = "HuskSync";
|
private String mySqlDatabase = "HuskSync";
|
||||||
|
|
||||||
@YamlKey("database.credentials.username")
|
@YamlKey("database.credentials.username")
|
||||||
public String mySqlUsername = "root";
|
private String mySqlUsername = "root";
|
||||||
|
|
||||||
@YamlKey("database.credentials.password")
|
@YamlKey("database.credentials.password")
|
||||||
public String mySqlPassword = "pa55w0rd";
|
private String mySqlPassword = "pa55w0rd";
|
||||||
|
|
||||||
@YamlKey("database.credentials.parameters")
|
@YamlKey("database.credentials.parameters")
|
||||||
public String mySqlConnectionParameters = "?autoReconnect=true&useSSL=false";
|
private String mySqlConnectionParameters = "?autoReconnect=true&useSSL=false";
|
||||||
|
|
||||||
@YamlComment("MySQL connection pool properties")
|
@YamlComment("MySQL connection pool properties")
|
||||||
@YamlKey("database.connection_pool.maximum_pool_size")
|
@YamlKey("database.connection_pool.maximum_pool_size")
|
||||||
public int mySqlConnectionPoolSize = 10;
|
private int mySqlConnectionPoolSize = 10;
|
||||||
|
|
||||||
@YamlKey("database.connection_pool.minimum_idle")
|
@YamlKey("database.connection_pool.minimum_idle")
|
||||||
public int mySqlConnectionPoolIdle = 10;
|
private int mySqlConnectionPoolIdle = 10;
|
||||||
|
|
||||||
@YamlKey("database.connection_pool.maximum_lifetime")
|
@YamlKey("database.connection_pool.maximum_lifetime")
|
||||||
public long mySqlConnectionPoolLifetime = 1800000;
|
private long mySqlConnectionPoolLifetime = 1800000;
|
||||||
|
|
||||||
@YamlKey("database.connection_pool.keepalive_time")
|
@YamlKey("database.connection_pool.keepalive_time")
|
||||||
public long mySqlConnectionPoolKeepAlive = 0;
|
private long mySqlConnectionPoolKeepAlive = 0;
|
||||||
|
|
||||||
@YamlKey("database.connection_pool.connection_timeout")
|
@YamlKey("database.connection_pool.connection_timeout")
|
||||||
public long mySqlConnectionPoolTimeout = 5000;
|
private long mySqlConnectionPoolTimeout = 5000;
|
||||||
|
|
||||||
@YamlKey("database.table_names")
|
@YamlKey("database.table_names")
|
||||||
public Map<String, String> tableNames = TableName.getDefaults();
|
private Map<String, String> tableNames = TableName.getDefaults();
|
||||||
|
|
||||||
|
|
||||||
|
// Redis settings
|
||||||
|
@YamlComment("Redis connection settings")
|
||||||
|
@YamlKey("redis.credentials.host")
|
||||||
|
private String redisHost = "localhost";
|
||||||
|
|
||||||
|
@YamlKey("redis.credentials.port")
|
||||||
|
private int redisPort = 6379;
|
||||||
|
|
||||||
|
@YamlKey("redis.credentials.password")
|
||||||
|
private String redisPassword = "";
|
||||||
|
|
||||||
|
@YamlKey("redis.use_ssl")
|
||||||
|
private boolean redisUseSsl = false;
|
||||||
|
|
||||||
|
|
||||||
|
// Synchronization settings
|
||||||
|
@YamlComment("Synchronization settings")
|
||||||
|
@YamlKey("synchronization.max_user_data_snapshots")
|
||||||
|
private int maxUserDataSnapshots = 5;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.save_on_world_save")
|
||||||
|
private boolean saveOnWorldSave = true;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.save_on_death")
|
||||||
|
private boolean saveOnDeath = false;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.save_empty_drops_on_death")
|
||||||
|
private boolean saveEmptyDropsOnDeath = true;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.compress_data")
|
||||||
|
private boolean compressData = true;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.notification_display_slot")
|
||||||
|
private NotificationDisplaySlot notificationDisplaySlot = NotificationDisplaySlot.ACTION_BAR;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.synchronise_dead_players_changing_server")
|
||||||
|
private boolean synchroniseDeadPlayersChangingServer = true;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.network_latency_milliseconds")
|
||||||
|
private int networkLatencyMilliseconds = 500;
|
||||||
|
|
||||||
|
@YamlKey("synchronization.features")
|
||||||
|
private Map<String, Boolean> synchronizationFeatures = SynchronizationFeature.getDefaults();
|
||||||
|
|
||||||
|
@YamlKey("synchronization.blacklisted_commands_while_locked")
|
||||||
|
private List<String> blacklistedCommandsWhileLocked = new ArrayList<>();
|
||||||
|
|
||||||
|
@YamlKey("synchronization.event_priorities")
|
||||||
|
private Map<String, String> synchronizationEventPriorities = EventType.getDefaults();
|
||||||
|
|
||||||
|
|
||||||
|
// Zero-args constructor for instantiation via Annotaml
|
||||||
|
public Settings() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doCheckForUpdates() {
|
||||||
|
return checkForUpdates;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getClusterId() {
|
||||||
|
return clusterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doDebugLogging() {
|
||||||
|
return debugLogging;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getMySqlHost() {
|
||||||
|
return mySqlHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMySqlPort() {
|
||||||
|
return mySqlPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getMySqlDatabase() {
|
||||||
|
return mySqlDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getMySqlUsername() {
|
||||||
|
return mySqlUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getMySqlPassword() {
|
||||||
|
return mySqlPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getMySqlConnectionParameters() {
|
||||||
|
return mySqlConnectionParameters;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getTableName(@NotNull TableName tableName) {
|
public String getTableName(@NotNull TableName tableName) {
|
||||||
return tableNames.getOrDefault(tableName.name().toLowerCase(), tableName.defaultName);
|
return tableNames.getOrDefault(tableName.name().toLowerCase(), tableName.defaultName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMySqlConnectionPoolSize() {
|
||||||
// Redis settings
|
return mySqlConnectionPoolSize;
|
||||||
@YamlComment("Redis connection settings")
|
|
||||||
@YamlKey("redis.credentials.host")
|
|
||||||
public String redisHost = "localhost";
|
|
||||||
|
|
||||||
@YamlKey("redis.credentials.port")
|
|
||||||
public int redisPort = 6379;
|
|
||||||
|
|
||||||
@YamlKey("redis.credentials.password")
|
|
||||||
public String redisPassword = "";
|
|
||||||
|
|
||||||
@YamlKey("redis.use_ssl")
|
|
||||||
public boolean redisUseSsl = false;
|
|
||||||
|
|
||||||
|
|
||||||
// Synchronization settings
|
|
||||||
@YamlComment("Synchronization settings")
|
|
||||||
@YamlKey("synchronization.max_user_data_snapshots")
|
|
||||||
public int maxUserDataSnapshots = 5;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.save_on_world_save")
|
|
||||||
public boolean saveOnWorldSave = true;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.save_on_death")
|
|
||||||
public boolean saveOnDeath = false;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.compress_data")
|
|
||||||
public boolean compressData = true;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.notification_display_slot")
|
|
||||||
public NotificationDisplaySlot notificationDisplaySlot = NotificationDisplaySlot.ACTION_BAR;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.save_dead_player_inventories")
|
|
||||||
public boolean saveDeadPlayerInventories = true;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.network_latency_milliseconds")
|
|
||||||
public int networkLatencyMilliseconds = 500;
|
|
||||||
|
|
||||||
@YamlKey("synchronization.features")
|
|
||||||
public Map<String, Boolean> synchronizationFeatures = SynchronizationFeature.getDefaults();
|
|
||||||
|
|
||||||
@YamlKey("synchronization.blacklisted_commands_while_locked")
|
|
||||||
public List<String> blacklistedCommandsWhileLocked = new ArrayList<>();
|
|
||||||
|
|
||||||
public boolean getSynchronizationFeature(@NotNull SynchronizationFeature feature) {
|
|
||||||
return synchronizationFeatures.getOrDefault(feature.name().toLowerCase(), feature.enabledByDefault);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@YamlKey("synchronization.event_priorities")
|
public int getMySqlConnectionPoolIdle() {
|
||||||
public Map<String, String> synchronizationEventPriorities = EventType.getDefaults();
|
return mySqlConnectionPoolIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMySqlConnectionPoolLifetime() {
|
||||||
|
return mySqlConnectionPoolLifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMySqlConnectionPoolKeepAlive() {
|
||||||
|
return mySqlConnectionPoolKeepAlive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMySqlConnectionPoolTimeout() {
|
||||||
|
return mySqlConnectionPoolTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getRedisHost() {
|
||||||
|
return redisHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRedisPort() {
|
||||||
|
return redisPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getRedisPassword() {
|
||||||
|
return redisPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRedisUseSsl() {
|
||||||
|
return redisUseSsl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxUserDataSnapshots() {
|
||||||
|
return maxUserDataSnapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doSaveOnWorldSave() {
|
||||||
|
return saveOnWorldSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doSaveOnDeath() {
|
||||||
|
return saveOnDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doSaveEmptyDropsOnDeath() {
|
||||||
|
return saveEmptyDropsOnDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doCompressData() {
|
||||||
|
return compressData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public NotificationDisplaySlot getNotificationDisplaySlot() {
|
||||||
|
return notificationDisplaySlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSynchroniseDeadPlayersChangingServer() {
|
||||||
|
return synchroniseDeadPlayersChangingServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNetworkLatencyMilliseconds() {
|
||||||
|
return networkLatencyMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Map<String, Boolean> getSynchronizationFeatures() {
|
||||||
|
return synchronizationFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSynchronizationFeature(@NotNull SynchronizationFeature feature) {
|
||||||
|
return getSynchronizationFeatures().getOrDefault(feature.name().toLowerCase(), feature.enabledByDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public List<String> getBlacklistedCommandsWhileLocked() {
|
||||||
|
return blacklistedCommandsWhileLocked;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public EventPriority getEventPriority(@NotNull Settings.EventType eventType) {
|
public EventPriority getEventPriority(@NotNull Settings.EventType eventType) {
|
||||||
@@ -142,7 +280,6 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the names of tables in the database
|
* Represents the names of tables in the database
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,4 +32,13 @@ public class ItemData {
|
|||||||
protected ItemData() {
|
protected ItemData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the item data is empty
|
||||||
|
*
|
||||||
|
* @return {@code true} if the item data is empty; {@code false} otherwise
|
||||||
|
*/
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return serializedItems.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,10 +114,9 @@ public abstract class Database {
|
|||||||
* <b>(Internal)</b> Prune user data for a given user to the maximum value as configured.
|
* <b>(Internal)</b> Prune user data for a given user to the maximum value as configured.
|
||||||
*
|
*
|
||||||
* @param user The user to prune data for
|
* @param user The user to prune data for
|
||||||
* @return A future returning void when complete
|
|
||||||
* @implNote Data snapshots marked as {@code pinned} are exempt from rotation
|
* @implNote Data snapshots marked as {@code pinned} are exempt from rotation
|
||||||
*/
|
*/
|
||||||
protected abstract CompletableFuture<Void> rotateUserData(@NotNull User user);
|
protected abstract void rotateUserData(@NotNull User user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a specific {@link UserDataSnapshot} entry for a user from the database, by its UUID.
|
* Deletes a specific {@link UserDataSnapshot} entry for a user from the database, by its UUID.
|
||||||
|
|||||||
@@ -52,17 +52,17 @@ public class MySqlDatabase extends Database {
|
|||||||
public MySqlDatabase(@NotNull HuskSync plugin) {
|
public MySqlDatabase(@NotNull HuskSync plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
final Settings settings = plugin.getSettings();
|
final Settings settings = plugin.getSettings();
|
||||||
this.mySqlHost = settings.mySqlHost;
|
this.mySqlHost = settings.getMySqlHost();
|
||||||
this.mySqlPort = settings.mySqlPort;
|
this.mySqlPort = settings.getMySqlPort();
|
||||||
this.mySqlDatabaseName = settings.mySqlDatabase;
|
this.mySqlDatabaseName = settings.getMySqlDatabase();
|
||||||
this.mySqlUsername = settings.mySqlUsername;
|
this.mySqlUsername = settings.getMySqlUsername();
|
||||||
this.mySqlPassword = settings.mySqlPassword;
|
this.mySqlPassword = settings.getMySqlPassword();
|
||||||
this.mySqlConnectionParameters = settings.mySqlConnectionParameters;
|
this.mySqlConnectionParameters = settings.getMySqlConnectionParameters();
|
||||||
this.hikariMaximumPoolSize = settings.mySqlConnectionPoolSize;
|
this.hikariMaximumPoolSize = settings.getMySqlConnectionPoolSize();
|
||||||
this.hikariMinimumIdle = settings.mySqlConnectionPoolIdle;
|
this.hikariMinimumIdle = settings.getMySqlConnectionPoolIdle();
|
||||||
this.hikariMaximumLifetime = settings.mySqlConnectionPoolLifetime;
|
this.hikariMaximumLifetime = settings.getMySqlConnectionPoolLifetime();
|
||||||
this.hikariKeepAliveTime = settings.mySqlConnectionPoolKeepAlive;
|
this.hikariKeepAliveTime = settings.getMySqlConnectionPoolKeepAlive();
|
||||||
this.hikariConnectionTimeOut = settings.mySqlConnectionPoolTimeout;
|
this.hikariConnectionTimeOut = settings.getMySqlConnectionPoolTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -297,27 +297,25 @@ public class MySqlDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletableFuture<Void> rotateUserData(@NotNull User user) {
|
protected void rotateUserData(@NotNull User user) {
|
||||||
return CompletableFuture.runAsync(() -> {
|
final List<UserDataSnapshot> unpinnedUserData = getUserData(user).join().stream()
|
||||||
final List<UserDataSnapshot> unpinnedUserData = getUserData(user).join().stream()
|
.filter(dataSnapshot -> !dataSnapshot.pinned()).toList();
|
||||||
.filter(dataSnapshot -> !dataSnapshot.pinned()).toList();
|
if (unpinnedUserData.size() > plugin.getSettings().getMaxUserDataSnapshots()) {
|
||||||
if (unpinnedUserData.size() > plugin.getSettings().maxUserDataSnapshots) {
|
try (Connection connection = getConnection()) {
|
||||||
try (Connection connection = getConnection()) {
|
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
DELETE FROM `%user_data_table%`
|
||||||
DELETE FROM `%user_data_table%`
|
WHERE `player_uuid`=?
|
||||||
WHERE `player_uuid`=?
|
AND `pinned` IS FALSE
|
||||||
AND `pinned` IS FALSE
|
ORDER BY `timestamp` ASC
|
||||||
ORDER BY `timestamp` ASC
|
LIMIT %entry_count%;""".replace("%entry_count%",
|
||||||
LIMIT %entry_count%;""".replace("%entry_count%",
|
Integer.toString(unpinnedUserData.size() - plugin.getSettings().getMaxUserDataSnapshots()))))) {
|
||||||
Integer.toString(unpinnedUserData.size() - plugin.getSettings().maxUserDataSnapshots))))) {
|
statement.setString(1, user.uuid.toString());
|
||||||
statement.setString(1, user.uuid.toString());
|
statement.executeUpdate();
|
||||||
statement.executeUpdate();
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
plugin.log(Level.SEVERE, "Failed to prune user data from the database", e);
|
|
||||||
}
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
plugin.log(Level.SEVERE, "Failed to prune user data from the database", e);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -362,7 +360,8 @@ public class MySqlDatabase extends Database {
|
|||||||
plugin.log(Level.SEVERE, "Failed to set user data in the database", e);
|
plugin.log(Level.SEVERE, "Failed to set user data in the database", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).thenRun(() -> rotateUserData(user).join());
|
this.rotateUserData(user);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public abstract class EventListener {
|
|||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
// Hold reading data for the network latency threshold, to ensure the source server has set the redis key
|
// Hold reading data for the network latency threshold, to ensure the source server has set the redis key
|
||||||
Thread.sleep(Math.max(0, plugin.getSettings().networkLatencyMilliseconds));
|
Thread.sleep(Math.max(0, plugin.getSettings().getNetworkLatencyMilliseconds()));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
plugin.log(Level.SEVERE, "An exception occurred handling a player join", e);
|
plugin.log(Level.SEVERE, "An exception occurred handling a player join", e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -124,7 +124,7 @@ public abstract class EventListener {
|
|||||||
*/
|
*/
|
||||||
private void handleSynchronisationCompletion(@NotNull OnlineUser user, boolean succeeded) {
|
private void handleSynchronisationCompletion(@NotNull OnlineUser user, boolean succeeded) {
|
||||||
if (succeeded) {
|
if (succeeded) {
|
||||||
switch (plugin.getSettings().notificationDisplaySlot) {
|
switch (plugin.getSettings().getNotificationDisplaySlot()) {
|
||||||
case CHAT -> plugin.getLocales().getLocale("synchronisation_complete")
|
case CHAT -> plugin.getLocales().getLocale("synchronisation_complete")
|
||||||
.ifPresent(user::sendMessage);
|
.ifPresent(user::sendMessage);
|
||||||
case ACTION_BAR -> plugin.getLocales().getLocale("synchronisation_complete")
|
case ACTION_BAR -> plugin.getLocales().getLocale("synchronisation_complete")
|
||||||
@@ -179,7 +179,7 @@ public abstract class EventListener {
|
|||||||
* @param usersInWorld a list of users in the world that is being saved
|
* @param usersInWorld a list of users in the world that is being saved
|
||||||
*/
|
*/
|
||||||
protected final void saveOnWorldSave(@NotNull List<OnlineUser> usersInWorld) {
|
protected final void saveOnWorldSave(@NotNull List<OnlineUser> usersInWorld) {
|
||||||
if (disabling || !plugin.getSettings().saveOnWorldSave) {
|
if (disabling || !plugin.getSettings().doSaveOnWorldSave()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usersInWorld.stream()
|
usersInWorld.stream()
|
||||||
@@ -196,7 +196,8 @@ public abstract class EventListener {
|
|||||||
* @param drops The items that this user would have dropped
|
* @param drops The items that this user would have dropped
|
||||||
*/
|
*/
|
||||||
protected void saveOnPlayerDeath(@NotNull OnlineUser user, @NotNull ItemData drops) {
|
protected void saveOnPlayerDeath(@NotNull OnlineUser user, @NotNull ItemData drops) {
|
||||||
if (disabling || !plugin.getSettings().saveOnDeath || lockedPlayers.contains(user.uuid) || user.isNpc()) {
|
if (disabling || !plugin.getSettings().doSaveOnDeath() || lockedPlayers.contains(user.uuid) || user.isNpc()
|
||||||
|
|| (!plugin.getSettings().doSaveEmptyDropsOnDeath() && drops.isEmpty())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ public abstract class OnlineUser extends User {
|
|||||||
public final CompletableFuture<Void> setStatus(@NotNull StatusData statusData,
|
public final CompletableFuture<Void> setStatus(@NotNull StatusData statusData,
|
||||||
@NotNull List<StatusDataFlag> statusDataFlags) {
|
@NotNull List<StatusDataFlag> statusDataFlags) {
|
||||||
final Settings settings = new Settings();
|
final Settings settings = new Settings();
|
||||||
settings.synchronizationFeatures.put(Settings.SynchronizationFeature.HEALTH.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_HEALTH));
|
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.HEALTH.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_HEALTH));
|
||||||
settings.synchronizationFeatures.put(Settings.SynchronizationFeature.MAX_HEALTH.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_MAX_HEALTH));
|
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.MAX_HEALTH.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_MAX_HEALTH));
|
||||||
settings.synchronizationFeatures.put(Settings.SynchronizationFeature.HUNGER.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_HUNGER));
|
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.HUNGER.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_HUNGER));
|
||||||
settings.synchronizationFeatures.put(Settings.SynchronizationFeature.EXPERIENCE.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_EXPERIENCE));
|
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.EXPERIENCE.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_EXPERIENCE));
|
||||||
settings.synchronizationFeatures.put(Settings.SynchronizationFeature.INVENTORIES.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_SELECTED_ITEM_SLOT));
|
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.INVENTORIES.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_SELECTED_ITEM_SLOT));
|
||||||
settings.synchronizationFeatures.put(Settings.SynchronizationFeature.LOCATION.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_GAME_MODE) || statusDataFlags.contains(StatusDataFlag.SET_FLYING));
|
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.LOCATION.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_GAME_MODE) || statusDataFlags.contains(StatusDataFlag.SET_FLYING));
|
||||||
return setStatus(statusData, settings);
|
return setStatus(statusData, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ public abstract class OnlineUser extends User {
|
|||||||
if (!isOffline()) {
|
if (!isOffline()) {
|
||||||
final Settings settings = plugin.getSettings();
|
final Settings settings = plugin.getSettings();
|
||||||
if (settings.getSynchronizationFeature(Settings.SynchronizationFeature.INVENTORIES)) {
|
if (settings.getSynchronizationFeature(Settings.SynchronizationFeature.INVENTORIES)) {
|
||||||
if (isDead() && settings.saveDeadPlayerInventories) {
|
if (isDead() && settings.isSynchroniseDeadPlayersChangingServer()) {
|
||||||
plugin.debug("Player " + username + " is dead, so their inventory will be set to empty.");
|
plugin.debug("Player " + username + " is dead, so their inventory will be set to empty.");
|
||||||
add(CompletableFuture.runAsync(() -> builder.setInventory(ItemData.empty())));
|
add(CompletableFuture.runAsync(() -> builder.setInventory(ItemData.empty())));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ public class RedisManager extends JedisPubSub {
|
|||||||
|
|
||||||
public RedisManager(@NotNull HuskSync plugin) {
|
public RedisManager(@NotNull HuskSync plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
clusterId = plugin.getSettings().clusterId;
|
clusterId = plugin.getSettings().getClusterId();
|
||||||
|
|
||||||
// Set redis credentials
|
// Set redis credentials
|
||||||
this.redisHost = plugin.getSettings().redisHost;
|
this.redisHost = plugin.getSettings().getRedisHost();
|
||||||
this.redisPort = plugin.getSettings().redisPort;
|
this.redisPort = plugin.getSettings().getRedisPort();
|
||||||
this.redisPassword = plugin.getSettings().redisPassword;
|
this.redisPassword = plugin.getSettings().getRedisPassword();
|
||||||
this.redisUseSsl = plugin.getSettings().redisUseSsl;
|
this.redisUseSsl = plugin.getSettings().isRedisUseSsl();
|
||||||
|
|
||||||
// Configure the jedis pool
|
// Configure the jedis pool
|
||||||
this.jedisPoolConfig = new JedisPoolConfig();
|
this.jedisPoolConfig = new JedisPoolConfig();
|
||||||
@@ -91,7 +91,7 @@ public class RedisManager extends JedisPubSub {
|
|||||||
final UserData userData = plugin.getDataAdapter().fromBytes(redisMessage.data);
|
final UserData userData = plugin.getDataAdapter().fromBytes(redisMessage.data);
|
||||||
user.setData(userData, plugin).thenAccept(succeeded -> {
|
user.setData(userData, plugin).thenAccept(succeeded -> {
|
||||||
if (succeeded) {
|
if (succeeded) {
|
||||||
switch (plugin.getSettings().notificationDisplaySlot) {
|
switch (plugin.getSettings().getNotificationDisplaySlot()) {
|
||||||
case CHAT -> plugin.getLocales().getLocale("data_update_complete")
|
case CHAT -> plugin.getLocales().getLocale("data_update_complete")
|
||||||
.ifPresent(user::sendMessage);
|
.ifPresent(user::sendMessage);
|
||||||
case ACTION_BAR -> plugin.getLocales().getLocale("data_update_complete")
|
case ACTION_BAR -> plugin.getLocales().getLocale("data_update_complete")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
synchronisation_complete: '[⏵ Daten synchronisiert!](#00fb9a)'
|
synchronisation_complete: '[⏵ Daten synchronisiert!](#00fb9a)'
|
||||||
synchronisation_failed: '[⏵ Ein Fehler ist beim Synchronisieren deiner Daten aufgetreten! Bitte kontaktiere einen Administrator.](#ff7e5e)'
|
synchronisation_failed: '[⏵ Ein Fehler ist beim Synchronisieren deiner Daten aufgetreten! Bitte kontaktiere einen Administrator.](#ff7e5e)'
|
||||||
reload_complete: '[HuskSync](#00fb9a bold) [| Die Konfigurations- und Sprachdateien wurden neu geladen.'
|
reload_complete: '[HuskSync](#00fb9a bold) [| Die Konfigurations- und Sprachdateien wurden neu geladen.](#00fb9a)'
|
||||||
error_invalid_syntax: '[Fehler:](#ff3300) [Falsche Syntax. Nutze: %1%](#ff7e5e)'
|
error_invalid_syntax: '[Fehler:](#ff3300) [Falsche Syntax. Nutze: %1%](#ff7e5e)'
|
||||||
error_invalid_player: '[Fehler:](#ff3300) [Es konnte kein Spieler mit diesem Namen gefunden werden.](#ff7e5e)'
|
error_invalid_player: '[Fehler:](#ff3300) [Es konnte kein Spieler mit diesem Namen gefunden werden.](#ff7e5e)'
|
||||||
error_no_permission: '[Fehler:](#ff3300) [Du hast nicht die benötigten Berechtigungen um diesen Befehl auszuführen](#ff7e5e)'
|
error_no_permission: '[Fehler:](#ff3300) [Du hast nicht die benötigten Berechtigungen um diesen Befehl auszuführen](#ff7e5e)'
|
||||||
@@ -14,19 +14,19 @@ inventory_viewer_opened: '[Du siehst den Schnappschuss des Inventares von](#00fb
|
|||||||
ender_chest_viewer_opened: '[Du siehst den Schnappschuss der Endertruhe von](#00fb9a) [%1%](#00fb9a bold) [von ⌚ %2%](#00fb9a)'
|
ender_chest_viewer_opened: '[Du siehst den Schnappschuss der Endertruhe von](#00fb9a) [%1%](#00fb9a bold) [von ⌚ %2%](#00fb9a)'
|
||||||
data_update_complete: '[🔔 Deine Daten wurden aktualisiert!](#00fb9a)'
|
data_update_complete: '[🔔 Deine Daten wurden aktualisiert!](#00fb9a)'
|
||||||
data_update_failed: '[🔔 Ein Fehler ist beim Aktualisieren deiner Daten aufgetreten! Bitte kontaktiere einen Administrator.](#ff7e5e)'
|
data_update_failed: '[🔔 Ein Fehler ist beim Aktualisieren deiner Daten aufgetreten! Bitte kontaktiere einen Administrator.](#ff7e5e)'
|
||||||
data_manager_title: '[Du siehst den Nutzerdaten-Schnappschuss](#00fb9a) [%1%](#00fb9a show_text=&7Versions-UUID:\n&8%2%) [für [%3%](#00fb9a bold show_text=&7Spieler-UUID:\n&8%4%)[:](#00fb9a)'
|
data_manager_title: '[Du siehst den Nutzerdaten-Schnappschuss](#00fb9a) [%1%](#00fb9a show_text=&7Versions-UUID:\n&8%2%) [für %3%](#00fb9a bold show_text=&7Spieler-UUID:\n&8%4%)[:](#00fb9a)'
|
||||||
data_manager_timestamp: '[⌚ %1%](#ffc43b-#f5c962 show_text=&7Versions-Zeitstempel:\n&8Zeitpunkt der Speicherung der Daten)'
|
data_manager_timestamp: '[⌚ %1%](#ffc43b-#f5c962 show_text=&7Versions-Zeitstempel:\n&8Zeitpunkt der Speicherung der Daten)'
|
||||||
data_manager_pinned: '[※ Schnappschuss angeheftet](#d8ff2b show_text=&7Angeheftet:\n&8Dieser Nutzerdaten-Schnappschuss wird nicht automatisch rotiert.)'
|
data_manager_pinned: '[※ Schnappschuss angeheftet](#d8ff2b show_text=&7Angeheftet:\n&8Dieser Nutzerdaten-Schnappschuss wird nicht automatisch rotiert.)'
|
||||||
data_manager_cause: '[⚑ %1%](#23a825-#36f539 show_text=&7Speicherungsgrund:\n&8Der Grund für das Speichern der Daten)\n'
|
data_manager_cause: '[⚑ %1%](#23a825-#36f539 show_text=&7Speicherungsgrund:\n&8Der Grund für das Speichern der Daten)\n'
|
||||||
data_manager_status: '[%1%](red)[/](gray)[%2%](red)[×](gray)[❤](red show_text=&7Lebenspunkte) [%3%](yellow)[×](gray)[🍖](yellow show_text=&7Hungerpunkte) [ʟᴠ](green)[.](gray)[%4%](green show_text=&7XP-Level) [🏹 %5%](dark_aqua show_text=&7Spielmodus)'
|
data_manager_status: '[%1%](red)[/](gray)[%2%](red)[×](gray)[❤](red show_text=&7Lebenspunkte) [%3%](yellow)[×](gray)[🍖](yellow show_text=&7Hungerpunkte) [ʟᴠ](green)[.](gray)[%4%](green show_text=&7XP-Level) [🏹 %5%](dark_aqua show_text=&7Spielmodus)'
|
||||||
data_manager_advancements_statistics: '[⭐ Erfolge: %1%](color=#ffc43b-#f5c962 show_text=&7Erfolge in denen du Fortschritt gemacht hast:\n&8%2%) [⌛ Spielzeit: %3%ʜʀs](color=#62a9f5-#7ab8fa show_text=&7Deine verbrachte Zeit im Spiel\n&8⚠ Basierend auf Spielstatistiken)\n'
|
data_manager_advancements_statistics: '[⭐ Erfolge: %1%](color=#ffc43b-#f5c962 show_text=&7Erfolge in denen du Fortschritt gemacht hast:\n&8%2%) [⌛ Spielzeit: %3%ʜʀs](color=#62a9f5-#7ab8fa show_text=&7Deine verbrachte Zeit im Spiel\n&8⚠ Basierend auf Spielstatistiken)\n'
|
||||||
data_manager_item_buttons: '[View:](gray) [[🪣 Inventar…]](color=#a17b5f-#f5b98c show_text=&7Klicke zum Ansehen run_command=/inventory %1% %2%) [[⌀ Endertruhe…]](#b649c4-#d254ff show_text=&7Klicke zum Ansehen run_command=/enderchest %1% %2%)'
|
data_manager_item_buttons: '[Sehen:](gray) [[🪣 Inventar…]](color=#a17b5f-#f5b98c show_text=&7Klicke zum Ansehen run_command=/inventory %1% %2%) [[⌀ Endertruhe…]](#b649c4-#d254ff show_text=&7Klicke zum Ansehen run_command=/enderchest %1% %2%)'
|
||||||
data_manager_management_buttons: '[Verwalte:](gray) [[❌ Löschen…]](#ff3300 show_text=&7Klicke, um diesen Nutzerdaten-Schnappschuss zu löschen.\n&8Dies betrifft nicht die aktuellen Nutzerdaten.\n&#ff3300&⚠ Dieser Schritt kann nicht rückgängig gemacht werden! suggest_command=/husksync:userdata delete %1% %2%) [[⏪ Wiederherstellen…]](#00fb9a show_text=&7Klicke, um die Nutzerdaten wiederherzustellen.\n&8Dies wird die Nutzerdaten auf den Stand des Schnappschusses setzen.\n&#ff3300&⚠ Die aktuellen Nutzerdaten von %1% werden überschrieben! suggest_command=/husksync:userdata restore %1% %2%) [[※ Anheften/Loslösen…]](#d8ff2b show_text=&7Klicke, um diesen Nutzerdaten-Schnappschuss anzuheften oder loszulösen\n&8Angeheftete Nutzerdaten-Schnappschüsse werden nicht automatisch rotiert run_command=/userdata pin %1% %2%)'
|
data_manager_management_buttons: '[Verwalten:](gray) [[❌ Löschen…]](#ff3300 show_text=&7Klicke, um diesen Nutzerdaten-Schnappschuss zu löschen.\n&8Dies betrifft nicht die aktuellen Nutzerdaten.\n&#ff3300&⚠ Dieser Schritt kann nicht rückgängig gemacht werden! suggest_command=/husksync:userdata delete %1% %2%) [[⏪ Wiederherstellen…]](#00fb9a show_text=&7Klicke, um die Nutzerdaten wiederherzustellen.\n&8Dies wird die Nutzerdaten auf den Stand des Schnappschusses setzen.\n&#ff3300&⚠ Die aktuellen Nutzerdaten von %1% werden überschrieben! suggest_command=/husksync:userdata restore %1% %2%) [[※ Anheften/Loslösen…]](#d8ff2b show_text=&7Klicke, um diesen Nutzerdaten-Schnappschuss anzuheften oder loszulösen\n&8Angeheftete Nutzerdaten-Schnappschüsse werden nicht automatisch rotiert run_command=/userdata pin %1% %2%)'
|
||||||
data_manager_system_buttons: '[System:](gray) [[⏷ Daten-Dump…]](dark_gray show_text=&7Klicke, um diesen rohen Nutzerdaten-Schnappschuss in eine Datei zu speichern.\n&8Daten-Dumps können unter ~/plugins/HuskSync/dumps/ gefunden werden. run_command=/husksync:userdata dump %1% %2% file) [[☂ Web-Dump…]](dark_gray show_text=&7Klicke, um diesen rohen Nutzerdaten-Schnappschuss auf den mc-logs Service hochzuladen.\n&8Du erhältst dann eine URL, die die Daten enthält. run_command=/husksync:userdata dump %1% %2% web)'
|
data_manager_system_buttons: '[System:](gray) [[⏷ Daten-Dump…]](dark_gray show_text=&7Klicke, um diesen rohen Nutzerdaten-Schnappschuss in eine Datei zu speichern.\n&8Daten-Dumps können unter ~/plugins/HuskSync/dumps/ gefunden werden. run_command=/husksync:userdata dump %1% %2% file) [[☂ Web-Dump…]](dark_gray show_text=&7Klicke, um diesen rohen Nutzerdaten-Schnappschuss auf den mc-logs Service hochzuladen.\n&8Du erhältst dann eine URL, die die Daten enthält. run_command=/husksync:userdata dump %1% %2% web)'
|
||||||
data_manager_advancements_preview_remaining: '&7und %1% weitere…'
|
data_manager_advancements_preview_remaining: '&7und %1% weitere…'
|
||||||
data_list_title: '[Nutzerdaten-Schnappschüsse von %1%:](#00fb9a) [(%2%-%3% von](#00fb9a) [%4%](#00fb9a bold)[)](#00fb9a)\n'
|
data_list_title: '[Nutzerdaten-Schnappschüsse von %1%:](#00fb9a) [(%2%-%3% von](#00fb9a) [%4%](#00fb9a bold)[)](#00fb9a)\n'
|
||||||
data_list_item: '[%1%](gray show_text=&7Daten-Schnappschuss %3% run_command=/userdata view %6% %4%) [%7%](#d8ff2b show_text=&7Angeheftet:\n&8Angeheftete Schnappschüsse werden nicht automatisch rotiert. run_command=/userdata view %6% %4%) [%2%](color=#ffc43b-#f5c962 show_text=&7Versions-Zeitstempel:&7\n&8Zeitpunkt der Speicherung der Daten run_command=/userdata view %6% %4%) [⚡ %3%](color=#62a9f5-#7ab8fa show_text=&7Versions-UUID:&7\n&8%4% run_command=/userdata view %6% %4%) [⚑ %5%](#23a825-#36f539 show_text=&7Speicherungsgrund:\n&8Der Grund für das Speichern der Daten run_command=/userdata view %6% %4%)'
|
data_list_item: '[%1%](gray show_text=&7Daten-Schnappschuss %3% run_command=/userdata view %6% %4%) [%7%](#d8ff2b show_text=&7Angeheftet:\n&8Angeheftete Schnappschüsse werden nicht automatisch rotiert. run_command=/userdata view %6% %4%) [%2%](color=#ffc43b-#f5c962 show_text=&7Versions-Zeitstempel:&7\n&8Zeitpunkt der Speicherung der Daten run_command=/userdata view %6% %4%) [⚡ %3%](color=#62a9f5-#7ab8fa show_text=&7Versions-UUID:&7\n&8%4% run_command=/userdata view %6% %4%) [⚑ %5%](#23a825-#36f539 show_text=&7Speicherungsgrund:\n&8Der Grund für das Speichern der Daten run_command=/userdata view %6% %4%)'
|
||||||
data_deleted: '[❌ Nutzerdaten-Schnappschuss erfolgreich gelöscht](#00fb9a) [%1%](#00fb9a show_text=&7Version UUID:\n&8%2%) [for](#00fb9a) [%3%.](#00fb9a show_text=&7Player UUID:\n&8%4%)'
|
data_deleted: '[❌ Nutzerdaten-Schnappschuss erfolgreich gelöscht](#00fb9a) [%1%](#00fb9a show_text=&7Version UUID:\n&8%2%) [für](#00fb9a) [%3%.](#00fb9a show_text=&7Player UUID:\n&8%4%)'
|
||||||
data_restored: '[⏪ Erfgreich wiederhergestellt](#00fb9a) [Aktuelle Nutzerdaten des Schnappschusses von %1%](#00fb9a show_text=&7Spieler-UUID:\n&8%2%) [%3%.](#00fb9a show_text=&7Versions-UUID:\n&8%4%)'
|
data_restored: '[⏪ Erfgreich wiederhergestellt](#00fb9a) [Aktuelle Nutzerdaten des Schnappschusses von %1%](#00fb9a show_text=&7Spieler-UUID:\n&8%2%) [%3%.](#00fb9a show_text=&7Versions-UUID:\n&8%4%)'
|
||||||
data_pinned: '[※ Nutzerdaten-Schnappschuss erfolgreich angepinnt](#00fb9a) [%1%](#00fb9a show_text=&7Versions-UUID:\n&8%2%) [für](#00fb9a) [%3%.](#00fb9a show_text=&7Spieler-UUID:\n&8%4%)'
|
data_pinned: '[※ Nutzerdaten-Schnappschuss erfolgreich angepinnt](#00fb9a) [%1%](#00fb9a show_text=&7Versions-UUID:\n&8%2%) [für](#00fb9a) [%3%.](#00fb9a show_text=&7Spieler-UUID:\n&8%4%)'
|
||||||
data_unpinned: '[※ Nutzerdaten-Schnappschuss erfolgreich losgelöst](#00fb9a) [%1%](#00fb9a show_text=&7Versions-UUID:\n&8%2%) [für](#00fb9a) [%3%.](#00fb9a show_text=&7Spieler-UUID:\n&8%4%)'
|
data_unpinned: '[※ Nutzerdaten-Schnappschuss erfolgreich losgelöst](#00fb9a) [%1%](#00fb9a show_text=&7Versions-UUID:\n&8%2%) [für](#00fb9a) [%3%.](#00fb9a show_text=&7Spieler-UUID:\n&8%4%)'
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8'
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
javaVersion=16
|
javaVersion=16
|
||||||
|
|
||||||
plugin_version=2.2.3
|
plugin_version=2.2.4
|
||||||
plugin_archive=husksync
|
plugin_archive=husksync
|
||||||
|
|
||||||
jedis_version=4.3.1
|
jedis_version=4.3.1
|
||||||
mysql_driver_version=8.0.31
|
mysql_driver_version=8.0.32
|
||||||
snappy_version=1.1.8.4
|
snappy_version=1.1.9.1
|
||||||
commons_text_version=1.10.0
|
commons_text_version=1.10.0
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
285
gradlew
vendored
285
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# Resolve links: $0 may be a link
|
||||||
APP_BASE_NAME=`basename "$0"`
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MSYS* | MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,105 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
Reference in New Issue
Block a user