mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-14 22:56:27 +01:00
Large Update
Fixed commands up. Added public chests. List command List members of ChestLink.
This commit is contained in:
parent
7d4380ddb6
commit
cba7fd7b5f
@ -1,7 +0,0 @@
|
||||
package com.jamesdpeters.minecraft.chests.commands;
|
||||
|
||||
public class CommandListener {
|
||||
|
||||
|
||||
|
||||
}
|
@ -20,12 +20,16 @@ import java.util.stream.Stream;
|
||||
public class RemoteChestCommand extends ServerCommand {
|
||||
|
||||
private enum OPTIONS {
|
||||
ADD("/chestlink add <Group>", "Create/add a chest to a ChestLink group"),
|
||||
REMOVE("/chestlink remove <Group>", "Delete a ChestLink and drop its inventory at your feet!"),
|
||||
OPEN("/chestlink open <Group>","Open the inventory of a ChestLink group"),
|
||||
ADD("/chestlink add <group>", "Create/add a chest to a ChestLink group"),
|
||||
HELP("/chestlink help","List of commands and their uses!"),
|
||||
LIST("/chestlink list","Lists all ChestLinks that you own!"),
|
||||
MEMBER("/chestlink member [add/remove <group> <player>] or [list <group>]","Add, remove or list members of a group"),
|
||||
MENU("/chestlink menu","Open the ChestLink menu to display all groups!"),
|
||||
ADDMEMBER("/chestlink addmember <group> <player>","Add a player to this ChestLink so they can access your chest!"),
|
||||
REMOVEMEMBER("/chestlink removemember <group> <player>","Remove a player from this ChestLink!");
|
||||
OPEN("/chestlink open <Group>","Open the inventory of a ChestLink group"),
|
||||
REMOVE("/chestlink remove <Group>", "Delete a ChestLink and drop its inventory at your feet!"),
|
||||
SETPUBLIC("/chestlink setpublic <group> <true/false>", "Set a ChestLink to be accessible by anyone.");
|
||||
//SORT("/chestlink sort <group> <sort-method>","Set the sorting option for the given ChestLink.");
|
||||
|
||||
|
||||
String description, commandHelp;
|
||||
static List<String> valuesList;
|
||||
@ -58,9 +62,15 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(args != null) {
|
||||
|
||||
if(args != null && args.length > 0) {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())){
|
||||
case HELP:
|
||||
for(OPTIONS option : OPTIONS.values()){
|
||||
if(!option.equals(OPTIONS.HELP));
|
||||
player.sendMessage(ChatColor.RED+option.commandHelp);
|
||||
player.sendMessage(ChatColor.WHITE+option.description);
|
||||
}
|
||||
return true;
|
||||
case ADD:
|
||||
if(args.length > 1){
|
||||
if(sender.hasPermission(Permissions.ADD)) {
|
||||
@ -100,6 +110,9 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
Messages.NO_PERMISSION(player);
|
||||
return true;
|
||||
}
|
||||
case LIST:
|
||||
Messages.LIST_CHESTLINKS(player);
|
||||
return true;
|
||||
case REMOVE:
|
||||
if(args.length > 1) {
|
||||
if (sender.hasPermission(Permissions.REMOVE)) {
|
||||
@ -114,37 +127,86 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.REMOVE.description);
|
||||
return true;
|
||||
}
|
||||
case ADDMEMBER:
|
||||
if(args.length > 2){
|
||||
// case SORT:
|
||||
// if(args.length > 1) {
|
||||
// if (sender.hasPermission(Permissions.REMOVE)) {
|
||||
// InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(),args[1]);
|
||||
// if(storage != null) {
|
||||
// storage.setSortMethod(Enum.valueOf(InventoryStorage.SORT_METHOD.class, args[2]));
|
||||
// storage.sort();
|
||||
// }
|
||||
// return true;
|
||||
// } else {
|
||||
// Messages.NO_PERMISSION(player);
|
||||
// return true;
|
||||
// }
|
||||
// } else {
|
||||
// player.sendMessage(ChatColor.RED+OPTIONS.SORT.commandHelp);
|
||||
// player.sendMessage(ChatColor.RED+OPTIONS.SORT.description);
|
||||
// return true;
|
||||
// }
|
||||
case MEMBER:
|
||||
if(args.length > 3){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
Player toAdd = Bukkit.getPlayer(args[2]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(),args[1]);
|
||||
if(storage != null && storage.addMember(toAdd)) Messages.ADDED_MEMBER(player,storage,args[2]);
|
||||
else Messages.UNABLE_TO_ADD_MEMBER(player,args[2]);
|
||||
if(args[1].equals("add")) {
|
||||
Player toAdd = Bukkit.getPlayer(args[3]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(), args[2]);
|
||||
if (storage != null && storage.addMember(toAdd))
|
||||
Messages.ADDED_MEMBER(player, storage, args[3]);
|
||||
else Messages.UNABLE_TO_ADD_MEMBER(player, args[3]);
|
||||
} else if(args[1].equals("remove")){
|
||||
Player toAdd = Bukkit.getPlayer(args[3]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(),args[2]);
|
||||
if(storage != null && storage.removeMember(toAdd))
|
||||
Messages.REMOVE_MEMBER(player, storage, args[3]);
|
||||
else Messages.UNABLE_TO_REMOVE_MEMBER(player,args[3]);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.description);
|
||||
}
|
||||
} else {
|
||||
Messages.NO_PERMISSION(player);
|
||||
}
|
||||
return true;
|
||||
} else if(args.length > 2){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
if(args[1].equals("list")) {
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(), args[2]);
|
||||
if(storage != null){
|
||||
Messages.LIST_MEMBERS(player,storage);
|
||||
return true;
|
||||
} else {
|
||||
// No chest.
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.ADDMEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.ADDMEMBER.description);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.description);
|
||||
return true;
|
||||
}
|
||||
case REMOVEMEMBER:
|
||||
case SETPUBLIC:
|
||||
if(args.length > 2){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
Player toAdd = Bukkit.getPlayer(args[2]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(),args[1]);
|
||||
if(storage != null && storage.removeMember(toAdd)) Messages.REMOVE_MEMBER(player,storage,args[2]);
|
||||
else Messages.UNABLE_TO_REMOVE_MEMBER(player,args[2]);
|
||||
InventoryStorage storage = Config.getInventoryStorage(player.getUniqueId(), args[1]);
|
||||
if(storage != null){
|
||||
boolean setpublic = Boolean.parseBoolean(args[2]);
|
||||
storage.setPublic(setpublic);
|
||||
Messages.SET_PUBLIC(player,storage);
|
||||
return true;
|
||||
} else {
|
||||
Bukkit.broadcastMessage("Storage null");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.REMOVEMEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.REMOVEMEMBER.description);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.SETPUBLIC.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.SETPUBLIC.description);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -164,19 +226,39 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
return null;
|
||||
case OPEN:
|
||||
case REMOVE:
|
||||
case ADDMEMBER:
|
||||
case REMOVEMEMBER:
|
||||
return new ArrayList<>(Config.getPlayer(player.getUniqueId()).keySet());
|
||||
//case SORT:
|
||||
return Utils.getInventoryStorageList(player);
|
||||
case MEMBER:
|
||||
return Arrays.asList("add","remove","list");
|
||||
// case ADDMEMBER:
|
||||
// case REMOVEMEMBER:
|
||||
// return new ArrayList<>(Config.getPlayer(player.getUniqueId()).keySet());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
}
|
||||
if(args.length == 3) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case ADDMEMBER:
|
||||
case MEMBER:
|
||||
return Utils.getInventoryStorageList(player);
|
||||
// case SORT:
|
||||
// return InventoryStorage.SORT_METHOD.valuesList;
|
||||
// case ADDMEMBER:
|
||||
// return Utils.getOnlinePlayers();
|
||||
// case REMOVEMEMBER:
|
||||
// return Utils.getPlayersAsNameList(Config.getInventoryStorage(player.getUniqueId(),args[1]).getMembers());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
}
|
||||
if(args.length == 4) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case MEMBER:
|
||||
return Utils.getOnlinePlayers();
|
||||
case REMOVEMEMBER:
|
||||
return Utils.getPlayersAsNameList(Config.getInventoryStorage(player.getUniqueId(),args[1]).getMembers());
|
||||
// case ADDMEMBER:
|
||||
// return Utils.getOnlinePlayers();
|
||||
// case REMOVEMEMBER:
|
||||
// return Utils.getPlayersAsNameList(Config.getInventoryStorage(player.getUniqueId(),args[1]).getMembers());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
}
|
||||
|
@ -9,10 +9,8 @@ import fr.minuskube.inv.SmartInventory;
|
||||
import fr.minuskube.inv.content.InventoryContents;
|
||||
import fr.minuskube.inv.content.InventoryProvider;
|
||||
import fr.minuskube.inv.content.Pagination;
|
||||
import fr.minuskube.inv.content.SlotPos;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -28,7 +26,7 @@ public class ChestLinkMenu implements InventoryProvider {
|
||||
private SmartInventory menu;
|
||||
|
||||
private ChestLinkMenu(Player player){
|
||||
this.storages = Config.getPlayer(player.getUniqueId()).values();
|
||||
this.storages = Config.getInventoryStorageMap(player.getUniqueId()).values();
|
||||
menu = SmartInventory.builder()
|
||||
.id("chestLinkMenu")
|
||||
.title("Inventory Storage")
|
||||
|
@ -40,7 +40,7 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<String, InventoryStorage> getPlayer(UUID playerUUID){
|
||||
public static HashMap<String, InventoryStorage> getInventoryStorageMap(UUID playerUUID){
|
||||
String id = playerUUID.toString();
|
||||
if(store.chests.containsKey(id)){
|
||||
return store.chests.get(id);
|
||||
@ -52,7 +52,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static InventoryStorage getInventoryStorage(UUID playerUUID, String identifier){
|
||||
HashMap<String, InventoryStorage> map = getPlayer(playerUUID);
|
||||
HashMap<String, InventoryStorage> map = getInventoryStorageMap(playerUUID);
|
||||
return map.getOrDefault(identifier, null);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class Config {
|
||||
|
||||
public static void addChest(Player player, String identifier, Location chestLocation){
|
||||
//List of groups this player has.
|
||||
HashMap<String, InventoryStorage> map = getPlayer(player.getUniqueId());
|
||||
HashMap<String, InventoryStorage> map = getInventoryStorageMap(player.getUniqueId());
|
||||
|
||||
//Get Inventory Storage for the given group or create it if it doesnt exist.
|
||||
if(!map.containsKey(identifier)){
|
||||
@ -109,7 +109,7 @@ public class Config {
|
||||
storage.getLocations().remove(location);
|
||||
if (storage.getLocations().size() == 0) {
|
||||
storage.dropInventory(location);
|
||||
getPlayer(storage.getOwner().getUniqueId()).remove(storage.getIdentifier());
|
||||
getInventoryStorageMap(storage.getOwner().getUniqueId()).remove(storage.getIdentifier());
|
||||
}
|
||||
save();
|
||||
return storage;
|
||||
@ -127,7 +127,7 @@ public class Config {
|
||||
}
|
||||
});
|
||||
storage.dropInventory(player.getLocation());
|
||||
getPlayer(player.getUniqueId()).remove(group);
|
||||
getInventoryStorageMap(player.getUniqueId()).remove(group);
|
||||
Messages.REMOVED_GROUP(player,group);
|
||||
} else {
|
||||
Messages.GROUP_DOESNT_EXIST(player,group);
|
||||
@ -137,7 +137,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static InventoryStorage removeChest(Player player, String identifier, Location chestLocation){
|
||||
return removeChest(getPlayer(player.getUniqueId()).get(identifier),chestLocation);
|
||||
return removeChest(getInventoryStorageMap(player.getUniqueId()).get(identifier),chestLocation);
|
||||
}
|
||||
|
||||
public static InventoryStorage removeChest(Location chestLocation){
|
||||
@ -146,7 +146,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean setChests(Player player, String group, InventoryStorage storage){
|
||||
HashMap<String, InventoryStorage> groups = getPlayer(player.getUniqueId());
|
||||
HashMap<String, InventoryStorage> groups = getInventoryStorageMap(player.getUniqueId());
|
||||
groups.put(group,storage);
|
||||
save();
|
||||
return true;
|
||||
|
@ -2,8 +2,12 @@ package com.jamesdpeters.minecraft.chests.misc;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Messages {
|
||||
|
||||
private static String TAG = "[Chests++]";
|
||||
@ -65,4 +69,25 @@ public class Messages {
|
||||
public static void GROUP_DOESNT_EXIST(Player target, String toRemove){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+toRemove+" isn't a valid group to remove!");
|
||||
}
|
||||
|
||||
public static void LIST_MEMBERS(Player target, InventoryStorage storage){
|
||||
if(storage.getMembers() != null){
|
||||
target.sendMessage(ChatColor.GREEN+"Members of group "+ChatColor.WHITE+storage.getIdentifier()+": "+Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers()));
|
||||
} else {
|
||||
target.sendMessage(ChatColor.YELLOW+"There are no additional members in the group: "+ChatColor.WHITE+storage.getIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
public static void SET_PUBLIC(Player target, InventoryStorage storage){
|
||||
target.sendMessage(ChatColor.GREEN+"Publicity for ChestLink "+storage.getIdentifier()+" is set to: "+ChatColor.WHITE+storage.isPublic());
|
||||
}
|
||||
|
||||
public static void LIST_CHESTLINKS(Player target){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+"List of your ChestLinks:");
|
||||
for(InventoryStorage storage : Config.getInventoryStorageMap(target.getUniqueId()).values()){
|
||||
if(storage != null){
|
||||
target.sendMessage(ChatColor.GREEN+storage.getIdentifier()+ChatColor.WHITE+" - "+storage.getTotalItems()+" items");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,4 +8,5 @@ public class Permissions {
|
||||
public static final String REMOVE = "chestlink.remove";
|
||||
public static final String OPEN_ANY = "chestlink.openall";
|
||||
public static final String MEMBER = "chestlink.member";
|
||||
public static final String SORT = "chestlink.sort";
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.jamesdpeters.minecraft.chests.misc;
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.containers.ChestLinkInfo;
|
||||
import com.jamesdpeters.minecraft.chests.runnables.ChestLinkVerifier;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
@ -20,6 +21,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Utils {
|
||||
|
||||
@ -249,16 +251,23 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String prettyPrintPlayers(ChatColor highlight, List<OfflinePlayer> players){
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(players.size());
|
||||
if(players.size() > 0) {
|
||||
str.append(" - " + highlight + "[");
|
||||
for (OfflinePlayer player : players) {
|
||||
str.append(ChatColor.WHITE + ChatColor.stripColor(player.getName())).append(", ");
|
||||
}
|
||||
str.delete(str.length() - 2, str.length());
|
||||
str.append(highlight + "]");
|
||||
}
|
||||
return str.toString();
|
||||
String playerString = players.stream().map(OfflinePlayer::getName).collect(Collectors.joining(","));
|
||||
return highlight+"["+ChatColor.WHITE+playerString+highlight+"]";
|
||||
//
|
||||
// StringBuilder str = new StringBuilder();
|
||||
// str.append(players.size());
|
||||
// if(players.size() > 0) {
|
||||
// str.append(" - " + highlight + "[");
|
||||
// for (OfflinePlayer player : players) {
|
||||
// str.append(ChatColor.WHITE + ChatColor.stripColor(player.getName())).append(", ");
|
||||
// }
|
||||
// str.delete(str.length() - 2, str.length());
|
||||
// str.append(highlight + "]");
|
||||
// }
|
||||
// return str.toString();
|
||||
}
|
||||
|
||||
public static List<String> getInventoryStorageList(Player player){
|
||||
return Config.getInventoryStorageMap(player.getUniqueId()).values().stream().map(InventoryStorage::getIdentifier).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.jamesdpeters.minecraft.chests.serialize;
|
||||
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.commands.RemoteChestCommand;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Config;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Permissions;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder;
|
||||
import com.jamesdpeters.minecraft.chests.runnables.VirtualChestToHopper;
|
||||
@ -17,6 +19,8 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class InventoryStorage implements ConfigurationSerializable {
|
||||
|
||||
@ -28,6 +32,20 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
VirtualChestToHopper chestToHopper;
|
||||
Player player;
|
||||
UUID playerUUID;
|
||||
boolean isPublic;
|
||||
SORT_METHOD sortMethod = SORT_METHOD.OFF;
|
||||
|
||||
public enum SORT_METHOD {
|
||||
OFF,
|
||||
ID,
|
||||
AMOUNT;
|
||||
|
||||
public static List<String> valuesList;
|
||||
|
||||
static {
|
||||
valuesList = Stream.of(SORT_METHOD.values()).map(SORT_METHOD::toString).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
@ -37,6 +55,8 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
hashMap.put("inventoryName",inventoryName);
|
||||
hashMap.put("playerUUID",playerUUID.toString());
|
||||
hashMap.put("members", members);
|
||||
hashMap.put("isPublic", isPublic);
|
||||
hashMap.put("sortMethod", sortMethod.toString());
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@ -55,6 +75,10 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
playerUUID = UUID.fromString((String) map.get("playerUUID"));
|
||||
player = Bukkit.getOfflinePlayer(playerUUID).getPlayer();
|
||||
|
||||
if(map.containsKey("isPublic")) isPublic = (boolean) map.get("isPublic");
|
||||
if(map.containsKey("sortMethod")) sortMethod = Enum.valueOf(SORT_METHOD.class, (String) map.get("sortMethod"));
|
||||
|
||||
|
||||
if(map.get("members") != null){
|
||||
members = (ArrayList<String>) map.get("members");
|
||||
bukkitMembers = new ArrayList<>();
|
||||
@ -70,6 +94,8 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
this.inventoryName = group;
|
||||
this.player = player;
|
||||
this.playerUUID = player.getUniqueId();
|
||||
this.isPublic = false;
|
||||
this.sortMethod = SORT_METHOD.OFF;
|
||||
locationsList = new ArrayList<>(Collections.singleton(location));
|
||||
|
||||
Block block = location.getBlock();
|
||||
@ -138,6 +164,7 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
meta.setDisplayName(ChatColor.BOLD + "" + ChatColor.GREEN + "" + getIdentifier() + ": " +ChatColor.WHITE+ ""+getTotalItems()+" items");
|
||||
if(getMembers() != null) {
|
||||
List<String> memberNames = new ArrayList<>();
|
||||
if(isPublic) memberNames.add(ChatColor.WHITE+"Public Chest");
|
||||
memberNames.add(ChatColor.BOLD+""+ChatColor.UNDERLINE+"Members:");
|
||||
getMembers().forEach(player1 -> memberNames.add(ChatColor.stripColor(player1.getName())));
|
||||
meta.setLore(memberNames);
|
||||
@ -155,6 +182,8 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player){
|
||||
if(isPublic) return true;
|
||||
if(player.hasPermission(Permissions.OPEN_ANY)) return true;
|
||||
if(player.getUniqueId().equals(playerUUID)) return true;
|
||||
if(members != null) {
|
||||
for (String uuid : members) {
|
||||
@ -201,4 +230,33 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setPublic(boolean value){
|
||||
this.isPublic = value;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setSortMethod(SORT_METHOD sortMethod){
|
||||
this.sortMethod = sortMethod;
|
||||
}
|
||||
|
||||
public void sort(){
|
||||
// switch (sortMethod){
|
||||
// case OFF: return;
|
||||
// case ID: {
|
||||
// ItemStack[] sorted = inventory.getContents();
|
||||
// Arrays.sort(sorted, (item1, item2) -> {
|
||||
// if(item1 == null) return 1;
|
||||
// if(item2 == null) return -1;
|
||||
// else {
|
||||
// return item1.getType().getKey().getKey().compareTo(item2.getType().getKey().getKey());
|
||||
// }
|
||||
// });
|
||||
// inventory.setContents(sorted);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: ChestsPlusPlus
|
||||
version: 1.15 v1.2.3
|
||||
version: 1.15 v1.3
|
||||
main: com.jamesdpeters.minecraft.chests.ChestsPlusPlus
|
||||
api-version: "1.15"
|
||||
|
||||
@ -7,6 +7,8 @@ commands:
|
||||
chestlink:
|
||||
description: Chest++ Commands.
|
||||
usage: Use /chestlink help for more info.
|
||||
aliases:
|
||||
- cl
|
||||
|
||||
permissions:
|
||||
chestlink.*:
|
||||
@ -34,6 +36,9 @@ permissions:
|
||||
chestlink.openall:
|
||||
description: Gives permission to open all chests, for admin use.
|
||||
default: false
|
||||
chestlink.member:
|
||||
chestlink.member:
|
||||
description: Gives permission to add/remove a member to/from their chestlink.
|
||||
default: true
|
||||
chestlink.sort:
|
||||
description: Set the sorting option for the given ChestLink.
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user