Allow players to toggle visibility in the chest ui

This commit is contained in:
Sam 2018-08-08 15:24:00 +01:00 committed by Alexander Meech
parent ab38705422
commit 6f0d29b20c
3 changed files with 34 additions and 6 deletions

View File

@ -400,7 +400,7 @@ public class FriendManager extends MiniDbClientPlugin<List<FriendStatus>>
{ {
if (_repository.updateVisibility(accountId, visibility)) if (_repository.updateVisibility(accountId, visibility))
{ {
runSync(() -> player.sendMessage(F.main(getName(), "Updated your friend visibility to " + F.elem(visibility.getName()) + "."))); runSync(() -> player.sendMessage(F.main(getName(), "Updated your friend status to " + F.elem(visibility.getName()) + ".")));
} }
}); });
} }

View File

@ -2,20 +2,30 @@ package mineplex.core.friend;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemBuilder;
public enum FriendVisibility public enum FriendVisibility
{ {
SHOWN("Visible", ChatColor.GREEN), SHOWN("Visible", ChatColor.GREEN, Material.EMERALD),
PRESENCE("Semi-Visible", ChatColor.YELLOW), PRESENCE("Semi-Visible", ChatColor.YELLOW, Material.GLOWSTONE_DUST),
INVISIBLE("Invisible", ChatColor.RED); INVISIBLE("Invisible", ChatColor.RED, Material.REDSTONE);
private final String _name; private final String _name;
private final ChatColor _colour; private final ChatColor _colour;
private final ItemStack _itemStack;
FriendVisibility(String name, ChatColor colour) FriendVisibility(String name, ChatColor colour, Material material)
{ {
_name = name; _name = name;
_colour = colour; _colour = colour;
_itemStack = new ItemBuilder(material)
.setTitle(colour + name)
.addLore("Click to set your status", "to " + name + "!")
.build();
} }
public String getName() public String getName()
@ -27,4 +37,9 @@ public enum FriendVisibility
{ {
return _colour; return _colour;
} }
public ItemStack getItemStack()
{
return _itemStack;
}
} }

View File

@ -125,10 +125,23 @@ public class FriendMainPage extends ShopPageBase<FriendManager, FriendShop>
.addLore("", "Click to display your friends in", "chat instead of this chest.") .addLore("", "Click to display your friends in", "chat instead of this chest.")
.build(), (player, clickType) -> .build(), (player, clickType) ->
{ {
player.closeInventory();
getPlugin().showFriends(player, true); getPlugin().showFriends(player, true);
player.closeInventory();
}); });
slot = 47;
for (FriendVisibility visibility : FriendVisibility.values())
{
addButton(slot, visibility.getItemStack(), (player, clickType) ->
{
getPlugin().setVisibility(player, visibility);
player.closeInventory();
});
slot += 2;
}
_pageManager.buildPage(); _pageManager.buildPage();
} }