9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-26 01:59:20 +00:00

1.0 release progress

This commit is contained in:
William
2021-10-24 21:46:48 +01:00
parent f842afac1e
commit f7f1dc50eb
35 changed files with 1780 additions and 245 deletions

View File

@@ -0,0 +1,28 @@
package me.william278.husksync;
import java.util.HashMap;
public class MessageManager {
private static HashMap<String, String> messages = new HashMap<>();
public static void setMessages(HashMap<String, String> newMessages) {
messages = new HashMap<>(newMessages);
}
public static String getMessage(String messageId) {
return messages.get(messageId);
}
public static StringBuilder PLUGIN_INFORMATION = new StringBuilder().append("[HuskSync](#00fb9a bold) [| %proxy_brand% Version %proxy_version% (%bukkit_brand% v%bukkit_version%)](#00fb9a)\n")
.append("[%plugin_description%](gray)\n")
.append("[• Author:](white) [William278](gray show_text=&7Click to pay a visit open_url=https://youtube.com/William27528)\n")
.append("[• Help Wiki:](white) [[Link]](#00fb9a show_text=&7Click to open link open_url=https://github.com/WiIIiam278/HuskSync/wiki/)\n")
.append("[• Report Issues:](white) [[Link]](#00fb9a show_text=&7Click to open link open_url=https://github.com/WiIIiam278/HuskSync/issues)\n")
.append("[• Support Discord:](white) [[Link]](#00fb9a show_text=&7Click to join open_url=https://discord.gg/tVYhJfyDWG)");
public static StringBuilder PLUGIN_STATUS = new StringBuilder().append("[HuskSync](#00fb9a bold) [| Current system status:](#00fb9a)\n")
.append("[• Connected servers:](white) [%1%](#00fb9a)")
.append("[• Cached player data:](white) [%2%](#00fb9a)");
}

View File

@@ -1,16 +0,0 @@
package me.william278.husksync;
public class MessageStrings {
public static final StringBuilder PLUGIN_INFORMATION = new StringBuilder().append("[HuskSync](#00fb9a bold) [| %proxy_brand% Version %proxy_version% (%bukkit_brand% v%bukkit_version%)](#00fb9a)\n")
.append("[%plugin_description%](gray)\n")
.append("[• Author:](white) [William278](gray show_text=&7Click to pay a visit open_url=https://youtube.com/William27528)\n")
.append("[• Help Wiki:](white) [[Link]](#00fb9a show_text=&7Click to open link open_url=https://github.com/WiIIiam278/HuskSync/wiki/)\n")
.append("[• Report Issues:](white) [[Link]](#00fb9a show_text=&7Click to open link open_url=https://github.com/WiIIiam278/HuskSync/issues)\n")
.append("[• Support Discord:](white) [[Link]](#00fb9a show_text=&7Click to join open_url=https://discord.gg/tVYhJfyDWG)");
public static final String ERROR_INVALID_SYNTAX = "[Error:](#ff3300) [Incorrect syntax. Usage: %1%](#ff7e5e)";
public static final String SYNCHRONISATION_COMPLETE = "[Data synchronised!](#00fb9a)";
}

View File

