Modifided output of friends list

- buttons to left side for alignment
- sorted by sent>offline>pending>online
- improved 'no friends' message
This commit is contained in:
Chiss 2014-10-09 12:15:45 +11:00
parent 4bed45c48c
commit ffc2ff5058
3 changed files with 63 additions and 15 deletions

View File

@ -1,5 +1,6 @@
package mineplex.core.friend; package mineplex.core.friend;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -263,6 +264,11 @@ public class FriendManager extends MiniClientPlugin<FriendData>
caller.sendMessage(C.cAqua + C.Strike + "======================[" + ChatColor.RESET + C.cWhite + C.Bold + "Friends" + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); caller.sendMessage(C.cAqua + C.Strike + "======================[" + ChatColor.RESET + C.cWhite + C.Bold + "Friends" + ChatColor.RESET + C.cAqua + C.Strike + "]======================");
ArrayList<ChildJsonMessage> sentLines = new ArrayList<ChildJsonMessage>();
ArrayList<ChildJsonMessage> pendingLines = new ArrayList<ChildJsonMessage>();
ArrayList<ChildJsonMessage> onlineLines = new ArrayList<ChildJsonMessage>();
ArrayList<ChildJsonMessage> offlineLines = new ArrayList<ChildJsonMessage>();
for (FriendStatus friend : friendStatuses) for (FriendStatus friend : friendStatuses)
{ {
if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied)
@ -273,37 +279,79 @@ public class FriendManager extends MiniClientPlugin<FriendData>
gotAFriend = true; gotAFriend = true;
ChildJsonMessage message = new JsonMessage(friend.Name).color(friend.Online ? "green" : "gray").extra(" - ").color("white"); ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white");
if (friend.Status == FriendStatusType.Accepted) if (friend.Status == FriendStatusType.Accepted)
{ {
//Online Friend
if (friend.Online) if (friend.Online)
{ {
message.add(friend.ServerName).color("dark_green").add(" - ").color("white"); message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName).hover("show_text", "Teleport to " + friend.Name + "'s server.");
message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName).hover("show_text", "Change to " + friend.Name + "'s server.").add(" - ").color("white"); message.add(" - ").color("white");
} message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Remove " + friend.Name + " from your friends list.");
else message.add(" - ").color("white");
message.add("Last online : ").color("gray").add(UtilTime.MakeStr(friend.LastSeenOnline)).color("gray").add(" - ").color("white"); message.add(friend.Name).color(friend.Online ? "green" : "gray");
message.add(" - ").color("white");
message.add(friend.ServerName).color("dark_green");
message.add("Unfriend").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Remove " + friend.Name + " from your friends list.").sendToPlayer(caller); onlineLines.add(message);
} }
//Offline Friend
else
{
message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Remove " + friend.Name + " from your friends list.");
message.add(" - ").color("white");
message.add(friend.Name).color(friend.Online ? "green" : "gray");
message.add(" - ").color("white");
message.add("Offline for ").color("gray").add(UtilTime.MakeStr(friend.LastSeenOnline)).color("gray");
offlineLines.add(message);
}
}
//Pending
else if (friend.Status == FriendStatusType.Pending) else if (friend.Status == FriendStatusType.Pending)
{ {
message.add("Friendship Pending").color("gray").add(" - ").color("white"); message.add("Accept").color("green").bold().click("run_command", "/friend " + friend.Name).hover("show_text", "Accept " + friend.Name + "'s friend request.");
message.add("Accept").color("green").bold().click("run_command", "/friend " + friend.Name).hover("show_text", "Accept " + friend.Name + "'s friend request.").add(" - ").color("white"); message.add(" - ").color("white");
message.add("Deny").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Deny " + friend.Name + "'s friend request.").sendToPlayer(caller); message.add("Deny").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Deny " + friend.Name + "'s friend request.");
message.add(" - ").color("white");
message.add(friend.Name + " Requested Friendship").color("gray");
pendingLines.add(message);
} }
//Sent
else if (friend.Status == FriendStatusType.Sent) else if (friend.Status == FriendStatusType.Sent)
{ {
message.add("Friendship Requested").color("gray").add(" - ").color("white"); message.add("Cancel").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Cancel friend request to " + friend.Name);
message.add("Cancel").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Cancel friend request to " + friend.Name).sendToPlayer(caller); message.add(" - ").color("white");
message.add(friend.Name + " Friendship Request").color("gray");
sentLines.add(message);
} }
} }
//Send In Order
for (JsonMessage msg : sentLines)
msg.sendToPlayer(caller);
for (JsonMessage msg : offlineLines)
msg.sendToPlayer(caller);
for (JsonMessage msg : pendingLines)
msg.sendToPlayer(caller);
for (JsonMessage msg : onlineLines)
msg.sendToPlayer(caller);
if (!gotAFriend) if (!gotAFriend)
{ {
caller.sendMessage(C.cGray + "You don't have any friends. Type " + ChatColor.GREEN + "/friend name" + ChatColor.GRAY + " to add someone!"); caller.sendMessage(" ");
caller.sendMessage("Welcome to your Friends List!");
caller.sendMessage(" ");
caller.sendMessage("To add friends, type " + C.cGreen + "/friend <Player Name>");
caller.sendMessage(" ");
caller.sendMessage("Type " + C.cGreen + "/friend" + ChatColor.RESET + " at any time to interact with your friends!");
caller.sendMessage(" ");
} }
caller.sendMessage(C.cAqua + C.Strike + "====================================================="); caller.sendMessage(C.cAqua + C.Strike + "=====================================================");

View File

@ -8,6 +8,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.4.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.4.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry kind="lib" path="C:/Users/CJ/Desktop/craftbukkit.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>