From b3ed3103e408a7fc3defcbe15bd1be0b6ce85c44 Mon Sep 17 00:00:00 2001 From: ucchy Date: Sat, 4 Jul 2020 00:52:47 +0900 Subject: [PATCH] LunaChat v3.0.3 : Re-fixed issue #178. --- .../github/ucchyocean/lc3/bukkit/BukkitEventListener.java | 3 ++- .../github/ucchyocean/lc3/bungee/BungeeEventListener.java | 3 ++- .../java/com/github/ucchyocean/lc3/command/ListCommand.java | 5 +++-- .../com/github/ucchyocean/lc3/util/ClickableFormat.java | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java b/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java index 3c97689..4133ef4 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java +++ b/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java @@ -478,7 +478,8 @@ public class BukkitEventListener implements Listener { ArrayList channels = new ArrayList<>(api.getChannels()); Collections.sort(channels, new Comparator() { public int compare(Channel c1, Channel c2) { - return c1.getOnlineNum() - c2.getOnlineNum(); + if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName()); + return c2.getOnlineNum() - c1.getOnlineNum(); } }); diff --git a/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java b/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java index a5d9c3d..959239c 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java +++ b/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java @@ -516,7 +516,8 @@ public class BungeeEventListener implements Listener { ArrayList channels = new ArrayList<>(api.getChannels()); Collections.sort(channels, new Comparator() { public int compare(Channel c1, Channel c2) { - return c1.getOnlineNum() - c2.getOnlineNum(); + if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName()); + return c2.getOnlineNum() - c1.getOnlineNum(); } }); diff --git a/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java index 81e4535..861fa4a 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java @@ -82,7 +82,7 @@ public class ListCommand extends LunaChatSubCommand { public boolean runCommand( ChannelMember sender, String label, String[] args) { - int page = 0; + int page = 1; if ( args.length >= 2 && args[1].matches("[0-9]") ) { page = Integer.parseInt(args[1]); } @@ -147,7 +147,8 @@ public class ListCommand extends LunaChatSubCommand { ArrayList channels = new ArrayList<>(api.getChannels()); Collections.sort(channels, new Comparator() { public int compare(Channel c1, Channel c2) { - return c1.getOnlineNum() - c2.getOnlineNum(); + if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName()); + return c2.getOnlineNum() - c1.getOnlineNum(); } }); diff --git a/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java b/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java index a25544d..2a705b1 100644 --- a/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java +++ b/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java @@ -152,12 +152,12 @@ public class ClickableFormat { public static ClickableFormat makeChannelClickableMessage(String format, String channelName) { KeywordReplacer msg = new KeywordReplacer(format); - + String stripped = Utility.stripColorCode(channelName); msg.replace("%channel%", String.format( PLACEHOLDER_RUN_COMMAND, channelName, - Messages.hoverChannelName(channelName), - String.format(JOIN_COMMAND_TEMPLATE, channelName))); + Messages.hoverChannelName(stripped), + String.format(JOIN_COMMAND_TEMPLATE, stripped))); return new ClickableFormat(msg); }