@@ -16,26 +16,27 @@ public class PlayerData implements Serializable {
private final UUID dataVersionUUID;
// Flag to indicate if the Bukkit server should use default data
private boolean useDefaultData = false;
public boolean useDefaultData = false;
// Player data
private final String serializedInventory;
private final String serializedEnderChest;
private final double health;
private final double maxHealth;
private final int hunger;
private final float saturation;
private final float saturationExhaustion;
private final int selectedSlot;
private final String serializedEffectData;
private final int totalExperience;
private final int expLevel;
private final float expProgress;
private final String gameMode;
private final String serializedStatistics;
private final boolean isFlying;
private final String serializedAdvancements;
private final String serializedLocation;
private String serializedInventory;
private String serializedEnderChest;
private double health;
private double maxHealth;
private double healthScale;
private int hunger;
private float saturation;
private float saturationExhaustion;
private int selectedSlot;
private String serializedEffectData;
private int totalExperience;
private int expLevel;
private float expProgress;
private String gameMode;
private String serializedStatistics;
private boolean isFlying;
private String serializedAdvancements;
private String serializedLocation;
/**
* Constructor to create new PlayerData from a bukkit {@code Player}'s data
@@ -45,6 +46,7 @@ public class PlayerData implements Serializable {
* @param serializedEnderChest Their serialized ender chest
* @param health Their health
* @param maxHealth Their max health
* @param healthScale Their health scale
* @param hunger Their hunger
* @param saturation Their saturation
* @param saturationExhaustion Their saturation exhaustion
@@ -56,8 +58,8 @@ public class PlayerData implements Serializable {
* @param gameMode Their game mode ({@code SURVIVAL}, {@code CREATIVE}, etc)
* @param serializedStatistics Their serialized statistics data (Displayed in Statistics menu in ESC menu)
*/
public PlayerData(UUID playerUUID, String serializedInventory, String serializedEnderChest, double health,
double maxHealth, int hunger, float saturation, float saturationExhaustion, int selectedSlot,
public PlayerData(UUID playerUUID, String serializedInventory, String serializedEnderChest, double health, double maxHealth,
double healthScale, int hunger, float saturation, float saturationExhaustion, int selectedSlot,
String serializedStatusEffects, int totalExperience, int expLevel, float expProgress, String gameMode,
String serializedStatistics, boolean isFlying, String serializedAdvancements, String serializedLocation) {
this.dataVersionUUID = UUID.randomUUID();
@@ -66,6 +68,7 @@ public class PlayerData implements Serializable {
this.serializedEnderChest = serializedEnderChest;
this.health = health;
this.maxHealth = maxHealth;
this.healthScale = healthScale;
this.hunger = hunger;
this.saturation = saturation;
this.saturationExhaustion = saturationExhaustion;
@@ -90,6 +93,7 @@ public class PlayerData implements Serializable {
* @param serializedEnderChest Their serialized ender chest
* @param health Their health
* @param maxHealth Their max health
* @param healthScale Their health scale
* @param hunger Their hunger
* @param saturation Their saturation
* @param saturationExhaustion Their saturation exhaustion
@@ -102,7 +106,7 @@ public class PlayerData implements Serializable {
* @param serializedStatistics Their serialized statistics data (Displayed in Statistics menu in ESC menu)
*/
public PlayerData(UUID playerUUID, UUID dataVersionUUID, String serializedInventory, String serializedEnderChest,
double health, double maxHealth, int hunger, float saturation, float saturationExhaustion,
double health, double maxHealth, double healthScale, int hunger, float saturation, float saturationExhaustion,
int selectedSlot, String serializedStatusEffects, int totalExperience, int expLevel, float expProgress,
String gameMode, String serializedStatistics, boolean isFlying, String serializedAdvancements,
String serializedLocation) {
@@ -112,6 +116,7 @@ public class PlayerData implements Serializable {
this.serializedEnderChest = serializedEnderChest;
this.health = health;
this.maxHealth = maxHealth;
this.healthScale = healthScale;
this.hunger = hunger;
this.saturation = saturation;
this.saturationExhaustion = saturationExhaustion;
@@ -135,7 +140,7 @@ public class PlayerData implements Serializable {
*/
public static PlayerData DEFAULT_PLAYER_DATA(UUID playerUUID) {
PlayerData data = new PlayerData(playerUUID, "", "", 20,
20, 20, 10, 1, 0,
20, 0, 20, 10, 1, 0,
"", 0, 0, 0, "SURVIVAL",
"", false, "", "");
data.useDefaultData = true;
@@ -166,6 +171,8 @@ public class PlayerData implements Serializable {
return maxHealth;
}
public double getHealthScale() { return healthScale; }
public int getHunger() {
return hunger;
}
@@ -222,4 +229,75 @@ public class PlayerData implements Serializable {
return useDefaultData;
}
public void setSerializedInventory(String serializedInventory) {
this.serializedInventory = serializedInventory;
}
public void setSerializedEnderChest(String serializedEnderChest) {
this.serializedEnderChest = serializedEnderChest;
}
public void setHealth(double health) {
this.health = health;
}
public void setMaxHealth(double maxHealth) {
this.maxHealth = maxHealth;
}
public void setHealthScale(double healthScale) {
this.healthScale = healthScale;
}
public void setHunger(int hunger) {
this.hunger = hunger;
}
public void setSaturation(float saturation) {
this.saturation = saturation;
}
public void setSaturationExhaustion(float saturationExhaustion) {
this.saturationExhaustion = saturationExhaustion;
}
public void setSelectedSlot(int selectedSlot) {
this.selectedSlot = selectedSlot;
}
public void setSerializedEffectData(String serializedEffectData) {
this.serializedEffectData = serializedEffectData;
}
public void setTotalExperience(int totalExperience) {
this.totalExperience = totalExperience;
}
public void setExpLevel(int expLevel) {
this.expLevel = expLevel;
}
public void setExpProgress(float expProgress) {
this.expProgress = expProgress;
}
public void setGameMode(String gameMode) {
this.gameMode = gameMode;
}
public void setSerializedStatistics(String serializedStatistics) {
this.serializedStatistics = serializedStatistics;
}
public void setFlying(boolean flying) {
isFlying = flying;
}
public void setSerializedAdvancements(String serializedAdvancements) {
this.serializedAdvancements = serializedAdvancements;
}
public void setSerializedLocation(String serializedLocation) {
this.serializedLocation = serializedLocation;
}
}

View File

@@ -9,6 +9,9 @@ public class Settings {
* General settings
*/
// Messages language
public static String language;
// The type of THIS server (Bungee or Bukkit)
public static ServerType serverType;

View File

@@ -0,0 +1,35 @@
package me.william278.husksync.migrator;
import java.io.Serializable;
import java.util.UUID;
/**
* A class that stores player data taken from MPDB's database, that can then be converted into HuskSync's format
*/
public class MPDBPlayerData implements Serializable {
/*
* Player information
*/
public final UUID playerUUID;
public final String playerName;
/*
* Inventory, ender chest and armor data
*/
public String inventoryData;
public String armorData;
public String enderChestData;
/*
* Experience data
*/
public int expLevel;
public float expProgress;
public int totalExperience;
public MPDBPlayerData(UUID playerUUID, String playerName) {
this.playerUUID = playerUUID;
this.playerName = playerName;
}
}

View File

@@ -9,6 +9,11 @@ import java.util.logging.Level;
public abstract class RedisListener {
/**
* Determines if the RedisListener is working properly
*/
public boolean isActiveAndEnabled;
/**
* Handle an incoming {@link RedisMessage}
* @param message The {@link RedisMessage} to handle
@@ -33,6 +38,7 @@ public abstract class RedisListener {
}
jedis.connect();
if (jedis.isConnected()) {
isActiveAndEnabled = true;
log(Level.INFO,"Enabled Redis listener successfully!");
new Thread(() -> jedis.subscribe(new JedisPubSub() {
@Override
@@ -51,6 +57,7 @@ public abstract class RedisListener {
}
}, RedisMessage.REDIS_CHANNEL), "Redis Subscriber").start();
} else {
isActiveAndEnabled = false;
log(Level.SEVERE, "Failed to initialize the redis listener!");
}
}

View File

@@ -112,7 +112,42 @@ public class RedisMessage {
/**
* Sent by the proxy to ask the Bukkit server to send the full plugin information, contains information about the proxy brand and version
*/
SEND_PLUGIN_INFORMATION
SEND_PLUGIN_INFORMATION,
/**
* Sent by the proxy to show a player the contents of another player's inventory, contains their username and {@link PlayerData}
*/
OPEN_INVENTORY,
/**
* Sent by the proxy to show a player the contents of another player's ender chest, contains their username and {@link PlayerData}
*/
OPEN_ENDER_CHEST,
/**
* Sent by both the proxy and bukkit servers to confirm cross-server communication has been established
*/
CONNECTION_HANDSHAKE,
/**
* Sent by both the proxy and bukkit servers to terminate communications (if a bukkit / the proxy goes offline)
*/
TERMINATE_HANDSHAKE,
/**
* Sent by a proxy to a bukkit server to decode MPDB data
*/
DECODE_MPDB_DATA,
/**
* Sent by a bukkit server back to the proxy with the correctly decoded MPDB data
*/
DECODED_MPDB_DATA_SET,
/**
* Sent by the proxy to a bukkit server to initiate a reload
*/
RELOAD_CONFIG
}
public enum RequestOnJoinUpdateType {