Fix /f kicking the player

This commit is contained in:
Sam 2018-08-04 19:58:54 +01:00 committed by Alexander Meech
parent 419a7d685a
commit 4207364798
2 changed files with 40 additions and 27 deletions

View File

@ -294,7 +294,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
// Use a LinkedHashMap so we maintain insertion order
Map<String, TextComponent> messages = new LinkedHashMap<>();
String joinCommand = "/server ", friendCommand = "/" + AddFriend.COMMAND, unfriendCommand = "/" + DeleteFriend.COMMAND + " ";
String joinCommand = "/server ", friendCommand = "/" + AddFriend.COMMAND + " ", unfriendCommand = "/" + DeleteFriend.COMMAND + " ", favouriteCommand = "/Hello";
for (FriendStatus friend : friendStatuses)
{
@ -305,8 +305,8 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
continue;
}
TextComponent message = new TextComponent();
boolean canJoin = canJoin(friend.ServerName, isStaff);
TextComponent message = new TextComponent("");
boolean canJoin = canJoin(friend.ServerName, isStaff) && friend.Visibility == FriendVisibility.SHOWN;
switch (type)
{
@ -344,13 +344,32 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name));
message.addExtra(delete);
message.addExtra(" - ");
TextComponent name = new TextComponent(friend.Name);
if (friend.Favourite)
{
name.setColor(ChatColor.YELLOW);
}
else if (friend.Online)
{
name.setColor(ChatColor.GREEN);
}
else
{
name.setColor(ChatColor.GRAY);
}
name.setColor(friend.Online ? ChatColor.GREEN : ChatColor.GRAY);
name.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(friend.Favourite ? ("Add " + friend.Name + " to") : ("Remove " + friend.Name + " from") + " your favourite friends")
.create()));
name.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, favouriteCommand + friend.Name));
message.addExtra(name);
message.addExtra(" - ");
if (friend.Online)
if (friend.Online && friend.Visibility != FriendVisibility.INVISIBLE)
{
if (canJoin)
{
@ -358,6 +377,14 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
server.setColor(ChatColor.DARK_GREEN);
message.addExtra(server);
}
else if (friend.Visibility == FriendVisibility.PRESENCE)
{
TextComponent server = new TextComponent("Hidden");
server.setColor(ChatColor.DARK_GREEN);
server.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(friend.Name + " is in hidden mode")
.create()));
message.addExtra(server);
}
else
{
TextComponent server = new TextComponent("Private Staff Server");
@ -409,6 +436,12 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
cancel.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name));
message.addExtra(cancel);
message.addExtra(" - ");
TextComponent pending = new TextComponent(friend.Name + " Request Pending");
pending.setColor(ChatColor.GRAY);
message.addExtra(pending);
break;
}
@ -430,7 +463,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
messages.values().forEach(textComponent -> caller.spigot().sendMessage(textComponent));
}
TextComponent toggle = new TextComponent();
TextComponent toggle = new TextComponent("");
TextComponent line = new TextComponent("======================");
line.setColor(ChatColor.AQUA);
@ -449,7 +482,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
caller.spigot().sendMessage(toggle);
}
private boolean canJoin(String serverName, boolean isPlayerStaff)
public boolean canJoin(String serverName, boolean isPlayerStaff)
{
if (serverName == null)
{
@ -466,31 +499,11 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
return !cust;
}
public boolean isFriends(Player player, String friend)
{
FriendData friendData = Get(player);
for (FriendStatus friendStatus : friendData.getFriends())
{
if (friendStatus.Name.equalsIgnoreCase(friend))
{
return true;
}
}
return false;
}
public void updatePlayerStatus(UUID playerUUID, PlayerStatus status)
{
_repository.updatePlayerStatus(playerUUID, status);
}
public PlayerStatus getStatus(UUID playerUUID)
{
return _repository.getStatus(playerUUID);
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
{

View File

@ -5,6 +5,6 @@ public enum FriendVisibility
SHOWN,
PRESENCE,
HIDDEN
INVISIBLE
}