Fix redis message not sending full payload, fix list formatting again, fix config not copying defaults and remove unnecessary stuff from default config

This commit is contained in:
William committed 2021-10-03 00:11:54 +01:00
1 parent 0bfc2faf2d
commit 15efffa881
9 files changed
+14 -17

No files matched your search

@@ -187,6 +187,8 @@ public final class HuskHomes extends JavaPlugin {
public void onEnable() { public void onEnable() {
// Fetch config file // Fetch config file
saveDefaultConfig(); saveDefaultConfig();
getConfig().options().copyDefaults(true);
saveConfig();
settings.reload(); settings.reload();
// Load the messages (in the right language) // Load the messages (in the right language)
@@ -180,7 +180,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
} }
// Confirmation message // Confirmation message
MessageManager.sendMessage(p, "edit_home_update_description", descriptionChangedHome.getName(), MineDown.escape(newDescriptionString.replace("]", "\\]").replace("[", "\\[").replace("(", "\\(").replace(")", "\\)"))); MessageManager.sendMessage(p, "edit_home_update_description", descriptionChangedHome.getName(), MineDown.escape(newDescriptionString).replace("]", "\\]").replace("[", "\\[").replace("(", "\\(").replace(")", "\\)"));
} catch (SQLException e) { } catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a home description."); plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a home description.");
} }
@@ -149,7 +149,7 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
} }
// Confirmation message // Confirmation message
MessageManager.sendMessage(p, "edit_warp_update_description", warpName, MineDown.escape(newDescriptionString.replace("]", "\\]").replace("[", "\\[").replace("(", "\\(").replace(")", "\\)"))); MessageManager.sendMessage(p, "edit_warp_update_description", warpName, MineDown.escape(newDescriptionString).replace("]", "\\]").replace("[", "\\[").replace("(", "\\(").replace(")", "\\)"));
} catch (SQLException e) { } catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a warp's description."); plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a warp's description.");
} }
@@ -67,10 +67,11 @@ public class HomeListCommand extends CommandBase {
ArrayList<String> homeList = new ArrayList<>(); ArrayList<String> homeList = new ArrayList<>();
for (Home home : homes) { for (Home home : homes) {
homeList.add(MessageManager.getRawMessage("home_list_item", home.getName(), MineDown.escape(home.getDescription().replace("]", "\\]") homeList.add(MessageManager.getRawMessage("home_list_item", home.getName(), MineDown.escape(home.getDescription())
.replace("]", "\\]")
.replace("[", "\\[") .replace("[", "\\[")
.replace("(", "\\(") .replace("(", "\\(")
.replace(")", "\\)")))); .replace(")", "\\)")));
} }
final int itemsPerPage = HuskHomes.getSettings().getPrivateHomesPerPage(); final int itemsPerPage = HuskHomes.getSettings().getPrivateHomesPerPage();
@@ -44,10 +44,10 @@ public class PublicHomeListCommand extends CommandBase {
} }
ArrayList<String> publicHomeList = new ArrayList<>(); ArrayList<String> publicHomeList = new ArrayList<>();
for (Home home : homes) { for (Home home : homes) {
publicHomeList.add(MessageManager.getRawMessage("public_home_list_item", home.getName(), home.getOwnerUsername(), MineDown.escape(home.getDescription().replace("]", "\\]") publicHomeList.add(MessageManager.getRawMessage("public_home_list_item", home.getName(), home.getOwnerUsername(), MineDown.escape(home.getDescription()).replace("]", "\\]")
.replace("[", "\\[") .replace("[", "\\[")
.replace("(", "\\(") .replace("(", "\\(")
.replace(")", "\\)")))); .replace(")", "\\)")));
} }
final int itemsPerPage = HuskHomes.getSettings().getPublicHomesPerPage(); final int itemsPerPage = HuskHomes.getSettings().getPublicHomesPerPage();
@@ -48,10 +48,10 @@ public class WarpListCommand extends CommandBase {
} }
} }
warpList.add(MessageManager.getRawMessage("warp_list_item", warp.getName(), warpList.add(MessageManager.getRawMessage("warp_list_item", warp.getName(),
MineDown.escape(warp.getDescription().replace("]", "\\]") MineDown.escape(warp.getDescription()).replace("]", "\\]")
.replace("[", "\\[") .replace("[", "\\[")
.replace("(", "\\(") .replace("(", "\\(")
.replace(")", "\\)")))); .replace(")", "\\)")));
} }
if (warpList.isEmpty()) { if (warpList.isEmpty()) {
MessageManager.sendMessage(player, "error_no_warps_set"); MessageManager.sendMessage(player, "error_no_warps_set");
@@ -8,6 +8,7 @@ import redis.clients.jedis.Jedis;
public class RedisMessage extends Message { public class RedisMessage extends Message {
public static final String REDIS_MESSAGE_HEADER_SEPARATOR = "£";
private static final HuskHomes plugin = HuskHomes.getInstance(); private static final HuskHomes plugin = HuskHomes.getInstance();
public RedisMessage(String targetPlayerName, MessageType pluginMessageType, String... messageData) { public RedisMessage(String targetPlayerName, MessageType pluginMessageType, String... messageData) {
@@ -30,7 +31,7 @@ public class RedisMessage extends Message {
publisher.auth(jedisPassword); publisher.auth(jedisPassword);
} }
publisher.connect(); publisher.connect();
publisher.publish(RedisReceiver.REDIS_CHANNEL, getClusterId() + ":" + getPluginMessageString(getMessageType()) + ":" + target); publisher.publish(RedisReceiver.REDIS_CHANNEL, getClusterId() + ":" + getPluginMessageString(getMessageType()) + ":" + target + REDIS_MESSAGE_HEADER_SEPARATOR + getMessageData());
} }
}); });
} }
@@ -40,7 +40,7 @@ public class RedisReceiver {
/* HuskHomes Redis messages have a header formatted as such: /* HuskHomes Redis messages have a header formatted as such:
* <cluster_id>:<message_type>:<target_player>£ followed by the message arguments and data. */ * <cluster_id>:<message_type>:<target_player>£ followed by the message arguments and data. */
final String[] splitMessage = message.split("£"); final String[] splitMessage = message.split(RedisMessage.REDIS_MESSAGE_HEADER_SEPARATOR);
final String messageHeader = splitMessage[0]; final String messageHeader = splitMessage[0];
int clusterID; int clusterID;
-7
View File
@@ -66,13 +66,6 @@ spawn_command:
bungee_network_spawn: bungee_network_spawn:
enabled: false enabled: false
warp_name: 'Spawn' warp_name: 'Spawn'
position:
world:
x:
y:
z:
yaw:
pitch:
random_teleport_command: random_teleport_command:
enabled: true enabled: true
cooldown: 30 cooldown: 30