mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-22 18:45:59 +01:00
Huge Code Cleanup!
This commit is contained in:
parent
9555c9f722
commit
6b0f37de2c
@ -3,27 +3,27 @@ package com.jamesdpeters.minecraft.chests;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class API {
|
||||
public class Api {
|
||||
|
||||
private static Plugin plugin;
|
||||
|
||||
public static void register(Plugin plugin){
|
||||
API.plugin = plugin;
|
||||
public static void register(Plugin plugin) {
|
||||
Api.plugin = plugin;
|
||||
}
|
||||
|
||||
public static Plugin getPlugin(){
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static NMSProvider getNMSProvider(){
|
||||
public static NMSProvider getNMSProvider() {
|
||||
String packageName = NMSProvider.class.getPackage().getName();
|
||||
String nmsVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
String nmsProvider = packageName+"."+nmsVersion+".NMSProviderImpl";
|
||||
plugin.getLogger().info("Found API version: "+nmsVersion);
|
||||
String nmsProvider = packageName + "." + nmsVersion + ".NMSProviderImpl";
|
||||
plugin.getLogger().info("Found API version: " + nmsVersion);
|
||||
try {
|
||||
return (NMSProvider) Class.forName(nmsProvider).newInstance();
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||
plugin.getLogger().warning("A valid server implementation wasn't found for: "+nmsVersion);
|
||||
plugin.getLogger().warning("A valid server implementation wasn't found for: " + nmsVersion);
|
||||
plugin.getLogger().warning("You may be running an outdated version of the plugin or it needs to be updated to the latest version!");
|
||||
return null;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.v1_16_R1;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.API;
|
||||
import com.jamesdpeters.minecraft.chests.Api;
|
||||
import com.jamesdpeters.minecraft.chests.ChestOpener;
|
||||
import com.jamesdpeters.minecraft.chests.TileEntityOpener;
|
||||
import com.jamesdpeters.minecraft.chests.v1_16_R1.tileentities.CustomTileEntityBarrel;
|
||||
@ -13,7 +13,6 @@ import net.minecraft.server.v1_16_R1.TileEntityChestTrapped;
|
||||
import net.minecraft.server.v1_16_R1.TileEntityTypes;
|
||||
import net.minecraft.server.v1_16_R1.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.Lidded;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||
@ -42,7 +41,7 @@ public class ChestOpener_1_16 implements ChestOpener {
|
||||
|
||||
if(tileEntityOpener != null) {
|
||||
TileEntityOpener opener = tileEntityOpener;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(API.getPlugin(), ()-> opener.setViewers(inventory.getViewers()),1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Api.getPlugin(), ()-> opener.setViewers(inventory.getViewers()),1);
|
||||
return tileEntityOpener;
|
||||
} else {
|
||||
CraftContainer craftContainer = (CraftContainer) container;
|
||||
@ -55,7 +54,7 @@ public class ChestOpener_1_16 implements ChestOpener {
|
||||
if (tileEntity instanceof TileEntityOpener) {
|
||||
tileEntityOpener = (TileEntityOpener) tileEntity;
|
||||
TileEntityOpener opener = tileEntityOpener;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(API.getPlugin(), ()-> opener.setViewers(inventory.getViewers()),1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Api.getPlugin(), ()-> opener.setViewers(inventory.getViewers()),1);
|
||||
return tileEntityOpener;
|
||||
} else {
|
||||
//If not set the new tile entity and set the viewers.
|
||||
@ -76,7 +75,7 @@ public class ChestOpener_1_16 implements ChestOpener {
|
||||
private <T extends TileEntity & TileEntityOpener> void setTileEnt(World world, BlockPosition position, T tileEntOpener, List<HumanEntity> viewers){
|
||||
world.removeTileEntity(position);
|
||||
world.setTileEntity(position, tileEntOpener);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(API.getPlugin(), ()-> tileEntOpener.setViewers(viewers),1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Api.getPlugin(), ()-> tileEntOpener.setViewers(viewers),1);
|
||||
}
|
||||
|
||||
private boolean hasLiddedAPI(){
|
||||
|
@ -88,7 +88,7 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
Stats.addCharts(metrics);
|
||||
|
||||
//API initialisation
|
||||
API.register(this);
|
||||
Api.register(this);
|
||||
ApiSpecific.init();
|
||||
|
||||
//Register commands
|
||||
@ -104,10 +104,12 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
|
||||
boolean isDev = BuildConstants.VERSION.contains("DEV");
|
||||
boolean isBeta = BuildConstants.VERSION.contains("BETA");
|
||||
if(isDev) getLogger().warning("You are currently running a Dev build - update checker disabled! Build: "+BuildConstants.VERSION);
|
||||
if(isBeta) getLogger().warning("You are currently running a Beta build - update checker disabled! Build: "+BuildConstants.VERSION);
|
||||
if (isDev)
|
||||
getLogger().warning("You are currently running a Dev build - update checker disabled! Build: " + BuildConstants.VERSION);
|
||||
if (isBeta)
|
||||
getLogger().warning("You are currently running a Beta build - update checker disabled! Build: " + BuildConstants.VERSION);
|
||||
|
||||
if(PluginConfig.IS_UPDATE_CHECKER_ENABLED.get() && !isDev && !isBeta) {
|
||||
if (PluginConfig.IS_UPDATE_CHECKER_ENABLED.get() && !isDev && !isBeta) {
|
||||
String BUKKIT_URL = "https://dev.bukkit.org/projects/chests-plus-plus/files";
|
||||
UpdateChecker.init(this, 71355, UpdateChecker.VERSION_SCHEME_DECIMAL);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
|
||||
@ -123,22 +125,22 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
}
|
||||
boot = true;
|
||||
});
|
||||
}, 0, PluginConfig.UPDATE_CHECKER_PERIOD.get()*20);
|
||||
}, 0, PluginConfig.UPDATE_CHECKER_PERIOD.get() * 20);
|
||||
}
|
||||
|
||||
//Load storages after load.
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () ->{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
Crafting.load();
|
||||
new Config();
|
||||
getLogger().info("Chests++ Successfully Loaded Config and Recipes");
|
||||
|
||||
//Register event listeners
|
||||
getServer().getPluginManager().registerEvents(new StorageListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new HopperListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new WorldListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new StorageListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new HopperListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new WorldListener(), this);
|
||||
getLogger().info("Chests++ enabled!");
|
||||
},1);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.api;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.API;
|
||||
import com.jamesdpeters.minecraft.chests.Api;
|
||||
import com.jamesdpeters.minecraft.chests.ChestOpener;
|
||||
import com.jamesdpeters.minecraft.chests.MaterialChecker;
|
||||
import com.jamesdpeters.minecraft.chests.NMSProvider;
|
||||
@ -13,9 +13,9 @@ public class ApiSpecific {
|
||||
private static ChestOpener chestOpener;
|
||||
private static NMSProvider nmsProvider;
|
||||
|
||||
public static void init(){
|
||||
nmsProvider = API.getNMSProvider();
|
||||
if(nmsProvider == null) nmsProvider = new NMSProviderDefault();
|
||||
public static void init() {
|
||||
nmsProvider = Api.getNMSProvider();
|
||||
if (nmsProvider == null) nmsProvider = new NMSProviderDefault();
|
||||
materialChecker = nmsProvider.getMaterialChecker();
|
||||
chestOpener = nmsProvider.getChestOpener();
|
||||
}
|
||||
@ -23,11 +23,16 @@ public class ApiSpecific {
|
||||
public static MaterialChecker getMaterialChecker() {
|
||||
return materialChecker;
|
||||
}
|
||||
|
||||
public static ChestOpener getChestOpener() {
|
||||
return chestOpener;
|
||||
}
|
||||
|
||||
public static NMSProvider getNmsProvider() {
|
||||
return nmsProvider;
|
||||
}
|
||||
public static String getApiVersion(){ return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; }
|
||||
|
||||
public static String getApiVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class NMSProviderDefault implements NMSProvider {
|
||||
//Latest version at time of build is 1.16
|
||||
NMSProviderImpl provider1_16;
|
||||
|
||||
public NMSProviderDefault(){
|
||||
public NMSProviderDefault() {
|
||||
provider1_16 = new NMSProviderImpl();
|
||||
}
|
||||
|
||||
|
@ -20,17 +20,16 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class AutoCraftCommand extends ServerCommand {
|
||||
public class AutoCraftCommand extends ServerCommand {
|
||||
|
||||
private enum OPTIONS {
|
||||
ADD("/autocraft add <group>", Message.COMMAND_AUTOCRAFT_ADD.getString()),
|
||||
HELP("/autocraft help",Message.COMMAND_HELP.getString()),
|
||||
LIST("/autocraft list",Message.COMMAND_AUTOCRAFT_LIST.getString()),
|
||||
MEMBER("/autocraft member [add/remove <group> <player>] or [list <group>]",Message.COMMAND_MEMBER.getString()),
|
||||
// MENU("/autocraft menu","Open the AutoCraft menu to display all groups!"),
|
||||
OPEN("/autocraft open <Group>",Message.COMMAND_AUTOCRAFT_OPEN.getString()),
|
||||
HELP("/autocraft help", Message.COMMAND_HELP.getString()),
|
||||
LIST("/autocraft list", Message.COMMAND_AUTOCRAFT_LIST.getString()),
|
||||
MEMBER("/autocraft member [add/remove <group> <player>] or [list <group>]", Message.COMMAND_MEMBER.getString()),
|
||||
OPEN("/autocraft open <Group>", Message.COMMAND_AUTOCRAFT_OPEN.getString()),
|
||||
REMOVE("/autocraft remove <Group>", Message.COMMAND_AUTOCRAFT_REMOVE.getString()),
|
||||
RENAME("/autocraft rename <group> <new-name>",Message.COMMAND_AUTOCRAFT_RENAME.getString()),
|
||||
RENAME("/autocraft rename <group> <new-name>", Message.COMMAND_AUTOCRAFT_RENAME.getString()),
|
||||
SETPUBLIC("/autocraft setpublic <group> <true/false>", Message.COMMAND_AUTOCRAFT_SETPUBLIC.getString());
|
||||
|
||||
String description, commandHelp;
|
||||
@ -40,7 +39,7 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
valuesList = Stream.of(OPTIONS.values()).map(OPTIONS::toString).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
OPTIONS( String commandHelp, String description){
|
||||
OPTIONS(String commandHelp, String description) {
|
||||
this.commandHelp = commandHelp;
|
||||
this.description = description;
|
||||
}
|
||||
@ -59,13 +58,13 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)){
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only a player can use this command");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if(args != null && args.length > 0) {
|
||||
if (args != null && args.length > 0) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case HELP:
|
||||
@ -170,7 +169,7 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException exception){
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -180,13 +179,13 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if((sender instanceof Player)) {
|
||||
if ((sender instanceof Player)) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (args.length == 1) {
|
||||
return OPTIONS.valuesList;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case ADD:
|
||||
@ -196,38 +195,42 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
case RENAME:
|
||||
return Config.getAutoCraft().getStorageList(player, args[1]);
|
||||
case MEMBER:
|
||||
return Stream.of("add","remove","list","add-to-all","remove-from-all").filter(s -> s.contains(args[1])).collect(Collectors.toList());
|
||||
return Stream.of("add", "remove", "list", "add-to-all", "remove-from-all").filter(s -> s.contains(args[1])).collect(Collectors.toList());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(args.length == 3) {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case MEMBER:
|
||||
if(args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if(args[1].equals("remove-from-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if (args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if (args[1].equals("remove-from-all"))
|
||||
return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
return Config.getAutoCraft().getStorageList(player, args[2]);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(args.length == 4) {
|
||||
if (args.length == 4) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case MEMBER:
|
||||
return Utils.filterList(Utils.getAllPlayers(), args[3]);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
return Collections.singletonList("");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean memberCommand(String[] args, CommandSender sender){
|
||||
private static boolean memberCommand(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
if(args.length > 3){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
if(args[1].equals("add")) {
|
||||
if (args.length > 3) {
|
||||
if (sender.hasPermission(Permissions.MEMBER)) {
|
||||
if (args[1].equals("add")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
|
||||
AutoCraftingStorage storage = Config.getAutoCraft().getStorage(player.getUniqueId(), args[2]);
|
||||
@ -235,7 +238,7 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
storage.getStorageType().getMessages().addedMember(player, storage, args[3]);
|
||||
else Config.getAutoCraft().getMessages().unableToAddMember(player, args[3]);
|
||||
});
|
||||
} else if(args[1].equals("remove")){
|
||||
} else if (args[1].equals("remove")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
|
||||
AutoCraftingStorage storage = Config.getAutoCraft().getStorage(player.getUniqueId(), args[2]);
|
||||
@ -244,29 +247,29 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
else Config.getAutoCraft().getMessages().unableToRemoveMember(player, args[3]);
|
||||
});
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+ OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+ OPTIONS.MEMBER.description);
|
||||
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")) {
|
||||
} else if (args.length > 2) {
|
||||
if (sender.hasPermission(Permissions.MEMBER)) {
|
||||
if (args[1].equals("list")) {
|
||||
AutoCraftingStorage storage = Config.getAutoCraft().getStorage(player.getUniqueId(), args[2]);
|
||||
if(storage != null){
|
||||
if (storage != null) {
|
||||
storage.getStorageType().getMessages().listMembers(player, storage);
|
||||
return true;
|
||||
}
|
||||
} else if(args[1].equals("add-to-all")){
|
||||
} else if (args[1].equals("add-to-all")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
|
||||
Config.getAutoCraft().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.addMember(toAdd));
|
||||
Config.getAutoCraft().getMessages().addMemberToAll(player, toAdd);
|
||||
});
|
||||
return true;
|
||||
} else if(args[1].equals("remove-from-all")) {
|
||||
} else if (args[1].equals("remove-from-all")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
|
||||
Config.getAutoCraft().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.removeMember(toAdd));
|
||||
@ -276,8 +279,8 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+ OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+ OPTIONS.MEMBER.description);
|
||||
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.description);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ChestLinkCommand extends ServerCommand {
|
||||
public class ChestLinkCommand extends ServerCommand {
|
||||
|
||||
private enum OPTIONS {
|
||||
ADD("/chestlink add <group>", Message.COMMAND_CHESTLINK_ADD.getString()),
|
||||
@ -43,7 +43,7 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
valuesList = Stream.of(OPTIONS.values()).map(OPTIONS::toString).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
OPTIONS( String commandHelp, String description){
|
||||
OPTIONS(String commandHelp, String description) {
|
||||
this.commandHelp = commandHelp;
|
||||
this.description = description;
|
||||
}
|
||||
@ -62,13 +62,13 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)){
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only a player can use this command");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if(args != null && args.length > 0) {
|
||||
if (args != null && args.length > 0) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case HELP:
|
||||
@ -191,7 +191,7 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException exception){
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -201,13 +201,13 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if((sender instanceof Player)) {
|
||||
if ((sender instanceof Player)) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (args.length == 1) {
|
||||
return OPTIONS.valuesList;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case ADD:
|
||||
@ -218,49 +218,53 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
case RENAME:
|
||||
return Config.getChestLink().getStorageList(player, args[1]);
|
||||
case MEMBER:
|
||||
return Stream.of("add","remove","list","add-to-all","remove-from-all").filter(s -> s.contains(args[1])).collect(Collectors.toList());
|
||||
return Stream.of("add", "remove", "list", "add-to-all", "remove-from-all").filter(s -> s.contains(args[1])).collect(Collectors.toList());
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(args.length == 3) {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case MEMBER:
|
||||
if(args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if(args[1].equals("remove-from-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if (args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if (args[1].equals("remove-from-all"))
|
||||
return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
return Config.getChestLink().getStorageList(player, args[2]);
|
||||
case SORT:
|
||||
return SortMethod.valuesList;
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(args.length == 4) {
|
||||
if (args.length == 4) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case MEMBER:
|
||||
return Utils.filterList(Utils.getAllPlayers(), args[3]);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
return Collections.singletonList("");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean memberCommand(String[] args, CommandSender sender){
|
||||
private static boolean memberCommand(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
if(args.length > 3){
|
||||
if(sender.hasPermission(Permissions.MEMBER)){
|
||||
if(args[1].equals("add")) {
|
||||
if (args.length > 3) {
|
||||
if (sender.hasPermission(Permissions.MEMBER)) {
|
||||
if (args[1].equals("add")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
|
||||
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
|
||||
if (storage != null && storage.addMember(toAdd))
|
||||
storage.getStorageType().getMessages().addedMember(player, storage, args[3]);
|
||||
else Config.getChestLink().getMessages().unableToAddMember(player,args[3]);
|
||||
else Config.getChestLink().getMessages().unableToAddMember(player, args[3]);
|
||||
});
|
||||
return true;
|
||||
} else if(args[1].equals("remove")){
|
||||
} else if (args[1].equals("remove")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
|
||||
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
|
||||
@ -270,29 +274,29 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.description);
|
||||
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")) {
|
||||
} else if (args.length > 2) {
|
||||
if (sender.hasPermission(Permissions.MEMBER)) {
|
||||
if (args[1].equals("list")) {
|
||||
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
|
||||
if(storage != null){
|
||||
if (storage != null) {
|
||||
storage.getStorageType().getMessages().listMembers(player, storage);
|
||||
return true;
|
||||
}
|
||||
} else if(args[1].equals("add-to-all")){
|
||||
} else if (args[1].equals("add-to-all")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
|
||||
Config.getChestLink().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.addMember(toAdd));
|
||||
Config.getChestLink().getMessages().addMemberToAll(player, toAdd);
|
||||
});
|
||||
return true;
|
||||
} else if(args[1].equals("remove-from-all")){
|
||||
} else if (args[1].equals("remove-from-all")) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
|
||||
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
|
||||
Config.getChestLink().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.removeMember(toAdd));
|
||||
@ -302,8 +306,8 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED+OPTIONS.MEMBER.description);
|
||||
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.commandHelp);
|
||||
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.description);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
|
||||
private enum OPTIONS {
|
||||
VERSION("/chestsplusplus version", "Display the current version of the plugin."),
|
||||
@ -26,7 +26,7 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
valuesList = Stream.of(OPTIONS.values()).map(OPTIONS::toString).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
OPTIONS( String commandHelp, String description){
|
||||
OPTIONS(String commandHelp, String description) {
|
||||
this.commandHelp = commandHelp;
|
||||
this.description = description;
|
||||
}
|
||||
@ -45,13 +45,13 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(args != null && args.length > 0) {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())){
|
||||
if (args != null && args.length > 0) {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case VERSION:
|
||||
sender.sendMessage("ChestsPlusPlus Version: "+ BuildConstants.VERSION);
|
||||
sender.sendMessage("Server Version: "+ Bukkit.getVersion());
|
||||
sender.sendMessage("CraftBukkit Version: "+ Bukkit.getBukkitVersion());
|
||||
sender.sendMessage("Detected API Version: "+ ApiSpecific.getApiVersion());
|
||||
sender.sendMessage("ChestsPlusPlus Version: " + BuildConstants.VERSION);
|
||||
sender.sendMessage("Server Version: " + Bukkit.getVersion());
|
||||
sender.sendMessage("CraftBukkit Version: " + Bukkit.getBukkitVersion());
|
||||
sender.sendMessage("Detected API Version: " + ApiSpecific.getApiVersion());
|
||||
return true;
|
||||
|
||||
case RELOAD:
|
||||
@ -59,7 +59,7 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
return true;
|
||||
|
||||
default:
|
||||
for(ChestsPlusPlusCommand.OPTIONS option : ChestsPlusPlusCommand.OPTIONS.values()){
|
||||
for (ChestsPlusPlusCommand.OPTIONS option : ChestsPlusPlusCommand.OPTIONS.values()) {
|
||||
sender.sendMessage(ChatColor.RED + option.commandHelp);
|
||||
sender.sendMessage(ChatColor.WHITE + option.description);
|
||||
}
|
||||
@ -71,26 +71,29 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if((sender instanceof Player)) {
|
||||
if ((sender instanceof Player)) {
|
||||
if (args.length == 1) {
|
||||
return OPTIONS.valuesList;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(args.length == 3) {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(args.length == 4) {
|
||||
if (args.length == 4) {
|
||||
try {
|
||||
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -10,9 +10,9 @@ public abstract class ServerCommand implements CommandExecutor, TabCompleter {
|
||||
/**
|
||||
* @param plugin Registers command to given plugin.
|
||||
*/
|
||||
public void register(JavaPlugin plugin){
|
||||
public void register(JavaPlugin plugin) {
|
||||
PluginCommand command = plugin.getCommand(getCommandName());
|
||||
if(command != null) {
|
||||
if (command != null) {
|
||||
command.setExecutor(this);
|
||||
command.setTabCompleter(this);
|
||||
}
|
||||
|
@ -21,30 +21,33 @@ public class Crafting {
|
||||
private static List<ShapedRecipe> shapedRecipes;
|
||||
private static List<ShapelessRecipe> shapelessRecipes;
|
||||
|
||||
public static void load(){
|
||||
public static void load() {
|
||||
shapedRecipes = new ArrayList<>();
|
||||
shapelessRecipes = new ArrayList<>();
|
||||
Bukkit.recipeIterator().forEachRemaining(recipe -> {
|
||||
if(recipe instanceof ShapedRecipe){ shapedRecipes.add((ShapedRecipe) recipe); }
|
||||
if(recipe instanceof ShapelessRecipe){ shapelessRecipes.add((ShapelessRecipe) recipe); }
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
shapedRecipes.add((ShapedRecipe) recipe);
|
||||
}
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
shapelessRecipes.add((ShapelessRecipe) recipe);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Recipe getResult(List<ItemStack> craftingTable){
|
||||
public static Recipe getResult(List<ItemStack> craftingTable) {
|
||||
Recipe returnRecipe = null;
|
||||
Iterator<Recipe> iterator = Bukkit.recipeIterator();
|
||||
while (iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
Recipe recipe = iterator.next();
|
||||
if(recipe instanceof ShapedRecipe){
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
ShapedRecipe shapedRecipe = (ShapedRecipe) recipe;
|
||||
if (matchesShaped(shapedRecipe, craftingTable)){
|
||||
if (matchesShaped(shapedRecipe, craftingTable)) {
|
||||
returnRecipe = shapedRecipe;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(recipe instanceof ShapelessRecipe){
|
||||
} else if (recipe instanceof ShapelessRecipe) {
|
||||
ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe;
|
||||
if (matchesShapeless(shapelessRecipe.getChoiceList(), craftingTable)){
|
||||
if (matchesShapeless(shapelessRecipe.getChoiceList(), craftingTable)) {
|
||||
returnRecipe = shapelessRecipe;
|
||||
break;
|
||||
}
|
||||
@ -71,7 +74,7 @@ public class Crafting {
|
||||
return false;
|
||||
}
|
||||
Set<ItemStack> remainingItems = new HashSet<>(items);
|
||||
return (remainingItems.size() == 1 && (items.contains(new ItemStack(Material.AIR))||items.contains(null)));
|
||||
return (remainingItems.size() == 1 && (items.contains(new ItemStack(Material.AIR)) || items.contains(null)));
|
||||
}
|
||||
|
||||
private static boolean matchesShaped(ShapedRecipe shape, List<ItemStack> items) {
|
||||
@ -79,9 +82,9 @@ public class Crafting {
|
||||
return userShapedRecipe.matchesRecipe(shape);
|
||||
}
|
||||
|
||||
public static Recipe getRecipeByKey(NamespacedKey key){
|
||||
public static Recipe getRecipeByKey(NamespacedKey key) {
|
||||
Optional<ShapelessRecipe> recipe = shapelessRecipes.stream().filter(s -> s.getKey().equals(key)).findFirst();
|
||||
if(recipe.isPresent()) return recipe.get();
|
||||
if (recipe.isPresent()) return recipe.get();
|
||||
|
||||
Optional<ShapedRecipe> shapedRecipe = shapedRecipes.stream().filter(s -> s.getKey().equals(key)).findFirst();
|
||||
return shapedRecipe.orElse(null);
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.inventory.Recipe;
|
||||
public class ToolRepairRecipe implements Recipe {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return null;
|
||||
|
@ -13,13 +13,15 @@ public class UserShapedRecipe {
|
||||
|
||||
private String[] shape;
|
||||
private Map<Character, ItemStack> ingredientMap;
|
||||
private Character[] chars = new Character[]{'a','b','c','d','e','f','g','h','i'};
|
||||
private final Character[] chars = new Character[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'};
|
||||
|
||||
public UserShapedRecipe(List<ItemStack> itemStacks){
|
||||
if(itemStacks.size() < 9) throw new IllegalArgumentException("ItemStack List must contain 9 items");
|
||||
if(itemStacks.size() == 10) itemStacks.remove(0);
|
||||
int firstRow=-1; int lastRow=0;
|
||||
int firstCol=-1; int lastCol=0;
|
||||
public UserShapedRecipe(List<ItemStack> itemStacks) {
|
||||
if (itemStacks.size() < 9) throw new IllegalArgumentException("ItemStack List must contain 9 items");
|
||||
if (itemStacks.size() == 10) itemStacks.remove(0);
|
||||
int firstRow = -1;
|
||||
int lastRow = 0;
|
||||
int firstCol = -1;
|
||||
int lastCol = 0;
|
||||
|
||||
for (int row = 0; row < 3; row++) {
|
||||
boolean removeRow = true;
|
||||
@ -30,8 +32,8 @@ public class UserShapedRecipe {
|
||||
}
|
||||
}
|
||||
if (!removeRow) {
|
||||
if(firstRow == -1) firstRow = row;
|
||||
if(row > lastRow) lastRow = row;
|
||||
if (firstRow == -1) firstRow = row;
|
||||
if (row > lastRow) lastRow = row;
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,24 +46,24 @@ public class UserShapedRecipe {
|
||||
}
|
||||
}
|
||||
if (!removeCol) {
|
||||
if(firstCol == -1) firstCol = col;
|
||||
if(col > lastCol) lastCol = col;
|
||||
if (firstCol == -1) firstCol = col;
|
||||
if (col > lastCol) lastCol = col;
|
||||
}
|
||||
}
|
||||
|
||||
if(firstRow == -1) firstRow = 0;
|
||||
if(firstCol == -1) firstCol = 0;
|
||||
if (firstRow == -1) firstRow = 0;
|
||||
if (firstCol == -1) firstCol = 0;
|
||||
|
||||
int index = 0;
|
||||
int rowIndex = 0;
|
||||
String[] shape = new String[(lastRow-firstRow+1)];
|
||||
Map<Character,ItemStack> itemMap = new HashMap<>();
|
||||
for(int row=firstRow; row <= lastRow; row++){
|
||||
String[] shape = new String[(lastRow - firstRow + 1)];
|
||||
Map<Character, ItemStack> itemMap = new HashMap<>();
|
||||
for (int row = firstRow; row <= lastRow; row++) {
|
||||
StringBuilder shapeRow = new StringBuilder();
|
||||
for(int col=firstCol; col <= lastCol; col++){
|
||||
shapeRow.append(chars[index]);
|
||||
itemMap.put(chars[index], itemStacks.get((row * 3) + col));
|
||||
index++;
|
||||
for (int col = firstCol; col <= lastCol; col++) {
|
||||
shapeRow.append(chars[index]);
|
||||
itemMap.put(chars[index], itemStacks.get((row * 3) + col));
|
||||
index++;
|
||||
}
|
||||
shape[rowIndex] = shapeRow.toString();
|
||||
rowIndex++;
|
||||
@ -86,47 +88,47 @@ public class UserShapedRecipe {
|
||||
this.ingredientMap = ingredientMap;
|
||||
}
|
||||
|
||||
public boolean matchesRecipe(ShapedRecipe recipe){
|
||||
if(!Arrays.equals(getShape(), recipe.getShape())) return false;
|
||||
if(!matchesChoiceMap(recipe.getChoiceMap(),recipe.getShape(),false)) {
|
||||
public boolean matchesRecipe(ShapedRecipe recipe) {
|
||||
if (!Arrays.equals(getShape(), recipe.getShape())) return false;
|
||||
if (!matchesChoiceMap(recipe.getChoiceMap(), recipe.getShape(), false)) {
|
||||
return matchesChoiceMap(recipe.getChoiceMap(), recipe.getShape(), true);
|
||||
}
|
||||
return true; // ingredients match
|
||||
}
|
||||
|
||||
private Map<Character,Character> flipShape(String[] shape){
|
||||
Map<Character,Character> map = new HashMap<>();
|
||||
for(int i=0; i < shape.length; i++){
|
||||
private Map<Character, Character> flipShape(String[] shape) {
|
||||
Map<Character, Character> map = new HashMap<>();
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
StringBuilder input = new StringBuilder();
|
||||
String row = shape[i];
|
||||
String reverse = input.append(row).reverse().toString();
|
||||
char[] originalChars = row.toCharArray();
|
||||
char[] reverseChars = reverse.toCharArray();
|
||||
for(int c=0; c < row.length(); c++){
|
||||
map.put(originalChars[c],reverseChars[c]);
|
||||
for (int c = 0; c < row.length(); c++) {
|
||||
map.put(originalChars[c], reverseChars[c]);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private boolean matchesChoiceMap(Map<Character, RecipeChoice> choiceMap, String[] shape, boolean mirror){
|
||||
private boolean matchesChoiceMap(Map<Character, RecipeChoice> choiceMap, String[] shape, boolean mirror) {
|
||||
boolean matches = true;
|
||||
Map<Character,Character> charMap = null;
|
||||
if(mirror) charMap = flipShape(shape);
|
||||
for(Map.Entry<Character,RecipeChoice> entry : choiceMap.entrySet()){
|
||||
Map<Character, Character> charMap = null;
|
||||
if (mirror) charMap = flipShape(shape);
|
||||
for (Map.Entry<Character, RecipeChoice> entry : choiceMap.entrySet()) {
|
||||
RecipeChoice choice = entry.getValue();
|
||||
//Flip characters if mirrored.
|
||||
Character character;
|
||||
if(mirror) character = charMap.get(entry.getKey());
|
||||
if (mirror) character = charMap.get(entry.getKey());
|
||||
else character = entry.getKey();
|
||||
|
||||
ItemStack item = getIngredientMap().get(character);
|
||||
if(choice != null && item != null) {
|
||||
if (choice != null && item != null) {
|
||||
if (!choice.test(item)) {
|
||||
matches = false;
|
||||
break;
|
||||
}
|
||||
} else if(choice == null ^ item == null) {
|
||||
} else if (choice == null ^ item == null) {
|
||||
matches = false;
|
||||
break;
|
||||
}
|
||||
|
@ -12,28 +12,27 @@ public class Filter {
|
||||
NONE
|
||||
}
|
||||
|
||||
private ItemStack filter;
|
||||
private boolean filterByItemMeta;
|
||||
private boolean dontAllowThisItem;
|
||||
private Type filteringMethod;
|
||||
private final ItemStack filter;
|
||||
private final boolean filterByItemMeta;
|
||||
private final boolean dontAllowThisItem;
|
||||
private final Type filteringMethod;
|
||||
|
||||
public Filter(ItemStack filter, ItemFrame itemFrame){
|
||||
public Filter(ItemStack filter, ItemFrame itemFrame) {
|
||||
this.filter = filter;
|
||||
this.filterByItemMeta = itemFrame.getRotation().equals(Rotation.FLIPPED) || itemFrame.getRotation().equals(Rotation.COUNTER_CLOCKWISE);
|
||||
this.dontAllowThisItem = itemFrame.getRotation().equals(Rotation.CLOCKWISE) || itemFrame.getRotation().equals(Rotation.COUNTER_CLOCKWISE);
|
||||
filteringMethod = dontAllowThisItem ? Type.REJECT : Type.ACCEPT;
|
||||
}
|
||||
|
||||
public Type getFilterType(ItemStack itemStack){
|
||||
if(dontAllowThisItem && !filterByItemMeta){
|
||||
if(filter.isSimilar(itemStack)) return Type.REJECT;
|
||||
public Type getFilterType(ItemStack itemStack) {
|
||||
if (dontAllowThisItem && !filterByItemMeta) {
|
||||
if (filter.isSimilar(itemStack)) return Type.REJECT;
|
||||
else return Type.ACCEPT;
|
||||
} else if (dontAllowThisItem) {
|
||||
if (isFilteredByMeta(itemStack)) return Type.REJECT;
|
||||
else return Type.ACCEPT;
|
||||
}
|
||||
else if (dontAllowThisItem){
|
||||
if(isFilteredByMeta(itemStack)) return Type.REJECT;
|
||||
else return Type.ACCEPT;
|
||||
}
|
||||
if(filterByItemMeta) {
|
||||
if (filterByItemMeta) {
|
||||
if (isFilteredByMeta(itemStack)) return Type.ACCEPT;
|
||||
} else {
|
||||
if (filter.isSimilar(itemStack)) return Type.ACCEPT;
|
||||
@ -41,15 +40,15 @@ public class Filter {
|
||||
return Type.NONE;
|
||||
}
|
||||
|
||||
private boolean isFilteredByMeta(ItemStack itemStack){
|
||||
if(filter.isSimilar(itemStack)) return true;
|
||||
if(filterByItemMeta){
|
||||
private boolean isFilteredByMeta(ItemStack itemStack) {
|
||||
if (filter.isSimilar(itemStack)) return true;
|
||||
if (filterByItemMeta) {
|
||||
return filter.getType().equals(itemStack.getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Type getFilteringMethod(){
|
||||
public Type getFilteringMethod() {
|
||||
return filteringMethod;
|
||||
}
|
||||
}
|
||||
|
@ -13,33 +13,33 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class HopperFilter {
|
||||
|
||||
public static boolean isInFilter(List<Filter> filters, ItemStack item){
|
||||
if(filters == null) return true;
|
||||
if(filters.size() == 0) return true;
|
||||
public static boolean isInFilter(List<Filter> filters, ItemStack item) {
|
||||
if (filters == null) return true;
|
||||
if (filters.size() == 0) return true;
|
||||
List<Filter> acceptFilters = filters.stream().filter(filter -> filter.getFilteringMethod() == Filter.Type.ACCEPT).collect(Collectors.toList());
|
||||
boolean hasAcceptFilter = acceptFilters.stream().anyMatch(filter -> filter.getFilterType(item).equals(Filter.Type.ACCEPT));
|
||||
boolean isRejected = filters.stream().filter(filter -> filter.getFilteringMethod() == Filter.Type.REJECT).anyMatch(filter -> filter.getFilterType(item).equals(Filter.Type.REJECT));
|
||||
if(acceptFilters.size() > 0) return hasAcceptFilter && !isRejected;
|
||||
if (acceptFilters.size() > 0) return hasAcceptFilter && !isRejected;
|
||||
else return !isRejected;
|
||||
}
|
||||
|
||||
public static List<Filter> getHopperFilters(Block block){
|
||||
Collection<Entity> ent = block.getWorld().getNearbyEntities(block.getLocation(),1.01,1.01,1.01);
|
||||
public static List<Filter> getHopperFilters(Block block) {
|
||||
Collection<Entity> ent = block.getWorld().getNearbyEntities(block.getLocation(), 1.01, 1.01, 1.01);
|
||||
List<Filter> filters = new ArrayList<>(ent.size());
|
||||
for(Entity entity : ent){
|
||||
if(entity instanceof ItemFrame){
|
||||
for (Entity entity : ent) {
|
||||
if (entity instanceof ItemFrame) {
|
||||
ItemFrame frame = (ItemFrame) entity;
|
||||
if(frame.getItem().getType().equals(Material.AIR)) continue;
|
||||
if (frame.getItem().getType().equals(Material.AIR)) continue;
|
||||
Block attachedBlock = frame.getLocation().getBlock().getRelative(frame.getAttachedFace());
|
||||
if(block.equals(attachedBlock)){
|
||||
filters.add(new Filter(frame.getItem(),frame));
|
||||
if (block.equals(attachedBlock)) {
|
||||
filters.add(new Filter(frame.getItem(), frame));
|
||||
}
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
public static boolean isInFilter(Block block, ItemStack itemStack){
|
||||
return isInFilter(getHopperFilters(block),itemStack);
|
||||
public static boolean isInFilter(Block block, ItemStack itemStack) {
|
||||
return isInFilter(getHopperFilters(block), itemStack);
|
||||
}
|
||||
}
|
||||
|
@ -33,22 +33,22 @@ import java.util.List;
|
||||
|
||||
public class VirtualCraftingHolder implements InventoryHolder {
|
||||
|
||||
private Inventory inventory;
|
||||
private AutoCraftingStorage storage;
|
||||
private final Inventory inventory;
|
||||
private final AutoCraftingStorage storage;
|
||||
private BukkitRunnable guiTask;
|
||||
private BukkitRunnable craftItemTask;
|
||||
|
||||
private ItemStack[][] recipeChoices = new ItemStack[9][];
|
||||
private ItemStack result;
|
||||
private int[] recipeChoiceIndex = new int[9];
|
||||
private final int[] recipeChoiceIndex = new int[9];
|
||||
private boolean hasCompleteRecipe = false;
|
||||
|
||||
/**
|
||||
* This gets set to true when updateCrafting() gets called on a 1 tick delay.
|
||||
* This gets set to true when updateCrafting() gets called on a 1 tick delay.
|
||||
*/
|
||||
private boolean isUpdatingRecipe = false;
|
||||
|
||||
private static ItemStack AIR = new ItemStack(Material.AIR);
|
||||
private static final ItemStack AIR = new ItemStack(Material.AIR);
|
||||
|
||||
public VirtualCraftingHolder(AutoCraftingStorage storage) {
|
||||
this.storage = storage;
|
||||
@ -65,12 +65,12 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void setCrafting(ShapelessRecipe shapelessRecipe){
|
||||
public void setCrafting(ShapelessRecipe shapelessRecipe) {
|
||||
result = shapelessRecipe.getResult();
|
||||
List<RecipeChoice> choiceList = shapelessRecipe.getChoiceList();
|
||||
for(int i=0; i<choiceList.size(); i++){
|
||||
for (int i = 0; i < choiceList.size(); i++) {
|
||||
RecipeChoice recipeChoice = choiceList.get(i);
|
||||
if(recipeChoice instanceof RecipeChoice.MaterialChoice){
|
||||
if (recipeChoice instanceof RecipeChoice.MaterialChoice) {
|
||||
RecipeChoice.MaterialChoice materialChoice = (RecipeChoice.MaterialChoice) recipeChoice;
|
||||
ItemStack[] choices = materialChoice.getChoices().stream().map(ItemStack::new).toArray(ItemStack[]::new);
|
||||
recipeChoices[i] = choices;
|
||||
@ -79,14 +79,14 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
setHasCompleteRecipe();
|
||||
}
|
||||
|
||||
public void setCrafting(ShapedRecipe recipe){
|
||||
public void setCrafting(ShapedRecipe recipe) {
|
||||
result = recipe.getResult();
|
||||
int row = 0;
|
||||
for(String r : recipe.getShape()){
|
||||
for (String r : recipe.getShape()) {
|
||||
int col = 0;
|
||||
for(char c : r.toCharArray()){
|
||||
for (char c : r.toCharArray()) {
|
||||
RecipeChoice recipeChoice = recipe.getChoiceMap().get(c);
|
||||
if(recipeChoice instanceof RecipeChoice.MaterialChoice){
|
||||
if (recipeChoice instanceof RecipeChoice.MaterialChoice) {
|
||||
RecipeChoice.MaterialChoice materialChoice = (RecipeChoice.MaterialChoice) recipeChoice;
|
||||
ItemStack[] choices = materialChoice.getChoices().stream().map(ItemStack::new).toArray(ItemStack[]::new);
|
||||
int i = (row * 3) + col;
|
||||
@ -99,32 +99,32 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
setHasCompleteRecipe();
|
||||
}
|
||||
|
||||
public void setCrafting(Recipe recipe){
|
||||
if(recipe instanceof ShapedRecipe) setCrafting((ShapedRecipe) recipe);
|
||||
if(recipe instanceof ShapelessRecipe) setCrafting((ShapelessRecipe) recipe);
|
||||
public void setCrafting(Recipe recipe) {
|
||||
if (recipe instanceof ShapedRecipe) setCrafting((ShapedRecipe) recipe);
|
||||
if (recipe instanceof ShapelessRecipe) setCrafting((ShapelessRecipe) recipe);
|
||||
}
|
||||
|
||||
private void setHasCompleteRecipe(){
|
||||
private void setHasCompleteRecipe() {
|
||||
hasCompleteRecipe = true;
|
||||
startCraftingItems();
|
||||
}
|
||||
|
||||
public void resetChoices(){
|
||||
public void resetChoices() {
|
||||
recipeChoices = new ItemStack[9][];
|
||||
result = null;
|
||||
hasCompleteRecipe = false;
|
||||
stopCraftingItems();
|
||||
}
|
||||
|
||||
public void updateCrafting(){
|
||||
public void updateCrafting() {
|
||||
List<ItemStack> craftingMatrix = new ArrayList<>(Arrays.asList(inventory.getContents()));
|
||||
if (craftingMatrix.get(0) != null) craftingMatrix.remove(0);
|
||||
Recipe recipe = Crafting.getResult(craftingMatrix);
|
||||
getStorage().setRecipe(recipe);
|
||||
resetChoices();
|
||||
if(recipe != null){
|
||||
if (recipe != null) {
|
||||
setCrafting(recipe);
|
||||
playSound(Sound.BLOCK_NOTE_BLOCK_CHIME,0.5f,1f);
|
||||
playSound(Sound.BLOCK_NOTE_BLOCK_CHIME, 0.5f, 1f);
|
||||
} else {
|
||||
stopCraftingItems();
|
||||
}
|
||||
@ -133,7 +133,7 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
storage.onItemDisplayUpdate(result);
|
||||
}
|
||||
|
||||
private void playSound(Sound sound, float volume, float pitch){
|
||||
private void playSound(Sound sound, float volume, float pitch) {
|
||||
storage.getInventory().getViewers().forEach(humanEntity -> {
|
||||
humanEntity.getWorld().playSound(humanEntity.getLocation(), sound, volume, pitch);
|
||||
});
|
||||
@ -145,27 +145,30 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
}
|
||||
|
||||
//Start and stop animation based on if the inventory is open.
|
||||
public void startAnimation(){
|
||||
public void startAnimation() {
|
||||
guiTask = new UpdateTask();
|
||||
}
|
||||
public void stopAnimation(){
|
||||
if(guiTask != null) guiTask.cancel();
|
||||
|
||||
public void stopAnimation() {
|
||||
if (guiTask != null) guiTask.cancel();
|
||||
}
|
||||
|
||||
private class UpdateTask extends BukkitRunnable {
|
||||
BukkitTask task;
|
||||
public UpdateTask(){
|
||||
task = runTaskTimer(ChestsPlusPlus.PLUGIN,1,15);
|
||||
|
||||
public UpdateTask() {
|
||||
task = runTaskTimer(ChestsPlusPlus.PLUGIN, 1, 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
updateGUI();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGUI(){
|
||||
public void updateGUI() {
|
||||
inventory.setItem(0, result);
|
||||
if(hasCompleteRecipe && !isUpdatingRecipe) {
|
||||
if (hasCompleteRecipe && !isUpdatingRecipe) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack[] choices = recipeChoices[i];
|
||||
if (choices != null) {
|
||||
@ -186,18 +189,21 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
}
|
||||
}
|
||||
|
||||
public void startCraftingItems(){
|
||||
if(craftItemTask == null || craftItemTask.isCancelled()) craftItemTask = new CraftItems();
|
||||
public void startCraftingItems() {
|
||||
if (craftItemTask == null || craftItemTask.isCancelled()) craftItemTask = new CraftItems();
|
||||
}
|
||||
public void stopCraftingItems(){
|
||||
if(craftItemTask != null) craftItemTask.cancel();
|
||||
|
||||
public void stopCraftingItems() {
|
||||
if (craftItemTask != null) craftItemTask.cancel();
|
||||
}
|
||||
|
||||
private class CraftItems extends BukkitRunnable {
|
||||
BukkitTask task;
|
||||
CraftItems(){
|
||||
|
||||
CraftItems() {
|
||||
task = runTaskTimer(ChestsPlusPlus.PLUGIN, 1, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
craftItem();
|
||||
@ -208,27 +214,27 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
* This method will craft an item if a chest above contains the correct amount of materials
|
||||
* And there is a hopper below.
|
||||
*/
|
||||
public void craftItem(){
|
||||
for(LocationInfo location : storage.getLocations()){
|
||||
if(!Utils.isLocationChunkLoaded(location.getLocation())) continue;
|
||||
public void craftItem() {
|
||||
for (LocationInfo location : storage.getLocations()) {
|
||||
if (!Utils.isLocationChunkLoaded(location.getLocation())) continue;
|
||||
Block block = location.getLocation().getBlock();
|
||||
Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
Block blockAbove = block.getRelative(BlockFace.UP);
|
||||
|
||||
Inventory output;
|
||||
|
||||
if(blockBelow.getState() instanceof Hopper){
|
||||
if (blockBelow.getState() instanceof Hopper) {
|
||||
Hopper hopper = (Hopper) blockBelow.getState();
|
||||
if(blockBelow.isBlockPowered() || blockBelow.isBlockIndirectlyPowered()){
|
||||
if (blockBelow.isBlockPowered() || blockBelow.isBlockIndirectlyPowered()) {
|
||||
continue; //If hopper is powered no crafting should happen.
|
||||
}
|
||||
output = hopper.getInventory();
|
||||
} else {
|
||||
output = getInventory(blockBelow);
|
||||
//If there is no output crafting isn't possible, so skip this location.
|
||||
if(output == null) continue;
|
||||
if (output == null) continue;
|
||||
//If crafting table is powered output into container is possible.
|
||||
if(!block.isBlockPowered()) continue;
|
||||
if (!block.isBlockPowered()) continue;
|
||||
}
|
||||
|
||||
List<Inventory> inventories = new ArrayList<>();
|
||||
@ -238,10 +244,10 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
Utils.addIfNotNull(inventories, getInventory(block.getRelative(BlockFace.SOUTH)));
|
||||
Utils.addIfNotNull(inventories, getInventory(block.getRelative(BlockFace.WEST)));
|
||||
|
||||
boolean didCraft = craftItem(inventories,output);
|
||||
boolean didCraft = craftItem(inventories, output);
|
||||
|
||||
//Play sound if crafting occured.
|
||||
if(didCraft) {
|
||||
if (didCraft) {
|
||||
if (location.getLocation().getWorld() != null) {
|
||||
location.getLocation().getWorld().playSound(location.getLocation(), Sound.BLOCK_DISPENSER_DISPENSE, 0.25f, 1f);
|
||||
if (output.getHolder() instanceof VirtualInventoryHolder) {
|
||||
@ -252,13 +258,13 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
}
|
||||
}
|
||||
|
||||
private Inventory getInventory(Block block){
|
||||
private Inventory getInventory(Block block) {
|
||||
Inventory inventory = null;
|
||||
if(block.getState() instanceof Container){
|
||||
if (block.getState() instanceof Container) {
|
||||
ChestLinkStorage storage = Config.getChestLink().getStorage(block.getLocation());
|
||||
//Check if a ChestLink exists above the CraftingTable and if the owner of the CraftingTable has permission to access that Chest.
|
||||
if(storage != null){
|
||||
if(storage.hasPermission(this.storage.getOwner())) {
|
||||
if (storage != null) {
|
||||
if (storage.hasPermission(this.storage.getOwner())) {
|
||||
inventory = storage.getInventory();
|
||||
} else {
|
||||
return null;
|
||||
@ -270,7 +276,7 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
private boolean craftItem(List<Inventory> inputs, Inventory output){
|
||||
private boolean craftItem(List<Inventory> inputs, Inventory output) {
|
||||
boolean sameInv = false;
|
||||
Inventory sameInventory = null;
|
||||
List<Inventory> tempInvs = new ArrayList<>();
|
||||
@ -278,17 +284,17 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
for (Inventory inv : inputs) {
|
||||
Inventory tempInv = Utils.copyInventory(inv);
|
||||
tempInvs.add(tempInv);
|
||||
if(inv.equals(output)){
|
||||
if (inv.equals(output)) {
|
||||
sameInv = true;
|
||||
sameInventory = tempInv;
|
||||
}
|
||||
}
|
||||
|
||||
for(ItemStack[] choices : recipeChoices){
|
||||
if(choices == null) continue;
|
||||
for (ItemStack[] choices : recipeChoices) {
|
||||
if (choices == null) continue;
|
||||
boolean foundMatch = false;
|
||||
for(ItemStack choice : choices){
|
||||
for(Inventory tempInv : tempInvs) {
|
||||
for (ItemStack choice : choices) {
|
||||
for (Inventory tempInv : tempInvs) {
|
||||
int index = tempInv.first(choice.getType());
|
||||
if (index != -1) {
|
||||
ItemStack item = tempInv.getItem(index);
|
||||
@ -302,7 +308,7 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
}
|
||||
}
|
||||
//If no match
|
||||
if(!foundMatch) return false;
|
||||
if (!foundMatch) return false;
|
||||
}
|
||||
|
||||
//If we reach here there are enough materials so check for space in the Hopper and update inventory.
|
||||
@ -311,25 +317,25 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
HashMap map = tempOutput.addItem(result.clone());
|
||||
|
||||
//If result fits into output copy over the temporary inventories.
|
||||
if(map.isEmpty()){
|
||||
for(int i=0; i<tempInvs.size(); i++) {
|
||||
if (map.isEmpty()) {
|
||||
for (int i = 0; i < tempInvs.size(); i++) {
|
||||
moveTempInv(tempInvs.get(i), inputs.get(i));
|
||||
}
|
||||
if(!sameInv) moveTempInv(tempOutput, output);
|
||||
if (!sameInv) moveTempInv(tempOutput, output);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void moveTempInv(Inventory tempInv, Inventory realInv){
|
||||
private void moveTempInv(Inventory tempInv, Inventory realInv) {
|
||||
ItemStack[] contents = new ItemStack[realInv.getSize()];
|
||||
System.arraycopy(tempInv.getContents(), 0, contents,0,realInv.getSize());
|
||||
System.arraycopy(tempInv.getContents(), 0, contents, 0, realInv.getSize());
|
||||
realInv.setContents(contents);
|
||||
}
|
||||
|
||||
public void forceUpdateInventory(){
|
||||
public void forceUpdateInventory() {
|
||||
inventory.getViewers().forEach(humanEntity -> {
|
||||
if(humanEntity instanceof Player){
|
||||
if (humanEntity instanceof Player) {
|
||||
((Player) humanEntity).updateInventory();
|
||||
}
|
||||
});
|
||||
|
@ -13,9 +13,9 @@ public class VirtualInventoryHolder implements InventoryHolder {
|
||||
|
||||
private Runnable openPreviousInventory;
|
||||
private boolean isPrevInvRunning = false;
|
||||
private HashMap<UUID, Boolean> remoteOpened;
|
||||
private final HashMap<UUID, Boolean> remoteOpened;
|
||||
|
||||
public VirtualInventoryHolder(ChestLinkStorage storage){
|
||||
public VirtualInventoryHolder(ChestLinkStorage storage) {
|
||||
this.storage = storage;
|
||||
remoteOpened = new HashMap<>();
|
||||
}
|
||||
@ -25,11 +25,11 @@ public class VirtualInventoryHolder implements InventoryHolder {
|
||||
return storage.getInventory();
|
||||
}
|
||||
|
||||
public ChestLinkStorage getStorage(){
|
||||
public ChestLinkStorage getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void setPreviousInventory(Runnable runnable){
|
||||
public void setPreviousInventory(Runnable runnable) {
|
||||
openPreviousInventory = runnable;
|
||||
isPrevInvRunning = false;
|
||||
}
|
||||
@ -37,12 +37,12 @@ public class VirtualInventoryHolder implements InventoryHolder {
|
||||
/**
|
||||
* @return true if previous inventory existed.
|
||||
*/
|
||||
public boolean openPreviousInventory(){
|
||||
if(isPrevInvRunning){
|
||||
public boolean openPreviousInventory() {
|
||||
if (isPrevInvRunning) {
|
||||
isPrevInvRunning = false;
|
||||
return false;
|
||||
}
|
||||
if(openPreviousInventory != null){
|
||||
if (openPreviousInventory != null) {
|
||||
isPrevInvRunning = true;
|
||||
openPreviousInventory.run();
|
||||
openPreviousInventory = null;
|
||||
@ -53,20 +53,22 @@ public class VirtualInventoryHolder implements InventoryHolder {
|
||||
|
||||
/**
|
||||
* Called when a player remotely opens this inventory.
|
||||
*
|
||||
* @param uuid - the players uuid.
|
||||
*/
|
||||
public void onPlayerRemoteOpened(UUID uuid){
|
||||
remoteOpened.put(uuid,true);
|
||||
public void onPlayerRemoteOpened(UUID uuid) {
|
||||
remoteOpened.put(uuid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player remotely opened this inventory, if so returns true and sets their remoteOpen to false.
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public boolean didPlayerRemoteOpen(UUID uuid){
|
||||
if(remoteOpened.getOrDefault(uuid,false)){
|
||||
remoteOpened.put(uuid,false);
|
||||
public boolean didPlayerRemoteOpen(UUID uuid) {
|
||||
if (remoteOpened.getOrDefault(uuid, false)) {
|
||||
remoteOpened.put(uuid, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -22,25 +22,25 @@ public class ChestLinkMenu implements InventoryProvider {
|
||||
|
||||
public static HashMap<Player, SmartInventory> menus;
|
||||
|
||||
private Collection<ChestLinkStorage> storages;
|
||||
private SmartInventory menu;
|
||||
private final Collection<ChestLinkStorage> storages;
|
||||
private final SmartInventory menu;
|
||||
|
||||
private ChestLinkMenu(Player player){
|
||||
private ChestLinkMenu(Player player) {
|
||||
this.storages = Config.getChestLink().getStorageMap(player.getUniqueId()).values();
|
||||
menu = SmartInventory.builder()
|
||||
.id("chestLinkMenu")
|
||||
.title("Inventory Storage")
|
||||
.provider(this)
|
||||
.manager(ChestsPlusPlus.INVENTORY_MANAGER)
|
||||
.size(6,9)
|
||||
.size(6, 9)
|
||||
.build();
|
||||
//menu.setInsertable(true);
|
||||
}
|
||||
|
||||
public static SmartInventory getMenu(Player player){
|
||||
if(menus == null) menus = new HashMap<>();
|
||||
public static SmartInventory getMenu(Player player) {
|
||||
if (menus == null) menus = new HashMap<>();
|
||||
|
||||
if(menus.containsKey(player)){
|
||||
if (menus.containsKey(player)) {
|
||||
return menus.get(player);
|
||||
} else {
|
||||
menus.put(player, new ChestLinkMenu(player).getMenu());
|
||||
@ -53,12 +53,12 @@ public class ChestLinkMenu implements InventoryProvider {
|
||||
Pagination pagination = contents.pagination();
|
||||
|
||||
List<ClickableItem> itemList = new ArrayList<>();
|
||||
for(ChestLinkStorage storage : storages){
|
||||
for (ChestLinkStorage storage : storages) {
|
||||
ClickableItem item = storage.getClickableItem(player);
|
||||
itemList.add(item);
|
||||
}
|
||||
List<ChestLinkStorage> memberOfStorage = Config.getChestLink().getStorageMemberOf(player);
|
||||
for(ChestLinkStorage storage : memberOfStorage){
|
||||
for (ChestLinkStorage storage : memberOfStorage) {
|
||||
ClickableItem item = storage.getClickableItem(player);
|
||||
itemList.add(item);
|
||||
}
|
||||
@ -66,14 +66,14 @@ public class ChestLinkMenu implements InventoryProvider {
|
||||
pagination.setItems(itemList.toArray(new ClickableItem[0]));
|
||||
pagination.setItemsPerPage(28);
|
||||
|
||||
contents.fillBorders(ClickableItem.empty(Utils.getNamedItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE)," ")));
|
||||
for(ClickableItem item : pagination.getPageItems()){
|
||||
contents.fillBorders(ClickableItem.empty(Utils.getNamedItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " ")));
|
||||
for (ClickableItem item : pagination.getPageItems()) {
|
||||
contents.add(item);
|
||||
}
|
||||
|
||||
contents.set(5, 2, ClickableItem.from(Utils.getNamedItem(new ItemStack(Material.ARROW),"Previous"),
|
||||
contents.set(5, 2, ClickableItem.from(Utils.getNamedItem(new ItemStack(Material.ARROW), "Previous"),
|
||||
e -> menu.open(player, pagination.previous().getPage())));
|
||||
contents.set(5, 6, ClickableItem.from(Utils.getNamedItem(new ItemStack(Material.ARROW),"Next"),
|
||||
contents.set(5, 6, ClickableItem.from(Utils.getNamedItem(new ItemStack(Material.ARROW), "Next"),
|
||||
e -> menu.open(player, pagination.next().getPage())));
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ public class LangFileProperties {
|
||||
|
||||
public static void serialize(LanguageFile properties) {
|
||||
for (Message value : Message.values()) {
|
||||
properties.setProperty(value.toString(),value.getTaggedMessage());
|
||||
properties.setProperty(value.toString(), value.getTaggedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void deserialize(Properties properties){
|
||||
public static void deserialize(Properties properties) {
|
||||
properties.forEach((key, value) -> {
|
||||
try {
|
||||
String val = new String(((String) value).getBytes());
|
||||
@ -37,24 +37,24 @@ public class LangFileProperties {
|
||||
//Save the language file after reading to insert any missing values.
|
||||
LanguageFile savedProperties = new LanguageFile();
|
||||
serialize(savedProperties);
|
||||
if(currentFile != null) savedProperties.store(currentFile);
|
||||
if (currentFile != null) savedProperties.store(currentFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadLangFile(String fileName){
|
||||
if(fileName.equals("default")){
|
||||
public static void loadLangFile(String fileName) {
|
||||
if (fileName.equals("default")) {
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("Loaded default language file");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
currentFile = getLangFile(fileName,false);
|
||||
currentFile = getLangFile(fileName, false);
|
||||
LanguageFile properties = loadProperties(currentFile);
|
||||
deserialize(properties);
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("Loaded '"+fileName+"' language file");
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("Loaded '" + fileName + "' language file");
|
||||
} catch (IOException e) {
|
||||
ChestsPlusPlus.PLUGIN.getLogger().warning("Failed to load language file: "+fileName+". It should be located in "+ChestsPlusPlus.PLUGIN.getDataFolder().getPath()+"/lang/");
|
||||
ChestsPlusPlus.PLUGIN.getLogger().warning("Failed to load language file: " + fileName + ". It should be located in " + ChestsPlusPlus.PLUGIN.getDataFolder().getPath() + "/lang/");
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,9 +67,9 @@ public class LangFileProperties {
|
||||
|
||||
private static File getLangFile(String fileName, boolean create) throws IOException {
|
||||
File pluginDataFolder = ChestsPlusPlus.PLUGIN.getDataFolder();
|
||||
File file = new File(pluginDataFolder, "lang/"+fileName+".properties");
|
||||
File file = new File(pluginDataFolder, "lang/" + fileName + ".properties");
|
||||
file.getParentFile().mkdirs();
|
||||
if(create && !file.exists()) file.createNewFile();
|
||||
if (create && !file.exists()) file.createNewFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class LangFileProperties {
|
||||
fileProperties.generateEnglishLanguageFile();
|
||||
}
|
||||
|
||||
private LangFileProperties(){
|
||||
private LangFileProperties() {
|
||||
|
||||
}
|
||||
|
||||
@ -100,8 +100,8 @@ public class LangFileProperties {
|
||||
serialize(properties);
|
||||
properties.storeGenerated(langSrcFile);
|
||||
properties.storeGenerated(langTargetFile);
|
||||
LOGGER.info("Saved language file to: "+langSrcFile.getPath());
|
||||
LOGGER.info("Saved language file to: "+langTargetFile.getPath());
|
||||
LOGGER.info("Saved language file to: " + langSrcFile.getPath());
|
||||
LOGGER.info("Saved language file to: " + langTargetFile.getPath());
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to generate language file!");
|
||||
e.printStackTrace();
|
||||
|
@ -22,9 +22,8 @@ public class LanguageFile extends Properties {
|
||||
}
|
||||
|
||||
private void store0(BufferedWriter bw, boolean generated)
|
||||
throws IOException
|
||||
{
|
||||
if(generated) {
|
||||
throws IOException {
|
||||
if (generated) {
|
||||
writeComments(bw, " Chests++ Language File (Version " + BuildConstants.VERSION + "))");
|
||||
writeComments(bw,
|
||||
" NOTE: This file gets replaced when the plugin launches! If you want to make modifications create a copy first!\n" +
|
||||
@ -35,9 +34,9 @@ public class LanguageFile extends Properties {
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
for (Enumeration<?> e = keys(); e.hasMoreElements();) {
|
||||
String key = (String)e.nextElement();
|
||||
String val = (String)get(key);
|
||||
for (Enumeration<?> e = keys(); e.hasMoreElements(); ) {
|
||||
String key = (String) e.nextElement();
|
||||
String val = (String) get(key);
|
||||
key = saveConvert(key, true, false);
|
||||
/* No need to escape embedded and trailing spaces for value, hence
|
||||
* pass false to flag.
|
||||
@ -66,9 +65,9 @@ public class LanguageFile extends Properties {
|
||||
bw.write(comments.substring(last, current));
|
||||
if (c > '\u00ff') {
|
||||
uu[2] = toHex((c >> 12) & 0xf);
|
||||
uu[3] = toHex((c >> 8) & 0xf);
|
||||
uu[4] = toHex((c >> 4) & 0xf);
|
||||
uu[5] = toHex( c & 0xf);
|
||||
uu[3] = toHex((c >> 8) & 0xf);
|
||||
uu[4] = toHex((c >> 4) & 0xf);
|
||||
uu[5] = toHex(c & 0xf);
|
||||
bw.write(new String(uu));
|
||||
} else {
|
||||
bw.newLine();
|
||||
@ -105,46 +104,56 @@ public class LanguageFile extends Properties {
|
||||
}
|
||||
StringBuffer outBuffer = new StringBuffer(bufLen);
|
||||
|
||||
for(int x=0; x<len; x++) {
|
||||
for (int x = 0; x < len; x++) {
|
||||
char aChar = theString.charAt(x);
|
||||
// Handle common case first, selecting largest block that
|
||||
// avoids the specials below
|
||||
if ((aChar > 61) && (aChar < 127)) {
|
||||
if (aChar == '\\') {
|
||||
outBuffer.append('\\'); outBuffer.append('\\');
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append('\\');
|
||||
continue;
|
||||
}
|
||||
outBuffer.append(aChar);
|
||||
continue;
|
||||
}
|
||||
switch(aChar) {
|
||||
switch (aChar) {
|
||||
case ' ':
|
||||
if (x == 0 || escapeSpace)
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append(' ');
|
||||
break;
|
||||
case '\t':outBuffer.append('\\'); outBuffer.append('t');
|
||||
case '\t':
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append('t');
|
||||
break;
|
||||
case '\n':outBuffer.append('\\'); outBuffer.append('n');
|
||||
case '\n':
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append('n');
|
||||
break;
|
||||
case '\r':outBuffer.append('\\'); outBuffer.append('r');
|
||||
case '\r':
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append('r');
|
||||
break;
|
||||
case '\f':outBuffer.append('\\'); outBuffer.append('f');
|
||||
case '\f':
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append('f');
|
||||
break;
|
||||
case '=': // Fall through
|
||||
case ':': // Fall through
|
||||
case '#': // Fall through
|
||||
case '!':
|
||||
outBuffer.append('\\'); outBuffer.append(aChar);
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append(aChar);
|
||||
break;
|
||||
default:
|
||||
if (((aChar < 0x0020) || (aChar > 0x007e)) & escapeUnicode ) {
|
||||
if (((aChar < 0x0020) || (aChar > 0x007e)) & escapeUnicode) {
|
||||
outBuffer.append('\\');
|
||||
outBuffer.append('u');
|
||||
outBuffer.append(toHex((aChar >> 12) & 0xF));
|
||||
outBuffer.append(toHex((aChar >> 8) & 0xF));
|
||||
outBuffer.append(toHex((aChar >> 4) & 0xF));
|
||||
outBuffer.append(toHex( aChar & 0xF));
|
||||
outBuffer.append(toHex((aChar >> 8) & 0xF));
|
||||
outBuffer.append(toHex((aChar >> 4) & 0xF));
|
||||
outBuffer.append(toHex(aChar & 0xF));
|
||||
} else {
|
||||
outBuffer.append(aChar);
|
||||
}
|
||||
@ -155,14 +164,17 @@ public class LanguageFile extends Properties {
|
||||
|
||||
/**
|
||||
* Convert a nibble to a hex character
|
||||
* @param nibble the nibble to convert.
|
||||
*
|
||||
* @param nibble the nibble to convert.
|
||||
*/
|
||||
private static char toHex(int nibble) {
|
||||
return hexDigit[(nibble & 0xF)];
|
||||
}
|
||||
|
||||
/** A table of hex digits */
|
||||
/**
|
||||
* A table of hex digits
|
||||
*/
|
||||
private static final char[] hexDigit = {
|
||||
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
}
|
||||
|
@ -64,44 +64,47 @@ public enum Message {
|
||||
COMMAND_CHESTLINK_SETPUBLIC("Set a ChestLink to be accessible by anyone.");
|
||||
|
||||
String message;
|
||||
Message(String defaultMessage){
|
||||
|
||||
Message(String defaultMessage) {
|
||||
this(defaultMessage, new Tag[]{});
|
||||
}
|
||||
|
||||
Tag[] tags;
|
||||
Message(String defaultMessage, Tag... tags){
|
||||
|
||||
Message(String defaultMessage, Tag... tags) {
|
||||
message = defaultMessage;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to set different messages for different languages.
|
||||
*
|
||||
* @param message - the template string for the message.
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = detagMessage(message, tags);
|
||||
}
|
||||
|
||||
public String getTaggedMessage(){
|
||||
public String getTaggedMessage() {
|
||||
return tagMessage(message, tags);
|
||||
}
|
||||
|
||||
private static String detagMessage(String string, Tag[] tags){
|
||||
private static String detagMessage(String string, Tag[] tags) {
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
string = string.replaceAll("\\{"+tags[i]+"}", "{"+i+"}");
|
||||
string = string.replaceAll("\\{" + tags[i] + "}", "{" + i + "}");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
private static String tagMessage(String string, Tag[] tags){
|
||||
private static String tagMessage(String string, Tag[] tags) {
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
String replace = "\\{"+i+"}";
|
||||
string = string.replaceAll(replace, "{"+tags[i]+"}");
|
||||
String replace = "\\{" + i + "}";
|
||||
string = string.replaceAll(replace, "{" + tags[i] + "}");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public String getString(Object... args){
|
||||
public String getString(Object... args) {
|
||||
return MessageFormat.format(message, args);
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@ public class HopperListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onHopperMoveEvent(InventoryMoveItemEvent event) {
|
||||
//TO HOPPER
|
||||
if(event.getDestination().getHolder() instanceof Hopper){
|
||||
if(event.getDestination().getLocation() != null){
|
||||
if(event.getDestination().getLocation().getBlock().isBlockPowered()) return;
|
||||
if (event.getDestination().getHolder() instanceof Hopper) {
|
||||
if (event.getDestination().getLocation() != null) {
|
||||
if (event.getDestination().getLocation().getBlock().isBlockPowered()) return;
|
||||
}
|
||||
if(!event.isCancelled()) Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, ()-> {
|
||||
if (!event.isCancelled()) Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, () -> {
|
||||
VirtualChestToHopper.move(event.getDestination().getLocation(), event.getSource(), event.getDestination());
|
||||
}, 1);
|
||||
event.setCancelled(true);
|
||||
@ -43,23 +43,24 @@ public class HopperListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void fromHopper(InventoryMoveItemEvent event){
|
||||
public void fromHopper(InventoryMoveItemEvent event) {
|
||||
//FROM HOPPER
|
||||
if (event.getInitiator().getHolder() instanceof Hopper) {
|
||||
Location location = event.getDestination().getLocation();
|
||||
ChestLinkStorage storage = Config.getChestLink().getStorage(location);
|
||||
if (storage != null) {
|
||||
if(!event.isCancelled()) {
|
||||
if (!event.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(location != null) {
|
||||
if (location != null) {
|
||||
int hopperAmount = SpigotConfig.getWorldSettings(location.getWorld()).getHopperAmount();
|
||||
if (Utils.hopperMove(event.getSource(), hopperAmount, storage.getInventory())) {
|
||||
storage.updateDisplayItem();
|
||||
}
|
||||
if (event.getDestination().getHolder() != null) event.getDestination().getHolder().getInventory().clear();
|
||||
if (event.getDestination().getHolder() != null)
|
||||
event.getDestination().getHolder().getInventory().clear();
|
||||
if (storage.getInventory().getViewers().size() > 0) storage.sort();
|
||||
}
|
||||
}
|
||||
@ -70,35 +71,35 @@ public class HopperListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHopperPickup(InventoryPickupItemEvent event){
|
||||
if(event.getInventory().getHolder() instanceof Hopper){
|
||||
public void onHopperPickup(InventoryPickupItemEvent event) {
|
||||
if (event.getInventory().getHolder() instanceof Hopper) {
|
||||
event.setCancelled(!HopperFilter.isInFilter(event.getInventory().getLocation().getBlock(), event.getItem().getItemStack()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void itemFrameInteract(PlayerInteractEntityEvent event){
|
||||
if(event.isCancelled()) return;
|
||||
if(event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)){
|
||||
public void itemFrameInteract(PlayerInteractEntityEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
|
||||
Block attachedBlock = itemFrame.getLocation().getBlock().getRelative(itemFrame.getAttachedFace());
|
||||
if(!(attachedBlock.getState() instanceof Hopper)) return;
|
||||
if (!(attachedBlock.getState() instanceof Hopper)) return;
|
||||
Rotation rotation = itemFrame.getRotation();
|
||||
|
||||
//Set ItemFrame invisible based on config.
|
||||
ApiSpecific.getNmsProvider().setItemFrameVisible(itemFrame, !PluginConfig.INVISIBLE_FILTER_ITEM_FRAMES.get());
|
||||
|
||||
//ItemFrame event acts weird, it returns the values of the itemframe *before* the event. So we have to calculate what the next state will be.
|
||||
if(!itemFrame.getItem().getType().equals(Material.AIR)) rotation = rotation.rotateClockwise();
|
||||
if (!itemFrame.getItem().getType().equals(Material.AIR)) rotation = rotation.rotateClockwise();
|
||||
|
||||
if(rotation.equals(Rotation.FLIPPED)){
|
||||
event.getPlayer().sendMessage(ChatColor.AQUA+"ItemFrame now filters all types of this item! e.g Enchanted Books.");
|
||||
} else if(rotation.equals(Rotation.NONE)) {
|
||||
event.getPlayer().sendMessage(ChatColor.GREEN+"ItemFrame is in default filtering mode. Rotate Item Frame to change mode!");
|
||||
} else if(rotation.equals(Rotation.CLOCKWISE)) {
|
||||
event.getPlayer().sendMessage(ChatColor.DARK_RED+"ItemFrame now prevents this item from being accepted in the hopper!");
|
||||
} else if(rotation.equals(Rotation.COUNTER_CLOCKWISE)) {
|
||||
event.getPlayer().sendMessage(ChatColor.GOLD+"ItemFrame now prevents all types of this item from being accepted in the hopper! e.g Enchanted Books.");
|
||||
if (rotation.equals(Rotation.FLIPPED)) {
|
||||
event.getPlayer().sendMessage(ChatColor.AQUA + "ItemFrame now filters all types of this item! e.g Enchanted Books.");
|
||||
} else if (rotation.equals(Rotation.NONE)) {
|
||||
event.getPlayer().sendMessage(ChatColor.GREEN + "ItemFrame is in default filtering mode. Rotate Item Frame to change mode!");
|
||||
} else if (rotation.equals(Rotation.CLOCKWISE)) {
|
||||
event.getPlayer().sendMessage(ChatColor.DARK_RED + "ItemFrame now prevents this item from being accepted in the hopper!");
|
||||
} else if (rotation.equals(Rotation.COUNTER_CLOCKWISE)) {
|
||||
event.getPlayer().sendMessage(ChatColor.GOLD + "ItemFrame now prevents all types of this item from being accepted in the hopper! e.g Enchanted Books.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryPlayerUpdate(InventoryClickEvent event){
|
||||
public void onInventoryPlayerUpdate(InventoryClickEvent event) {
|
||||
inventoryUpdate(event);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onInventoryOpen(InventoryOpenEvent event){
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
try {
|
||||
if (event.getPlayer() instanceof Player) {
|
||||
if (event.getInventory().getLocation() != null) {
|
||||
@ -50,9 +50,9 @@ public class InventoryListener implements Listener {
|
||||
//If no Inventory Storage here check for AutoCraft
|
||||
AutoCraftingStorage craftingStorage = Config.getAutoCraft().getStorage(event.getInventory().getLocation());
|
||||
|
||||
if(craftingStorage != null){
|
||||
if (craftingStorage != null) {
|
||||
event.setCancelled(true);
|
||||
if(event.getPlayer().hasPermission(Permissions.AUTOCRAFT_OPEN) && craftingStorage.hasPermission((Player) event.getPlayer())) {
|
||||
if (event.getPlayer().hasPermission(Permissions.AUTOCRAFT_OPEN) && craftingStorage.hasPermission((Player) event.getPlayer())) {
|
||||
event.getPlayer().openInventory(craftingStorage.getInventory());
|
||||
craftingStorage.getVirtualCraftingHolder().startAnimation();
|
||||
}
|
||||
@ -60,11 +60,12 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException ignore){} //Essentials does something weird with enderchests - shit fix but works :)
|
||||
} catch (NullPointerException ignore) {
|
||||
} //Essentials does something weird with enderchests - shit fix but works :)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event){
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
try {
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
if (holder instanceof VirtualInventoryHolder) {
|
||||
@ -77,26 +78,27 @@ public class InventoryListener implements Listener {
|
||||
Utils.closeStorageInventory(vHolder.getStorage());
|
||||
vHolder.getStorage().onItemDisplayUpdate(InventorySorter.getMostCommonItem(event.getInventory()));
|
||||
}
|
||||
if(holder instanceof VirtualCraftingHolder){
|
||||
if (holder instanceof VirtualCraftingHolder) {
|
||||
((VirtualCraftingHolder) holder).stopAnimation();
|
||||
}
|
||||
} catch (NullPointerException ignore){} //Essentials does something weird with enderchests - shit fix but works :)
|
||||
} catch (NullPointerException ignore) {
|
||||
} //Essentials does something weird with enderchests - shit fix but works :)
|
||||
}
|
||||
|
||||
public void inventoryUpdate(InventoryInteractEvent event){
|
||||
public void inventoryUpdate(InventoryInteractEvent event) {
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
if(holder instanceof VirtualInventoryHolder){
|
||||
if (holder instanceof VirtualInventoryHolder) {
|
||||
VirtualInventoryHolder vHolder = (VirtualInventoryHolder) holder;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, () -> {
|
||||
vHolder.getStorage().sort();
|
||||
vHolder.getStorage().onItemDisplayUpdate(InventorySorter.getMostCommonItem(event.getInventory()));
|
||||
},1);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryPlayerUpdate(InventoryDragEvent event){
|
||||
public void onInventoryPlayerUpdate(InventoryDragEvent event) {
|
||||
inventoryUpdate(event);
|
||||
craftingUpdate(event);
|
||||
}
|
||||
@ -104,26 +106,26 @@ public class InventoryListener implements Listener {
|
||||
|
||||
//CRAFTING
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void inventoryDragEvent(InventoryDragEvent event){
|
||||
public void inventoryDragEvent(InventoryDragEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
if(inventory.getHolder() instanceof VirtualCraftingHolder){
|
||||
if (inventory.getHolder() instanceof VirtualCraftingHolder) {
|
||||
Player p = (Player) event.getWhoClicked();
|
||||
for(int slot : event.getRawSlots()) {
|
||||
if(slot >= p.getOpenInventory().getTopInventory().getSize())
|
||||
for (int slot : event.getRawSlots()) {
|
||||
if (slot >= p.getOpenInventory().getTopInventory().getSize())
|
||||
continue;
|
||||
|
||||
setCraftingItem(event.getInventory(),slot,event.getOldCursor());
|
||||
setCraftingItem(event.getInventory(), slot, event.getOldCursor());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onCraftingPlayerUpdate(InventoryClickEvent event){
|
||||
public void onCraftingPlayerUpdate(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
if(event.getView().getTopInventory().getHolder() instanceof VirtualCraftingHolder){
|
||||
if(event.getAction() == InventoryAction.COLLECT_TO_CURSOR ||
|
||||
if (event.getView().getTopInventory().getHolder() instanceof VirtualCraftingHolder) {
|
||||
if (event.getAction() == InventoryAction.COLLECT_TO_CURSOR ||
|
||||
event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY ||
|
||||
event.getAction() == InventoryAction.NOTHING) {
|
||||
event.setCancelled(true);
|
||||
@ -131,10 +133,10 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getClickedInventory() == player.getOpenInventory().getTopInventory()){
|
||||
if(event.getSlot() == 0) event.setCancelled(true);
|
||||
if(event.getSlot() >= 1 && event.getSlot() <= 9){
|
||||
setCraftingItem(event.getInventory(),event.getSlot(),event.getCursor());
|
||||
if (event.getClickedInventory() == player.getOpenInventory().getTopInventory()) {
|
||||
if (event.getSlot() == 0) event.setCancelled(true);
|
||||
if (event.getSlot() >= 1 && event.getSlot() <= 9) {
|
||||
setCraftingItem(event.getInventory(), event.getSlot(), event.getCursor());
|
||||
event.setCancelled(true);
|
||||
craftingUpdate(event);
|
||||
}
|
||||
@ -142,23 +144,22 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void setCraftingItem(Inventory inventory, int slot, ItemStack cursor){
|
||||
private void setCraftingItem(Inventory inventory, int slot, ItemStack cursor) {
|
||||
ItemStack clone = null;
|
||||
if(cursor != null){
|
||||
if (cursor != null) {
|
||||
clone = cursor.clone();
|
||||
clone.setAmount(1);
|
||||
}
|
||||
inventory.setItem(slot,clone);
|
||||
inventory.setItem(slot, clone);
|
||||
}
|
||||
|
||||
private void craftingUpdate(InventoryInteractEvent event){
|
||||
private void craftingUpdate(InventoryInteractEvent event) {
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
if(holder instanceof VirtualCraftingHolder){
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, (((VirtualCraftingHolder) holder).setUpdatingRecipe(true))::updateCrafting,1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, (((VirtualCraftingHolder) holder))::forceUpdateInventory,1);
|
||||
if (holder instanceof VirtualCraftingHolder) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, (((VirtualCraftingHolder) holder).setUpdatingRecipe(true))::updateCrafting, 1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, (((VirtualCraftingHolder) holder))::forceUpdateInventory, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,46 +38,46 @@ import java.util.stream.Collectors;
|
||||
public class StorageListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void playerInteract(BlockPlaceEvent event){
|
||||
if(event.getBlockPlaced().getState() instanceof Sign){
|
||||
if(Config.getStorageTypes().stream().anyMatch(storageType -> storageType.isValidBlockType(event.getBlockAgainst()))) {
|
||||
new TempListener() {
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent signChangeEvent) {
|
||||
if (event.getBlockPlaced().getLocation().equals(signChangeEvent.getBlock().getLocation())) {
|
||||
Sign sign = (Sign) signChangeEvent.getBlock().getState();
|
||||
public void playerInteract(BlockPlaceEvent event) {
|
||||
if (event.getBlockPlaced().getState() instanceof Sign) {
|
||||
if (Config.getStorageTypes().stream().anyMatch(storageType -> storageType.isValidBlockType(event.getBlockAgainst()))) {
|
||||
new TempListener() {
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent signChangeEvent) {
|
||||
if (event.getBlockPlaced().getLocation().equals(signChangeEvent.getBlock().getLocation())) {
|
||||
Sign sign = (Sign) signChangeEvent.getBlock().getState();
|
||||
|
||||
for (StorageType storageType : Config.getStorageTypes().stream().filter(storageType -> storageType.isValidBlockType(event.getBlockAgainst())).collect(Collectors.toList())) {
|
||||
if(storageType.hasPermissionToAdd(event.getPlayer())) {
|
||||
Location signLocation = event.getBlockPlaced().getLocation();
|
||||
if (storageType.getStorageUtils().isValidSignPosition(signLocation)) {
|
||||
StorageInfo info = storageType.getStorageUtils().getStorageInfo(sign, signChangeEvent.getLines(), event.getPlayer().getUniqueId());
|
||||
if (info != null) {
|
||||
if (!storageType.add(event.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation(), event.getBlockPlaced().getLocation(), info.getPlayer())) {
|
||||
sign.getBlock().breakNaturally();
|
||||
done();
|
||||
return;
|
||||
}
|
||||
storageType.validate(event.getBlockAgainst());
|
||||
storageType.getMessages().storageAdded(event.getPlayer(), signChangeEvent.getLine(1), info.getPlayer().getName());
|
||||
signChange(sign, signChangeEvent, info.getPlayer(), event.getPlayer());
|
||||
}
|
||||
} else {
|
||||
storageType.getMessages().invalidSignPlacement(event.getPlayer());
|
||||
}
|
||||
} else {
|
||||
Messages.NO_PERMISSION(event.getPlayer());
|
||||
for (StorageType storageType : Config.getStorageTypes().stream().filter(storageType -> storageType.isValidBlockType(event.getBlockAgainst())).collect(Collectors.toList())) {
|
||||
if (storageType.hasPermissionToAdd(event.getPlayer())) {
|
||||
Location signLocation = event.getBlockPlaced().getLocation();
|
||||
if (storageType.getStorageUtils().isValidSignPosition(signLocation)) {
|
||||
StorageInfo info = storageType.getStorageUtils().getStorageInfo(sign, signChangeEvent.getLines(), event.getPlayer().getUniqueId());
|
||||
if (info != null) {
|
||||
if (!storageType.add(event.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation(), event.getBlockPlaced().getLocation(), info.getPlayer())) {
|
||||
sign.getBlock().breakNaturally();
|
||||
done();
|
||||
return;
|
||||
}
|
||||
storageType.validate(event.getBlockAgainst());
|
||||
storageType.getMessages().storageAdded(event.getPlayer(), signChangeEvent.getLine(1), info.getPlayer().getName());
|
||||
signChange(sign, signChangeEvent, info.getPlayer(), event.getPlayer());
|
||||
}
|
||||
} else {
|
||||
storageType.getMessages().invalidSignPlacement(event.getPlayer());
|
||||
}
|
||||
} else {
|
||||
Messages.NO_PERMISSION(event.getPlayer());
|
||||
}
|
||||
done();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
done();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void signChange(Sign sign, SignChangeEvent signChangeEvent, OfflinePlayer addedPlayer, Player player){
|
||||
private void signChange(Sign sign, SignChangeEvent signChangeEvent, OfflinePlayer addedPlayer, Player player) {
|
||||
setLine(sign, signChangeEvent, 0, ChatColor.RED + ChatColor.stripColor(signChangeEvent.getLine(0)));
|
||||
setLine(sign, signChangeEvent, 1, ChatColor.GREEN + ChatColor.stripColor(signChangeEvent.getLine(1)));
|
||||
setLine(sign, signChangeEvent, 2, ChatColor.BOLD + ChatColor.stripColor(addedPlayer.getName()));
|
||||
@ -86,19 +86,19 @@ public class StorageListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSignBreak(BlockBreakEvent event){
|
||||
if(event.getBlock().getState() instanceof Sign) {
|
||||
public void onSignBreak(BlockBreakEvent event) {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) event.getBlock().getState();
|
||||
//Get blockface of sign.
|
||||
if(sign.getBlockData() instanceof Directional) {
|
||||
if (sign.getBlockData() instanceof Directional) {
|
||||
|
||||
BlockFace chestFace = ((Directional) sign.getBlockData()).getFacing().getOppositeFace();
|
||||
Block block = sign.getBlock().getRelative(chestFace);
|
||||
|
||||
Config.getStorageTypes().forEach(storageType -> {
|
||||
if(storageType.isValidBlockType(block)){
|
||||
StorageInfo info = storageType.getStorageUtils().getStorageInfo(sign,sign.getLines());
|
||||
if(info != null){
|
||||
if (storageType.isValidBlockType(block)) {
|
||||
StorageInfo info = storageType.getStorageUtils().getStorageInfo(sign, sign.getLines());
|
||||
if (info != null) {
|
||||
storageType.removeBlock(info.getPlayer(), info.getGroup(), block.getLocation());
|
||||
storageType.onSignRemoval(block);
|
||||
storageType.getMessages().storageRemoved(event.getPlayer(), info.getGroup(), info.getPlayer().getName());
|
||||
@ -110,15 +110,15 @@ public class StorageListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChestPlace(BlockPlaceEvent event){
|
||||
for(StorageType storageType : Config.getStorageTypes()){
|
||||
if(storageType.isValidBlockType(event.getBlockPlaced())){
|
||||
public void onChestPlace(BlockPlaceEvent event) {
|
||||
for (StorageType storageType : Config.getStorageTypes()) {
|
||||
if (storageType.isValidBlockType(event.getBlockPlaced())) {
|
||||
ItemMeta itemMeta = event.getItemInHand().getItemMeta();
|
||||
if(itemMeta != null){
|
||||
if (itemMeta != null) {
|
||||
String playerUUID = itemMeta.getPersistentDataContainer().get(Values.playerUUID, PersistentDataType.STRING);
|
||||
String storageID = itemMeta.getPersistentDataContainer().get(Values.storageID, PersistentDataType.STRING);
|
||||
|
||||
if(playerUUID != null && storageID != null) {
|
||||
if (playerUUID != null && storageID != null) {
|
||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(playerUUID));
|
||||
|
||||
BlockFace blockFace = storageType.onStoragePlacedBlockFace(event.getPlayer(), event.getBlockPlaced());
|
||||
@ -138,41 +138,41 @@ public class StorageListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(event.getBlockPlaced().getState() instanceof Chest){
|
||||
if (event.getBlockPlaced().getState() instanceof Chest) {
|
||||
new ChestLinkVerifier(event.getBlock()).check();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onChestBreak(BlockBreakEvent event){
|
||||
if(event.isCancelled()) return;
|
||||
public void onChestBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
for (StorageType storageType : Config.getStorageTypes()) {
|
||||
if(storageType.isValidBlockType(event.getBlock())) {
|
||||
if (storageType.isValidBlockType(event.getBlock())) {
|
||||
boolean hasPickedUp = false;
|
||||
ItemStack mainHand = event.getPlayer().getInventory().getItemInMainHand();
|
||||
if(mainHand.containsEnchantment(Enchantment.SILK_TOUCH)){
|
||||
if (mainHand.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
hasPickedUp = true;
|
||||
}
|
||||
AbstractStorage storage = storageType.removeBlock(event.getBlock().getLocation(),hasPickedUp);
|
||||
AbstractStorage storage = storageType.removeBlock(event.getBlock().getLocation(), hasPickedUp);
|
||||
if (storage != null) {
|
||||
if(hasPickedUp){
|
||||
if (hasPickedUp) {
|
||||
event.setCancelled(true);
|
||||
Block storageBlock = event.getBlock();
|
||||
Location signLoc = storage.getSignLocation(storageBlock.getLocation());
|
||||
|
||||
//Custom dropped Chest
|
||||
ItemStack customChest = new ItemStack(storageBlock.getType(),1);
|
||||
ItemStack customChest = new ItemStack(storageBlock.getType(), 1);
|
||||
ItemMeta itemMeta = customChest.getItemMeta();
|
||||
if(itemMeta != null){
|
||||
itemMeta.setDisplayName(ChatColor.AQUA+""+storageType.getSignTag()+" "+storage.getIdentifier());
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setDisplayName(ChatColor.AQUA + "" + storageType.getSignTag() + " " + storage.getIdentifier());
|
||||
itemMeta.getPersistentDataContainer().set(Values.playerUUID, PersistentDataType.STRING, storage.getOwner().getUniqueId().toString());
|
||||
itemMeta.getPersistentDataContainer().set(Values.storageID, PersistentDataType.STRING, storage.getIdentifier());
|
||||
}
|
||||
customChest.setItemMeta(itemMeta);
|
||||
storageBlock.getWorld().dropItemNaturally(storageBlock.getLocation(),customChest);
|
||||
storageBlock.getWorld().dropItemNaturally(storageBlock.getLocation(), customChest);
|
||||
|
||||
if(signLoc != null) signLoc.getBlock().setType(Material.AIR);
|
||||
if (signLoc != null) signLoc.getBlock().setType(Material.AIR);
|
||||
storageBlock.setType(Material.AIR);
|
||||
|
||||
} else {
|
||||
@ -184,34 +184,34 @@ public class StorageListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonMove(BlockPistonExtendEvent event){
|
||||
public void onPistonMove(BlockPistonExtendEvent event) {
|
||||
event.getBlocks().forEach(block -> {
|
||||
for(StorageType storageType : Config.getStorageTypes()){
|
||||
if(storageType.isValidBlockType(block)){
|
||||
for (StorageType storageType : Config.getStorageTypes()) {
|
||||
if (storageType.isValidBlockType(block)) {
|
||||
Location blockLoc = block.getLocation();
|
||||
AbstractStorage storage = storageType.getStorage(blockLoc);
|
||||
if(storage != null) event.setCancelled(true);
|
||||
if (storage != null) event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent event){
|
||||
public void onPistonRetract(BlockPistonRetractEvent event) {
|
||||
event.getBlocks().forEach(block -> {
|
||||
for(StorageType storageType : Config.getStorageTypes()){
|
||||
if(storageType.isValidBlockType(block)){
|
||||
for (StorageType storageType : Config.getStorageTypes()) {
|
||||
if (storageType.isValidBlockType(block)) {
|
||||
Location blockLoc = block.getLocation();
|
||||
AbstractStorage storage = storageType.getStorage(blockLoc);
|
||||
if(storage != null) event.setCancelled(true);
|
||||
if (storage != null) event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLine(Sign sign, SignChangeEvent signChangeEvent, int i, String s){
|
||||
sign.setLine(i,s);
|
||||
signChangeEvent.setLine(i,s);
|
||||
private void setLine(Sign sign, SignChangeEvent signChangeEvent, int i, String s) {
|
||||
sign.setLine(i, s);
|
||||
signChangeEvent.setLine(i, s);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,15 +7,15 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TempListener implements Listener {
|
||||
|
||||
public TempListener(){
|
||||
public TempListener() {
|
||||
this(ChestsPlusPlus.PLUGIN);
|
||||
}
|
||||
|
||||
public TempListener(Plugin plugin){
|
||||
plugin.getServer().getPluginManager().registerEvents(this,plugin);
|
||||
public TempListener(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void done(){
|
||||
public void done() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
|
@ -15,33 +15,33 @@ public class WorldListener implements Listener {
|
||||
private static boolean justSaved = false;
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event){
|
||||
if(!justSaved){
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
if (!justSaved) {
|
||||
Config.saveASync();
|
||||
justSaved = true;
|
||||
new BukkitRunnable(){
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
justSaved = false;
|
||||
}
|
||||
}.runTaskLater(ChestsPlusPlus.PLUGIN,20);
|
||||
}.runTaskLater(ChestsPlusPlus.PLUGIN, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event){
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
Utils.removeEntities(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event){
|
||||
if(!event.isNewChunk()){
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if (!event.isNewChunk()) {
|
||||
Utils.fixEntities(event.getChunk());
|
||||
Config.getStorageTypes().forEach(storageType -> {
|
||||
storageType.getStorageMap().values().forEach(stringHashMap -> {
|
||||
stringHashMap.values().forEach(o -> {
|
||||
o.getLocations().forEach(locationInfo -> {
|
||||
if(locationInfo != null && locationInfo.getSignLocation() != null && Utils.isLocationInChunk(locationInfo.getSignLocation(),event.getChunk())) {
|
||||
if (locationInfo != null && locationInfo.getSignLocation() != null && Utils.isLocationInChunk(locationInfo.getSignLocation(), event.getChunk())) {
|
||||
o.updateClient(locationInfo);
|
||||
}
|
||||
});
|
||||
|
@ -8,37 +8,37 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Messages {
|
||||
|
||||
private static String TAG = "[Chests++]";
|
||||
private static final String TAG = "[Chests++]";
|
||||
|
||||
public static void CHEST_HAD_OVERFLOW(Player target){
|
||||
target.sendMessage(ChatColor.GOLD+TAG+" "+ Message.CHEST_HAD_OVERFLOW.getString());
|
||||
public static void CHEST_HAD_OVERFLOW(Player target) {
|
||||
target.sendMessage(ChatColor.GOLD + TAG + " " + Message.CHEST_HAD_OVERFLOW.getString());
|
||||
}
|
||||
|
||||
public static void MUST_HOLD_SIGN(Player target){
|
||||
target.sendMessage(ChatColor.RED+TAG+" "+Message.MUST_HOLD_SIGN.getString());
|
||||
public static void MUST_HOLD_SIGN(Player target) {
|
||||
target.sendMessage(ChatColor.RED + TAG + " " + Message.MUST_HOLD_SIGN.getString());
|
||||
}
|
||||
|
||||
public static void NO_PERMISSION(Player target){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.NO_PERMISSION.getString());
|
||||
public static void NO_PERMISSION(Player target) {
|
||||
target.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + TAG + " " + Message.NO_PERMISSION.getString());
|
||||
}
|
||||
|
||||
public static void SORT(Player target, ChestLinkStorage storage){
|
||||
target.sendMessage(ChatColor.GREEN+Message.SORT.getString(ChatColor.WHITE+storage.getIdentifier()+ChatColor.GREEN, ChatColor.WHITE+storage.getSortMethod().toString()));
|
||||
public static void SORT(Player target, ChestLinkStorage storage) {
|
||||
target.sendMessage(ChatColor.GREEN + Message.SORT.getString(ChatColor.WHITE + storage.getIdentifier() + ChatColor.GREEN, ChatColor.WHITE + storage.getSortMethod().toString()));
|
||||
}
|
||||
|
||||
public static void CANNOT_RENAME_GROUP_ALREADY_EXISTS(Player target, String newidentifier){
|
||||
target.sendMessage(ChatColor.RED+Message.CANNOT_RENAME_GROUP_ALREADY_EXISTS.getString(ChatColor.WHITE+newidentifier+ChatColor.RED));
|
||||
public static void CANNOT_RENAME_GROUP_ALREADY_EXISTS(Player target, String newidentifier) {
|
||||
target.sendMessage(ChatColor.RED + Message.CANNOT_RENAME_GROUP_ALREADY_EXISTS.getString(ChatColor.WHITE + newidentifier + ChatColor.RED));
|
||||
}
|
||||
|
||||
public static void CANNOT_RENAME_GROUP_DOESNT_EXIST(Player target, String oldidentifier){
|
||||
target.sendMessage(ChatColor.RED+Message.CANNOT_RENAME_GROUP_DOESNT_EXIST.getString(ChatColor.WHITE+oldidentifier+ChatColor.RED));
|
||||
public static void CANNOT_RENAME_GROUP_DOESNT_EXIST(Player target, String oldidentifier) {
|
||||
target.sendMessage(ChatColor.RED + Message.CANNOT_RENAME_GROUP_DOESNT_EXIST.getString(ChatColor.WHITE + oldidentifier + ChatColor.RED));
|
||||
}
|
||||
|
||||
public static void OWNER_HAS_TOO_MANY_CHESTS(Player target, OfflinePlayer owner){
|
||||
target.sendMessage(ChatColor.RED+Message.OWNER_HAS_TOO_MANY_CHESTS.getString(ChatColor.WHITE+owner.getName()+ChatColor.RED));
|
||||
public static void OWNER_HAS_TOO_MANY_CHESTS(Player target, OfflinePlayer owner) {
|
||||
target.sendMessage(ChatColor.RED + Message.OWNER_HAS_TOO_MANY_CHESTS.getString(ChatColor.WHITE + owner.getName() + ChatColor.RED));
|
||||
}
|
||||
|
||||
public static void ALREADY_PART_OF_GROUP(Player target, String type){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.ALREADY_PART_OF_GROUP);
|
||||
public static void ALREADY_PART_OF_GROUP(Player target, String type) {
|
||||
target.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + TAG + " " + Message.ALREADY_PART_OF_GROUP);
|
||||
}
|
||||
}
|
||||
|
@ -6,19 +6,19 @@ import org.bstats.bukkit.Metrics;
|
||||
|
||||
public class Stats {
|
||||
|
||||
public static void addCharts(Metrics metrics){
|
||||
public static void addCharts(Metrics metrics) {
|
||||
metrics.addCustomChart(new Metrics.SimplePie("chestlink-amount", () -> {
|
||||
int chestlinks = Config.getChestLink().getTotalLocations();
|
||||
return chestlinks+"";
|
||||
return chestlinks + "";
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("autocraft-amount", () -> {
|
||||
int locations = Config.getAutoCraft().getTotalLocations();
|
||||
return locations+"";
|
||||
return locations + "";
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("update_checker_setting", () -> {
|
||||
if(PluginConfig.IS_UPDATE_CHECKER_ENABLED.get()) return "enabled";
|
||||
if (PluginConfig.IS_UPDATE_CHECKER_ENABLED.get()) return "enabled";
|
||||
else return "disabled";
|
||||
}));
|
||||
|
||||
|
@ -45,10 +45,10 @@ import java.util.stream.Stream;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static void openChestInventory(Player player, ChestLinkStorage storage, LocationInfo openedChestLocation){
|
||||
public static void openChestInventory(Player player, ChestLinkStorage storage, LocationInfo openedChestLocation) {
|
||||
player.openInventory(storage.getInventory());
|
||||
//Check if all chests should perform open animation.
|
||||
if(PluginConfig.SHOULD_ANIMATE_ALL_CHESTS.get()) {
|
||||
if (PluginConfig.SHOULD_ANIMATE_ALL_CHESTS.get()) {
|
||||
storage.getLocations().forEach(locationInfo -> {
|
||||
Location location = locationInfo.getLocation();
|
||||
if (location != null) {
|
||||
@ -60,23 +60,23 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void containerAnimation(Inventory inventory, LocationInfo location, boolean open){
|
||||
private static void containerAnimation(Inventory inventory, LocationInfo location, boolean open) {
|
||||
if (location != null && Utils.isLocationChunkLoaded(location.getLocation())) {
|
||||
Block block = location.getLocation().getBlock();
|
||||
if (block.getState() instanceof Container) {
|
||||
Container chest = (Container) block.getState();
|
||||
if(open){
|
||||
if (open) {
|
||||
location.setTileEntityOpener(ApiSpecific.getChestOpener().updateState(inventory, chest, location.getTileEntityOpener()));
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN,() -> {
|
||||
location.setTileEntityOpener(ApiSpecific.getChestOpener().updateState(inventory, chest, location.getTileEntityOpener()));
|
||||
},1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, () -> {
|
||||
location.setTileEntityOpener(ApiSpecific.getChestOpener().updateState(inventory, chest, location.getTileEntityOpener()));
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeStorageInventory(ChestLinkStorage storage){
|
||||
public static void closeStorageInventory(ChestLinkStorage storage) {
|
||||
storage.getLocations().forEach(locationInfo -> {
|
||||
Location location = locationInfo.getLocation();
|
||||
if (location != null) {
|
||||
@ -86,40 +86,41 @@ public class Utils {
|
||||
}
|
||||
|
||||
|
||||
public static void openChestInventory(Player player, Inventory inventory){
|
||||
public static void openChestInventory(Player player, Inventory inventory) {
|
||||
VirtualInventoryHolder holder = (VirtualInventoryHolder) inventory.getHolder();
|
||||
if (holder != null) holder.onPlayerRemoteOpened(player.getUniqueId());
|
||||
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN,0.5f,1f);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN, 0.5f, 1f);
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
public static void closeInventorySound(Player player, Inventory inventory){
|
||||
if(inventory.getLocation() != null) player.getWorld().playSound(inventory.getLocation(), Sound.BLOCK_CHEST_CLOSE,0.5f,1f);
|
||||
else player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_CLOSE,0.5f,1f);
|
||||
public static void closeInventorySound(Player player, Inventory inventory) {
|
||||
if (inventory.getLocation() != null)
|
||||
player.getWorld().playSound(inventory.getLocation(), Sound.BLOCK_CHEST_CLOSE, 0.5f, 1f);
|
||||
else player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_CLOSE, 0.5f, 1f);
|
||||
//player.closeInventory();
|
||||
}
|
||||
|
||||
public static ItemStack removeStackFromInventory(Inventory inventory, int amount, List<Filter> filters){
|
||||
public static ItemStack removeStackFromInventory(Inventory inventory, int amount, List<Filter> filters) {
|
||||
ItemStack toRemove;
|
||||
for(int i=0; i<inventory.getContents().length; i++){
|
||||
for (int i = 0; i < inventory.getContents().length; i++) {
|
||||
ItemStack stack = inventory.getItem(i);
|
||||
if((stack != null) && (HopperFilter.isInFilter(filters,stack))){
|
||||
if ((stack != null) && (HopperFilter.isInFilter(filters, stack))) {
|
||||
toRemove = stack.clone();
|
||||
toRemove.setAmount(Math.min(stack.getAmount(),amount));
|
||||
stack.setAmount(stack.getAmount()-toRemove.getAmount());
|
||||
toRemove.setAmount(Math.min(stack.getAmount(), amount));
|
||||
stack.setAmount(stack.getAmount() - toRemove.getAmount());
|
||||
return toRemove;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hopperMove(Inventory from, int amount, Inventory to, List<Filter> filters){
|
||||
ItemStack removed = removeStackFromInventory(from,amount,filters);
|
||||
if(removed != null) {
|
||||
public static boolean hopperMove(Inventory from, int amount, Inventory to, List<Filter> filters) {
|
||||
ItemStack removed = removeStackFromInventory(from, amount, filters);
|
||||
if (removed != null) {
|
||||
HashMap<Integer, ItemStack> leftOvers = to.addItem(removed);
|
||||
for (ItemStack leftOver : leftOvers.values()) {
|
||||
from.addItem(leftOver);
|
||||
if(removed.equals(leftOver)) return false;
|
||||
if (removed.equals(leftOver)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -127,37 +128,37 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static boolean hopperMove(Inventory from, int amount, Inventory to) {
|
||||
return hopperMove(from,amount,to,null);
|
||||
return hopperMove(from, amount, to, null);
|
||||
}
|
||||
|
||||
public static ItemStack getNamedItem(ItemStack item, String name){
|
||||
public static ItemStack getNamedItem(ItemStack item, String name) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if(meta != null) {
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static List<String> getOnlinePlayers(){
|
||||
public static List<String> getOnlinePlayers() {
|
||||
return getPlayersAsNameList(Bukkit.getOnlinePlayers());
|
||||
}
|
||||
|
||||
public static List<String> getAllPlayers(){
|
||||
public static List<String> getAllPlayers() {
|
||||
return getPlayersAsNameList(Arrays.asList(Bukkit.getOfflinePlayers()));
|
||||
}
|
||||
|
||||
public static List<String> getPlayersAsNameList(Collection<? extends OfflinePlayer> players){
|
||||
public static List<String> getPlayersAsNameList(Collection<? extends OfflinePlayer> players) {
|
||||
List<String> arr = new ArrayList<>();
|
||||
for(OfflinePlayer player : players){
|
||||
for (OfflinePlayer player : players) {
|
||||
arr.add(ChatColor.stripColor(player.getName()));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static String prettyPrintPlayers(ChatColor highlight, List<OfflinePlayer> players){
|
||||
public static String prettyPrintPlayers(ChatColor highlight, List<OfflinePlayer> players) {
|
||||
String playerString = players.stream().map(OfflinePlayer::getName).collect(Collectors.joining(","));
|
||||
return highlight+"["+ChatColor.WHITE+playerString+highlight+"]";
|
||||
return highlight + "[" + ChatColor.WHITE + playerString + highlight + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,32 +175,32 @@ public class Utils {
|
||||
return targetBlock.getFace(adjacentBlock);
|
||||
}
|
||||
|
||||
public static BlockFace getNearestBlockFace(Player player, Location blockPlaced){
|
||||
public static BlockFace getNearestBlockFace(Player player, Location blockPlaced) {
|
||||
Vector blockCentre = blockPlaced.add(0.5, 0, 0.5).toVector().setY(0);
|
||||
Vector directionLoc = player.getEyeLocation().toVector().setY(0);
|
||||
double angle = Math.toDegrees(calculateXZAngle(blockCentre,directionLoc));
|
||||
if(angle <= 45 && angle > -45) return BlockFace.EAST;
|
||||
if(angle <= 135 && angle > 45) return BlockFace.SOUTH;
|
||||
if(angle <= -45 && angle > -135) return BlockFace.NORTH;
|
||||
if(angle <= -135 || angle > 135) return BlockFace.WEST;
|
||||
double angle = Math.toDegrees(calculateXZAngle(blockCentre, directionLoc));
|
||||
if (angle <= 45 && angle > -45) return BlockFace.EAST;
|
||||
if (angle <= 135 && angle > 45) return BlockFace.SOUTH;
|
||||
if (angle <= -45 && angle > -135) return BlockFace.NORTH;
|
||||
if (angle <= -135 || angle > 135) return BlockFace.WEST;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static double calculateXZAngle(Vector origin, Vector to){
|
||||
private static double calculateXZAngle(Vector origin, Vector to) {
|
||||
Vector vec = to.subtract(origin);
|
||||
return Math.atan2(vec.getZ(), vec.getX());
|
||||
}
|
||||
|
||||
public static boolean isSideFace(BlockFace face){
|
||||
if(face == BlockFace.NORTH) return true;
|
||||
if(face == BlockFace.EAST) return true;
|
||||
if(face == BlockFace.SOUTH) return true;
|
||||
public static boolean isSideFace(BlockFace face) {
|
||||
if (face == BlockFace.NORTH) return true;
|
||||
if (face == BlockFace.EAST) return true;
|
||||
if (face == BlockFace.SOUTH) return true;
|
||||
return face == BlockFace.WEST;
|
||||
}
|
||||
|
||||
public static Inventory copyInventory(Inventory inventory){
|
||||
public static Inventory copyInventory(Inventory inventory) {
|
||||
Inventory tempInv;
|
||||
if(inventory.getType() != InventoryType.CHEST) {
|
||||
if (inventory.getType() != InventoryType.CHEST) {
|
||||
tempInv = Bukkit.createInventory(null, inventory.getType());
|
||||
} else {
|
||||
tempInv = Bukkit.createInventory(null, inventory.getSize());
|
||||
@ -212,89 +213,89 @@ public class Utils {
|
||||
* Removes all entities that contain a value of 1 under the Values.PluginKey key.
|
||||
* Updates all Item Frames with invisibility status.
|
||||
*/
|
||||
public static void fixEntities(){
|
||||
public static void fixEntities() {
|
||||
Bukkit.getServer().getWorlds().forEach(world -> {
|
||||
removeEntities(world);
|
||||
setItemFrames(world);
|
||||
});
|
||||
}
|
||||
|
||||
public static void fixEntities(Chunk chunk){
|
||||
public static void fixEntities(Chunk chunk) {
|
||||
removeEntities(chunk);
|
||||
setItemFrames(chunk);
|
||||
}
|
||||
|
||||
public static void removeEntities(World world){
|
||||
public static void removeEntities(World world) {
|
||||
world.getEntities().forEach(Utils::removeEntity);
|
||||
}
|
||||
|
||||
public static void removeEntities(Chunk chunk){
|
||||
|
||||
public static void removeEntities(Chunk chunk) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
removeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeEntity(Entity entity){
|
||||
private static void removeEntity(Entity entity) {
|
||||
Integer val = entity.getPersistentDataContainer().get(Values.PluginKey, PersistentDataType.INTEGER);
|
||||
if(val != null && val == 1) entity.remove();
|
||||
if (val != null && val == 1) entity.remove();
|
||||
}
|
||||
|
||||
public static void setItemFrames(World world){
|
||||
public static void setItemFrames(World world) {
|
||||
setItemFrames(world.getEntities().stream());
|
||||
}
|
||||
|
||||
public static void setItemFrames(Chunk chunk){
|
||||
public static void setItemFrames(Chunk chunk) {
|
||||
setItemFrames(Arrays.stream(chunk.getEntities()));
|
||||
}
|
||||
|
||||
private static void setItemFrames(Stream<Entity> entityStream){
|
||||
private static void setItemFrames(Stream<Entity> entityStream) {
|
||||
entityStream.filter(entity ->
|
||||
(entity instanceof ItemFrame
|
||||
&& entity.getLocation().getBlock().getRelative(((ItemFrame) entity).getAttachedFace()).getState() instanceof Hopper))
|
||||
.forEach(entity -> ApiSpecific.getNmsProvider().setItemFrameVisible((ItemFrame) entity, !PluginConfig.INVISIBLE_FILTER_ITEM_FRAMES.get()));
|
||||
}
|
||||
|
||||
public static List<String> filterList(List<String> list, String phrase){
|
||||
public static List<String> filterList(List<String> list, String phrase) {
|
||||
return list.stream().filter(s -> s.contains(phrase)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T> void addIfNotNull(List<T> list, T value){
|
||||
if(value != null) list.add(value);
|
||||
public static <T> void addIfNotNull(List<T> list, T value) {
|
||||
if (value != null) list.add(value);
|
||||
}
|
||||
|
||||
public static boolean isAir(Block block){
|
||||
public static boolean isAir(Block block) {
|
||||
return (block.getType() == Material.AIR) || (block.getType() == Material.CAVE_AIR);
|
||||
}
|
||||
|
||||
public static boolean isLocationChunkLoaded(Location location){
|
||||
public static boolean isLocationChunkLoaded(Location location) {
|
||||
int chunkX = location.getBlockX() >> 4;
|
||||
int chunkZ = location.getBlockZ() >> 4;
|
||||
return location.getWorld() != null && location.getWorld().isChunkLoaded(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public static boolean isLocationInChunk(Location location, Chunk chunk){
|
||||
public static boolean isLocationInChunk(Location location, Chunk chunk) {
|
||||
int chunkX = location.getBlockX() >> 4;
|
||||
int chunkZ = location.getBlockZ() >> 4;
|
||||
return (chunkX == chunk.getX()) && (chunkZ == chunk.getZ());
|
||||
}
|
||||
|
||||
public static Collection<Entity> getPlayersInViewDistance(Location location){
|
||||
if(location.getWorld() == null) return null;
|
||||
return location.getWorld().getNearbyEntities(location, Bukkit.getViewDistance()*16, 256, Bukkit.getViewDistance()*16, entity -> entity instanceof Player);
|
||||
public static Collection<Entity> getPlayersInViewDistance(Location location) {
|
||||
if (location.getWorld() == null) return null;
|
||||
return location.getWorld().getNearbyEntities(location, Bukkit.getViewDistance() * 16, 256, Bukkit.getViewDistance() * 16, entity -> entity instanceof Player);
|
||||
}
|
||||
|
||||
public static boolean isLocationInViewDistance(Player player, Location location){
|
||||
if(location == null) return false;
|
||||
if(!player.getWorld().equals(location.getWorld())) return false;
|
||||
public static boolean isLocationInViewDistance(Player player, Location location) {
|
||||
if (location == null) return false;
|
||||
if (!player.getWorld().equals(location.getWorld())) return false;
|
||||
Location delta = player.getLocation().subtract(location);
|
||||
return (delta.getX() <= Bukkit.getViewDistance()*16) && (delta.getZ() <= Bukkit.getViewDistance()*16);
|
||||
return (delta.getX() <= Bukkit.getViewDistance() * 16) && (delta.getZ() <= Bukkit.getViewDistance() * 16);
|
||||
}
|
||||
|
||||
public static boolean isBlacklistedWorld(World world){
|
||||
public static boolean isBlacklistedWorld(World world) {
|
||||
return PluginConfig.WORLD_BLACKLIST.get().contains(world.getName());
|
||||
}
|
||||
|
||||
public static void copyFromResources(File jarFile, String directory){
|
||||
public static void copyFromResources(File jarFile, String directory) {
|
||||
try (JarFile jar = new JarFile(jarFile)) {
|
||||
Enumeration<JarEntry> entries = jar.entries();
|
||||
|
||||
|
@ -6,11 +6,12 @@ import org.bukkit.NamespacedKey;
|
||||
public class Values {
|
||||
public final static String ChestLinkTag = "[ChestLink]";
|
||||
public final static String AutoCraftTag = "[AutoCraft]";
|
||||
public static String identifier(String identifier){
|
||||
return "["+identifier+"]";
|
||||
|
||||
public static String identifier(String identifier) {
|
||||
return "[" + identifier + "]";
|
||||
}
|
||||
|
||||
public final static NamespacedKey playerUUID = new NamespacedKey(ChestsPlusPlus.PLUGIN,"playerUUID");
|
||||
public final static NamespacedKey PluginKey = new NamespacedKey(ChestsPlusPlus.PLUGIN,"ChestsPlusPlus");
|
||||
public final static NamespacedKey storageID = new NamespacedKey(ChestsPlusPlus.PLUGIN,"storageID");
|
||||
public final static NamespacedKey playerUUID = new NamespacedKey(ChestsPlusPlus.PLUGIN, "playerUUID");
|
||||
public final static NamespacedKey PluginKey = new NamespacedKey(ChestsPlusPlus.PLUGIN, "ChestsPlusPlus");
|
||||
public final static NamespacedKey storageID = new NamespacedKey(ChestsPlusPlus.PLUGIN, "storageID");
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ChestLinkVerifier extends BukkitRunnable {
|
||||
|
||||
private Block block;
|
||||
private final Block block;
|
||||
private int delay = 1;
|
||||
|
||||
public ChestLinkVerifier(Block block){
|
||||
public ChestLinkVerifier(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public void check(){
|
||||
runTaskLater(ChestsPlusPlus.PLUGIN,delay);
|
||||
public void check() {
|
||||
runTaskLater(ChestsPlusPlus.PLUGIN, delay);
|
||||
}
|
||||
|
||||
public ChestLinkVerifier withDelay(int delay){
|
||||
public ChestLinkVerifier withDelay(int delay) {
|
||||
this.delay = delay;
|
||||
return this;
|
||||
}
|
||||
@ -35,11 +35,11 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
public void run() {
|
||||
Chest chest = (Chest) block.getState();
|
||||
|
||||
if(chest.getInventory().getHolder() instanceof DoubleChest) {
|
||||
if (chest.getInventory().getHolder() instanceof DoubleChest) {
|
||||
DoubleChest doubleChest = (DoubleChest) chest.getInventory().getHolder();
|
||||
InventoryHolder right = doubleChest.getRightSide();
|
||||
InventoryHolder left = doubleChest.getLeftSide();
|
||||
if(isChestLinked(doubleChest) && left != null && right != null) {
|
||||
if (isChestLinked(doubleChest) && left != null && right != null) {
|
||||
convertToSingleChest(right.getInventory());
|
||||
convertToSingleChest(left.getInventory());
|
||||
convertToSingleChest(right.getInventory());
|
||||
@ -51,10 +51,11 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
|
||||
/**
|
||||
* Converts the block associated with this inventory into a Single Chest.
|
||||
*
|
||||
* @param inventory
|
||||
*/
|
||||
private void convertToSingleChest(Inventory inventory){
|
||||
if(inventory != null) {
|
||||
private void convertToSingleChest(Inventory inventory) {
|
||||
if (inventory != null) {
|
||||
org.bukkit.block.data.type.Chest blockData = (org.bukkit.block.data.type.Chest) inventory.getLocation().getBlock().getBlockData();
|
||||
blockData.setType(org.bukkit.block.data.type.Chest.Type.SINGLE);
|
||||
inventory.getLocation().getBlock().setBlockData(blockData);
|
||||
@ -63,10 +64,11 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
|
||||
/**
|
||||
* Checks if either side of a @{@link DoubleChest} has been added to a ChestLink
|
||||
*
|
||||
* @param chest - the double chest being tested.
|
||||
* @return true if either side has been added to a ChestLink.
|
||||
*/
|
||||
private boolean isChestLinked(DoubleChest chest){
|
||||
private boolean isChestLinked(DoubleChest chest) {
|
||||
Location chestSide1 = block.getLocation();
|
||||
Location diff = chest.getLocation().clone().subtract(chestSide1).multiply(2);
|
||||
Location chestSide2 = chestSide1.clone().add(diff);
|
||||
@ -77,15 +79,15 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
return (leftStorage != null) || (rightStorage != null);
|
||||
}
|
||||
|
||||
private void manualCheck(Chest chest){
|
||||
if(chest.getBlockData() instanceof Directional) {
|
||||
private void manualCheck(Chest chest) {
|
||||
if (chest.getBlockData() instanceof Directional) {
|
||||
Directional directional = (Directional) chest.getBlockData();
|
||||
BlockFace facing = directional.getFacing();
|
||||
BlockFace[] perpendulcarFaces = getPerpendicularFaces(facing);
|
||||
if(perpendulcarFaces == null) return;
|
||||
if (perpendulcarFaces == null) return;
|
||||
for (BlockFace perpendicularFace : perpendulcarFaces) {
|
||||
Block toTest = block.getRelative(perpendicularFace);
|
||||
if(toTest.getState() instanceof Chest && Config.getChestLink().getStorage(toTest.getLocation()) != null){
|
||||
if (toTest.getState() instanceof Chest && Config.getChestLink().getStorage(toTest.getLocation()) != null) {
|
||||
convertToSingleChest(chest.getInventory());
|
||||
convertToSingleChest(((Chest) toTest.getState()).getInventory());
|
||||
convertToSingleChest(chest.getInventory());
|
||||
@ -97,8 +99,8 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
private static final BlockFace[] NS = new BlockFace[]{BlockFace.WEST, BlockFace.EAST};
|
||||
private static final BlockFace[] WE = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH};
|
||||
|
||||
private BlockFace[] getPerpendicularFaces(BlockFace face){
|
||||
switch (face){
|
||||
private BlockFace[] getPerpendicularFaces(BlockFace face) {
|
||||
switch (face) {
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
return NS;
|
||||
|
@ -15,44 +15,45 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class VirtualChestToHopper extends BukkitRunnable {
|
||||
|
||||
private ChestLinkStorage storage;
|
||||
private final ChestLinkStorage storage;
|
||||
private BukkitTask task;
|
||||
|
||||
public VirtualChestToHopper(ChestLinkStorage storage){
|
||||
public VirtualChestToHopper(ChestLinkStorage storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
public void start(){
|
||||
task = runTaskTimer(ChestsPlusPlus.PLUGIN,1,8);
|
||||
public void start() {
|
||||
task = runTaskTimer(ChestsPlusPlus.PLUGIN, 1, 8);
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
public void stop() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(LocationInfo location : storage.getLocations()) {
|
||||
if(location != null) {
|
||||
for (LocationInfo location : storage.getLocations()) {
|
||||
if (location != null) {
|
||||
if (location.getLocation() != null) {
|
||||
if(!PluginConfig.SHOULD_RUN_HOPPERS_UNLOADED_CHUNKS.get() && !Utils.isLocationChunkLoaded(location.getLocation())) continue;
|
||||
if (!PluginConfig.SHOULD_RUN_HOPPERS_UNLOADED_CHUNKS.get() && !Utils.isLocationChunkLoaded(location.getLocation()))
|
||||
continue;
|
||||
Location below = location.getLocation().clone().subtract(0, 1, 0);
|
||||
if (below.getBlock().getState() instanceof Hopper) {
|
||||
Hopper hopper = (Hopper) below.getBlock().getState();
|
||||
if (below.getBlock().isBlockIndirectlyPowered() || below.getBlock().isBlockPowered()) {
|
||||
continue;
|
||||
}
|
||||
if (move(hopper.getLocation(), hopper.getInventory(), storage.getInventory())){
|
||||
if (move(hopper.getLocation(), hopper.getInventory(), storage.getInventory())) {
|
||||
storage.updateDisplayItem();
|
||||
}
|
||||
if(storage.getInventory().getViewers().size() > 0) storage.sort();
|
||||
if (storage.getInventory().getViewers().size() > 0) storage.sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean move(Location targetLocation, Inventory source, Inventory target){
|
||||
public static boolean move(Location targetLocation, Inventory source, Inventory target) {
|
||||
int hopperAmount = SpigotConfig.getWorldSettings(targetLocation.getWorld()).getHopperAmount();
|
||||
return Utils.hopperMove(source, hopperAmount, target, HopperFilter.getHopperFilters(targetLocation.getBlock()));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class Config {
|
||||
private static ConfigStorage store;
|
||||
private static FileConfiguration config;
|
||||
|
||||
private static String saveName = "/data/storage.yml";
|
||||
private static final String saveName = "/data/storage.yml";
|
||||
|
||||
/* ALL STORAGE TYPES */
|
||||
private static ChestLinkStorageType chestLinkStorageType;
|
||||
@ -39,7 +39,7 @@ public class Config {
|
||||
|
||||
try {
|
||||
config = YamlConfiguration.loadConfiguration(getStorageFile());
|
||||
} catch (IllegalArgumentException | IOException e){
|
||||
} catch (IllegalArgumentException | IOException e) {
|
||||
ChestsPlusPlus.PLUGIN.getLogger().severe("Config was null or couldn't be read!");
|
||||
config = new YamlConfiguration();
|
||||
}
|
||||
@ -70,7 +70,7 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveASync(){
|
||||
public static void saveASync() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, Config::save);
|
||||
}
|
||||
|
||||
@ -82,11 +82,13 @@ public class Config {
|
||||
return chestLinkStorageType;
|
||||
}
|
||||
|
||||
public static List<StorageType<? extends AbstractStorage>> getStorageTypes(){
|
||||
public static List<StorageType<? extends AbstractStorage>> getStorageTypes() {
|
||||
return storageTypes != null ? storageTypes : new ArrayList<>();
|
||||
}
|
||||
|
||||
public static ConfigStorage getStore(){ return store; }
|
||||
public static ConfigStorage getStore() {
|
||||
return store;
|
||||
}
|
||||
|
||||
//TODO This needs improving
|
||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||
@ -101,23 +103,23 @@ public class Config {
|
||||
File pluginDataFolder = ChestsPlusPlus.PLUGIN.getDataFolder();
|
||||
File file = new File(pluginDataFolder, saveName);
|
||||
file.getParentFile().mkdirs();
|
||||
if(!file.exists()) file.createNewFile();
|
||||
if (!file.exists()) file.createNewFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
private File getLegacyFile(){
|
||||
private File getLegacyFile() {
|
||||
return new File("chests.yml");
|
||||
}
|
||||
|
||||
private void legacyConverter(){
|
||||
private void legacyConverter() {
|
||||
File legacyFile = getLegacyFile();
|
||||
if(!legacyFile.exists()) return;
|
||||
if (!legacyFile.exists()) return;
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("Found a Legacy config! Converting to new data-format and moving to: /plugins/ChestsPlusPlus/data/storage.yml");
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("If you are having issues with data-loss the plugin may not have permissions to delete the legacy file 'chests.yml'");
|
||||
|
||||
try {
|
||||
Path path = Paths.get(legacyFile.toURI());
|
||||
String content = new String(Files.readAllBytes(path),Charsets.UTF_8);
|
||||
String content = new String(Files.readAllBytes(path), Charsets.UTF_8);
|
||||
content = legacyContentConverter(content);
|
||||
Files.write(getStorageFile().toPath(), content.getBytes(Charsets.UTF_8));
|
||||
legacyFile.createNewFile();
|
||||
@ -127,17 +129,17 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
private String legacyContentConverter(String content){
|
||||
private String legacyContentConverter(String content) {
|
||||
content = content.replaceAll("==: LinkedChest", "==: ConfigStorage");
|
||||
content = content.replaceAll("==: com.jamesdpeters.minecraft.chests.storage.InventoryStorage", "==: ChestLinkStorage");
|
||||
content = content.replaceAll("==: com.jamesdpeters.minecraft.chests.serialize.InventoryStorage", "==: ChestLinkStorage");
|
||||
return content;
|
||||
}
|
||||
|
||||
private void configConverter(){
|
||||
private void configConverter() {
|
||||
try {
|
||||
Path path = Paths.get(getStorageFile().toURI());
|
||||
String content = new String(Files.readAllBytes(path),Charsets.UTF_8);
|
||||
String content = new String(Files.readAllBytes(path), Charsets.UTF_8);
|
||||
content = content.replaceAll("==: Recipe", "==: C++Recipe");
|
||||
Files.write(getStorageFile().toPath(), content.getBytes(Charsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
|
@ -19,13 +19,13 @@ public class ConfigStorage implements ConfigurationSerializable {
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
LinkedHashMap<String, Object> hashMap = new LinkedHashMap<>();
|
||||
hashMap.put("chests",chests);
|
||||
hashMap.put("autocraftingtables",autocraftingtables);
|
||||
hashMap.put("chests", chests);
|
||||
hashMap.put("autocraftingtables", autocraftingtables);
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ConfigStorage(Map<String, Object> map){
|
||||
public ConfigStorage(Map<String, Object> map) {
|
||||
//Legacy handling
|
||||
|
||||
|
||||
@ -34,16 +34,17 @@ public class ConfigStorage implements ConfigurationSerializable {
|
||||
// }
|
||||
|
||||
autocraftingtables = (HashMap<String, HashMap<String, AutoCraftingStorage>>) map.get("autocraftingtables");
|
||||
if(autocraftingtables == null) autocraftingtables = new HashMap<>();
|
||||
if (autocraftingtables == null) autocraftingtables = new HashMap<>();
|
||||
validate();
|
||||
}
|
||||
|
||||
private void validate(){
|
||||
if(chests != null) chests.forEach((s, invMap) -> invMap.values().removeIf(Objects::isNull));
|
||||
if(autocraftingtables != null) autocraftingtables.forEach((s, craftMap) -> craftMap.values().removeIf(Objects::isNull));
|
||||
private void validate() {
|
||||
if (chests != null) chests.forEach((s, invMap) -> invMap.values().removeIf(Objects::isNull));
|
||||
if (autocraftingtables != null)
|
||||
autocraftingtables.forEach((s, craftMap) -> craftMap.values().removeIf(Objects::isNull));
|
||||
}
|
||||
|
||||
public ConfigStorage(){
|
||||
public ConfigStorage() {
|
||||
chests = new HashMap<>();
|
||||
autocraftingtables = new HashMap<>();
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ import java.util.Optional;
|
||||
@SerializableAs("LocationInfo")
|
||||
public class LocationInfo implements ConfigurationSerializable {
|
||||
|
||||
private Location location, signLocation;
|
||||
private final Location location;
|
||||
private Location signLocation;
|
||||
private ArmorStand itemStand, blockStand, toolItemStand;
|
||||
private TileEntityOpener tileEntityOpener;
|
||||
|
||||
@ -28,11 +29,11 @@ public class LocationInfo implements ConfigurationSerializable {
|
||||
return map;
|
||||
}
|
||||
|
||||
public LocationInfo(Map<String, Object> map){
|
||||
public LocationInfo(Map<String, Object> map) {
|
||||
location = (Location) map.get("Location");
|
||||
}
|
||||
|
||||
public LocationInfo(Location location){
|
||||
public LocationInfo(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@ -44,8 +45,8 @@ public class LocationInfo implements ConfigurationSerializable {
|
||||
return signLocation;
|
||||
}
|
||||
|
||||
public Sign getSign(){
|
||||
if(signLocation.getBlock().getState() instanceof Sign){
|
||||
public Sign getSign() {
|
||||
if (signLocation.getBlock().getState() instanceof Sign) {
|
||||
return (Sign) signLocation.getBlock().getState();
|
||||
}
|
||||
return null;
|
||||
@ -87,7 +88,7 @@ public class LocationInfo implements ConfigurationSerializable {
|
||||
return tileEntityOpener;
|
||||
}
|
||||
|
||||
public static List<LocationInfo> convert(List<Location> locationList){
|
||||
public static List<LocationInfo> convert(List<Location> locationList) {
|
||||
List<LocationInfo> locationInfos = new ArrayList<>();
|
||||
for (Location location : locationList) {
|
||||
locationInfos.add(new LocationInfo(location));
|
||||
@ -95,11 +96,11 @@ public class LocationInfo implements ConfigurationSerializable {
|
||||
return locationInfos;
|
||||
}
|
||||
|
||||
public static Optional<LocationInfo> getLocationInfo(List<LocationInfo> locationInfos, Location location){
|
||||
public static Optional<LocationInfo> getLocationInfo(List<LocationInfo> locationInfos, Location location) {
|
||||
return locationInfos.stream().filter(locationInfo -> locationInfo.getLocation().equals(location)).findFirst();
|
||||
}
|
||||
|
||||
public boolean isInWorld(Player player){
|
||||
public boolean isInWorld(Player player) {
|
||||
return getLocation() != null && player.getWorld().equals(getLocation().getWorld());
|
||||
}
|
||||
}
|
||||
|
@ -8,22 +8,22 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SerializableAs("Material")
|
||||
public class MaterialSerializer implements ConfigurationSerializable {
|
||||
public class MaterialSerializer implements ConfigurationSerializable {
|
||||
|
||||
private Material material;
|
||||
private final Material material;
|
||||
|
||||
public MaterialSerializer(Material material){
|
||||
public MaterialSerializer(Material material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
LinkedHashMap<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("Material",material.name());
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("Material", material.name());
|
||||
return map;
|
||||
}
|
||||
|
||||
public MaterialSerializer(Map<String, Object> map){
|
||||
public MaterialSerializer(Map<String, Object> map) {
|
||||
String matName = (String) map.get("Material");
|
||||
material = Material.getMaterial(matName);
|
||||
}
|
||||
|
@ -27,29 +27,30 @@ public class PluginConfig {
|
||||
/* ***************
|
||||
* Config Values
|
||||
* ***************/
|
||||
public final static Value<Boolean> IS_UPDATE_CHECKER_ENABLED = new Value<>("update-checker", Boolean.class, true);
|
||||
public final static Value<Integer> UPDATE_CHECKER_PERIOD = new Value<>("update-checker-period", Integer.class, 60*60);
|
||||
public final static Value<Boolean> SHOULD_LIMIT_CHESTS = new Value<>("limit-chests", Boolean.class, false);
|
||||
public final static Value<Integer> LIMIT_CHESTS_AMOUNT = new Value<>("limit-chestlinks-amount", Integer.class, 0);
|
||||
public final static Value<Boolean> SHOULD_ANIMATE_ALL_CHESTS = new Value<>("should-animate-all-chests", Boolean.class, true);
|
||||
public final static Value<Boolean> SHOULD_RUN_HOPPERS_UNLOADED_CHUNKS = new Value<>("run-hoppers-unloaded-chunks", Boolean.class, false);
|
||||
public final static Value<Boolean> DISPLAY_CHESTLINK_ARMOUR_STAND = new Value<>("display_chestlink_armour_stand", Boolean.class, true);
|
||||
public final static Value<Boolean> DISPLAY_AUTOCRAFT_ARMOUR_STAND = new Value<>("display_autocraft_armour_stands", Boolean.class, true);
|
||||
public final static Value<Boolean> INVISIBLE_FILTER_ITEM_FRAMES = new Value<>("set-filter-itemframe-invisible", Boolean.class, false);
|
||||
public final static ListValue<String> WORLD_BLACKLIST = new ListValue<>("world-blacklist", String.class, Collections.singletonList(""));
|
||||
public final static Value<String> LANG_FILE = new Value<>("language-file", String.class, "default");
|
||||
public final static Value<Boolean> IS_UPDATE_CHECKER_ENABLED = new Value<>("update-checker", Boolean.class, true);
|
||||
public final static Value<Integer> UPDATE_CHECKER_PERIOD = new Value<>("update-checker-period", Integer.class, 60 * 60);
|
||||
public final static Value<Boolean> SHOULD_LIMIT_CHESTS = new Value<>("limit-chests", Boolean.class, false);
|
||||
public final static Value<Integer> LIMIT_CHESTS_AMOUNT = new Value<>("limit-chestlinks-amount", Integer.class, 0);
|
||||
public final static Value<Boolean> SHOULD_ANIMATE_ALL_CHESTS = new Value<>("should-animate-all-chests", Boolean.class, true);
|
||||
public final static Value<Boolean> SHOULD_RUN_HOPPERS_UNLOADED_CHUNKS = new Value<>("run-hoppers-unloaded-chunks", Boolean.class, false);
|
||||
public final static Value<Boolean> DISPLAY_CHESTLINK_ARMOUR_STAND = new Value<>("display_chestlink_armour_stand", Boolean.class, true);
|
||||
public final static Value<Boolean> DISPLAY_AUTOCRAFT_ARMOUR_STAND = new Value<>("display_autocraft_armour_stands", Boolean.class, true);
|
||||
public final static Value<Boolean> INVISIBLE_FILTER_ITEM_FRAMES = new Value<>("set-filter-itemframe-invisible", Boolean.class, false);
|
||||
public final static ListValue<String> WORLD_BLACKLIST = new ListValue<>("world-blacklist", String.class, Collections.singletonList(""));
|
||||
public final static Value<String> LANG_FILE = new Value<>("language-file", String.class, "default");
|
||||
|
||||
/**
|
||||
* Loads this @{@link Plugin}'s Config and adds default values if they don't exist.
|
||||
*
|
||||
* @param plugin - the plugin of the @{@link org.bukkit.configuration.Configuration} to be loaded.
|
||||
*/
|
||||
public static void load(Plugin plugin){
|
||||
public static void load(Plugin plugin) {
|
||||
//Read in config
|
||||
configuration = plugin.getConfig();
|
||||
|
||||
//Add default values
|
||||
values.forEach((configSection, values) -> {
|
||||
if(configSection != null){
|
||||
if (configSection != null) {
|
||||
ConfigurationSection section = Optional.ofNullable(configuration.getConfigurationSection(configSection)).orElse(configuration.createSection(configSection));
|
||||
values.forEach(value -> section.addDefault(value.getPath(), value.getDefaultValue()));
|
||||
} else {
|
||||
@ -64,7 +65,7 @@ public class PluginConfig {
|
||||
//Read config in and set values
|
||||
configuration = plugin.getConfig();
|
||||
values.forEach((configSection, values) -> {
|
||||
if(configSection != null){
|
||||
if (configSection != null) {
|
||||
ConfigurationSection section = Optional.ofNullable(configuration.getConfigurationSection(configSection)).orElse(configuration.createSection(configSection));
|
||||
values.forEach(value -> value.setValue(section.get(value.getPath())));
|
||||
} else {
|
||||
@ -78,25 +79,25 @@ public class PluginConfig {
|
||||
protected final T defaultValue;
|
||||
protected T value;
|
||||
|
||||
AbstractValue(String configurationSection, String path, T defaultValue){
|
||||
AbstractValue(String configurationSection, String path, T defaultValue) {
|
||||
this.path = path;
|
||||
this.value = defaultValue;
|
||||
this.defaultValue = defaultValue;
|
||||
this.configurationSection = configurationSection;
|
||||
|
||||
List<AbstractValue<?>> valueList = values.computeIfAbsent(configurationSection, k -> new ArrayList<>());
|
||||
if(valueList.stream().anyMatch(value -> value.getPath().equals(path))){
|
||||
throw new IllegalArgumentException("Two values with the same path have been added to the Config: '"+path+"'");
|
||||
if (valueList.stream().anyMatch(value -> value.getPath().equals(path))) {
|
||||
throw new IllegalArgumentException("Two values with the same path have been added to the Config: '" + path + "'");
|
||||
}
|
||||
valueList.add(this);
|
||||
}
|
||||
|
||||
|
||||
public T get(){
|
||||
public T get() {
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
|
||||
public void set(T value){
|
||||
public void set(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -113,6 +114,7 @@ public class PluginConfig {
|
||||
|
||||
/**
|
||||
* A class that represents a singular value in a @{@link org.bukkit.configuration.Configuration}
|
||||
*
|
||||
* @param <T> the type of the variable to be stored/loaded.
|
||||
*/
|
||||
public static class Value<T> extends AbstractValue<T> {
|
||||
@ -120,25 +122,25 @@ public class PluginConfig {
|
||||
|
||||
/**
|
||||
* @param configSection the @{@link ConfigurationSection} this value belongs to.
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents this value
|
||||
* @param defaultValue the default value to be inserted into the @{@link org.bukkit.configuration.Configuration}
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents this value
|
||||
* @param defaultValue the default value to be inserted into the @{@link org.bukkit.configuration.Configuration}
|
||||
*/
|
||||
public Value(String configSection, String path, Class<T> type, T defaultValue){
|
||||
public Value(String configSection, String path, Class<T> type, T defaultValue) {
|
||||
super(configSection, path, defaultValue);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents this value
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents this value
|
||||
* @param defaultValue the default value to be inserted into the @{@link org.bukkit.configuration.Configuration}
|
||||
*/
|
||||
public Value(String path, Class<T> type, T defaultValue){
|
||||
public Value(String path, Class<T> type, T defaultValue) {
|
||||
this(null, path, type, defaultValue);
|
||||
}
|
||||
|
||||
public void setValue(Object value){
|
||||
public void setValue(Object value) {
|
||||
this.value = type.isInstance(value) ? type.cast(value) : defaultValue;
|
||||
}
|
||||
|
||||
@ -146,6 +148,7 @@ public class PluginConfig {
|
||||
|
||||
/**
|
||||
* A class that represents a list of values in a @{@link org.bukkit.configuration.Configuration}
|
||||
*
|
||||
* @param <T> the type of the variable to be stored/loaded.
|
||||
*/
|
||||
public static class ListValue<T> extends AbstractValue<List<T>> {
|
||||
@ -154,30 +157,30 @@ public class PluginConfig {
|
||||
|
||||
/**
|
||||
* @param configSection the @{@link ConfigurationSection} this value belongs to.
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents a value in the list
|
||||
* @param defaultValue the default value to be inserted into the @{@link org.bukkit.configuration.Configuration}
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents a value in the list
|
||||
* @param defaultValue the default value to be inserted into the @{@link org.bukkit.configuration.Configuration}
|
||||
*/
|
||||
public ListValue(String configSection, String path, Class<T> type, List<T> defaultValue){
|
||||
public ListValue(String configSection, String path, Class<T> type, List<T> defaultValue) {
|
||||
super(configSection, path, defaultValue);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents a value in the list
|
||||
* @param path the key that represents this value.
|
||||
* @param type the @{@link Class} that represents a value in the list
|
||||
* @param defaultValue the default value to be inserted into the @{@link org.bukkit.configuration.Configuration}
|
||||
*/
|
||||
public ListValue(String path, Class<T> type, List<T> defaultValue){
|
||||
public ListValue(String path, Class<T> type, List<T> defaultValue) {
|
||||
this(null, path, type, defaultValue);
|
||||
}
|
||||
|
||||
public void setValue(Object value){
|
||||
public void setValue(Object value) {
|
||||
List<?> list = (value instanceof List) ? (List<?>) value : defaultValue;
|
||||
this.value = new ArrayList<T>();
|
||||
|
||||
for (Object o : list) {
|
||||
if(type.isInstance(o)){
|
||||
if (type.isInstance(o)) {
|
||||
this.value.add(type.cast(o));
|
||||
}
|
||||
}
|
||||
|
@ -14,17 +14,18 @@ import java.util.Map;
|
||||
@SerializableAs("C++Recipe")
|
||||
public class RecipeSerializable implements ConfigurationSerializable {
|
||||
|
||||
private Recipe recipe;
|
||||
private NamespacedKey key;
|
||||
private final Recipe recipe;
|
||||
private final NamespacedKey key;
|
||||
|
||||
public RecipeSerializable(Recipe recipe){
|
||||
public RecipeSerializable(Recipe recipe) {
|
||||
this.recipe = recipe;
|
||||
if(recipe instanceof ShapedRecipe) key = ((ShapedRecipe) recipe).getKey();
|
||||
else if(recipe instanceof ShapelessRecipe) key = ((ShapelessRecipe) recipe).getKey();
|
||||
else throw new IllegalArgumentException("Recipe type has not been implemented! "+recipe.getClass().toGenericString());
|
||||
if (recipe instanceof ShapedRecipe) key = ((ShapedRecipe) recipe).getKey();
|
||||
else if (recipe instanceof ShapelessRecipe) key = ((ShapelessRecipe) recipe).getKey();
|
||||
else
|
||||
throw new IllegalArgumentException("Recipe type has not been implemented! " + recipe.getClass().toGenericString());
|
||||
}
|
||||
|
||||
public RecipeSerializable(Map<String, Object> map){
|
||||
public RecipeSerializable(Map<String, Object> map) {
|
||||
//noinspection deprecation
|
||||
key = new NamespacedKey((String) map.get("namespace"), (String) map.get("key"));
|
||||
recipe = Crafting.getRecipeByKey(key);
|
||||
@ -33,8 +34,8 @@ public class RecipeSerializable implements ConfigurationSerializable {
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("namespace",key.getNamespace());
|
||||
map.put("key",key.getKey());
|
||||
map.put("namespace", key.getNamespace());
|
||||
map.put("key", key.getKey());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -8,35 +8,37 @@ import java.util.HashMap;
|
||||
|
||||
public class SpigotConfig {
|
||||
|
||||
private static HashMap<String,WorldSettings> worlds;
|
||||
private static HashMap<String, WorldSettings> worlds;
|
||||
private static WorldSettings default_;
|
||||
|
||||
public static void load(JavaPlugin plugin){
|
||||
public static void load(JavaPlugin plugin) {
|
||||
worlds = new HashMap<>();
|
||||
try {
|
||||
//Check if we're using the Spigot API.
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
ConfigurationSection worldSettings = plugin.getServer().spigot().getConfig().getConfigurationSection("world-settings");
|
||||
if(worldSettings != null) {
|
||||
if (worldSettings != null) {
|
||||
worldSettings.getValues(false).forEach((worldName, o) -> {
|
||||
ConfigurationSection worldSetting = worldSettings.getConfigurationSection(worldName);
|
||||
if (!worldName.equals("default") && worldSetting != null)
|
||||
worlds.put(worldName, new WorldSettings(worldSetting));
|
||||
});
|
||||
ConfigurationSection section = worldSettings.getConfigurationSection("default");
|
||||
if(section != null) default_ = new WorldSettings(section);
|
||||
if (section != null) default_ = new WorldSettings(section);
|
||||
}
|
||||
if(default_ == null) default_ = new WorldSettings();
|
||||
} catch (ClassNotFoundException e){
|
||||
if (default_ == null) default_ = new WorldSettings();
|
||||
} catch (ClassNotFoundException e) {
|
||||
//Not using the Spigot API so fallback to defaults
|
||||
default_ = new WorldSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldSettings getDefault(){ return default_; }
|
||||
public static WorldSettings getDefault() {
|
||||
return default_;
|
||||
}
|
||||
|
||||
public static WorldSettings getWorldSettings(World world){
|
||||
return world != null ? worlds.getOrDefault(world.getName(),default_) : default_;
|
||||
public static WorldSettings getWorldSettings(World world) {
|
||||
return world != null ? worlds.getOrDefault(world.getName(), default_) : default_;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,24 +2,28 @@ package com.jamesdpeters.minecraft.chests.serialize;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class WorldSettings{
|
||||
public class WorldSettings {
|
||||
|
||||
//Values
|
||||
private int ticksPerHopperTransfer, hopperAmount;
|
||||
private final int ticksPerHopperTransfer;
|
||||
private final int hopperAmount;
|
||||
|
||||
public WorldSettings(ConfigurationSection settings){
|
||||
public WorldSettings(ConfigurationSection settings) {
|
||||
ticksPerHopperTransfer = settings.getInt("ticks-per.hopper-transfer");
|
||||
hopperAmount = settings.getInt("hopper-amount");
|
||||
}
|
||||
|
||||
//Default class used as a fallback if Spigot isn't being used etc.
|
||||
public WorldSettings(){
|
||||
public WorldSettings() {
|
||||
ticksPerHopperTransfer = 8;
|
||||
hopperAmount = 1;
|
||||
}
|
||||
|
||||
public int getTicksPerHopperTransfer(){
|
||||
public int getTicksPerHopperTransfer() {
|
||||
return ticksPerHopperTransfer;
|
||||
}
|
||||
public int getHopperAmount() { return hopperAmount; }
|
||||
|
||||
public int getHopperAmount() {
|
||||
return hopperAmount;
|
||||
}
|
||||
}
|
@ -11,9 +11,10 @@ import java.util.Optional;
|
||||
|
||||
public class InventorySorter {
|
||||
|
||||
public static ItemStack[] sort(Inventory inventory, SortMethod sortMethod){
|
||||
switch (sortMethod){
|
||||
case OFF: return inventory.getContents();
|
||||
public static ItemStack[] sort(Inventory inventory, SortMethod sortMethod) {
|
||||
switch (sortMethod) {
|
||||
case OFF:
|
||||
return inventory.getContents();
|
||||
case NAME: {
|
||||
List<ItemStack> condensed = condenseInventory(inventory.getContents());
|
||||
condensed.sort((item1, item2) -> {
|
||||
@ -27,17 +28,17 @@ public class InventorySorter {
|
||||
return condensed.toArray(new ItemStack[0]);
|
||||
}
|
||||
case AMOUNT_DESC: {
|
||||
return sortByAmount(inventory,true);
|
||||
return sortByAmount(inventory, true);
|
||||
}
|
||||
case AMOUNT_ASC: {
|
||||
return sortByAmount(inventory,false);
|
||||
return sortByAmount(inventory, false);
|
||||
}
|
||||
}
|
||||
return inventory.getContents();
|
||||
}
|
||||
|
||||
private static ItemStack[] sortByAmount(Inventory inventory, boolean descending){
|
||||
HashMap<ItemStack,Integer> itemAmounts = getItemAmounts(inventory.getContents());
|
||||
private static ItemStack[] sortByAmount(Inventory inventory, boolean descending) {
|
||||
HashMap<ItemStack, Integer> itemAmounts = getItemAmounts(inventory.getContents());
|
||||
List<ItemStack> condensed = condenseInventory(inventory.getContents());
|
||||
|
||||
condensed.sort((item1, item2) -> {
|
||||
@ -46,26 +47,26 @@ public class InventorySorter {
|
||||
|
||||
Optional<ItemStack> matchItem1 = itemAmounts.keySet().stream().filter(is -> is.isSimilar(item1)).findFirst();
|
||||
Optional<ItemStack> matchItem2 = itemAmounts.keySet().stream().filter(is -> is.isSimilar(item2)).findFirst();
|
||||
if(!matchItem1.isPresent()) return 1;
|
||||
if(!matchItem2.isPresent()) return -1;
|
||||
if (!matchItem1.isPresent()) return 1;
|
||||
if (!matchItem2.isPresent()) return -1;
|
||||
|
||||
int itemOrder = itemAmounts.get(matchItem1.get()).compareTo(itemAmounts.get(matchItem2.get()));
|
||||
if(descending) itemOrder *= -1;
|
||||
if (descending) itemOrder *= -1;
|
||||
return itemOrder;
|
||||
});
|
||||
|
||||
return condensed.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
private static HashMap<ItemStack,Integer> getItemAmounts(ItemStack[] itemStacks){
|
||||
HashMap<ItemStack,Integer> itemAmounts = new HashMap<>();
|
||||
for(ItemStack itemStack : itemStacks){
|
||||
if(itemStack == null) continue;
|
||||
private static HashMap<ItemStack, Integer> getItemAmounts(ItemStack[] itemStacks) {
|
||||
HashMap<ItemStack, Integer> itemAmounts = new HashMap<>();
|
||||
for (ItemStack itemStack : itemStacks) {
|
||||
if (itemStack == null) continue;
|
||||
int amount;
|
||||
Optional<ItemStack> match = itemAmounts.keySet().stream().filter(is -> is.isSimilar(itemStack)).findFirst();
|
||||
if(!match.isPresent()){
|
||||
if (!match.isPresent()) {
|
||||
amount = itemStack.getAmount();
|
||||
itemAmounts.put(itemStack,amount);
|
||||
itemAmounts.put(itemStack, amount);
|
||||
} else {
|
||||
amount = itemAmounts.get(match.get()) + itemStack.getAmount();
|
||||
itemAmounts.put(match.get(), amount);
|
||||
@ -74,34 +75,34 @@ public class InventorySorter {
|
||||
return itemAmounts;
|
||||
}
|
||||
|
||||
private static List<ItemStack> condenseInventory(ItemStack[] itemStacks){
|
||||
HashMap<ItemStack,Integer> itemAmounts = getItemAmounts(itemStacks);
|
||||
private static List<ItemStack> condenseInventory(ItemStack[] itemStacks) {
|
||||
HashMap<ItemStack, Integer> itemAmounts = getItemAmounts(itemStacks);
|
||||
return condenseInventory(itemAmounts);
|
||||
}
|
||||
|
||||
private static List<ItemStack> condenseInventory(HashMap<ItemStack,Integer> itemAmounts){
|
||||
private static List<ItemStack> condenseInventory(HashMap<ItemStack, Integer> itemAmounts) {
|
||||
List<ItemStack> condensedItems = new ArrayList<>();
|
||||
itemAmounts.forEach((itemStack, amount) -> {
|
||||
int maxStack = itemStack.getMaxStackSize();
|
||||
int amountOfMaxStacks = amount/maxStack;
|
||||
int amountOfMaxStacks = amount / maxStack;
|
||||
int remainder = amount % maxStack;
|
||||
|
||||
for(int i=0; i<amountOfMaxStacks; i++){
|
||||
condensedItems.add(cloneItem(itemStack,maxStack));
|
||||
for (int i = 0; i < amountOfMaxStacks; i++) {
|
||||
condensedItems.add(cloneItem(itemStack, maxStack));
|
||||
}
|
||||
if(remainder != 0) condensedItems.add(cloneItem(itemStack,remainder));
|
||||
if (remainder != 0) condensedItems.add(cloneItem(itemStack, remainder));
|
||||
});
|
||||
return condensedItems;
|
||||
}
|
||||
|
||||
public static ItemStack getMostCommonItem(Inventory inventory){
|
||||
public static ItemStack getMostCommonItem(Inventory inventory) {
|
||||
return getItemAmounts(inventory.getContents()).entrySet().stream()
|
||||
.max(Map.Entry.comparingByValue())
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private static ItemStack cloneItem(ItemStack itemStack, int newAmount){
|
||||
private static ItemStack cloneItem(ItemStack itemStack, int newAmount) {
|
||||
ItemStack item = itemStack.clone();
|
||||
item.setAmount(newAmount);
|
||||
return item;
|
||||
|
@ -21,25 +21,27 @@ import java.util.UUID;
|
||||
|
||||
public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
|
||||
private StorageType<S> storageType;
|
||||
public StorageUtils(StorageType<S> storageType){
|
||||
private final StorageType<S> storageType;
|
||||
|
||||
public StorageUtils(StorageType<S> storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
|
||||
public StorageInfo<S> getStorageInfo(Sign sign, String[] lines, UUID uuid){
|
||||
if(lines != null) {
|
||||
public StorageInfo<S> getStorageInfo(Sign sign, String[] lines, UUID uuid) {
|
||||
if (lines != null) {
|
||||
if (lines.length >= 2 && lines[0].contains(storageType.getSignTag())) {
|
||||
String playerUUID = sign.getPersistentDataContainer().get(Values.playerUUID, PersistentDataType.STRING);
|
||||
String group = ChatColor.stripColor(StringUtils.substringBetween(lines[1], "[", "]"));
|
||||
if(playerUUID == null){
|
||||
if(uuid == null) return null;
|
||||
if (playerUUID == null) {
|
||||
if (uuid == null) return null;
|
||||
playerUUID = uuid.toString();
|
||||
if(lines[2] != null){
|
||||
if (lines[2] != null) {
|
||||
OfflinePlayer owner = Config.getOfflinePlayer(lines[2]);
|
||||
if(owner != null){
|
||||
if (owner != null) {
|
||||
AbstractStorage storage = storageType.getStorage(owner.getUniqueId(), group);
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player != null && storage.hasPermission(player)) playerUUID = owner.getUniqueId().toString();
|
||||
if (player != null && storage.hasPermission(player))
|
||||
playerUUID = owner.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,29 +51,30 @@ public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public StorageInfo<S> getStorageInfo(Sign sign, String[] lines){
|
||||
public StorageInfo<S> getStorageInfo(Sign sign, String[] lines) {
|
||||
return getStorageInfo(sign, lines, null);
|
||||
}
|
||||
|
||||
public StorageInfo<S> getStorageInfo(Sign sign){
|
||||
public StorageInfo<S> getStorageInfo(Sign sign) {
|
||||
return getStorageInfo(sign, sign.getLines());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns StorageInfo for a sign.
|
||||
*
|
||||
* @param location - Location of Storage to find.
|
||||
* @return @{@link StorageInfo}
|
||||
*/
|
||||
public StorageInfo<S> getStorageInfo(Location location){
|
||||
public StorageInfo<S> getStorageInfo(Location location) {
|
||||
Block block = location.getBlock();
|
||||
BlockFace face = storageType.getStorageFacing(block);
|
||||
if(face == null) return null;
|
||||
if (face == null) return null;
|
||||
Block sign = block.getRelative(face);
|
||||
|
||||
if(sign.getBlockData() instanceof Directional){
|
||||
if (sign.getBlockData() instanceof Directional) {
|
||||
//Check if the sign is attached to the given block.
|
||||
Directional directional = (Directional) sign.getBlockData();
|
||||
if(directional.getFacing() != face) return null;
|
||||
if (directional.getFacing() != face) return null;
|
||||
//If it is we can extract info from it.
|
||||
if (sign.getState() instanceof Sign) {
|
||||
Sign s = (Sign) sign.getState();
|
||||
@ -84,18 +87,19 @@ public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
/**
|
||||
* Checks if the block being placed against is valid.
|
||||
* Doesn't check if this block is already apart of the group.
|
||||
*
|
||||
* @param location - location of sign being placed.
|
||||
* @return true if valid.
|
||||
*/
|
||||
public boolean isValidSignPosition(Location location){
|
||||
public boolean isValidSignPosition(Location location) {
|
||||
Block block = location.getBlock();
|
||||
if(block.getBlockData() instanceof Directional){
|
||||
if (block.getBlockData() instanceof Directional) {
|
||||
Directional sign = (Directional) block.getBlockData();
|
||||
BlockFace facing = sign.getFacing().getOppositeFace();
|
||||
Block toTest = block.getRelative(facing);
|
||||
|
||||
//Check if block face is a valid place for a sign!
|
||||
if(!storageType.getValidBlockFaces(toTest).contains(sign.getFacing())) return false;
|
||||
if (!storageType.getValidBlockFaces(toTest).contains(sign.getFacing())) return false;
|
||||
|
||||
//Return if block isn't valid
|
||||
if (!storageType.isValidBlockType(toTest)) return false;
|
||||
|
@ -40,15 +40,15 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
//Serializables
|
||||
private ArrayList<String> members;
|
||||
private List<OfflinePlayer> bukkitMembers;
|
||||
private OfflinePlayer player;
|
||||
private UUID playerUUID;
|
||||
private final OfflinePlayer player;
|
||||
private final UUID playerUUID;
|
||||
private boolean isPublic;
|
||||
private List<LocationInfo> locationInfoList;
|
||||
private Inventory inventory;
|
||||
|
||||
private int signUpdateTask;
|
||||
|
||||
public AbstractStorage(OfflinePlayer player, String identifier, Location location, Location signLocation){
|
||||
public AbstractStorage(OfflinePlayer player, String identifier, Location location, Location signLocation) {
|
||||
this.player = player;
|
||||
this.playerUUID = player.getUniqueId();
|
||||
this.isPublic = false;
|
||||
@ -63,16 +63,17 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* This constructor MUST be in the subclass in order for deserialization to work!
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AbstractStorage(Map<String, Object> map){
|
||||
public AbstractStorage(Map<String, Object> map) {
|
||||
//Pass map through
|
||||
deserialize(map);
|
||||
|
||||
//This reformats the previous method of location storage to the newer version.
|
||||
List<Location> locations = (ArrayList<Location>) map.get("locations");
|
||||
if(locations != null) {
|
||||
if (locations != null) {
|
||||
locations.removeAll(Collections.singletonList(null));
|
||||
locationInfoList = LocationInfo.convert(locations);
|
||||
} else {
|
||||
@ -87,20 +88,20 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
player = Bukkit.getOfflinePlayer(playerUUID);
|
||||
|
||||
//Read publicity data
|
||||
if(map.containsKey("isPublic")) isPublic = (boolean) map.get("isPublic");
|
||||
if (map.containsKey("isPublic")) isPublic = (boolean) map.get("isPublic");
|
||||
else isPublic = false;
|
||||
|
||||
//Read members for this storage
|
||||
if(map.get("members") != null){
|
||||
if (map.get("members") != null) {
|
||||
members = (ArrayList<String>) map.get("members");
|
||||
bukkitMembers = new ArrayList<>();
|
||||
for(String uuid : members){
|
||||
for (String uuid : members) {
|
||||
bukkitMembers.add(Bukkit.getOfflinePlayer(UUID.fromString(uuid)));
|
||||
}
|
||||
}
|
||||
|
||||
inventory = initInventory();
|
||||
if(storeInventory()) {
|
||||
if (storeInventory()) {
|
||||
ItemStack[] itemStacks = ((ArrayList<ItemStack>) map.get("inventory")).toArray(new ItemStack[0]);
|
||||
inventory.setContents(itemStacks);
|
||||
}
|
||||
@ -110,7 +111,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> map = new LinkedHashMap<>();
|
||||
//Add default parameters
|
||||
if(storeInventory()) map.put("inventory", inventory.getContents());
|
||||
if (storeInventory()) map.put("inventory", inventory.getContents());
|
||||
map.put("locationInfo", locationInfoList);
|
||||
map.put("playerUUID", player.getUniqueId().toString());
|
||||
map.put("members", members);
|
||||
@ -120,28 +121,29 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
return map;
|
||||
}
|
||||
|
||||
private void init(){
|
||||
if(shouldDisplayArmourStands()) {
|
||||
private void init() {
|
||||
if (shouldDisplayArmourStands()) {
|
||||
startSignChangeTask();
|
||||
} else {
|
||||
for (LocationInfo locationInfo : locationInfoList) {
|
||||
if(locationInfo.getSignLocation() != null) locationInfo.getSignLocation().getBlock().getState().update();
|
||||
if(locationInfo.getBlockStand() != null) locationInfo.getBlockStand().remove();
|
||||
if(locationInfo.getToolItemStand() != null) locationInfo.getToolItemStand().remove();
|
||||
if (locationInfo.getSignLocation() != null)
|
||||
locationInfo.getSignLocation().getBlock().getState().update();
|
||||
if (locationInfo.getBlockStand() != null) locationInfo.getBlockStand().remove();
|
||||
if (locationInfo.getToolItemStand() != null) locationInfo.getToolItemStand().remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int startSignChangeTask(){
|
||||
private int startSignChangeTask() {
|
||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(ChestsPlusPlus.PLUGIN, this::updateSign, 1, 5);
|
||||
}
|
||||
|
||||
private void updateSign(){
|
||||
private void updateSign() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
List<LocationInfo> locationInfos = locationInfoList.stream().filter(locationInfo -> locationInfo.isInWorld(player)).collect(Collectors.toList()); // Create a utility method for this
|
||||
locationInfos.forEach(locationInfo -> {
|
||||
if (Utils.isLocationInViewDistance(player, locationInfo.getSignLocation()) && Utils.isLocationChunkLoaded(locationInfo.getSignLocation())) {
|
||||
if(displayItem != null) player.sendBlockChange(locationInfo.getSignLocation(), air);
|
||||
if (displayItem != null) player.sendBlockChange(locationInfo.getSignLocation(), air);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -150,8 +152,8 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
/**
|
||||
* This is called after the config has loaded into memory.
|
||||
*/
|
||||
public void postConfigLoad(){
|
||||
for(LocationInfo locationInfo : locationInfoList) {
|
||||
public void postConfigLoad() {
|
||||
for (LocationInfo locationInfo : locationInfoList) {
|
||||
locationInfo.setSignLocation(getSignLocation(locationInfo.getLocation()));
|
||||
}
|
||||
|
||||
@ -167,6 +169,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Add custom parameters here to be serialized.
|
||||
*
|
||||
* @param map - the map to be added to.
|
||||
*/
|
||||
protected abstract void serialize(Map<String, Object> map);
|
||||
@ -174,12 +177,17 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Use this to deserialize custom parameters.
|
||||
*
|
||||
* @param map - the map to deserialize from.
|
||||
*/
|
||||
protected abstract void deserialize(Map<String, Object> map);
|
||||
|
||||
protected abstract Inventory initInventory();
|
||||
|
||||
protected abstract void setIdentifier(String newIdentifier);
|
||||
|
||||
public abstract String getIdentifier();
|
||||
|
||||
public abstract boolean shouldDisplayArmourStands();
|
||||
|
||||
/**
|
||||
@ -189,13 +197,15 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* This is the distance from a full block to the size of the storage block. (e.g Chest is smaller than a regular block.)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract double getBlockOffset(Block block);
|
||||
|
||||
/**
|
||||
* This is called when a block is added to the storage system.
|
||||
* @param block - the block that was added.
|
||||
*
|
||||
* @param block - the block that was added.
|
||||
* @param player - the player who added the storage.
|
||||
*/
|
||||
public abstract void onStorageAdded(Block block, Player player);
|
||||
@ -210,14 +220,15 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Adds a location to this storage.
|
||||
*
|
||||
* @param location - location to be added.
|
||||
*/
|
||||
public void addLocation(Location location, Location signLocation){
|
||||
public void addLocation(Location location, Location signLocation) {
|
||||
LocationInfo locationInfo = new LocationInfo(location);
|
||||
locationInfo.setSignLocation(signLocation);
|
||||
locationInfoList.add(locationInfo);
|
||||
if(shouldDisplayArmourStands()){
|
||||
if(displayItem != null) {
|
||||
if (shouldDisplayArmourStands()) {
|
||||
if (displayItem != null) {
|
||||
updateSign();
|
||||
updateClient(locationInfo);
|
||||
}
|
||||
@ -226,17 +237,18 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Removes a location from this storage and removes any @{@link ArmorStand} associated with that location
|
||||
*
|
||||
* @param location - location to be removed.
|
||||
*/
|
||||
public void removeLocation(Location location){
|
||||
public void removeLocation(Location location) {
|
||||
//Remove armor stands from the world.
|
||||
locationInfoList.stream().filter(locationInfo -> locationInfo.getLocation().equals(location)).forEach(locationInfo -> {
|
||||
ArmorStand blockStand = locationInfo.getBlockStand();
|
||||
if(blockStand != null) blockStand.remove();
|
||||
if (blockStand != null) blockStand.remove();
|
||||
ArmorStand itemStand = locationInfo.getItemStand();
|
||||
if(itemStand != null) itemStand.remove();
|
||||
if (itemStand != null) itemStand.remove();
|
||||
ArmorStand toolStand = locationInfo.getToolItemStand();
|
||||
if(toolStand != null) toolStand.remove();
|
||||
if (toolStand != null) toolStand.remove();
|
||||
});
|
||||
//Remove this location from storage.
|
||||
locationInfoList.removeIf(locationInfo -> locationInfo.getLocation().equals(location));
|
||||
@ -246,21 +258,21 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
* @param location - location being checked
|
||||
* @return true if this storage contains this location
|
||||
*/
|
||||
public boolean containsLocation(Location location){
|
||||
public boolean containsLocation(Location location) {
|
||||
return locationInfoList.stream().filter(locationInfo -> locationInfo.getLocation() != null).anyMatch(locationInfo -> locationInfo.getLocation().equals(location));
|
||||
}
|
||||
|
||||
public LocationInfo getLocationInfo(Location location){
|
||||
public LocationInfo getLocationInfo(Location location) {
|
||||
return locationInfoList.stream().filter(locationInfo -> locationInfo.getLocation().equals(location)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public int getLocationsSize(){
|
||||
public int getLocationsSize() {
|
||||
return locationInfoList.size();
|
||||
}
|
||||
|
||||
public void rename(String newName){
|
||||
public void rename(String newName) {
|
||||
setIdentifier(newName);
|
||||
if(storeInventory()){
|
||||
if (storeInventory()) {
|
||||
ItemStack[] items = getInventory().getContents();
|
||||
inventory = initInventory();
|
||||
inventory.setContents(items);
|
||||
@ -271,11 +283,11 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
getLocations().forEach(location -> {
|
||||
Block block = location.getLocation().getBlock();
|
||||
BlockFace face = getStorageType().getStorageFacing(block);
|
||||
if(face != null) {
|
||||
if (face != null) {
|
||||
Block signBlock = block.getRelative(face);
|
||||
if(signBlock.getState() instanceof Sign) {
|
||||
if (signBlock.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) signBlock.getState();
|
||||
sign.setLine(1, ChatColor.GREEN + ChatColor.stripColor("[" + newName+ "]"));
|
||||
sign.setLine(1, ChatColor.GREEN + ChatColor.stripColor("[" + newName + "]"));
|
||||
sign.update();
|
||||
}
|
||||
}
|
||||
@ -284,10 +296,11 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Drops the contents of the storage at the provided location.
|
||||
*
|
||||
* @param location - location to drop.
|
||||
*/
|
||||
public void dropInventory(Location location){
|
||||
if(doesDropInventory()) {
|
||||
public void dropInventory(Location location) {
|
||||
if (doesDropInventory()) {
|
||||
for (ItemStack item : getInventory().getContents()) {
|
||||
if (location.getWorld() != null) {
|
||||
if (item != null) {
|
||||
@ -299,12 +312,12 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
public Location getSignLocation(Location storageBlock){
|
||||
if(storageBlock == null) return null;
|
||||
public Location getSignLocation(Location storageBlock) {
|
||||
if (storageBlock == null) return null;
|
||||
World world = storageBlock.getWorld();
|
||||
Block block = storageBlock.getBlock();
|
||||
|
||||
if(world != null) {
|
||||
if (world != null) {
|
||||
BlockFace facing = getStorageType().getStorageFacing(block);
|
||||
|
||||
if (facing != null) {
|
||||
@ -319,23 +332,25 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Checks if the given @{@link Player} has permission to access this storage
|
||||
*
|
||||
* @param player - the player being checked
|
||||
* @return true if player has permission.
|
||||
*/
|
||||
public boolean hasPermission(Player player){
|
||||
if(player.hasPermission(Permissions.OPEN_ANY)) return true;
|
||||
public boolean hasPermission(Player player) {
|
||||
if (player.hasPermission(Permissions.OPEN_ANY)) return true;
|
||||
return hasPermission((OfflinePlayer) player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given @{@link OfflinePlayer} has permission to access this storage
|
||||
*
|
||||
* @param player - the player being checked
|
||||
* @return true if player has permission.
|
||||
*/
|
||||
public boolean hasPermission(OfflinePlayer player){
|
||||
if(isPublic) return true;
|
||||
if(player.getUniqueId().equals(playerUUID)) return true;
|
||||
if(members != null) {
|
||||
public boolean hasPermission(OfflinePlayer player) {
|
||||
if (isPublic) return true;
|
||||
if (player.getUniqueId().equals(playerUUID)) return true;
|
||||
if (members != null) {
|
||||
for (String uuid : members) {
|
||||
if (player.getUniqueId().toString().equals(uuid)) return true;
|
||||
}
|
||||
@ -346,15 +361,16 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
/**
|
||||
* Add a @{@link Player} to this storage.
|
||||
* This will return false if the player is null or the player was already present.
|
||||
*
|
||||
* @param player - the player being added.
|
||||
* @return true if the player was added
|
||||
*/
|
||||
public boolean addMember(OfflinePlayer player){
|
||||
if(player != null){
|
||||
if(members == null) members = new ArrayList<>();
|
||||
if(bukkitMembers == null) bukkitMembers = new ArrayList<>();
|
||||
public boolean addMember(OfflinePlayer player) {
|
||||
if (player != null) {
|
||||
if (members == null) members = new ArrayList<>();
|
||||
if (bukkitMembers == null) bukkitMembers = new ArrayList<>();
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if(members.contains(uuid)) return false;
|
||||
if (members.contains(uuid)) return false;
|
||||
members.add(uuid);
|
||||
bukkitMembers.add(player);
|
||||
return true;
|
||||
@ -364,13 +380,14 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Remove a @{@link Player} from this storage.
|
||||
*
|
||||
* @param player - player being removed.
|
||||
* @return true if player was removed.
|
||||
*/
|
||||
public boolean removeMember(OfflinePlayer player){
|
||||
if(player != null){
|
||||
if(bukkitMembers != null) bukkitMembers.remove(player);
|
||||
if(members != null){
|
||||
public boolean removeMember(OfflinePlayer player) {
|
||||
if (player != null) {
|
||||
if (bukkitMembers != null) bukkitMembers.remove(player);
|
||||
if (members != null) {
|
||||
return members.remove(player.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
@ -382,12 +399,12 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
private ItemStack displayItem;
|
||||
private DISPLAY_TYPE displayType;
|
||||
|
||||
private void resetSign(){
|
||||
private void resetSign() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
List<LocationInfo> locationInfos = locationInfoList.stream().filter(locationInfo -> locationInfo.isInWorld(player)).collect(Collectors.toList()); // Create a utility method for this
|
||||
locationInfos.forEach(locationInfo -> {
|
||||
if (Utils.isLocationInViewDistance(player, locationInfo.getSignLocation())) {
|
||||
if( locationInfo.getSignLocation().getBlock().getState() instanceof Sign) {
|
||||
if (locationInfo.getSignLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) locationInfo.getSignLocation().getBlock().getState();
|
||||
player.sendBlockChange(locationInfo.getSignLocation(), sign.getBlockData());
|
||||
player.sendSignChange(locationInfo.getSignLocation(), sign.getLines());
|
||||
@ -397,10 +414,10 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
});
|
||||
}
|
||||
|
||||
public void onItemDisplayUpdate(ItemStack newItem){
|
||||
if(shouldDisplayArmourStands()) {
|
||||
public void onItemDisplayUpdate(ItemStack newItem) {
|
||||
if (shouldDisplayArmourStands()) {
|
||||
if (newItem == null || newItem.getType().equals(Material.AIR)) {
|
||||
if(displayItem != null) resetSign();
|
||||
if (displayItem != null) resetSign();
|
||||
Bukkit.getScheduler().cancelTask(signUpdateTask);
|
||||
signUpdateTask = -1;
|
||||
} else {
|
||||
@ -409,26 +426,26 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
}
|
||||
displayItem = newItem;
|
||||
displayType = DISPLAY_TYPE.getType(displayItem);
|
||||
if(shouldDisplayArmourStands()) updateClients();
|
||||
if (shouldDisplayArmourStands()) updateClients();
|
||||
}
|
||||
|
||||
private EulerAngle BLOCK_POSE = new EulerAngle( Math.toRadians( -15 ), Math.toRadians( -45 ), Math.toRadians(0) );
|
||||
private EulerAngle STANDARD_ITEM_POSE = new EulerAngle(Math.toRadians(90),0,Math.toRadians(180));
|
||||
private EulerAngle TOOL_ITEM_POSE = new EulerAngle(Math.toRadians(-145),0,Math.toRadians(0));
|
||||
private final EulerAngle BLOCK_POSE = new EulerAngle(Math.toRadians(-15), Math.toRadians(-45), Math.toRadians(0));
|
||||
private final EulerAngle STANDARD_ITEM_POSE = new EulerAngle(Math.toRadians(90), 0, Math.toRadians(180));
|
||||
private final EulerAngle TOOL_ITEM_POSE = new EulerAngle(Math.toRadians(-145), 0, Math.toRadians(0));
|
||||
|
||||
/**
|
||||
* Updates nearby clients for all locations of this storage:
|
||||
* - If getArmorStandItem() is non-null the block in-front of the storage is set to Air and an @{@link ArmorStand} is
|
||||
* spawned that displays the item.
|
||||
* spawned that displays the item.
|
||||
*/
|
||||
private void updateClients(){
|
||||
if(locationInfoList == null) return;
|
||||
for (LocationInfo location : locationInfoList){
|
||||
private void updateClients() {
|
||||
if (locationInfoList == null) return;
|
||||
for (LocationInfo location : locationInfoList) {
|
||||
updateClient(location);
|
||||
}
|
||||
}
|
||||
|
||||
private BlockData air = Material.AIR.createBlockData();
|
||||
private final BlockData air = Material.AIR.createBlockData();
|
||||
|
||||
enum DISPLAY_TYPE {
|
||||
IGNORE,
|
||||
@ -436,71 +453,72 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
BLOCK,
|
||||
ITEM;
|
||||
|
||||
public static DISPLAY_TYPE getType(ItemStack itemStack){
|
||||
if(itemStack == null) return IGNORE;
|
||||
if(ApiSpecific.getMaterialChecker().isIgnored(itemStack)) return IGNORE;
|
||||
if(ApiSpecific.getMaterialChecker().isTool(itemStack)) return TOOL;
|
||||
if(ApiSpecific.getMaterialChecker().isGraphically2D(itemStack)) return ITEM;
|
||||
public static DISPLAY_TYPE getType(ItemStack itemStack) {
|
||||
if (itemStack == null) return IGNORE;
|
||||
if (ApiSpecific.getMaterialChecker().isIgnored(itemStack)) return IGNORE;
|
||||
if (ApiSpecific.getMaterialChecker().isTool(itemStack)) return TOOL;
|
||||
if (ApiSpecific.getMaterialChecker().isGraphically2D(itemStack)) return ITEM;
|
||||
else return BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateClient(LocationInfo location){
|
||||
if(location.getLocation() == null || !Utils.isLocationChunkLoaded(location.getLocation())) return;
|
||||
public void updateClient(LocationInfo location) {
|
||||
if (location.getLocation() == null || !Utils.isLocationChunkLoaded(location.getLocation())) return;
|
||||
World world = location.getLocation().getWorld();
|
||||
|
||||
if(world != null) {
|
||||
if(location.getSignLocation() == null) return;
|
||||
Block storageBlock = location.getLocation().getBlock();
|
||||
Block anchor = location.getSignLocation().getBlock();
|
||||
if (world != null) {
|
||||
if (location.getSignLocation() == null) return;
|
||||
Block storageBlock = location.getLocation().getBlock();
|
||||
Block anchor = location.getSignLocation().getBlock();
|
||||
|
||||
if(displayItem != null && displayType != DISPLAY_TYPE.IGNORE) {
|
||||
boolean isBlock = displayType == DISPLAY_TYPE.BLOCK;
|
||||
boolean isTool = displayType == DISPLAY_TYPE.TOOL;
|
||||
if (displayItem != null && displayType != DISPLAY_TYPE.IGNORE) {
|
||||
boolean isBlock = displayType == DISPLAY_TYPE.BLOCK;
|
||||
boolean isTool = displayType == DISPLAY_TYPE.TOOL;
|
||||
|
||||
//Get currently stored armorStand if there isn't one spawn it.
|
||||
ArmorStand stand = isTool ? location.getToolItemStand() : (isBlock ? location.getBlockStand() : location.getItemStand());
|
||||
if(stand == null || !stand.isValid()) {
|
||||
BlockFace facing;
|
||||
if(anchor.getBlockData() instanceof Directional){
|
||||
facing = ((Directional) anchor.getBlockData()).getFacing();
|
||||
} else return;
|
||||
Location standLoc = isTool ? getHeldItemArmorStandLoc(storageBlock,anchor, facing) : getArmorStandLoc(storageBlock, anchor, facing, isBlock);
|
||||
stand = createArmorStand(world, standLoc, isBlock, isTool);
|
||||
addArmorStand(isBlock, isTool, location, stand);
|
||||
}
|
||||
//Get currently stored armorStand if there isn't one spawn it.
|
||||
ArmorStand stand = isTool ? location.getToolItemStand() : (isBlock ? location.getBlockStand() : location.getItemStand());
|
||||
if (stand == null || !stand.isValid()) {
|
||||
BlockFace facing;
|
||||
if (anchor.getBlockData() instanceof Directional) {
|
||||
facing = ((Directional) anchor.getBlockData()).getFacing();
|
||||
} else return;
|
||||
Location standLoc = isTool ? getHeldItemArmorStandLoc(storageBlock, anchor, facing) : getArmorStandLoc(storageBlock, anchor, facing, isBlock);
|
||||
stand = createArmorStand(world, standLoc, isBlock, isTool);
|
||||
addArmorStand(isBlock, isTool, location, stand);
|
||||
}
|
||||
|
||||
stand.setItemInHand(displayItem);
|
||||
stand.setItemInHand(displayItem);
|
||||
|
||||
//Set on fire to correct lighting.
|
||||
stand.setFireTicks(Integer.MAX_VALUE);
|
||||
//Set on fire to correct lighting.
|
||||
stand.setFireTicks(Integer.MAX_VALUE);
|
||||
|
||||
//Set other armor stand helmet to null.
|
||||
if(isBlock) {
|
||||
removeArmorStandItem(location.getToolItemStand());
|
||||
removeArmorStandItem(location.getItemStand());
|
||||
} else {
|
||||
removeArmorStandItem(location.getBlockStand());
|
||||
if(isTool) removeArmorStandItem(location.getItemStand());
|
||||
else removeArmorStandItem(location.getToolItemStand());
|
||||
}
|
||||
} else {
|
||||
// anchor.getState().update();
|
||||
//Set other armor stand helmet to null.
|
||||
if (isBlock) {
|
||||
removeArmorStandItem(location.getToolItemStand());
|
||||
removeArmorStandItem(location.getItemStand());
|
||||
} else {
|
||||
removeArmorStandItem(location.getBlockStand());
|
||||
if (isTool) removeArmorStandItem(location.getItemStand());
|
||||
else removeArmorStandItem(location.getToolItemStand());
|
||||
}
|
||||
} else {
|
||||
// anchor.getState().update();
|
||||
removeArmorStandItem(location.getToolItemStand());
|
||||
removeArmorStandItem(location.getItemStand());
|
||||
removeArmorStandItem(location.getBlockStand());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty @{@link ArmorStand} with properties to make it invisible, invulnerable etc.
|
||||
* @param world - the world to spawn in.
|
||||
*
|
||||
* @param world - the world to spawn in.
|
||||
* @param standLoc - location to spawn the @{@link ArmorStand} at.
|
||||
* @return instance of @{@link ArmorStand} that was spawned.
|
||||
*/
|
||||
private ArmorStand createArmorStand(World world, Location standLoc, boolean isBlock, boolean isTool){
|
||||
private ArmorStand createArmorStand(World world, Location standLoc, boolean isBlock, boolean isTool) {
|
||||
ArmorStand stand = world.spawn(standLoc, ArmorStand.class);
|
||||
stand.setVisible(false);
|
||||
stand.setGravity(false);
|
||||
@ -520,12 +538,13 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Gets the location of an @{@link ArmorStand} based on the Block, BlockFace and if it's a Block/Item.
|
||||
* @param anchor - anchor block to base @{@link ArmorStand} location from.
|
||||
* @param facing - BlockFace the stand should be placed on.
|
||||
*
|
||||
* @param anchor - anchor block to base @{@link ArmorStand} location from.
|
||||
* @param facing - BlockFace the stand should be placed on.
|
||||
* @param isBlock - true if the @{@link ItemStack} is a Block / false if an Item.
|
||||
* @return the calculated location for the @{@link ArmorStand}
|
||||
*/
|
||||
private Location getArmorStandLoc(Block storageBlock, Block anchor, BlockFace facing, boolean isBlock){
|
||||
private Location getArmorStandLoc(Block storageBlock, Block anchor, BlockFace facing, boolean isBlock) {
|
||||
double directionFactor = isBlock ? 0.65 : 0.275;
|
||||
double perpendicularFactor = isBlock ? 0.025 : 0.125;
|
||||
double y = isBlock ? -0.3 : 0.1;
|
||||
@ -534,7 +553,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
}
|
||||
|
||||
|
||||
private Location getHeldItemArmorStandLoc(Block storageBlock, Block anchor, BlockFace facing){
|
||||
private Location getHeldItemArmorStandLoc(Block storageBlock, Block anchor, BlockFace facing) {
|
||||
double directionFactor = 0.36;
|
||||
double perpendicularFactor = 0;
|
||||
double y = 0.275;
|
||||
@ -542,43 +561,44 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
return getArmorStandLoc(storageBlock, anchor, facing, directionFactor, perpendicularFactor, y, yaw);
|
||||
}
|
||||
|
||||
private Location getArmorStandLoc(Block storageBlock, Block anchor, BlockFace facing, double directionFactor, double perpendicularFactor, double y, float yaw){
|
||||
private Location getArmorStandLoc(Block storageBlock, Block anchor, BlockFace facing, double directionFactor, double perpendicularFactor, double y, float yaw) {
|
||||
//Get centre of block location.
|
||||
Location standLoc = anchor.getLocation().add(0.5,-0.5,0.5);
|
||||
Location standLoc = anchor.getLocation().add(0.5, -0.5, 0.5);
|
||||
Vector direction = facing.getDirection();
|
||||
|
||||
directionFactor = directionFactor + getBlockOffset(storageBlock);
|
||||
double x = directionFactor*direction.getX() - perpendicularFactor*direction.getZ();
|
||||
double z = directionFactor*direction.getZ() + perpendicularFactor*direction.getX();
|
||||
double x = directionFactor * direction.getX() - perpendicularFactor * direction.getZ();
|
||||
double z = directionFactor * direction.getZ() + perpendicularFactor * direction.getX();
|
||||
|
||||
standLoc.setYaw(getYaw(direction.getX(),direction.getZ())+yaw);
|
||||
standLoc.setYaw(getYaw(direction.getX(), direction.getZ()) + yaw);
|
||||
return standLoc.subtract(x, y, z);
|
||||
}
|
||||
|
||||
private void removeArmorStandItem(ArmorStand stand){
|
||||
if(stand != null) stand.setItemInHand(null);
|
||||
private void removeArmorStandItem(ArmorStand stand) {
|
||||
if (stand != null) stand.setItemInHand(null);
|
||||
}
|
||||
|
||||
private void addArmorStand(boolean isBlock, boolean isTool, LocationInfo location, ArmorStand stand){
|
||||
if(isTool) location.setToolItemStand(stand);
|
||||
else if(isBlock) location.setBlockStand(stand);
|
||||
private void addArmorStand(boolean isBlock, boolean isTool, LocationInfo location, ArmorStand stand) {
|
||||
if (isTool) location.setToolItemStand(stand);
|
||||
else if (isBlock) location.setBlockStand(stand);
|
||||
else location.setItemStand(stand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get yaw based upon the direction of the x and y components of the Chest BlockFace
|
||||
* Uses precalculated values for most orientations.
|
||||
*
|
||||
* @param x component
|
||||
* @param y component
|
||||
* @return yaw
|
||||
*/
|
||||
private float getYaw(double x, double y){
|
||||
if(x == 0 && y == -1) return 0;
|
||||
if(x == 1 && y == 0) return 90;
|
||||
if(x == 0 && y == 1) return 180;
|
||||
if(x == -1 && y == 0) return 270;
|
||||
private float getYaw(double x, double y) {
|
||||
if (x == 0 && y == -1) return 0;
|
||||
if (x == 1 && y == 0) return 90;
|
||||
if (x == 0 && y == 1) return 180;
|
||||
if (x == -1 && y == 0) return 270;
|
||||
|
||||
return (float) (Math.asin(y/Math.sqrt(y*y+x*x))+90);
|
||||
return (float) (Math.asin(y / Math.sqrt(y * y + x * x)) + 90);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,27 +14,27 @@ import java.util.UUID;
|
||||
|
||||
public class StorageInfo<T extends AbstractStorage> {
|
||||
|
||||
private String group;
|
||||
private OfflinePlayer player;
|
||||
private final String group;
|
||||
private final OfflinePlayer player;
|
||||
private T storage;
|
||||
|
||||
public StorageInfo(String playerUUID, String group, StorageType<T> storageType, Sign sign){
|
||||
this(UUID.fromString(playerUUID),group, storageType, sign);
|
||||
public StorageInfo(String playerUUID, String group, StorageType<T> storageType, Sign sign) {
|
||||
this(UUID.fromString(playerUUID), group, storageType, sign);
|
||||
}
|
||||
|
||||
public StorageInfo(UUID playerUUID, String group, StorageType<T> storageType, Sign sign){
|
||||
public StorageInfo(UUID playerUUID, String group, StorageType<T> storageType, Sign sign) {
|
||||
this.group = group;
|
||||
this.player = Bukkit.getOfflinePlayer(playerUUID);
|
||||
this.storage = storageType.getStorage(playerUUID,group);
|
||||
if(storage == null){
|
||||
if(sign.getBlockData() instanceof Directional) {
|
||||
this.storage = storageType.getStorage(playerUUID, group);
|
||||
if (storage == null) {
|
||||
if (sign.getBlockData() instanceof Directional) {
|
||||
Directional directional = (Directional) sign.getBlockData();
|
||||
BlockFace storageFace = directional.getFacing().getOppositeFace();
|
||||
Block storageBlock = sign.getBlock().getRelative(storageFace);
|
||||
Player player = Bukkit.getPlayer(playerUUID);
|
||||
if(player != null) {
|
||||
if (player != null) {
|
||||
boolean added = storageType.add(player, group, storageBlock.getLocation(), sign.getLocation(), this.player);
|
||||
if(added) {
|
||||
if (added) {
|
||||
this.storage = storageType.getStorage(playerUUID, group);
|
||||
// storageType.getMessages().foundUnlinkedStorage(player,group);
|
||||
}
|
||||
@ -54,14 +54,15 @@ public class StorageInfo<T extends AbstractStorage> {
|
||||
/**
|
||||
* Get the AutoCraftingStorage for this Sign and check if the given location is apart of the system if not
|
||||
* add it.
|
||||
*
|
||||
* @return @{@link AutoCraftingStorage}
|
||||
*/
|
||||
public T getStorage(Location location) {
|
||||
if(storage == null) return null;
|
||||
if(!storage.containsLocation(location)){
|
||||
if (storage == null) return null;
|
||||
if (!storage.containsLocation(location)) {
|
||||
storage.addLocation(location, storage.getSignLocation(location));
|
||||
Player player = storage.getOwner().getPlayer();
|
||||
if(player != null) storage.getStorageType().getMessages().foundUnlinkedStorage(player,getGroup());
|
||||
if (player != null) storage.getStorageType().getMessages().foundUnlinkedStorage(player, getGroup());
|
||||
}
|
||||
return storage;
|
||||
}
|
||||
|
@ -12,67 +12,70 @@ public abstract class StorageMessages {
|
||||
|
||||
public abstract String getStorageName();
|
||||
|
||||
public void storageAdded(Player target, String group, String player){
|
||||
target.sendMessage(ChatColor.GREEN+TAG+" "+ Message.STORAGE_ADDED.getString(getStorageName(), ChatColor.WHITE+group+ChatColor.GREEN, ChatColor.WHITE+player));
|
||||
public void storageAdded(Player target, String group, String player) {
|
||||
target.sendMessage(ChatColor.GREEN + TAG + " " + Message.STORAGE_ADDED.getString(getStorageName(), ChatColor.WHITE + group + ChatColor.GREEN, ChatColor.WHITE + player));
|
||||
}
|
||||
|
||||
public void storageRemoved(Player target, String group, String player){
|
||||
target.sendMessage(ChatColor.RED+TAG+" "+Message.STORAGE_REMOVED.getString(getStorageName(), ChatColor.WHITE+group+ChatColor.RED, ChatColor.WHITE+player));
|
||||
public void storageRemoved(Player target, String group, String player) {
|
||||
target.sendMessage(ChatColor.RED + TAG + " " + Message.STORAGE_REMOVED.getString(getStorageName(), ChatColor.WHITE + group + ChatColor.RED, ChatColor.WHITE + player));
|
||||
}
|
||||
|
||||
public void removedGroup(Player target, String toRemove){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.REMOVED_GROUP.getString(toRemove, getStorageName()));
|
||||
public void removedGroup(Player target, String toRemove) {
|
||||
target.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + TAG + " " + Message.REMOVED_GROUP.getString(toRemove, getStorageName()));
|
||||
}
|
||||
|
||||
public void groupDoesntExist(Player target, String toRemove){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.GROUP_DOESNT_EXIST.getString(toRemove, getStorageName()));
|
||||
public void groupDoesntExist(Player target, String toRemove) {
|
||||
target.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + TAG + " " + Message.GROUP_DOESNT_EXIST.getString(toRemove, getStorageName()));
|
||||
}
|
||||
|
||||
public void foundUnlinkedStorage(Player target, String group){
|
||||
target.sendMessage(ChatColor.GOLD+TAG+" "+Message.FOUND_UNLINKED_STORAGE.getString(getStorageName(), group));
|
||||
public void foundUnlinkedStorage(Player target, String group) {
|
||||
target.sendMessage(ChatColor.GOLD + TAG + " " + Message.FOUND_UNLINKED_STORAGE.getString(getStorageName(), group));
|
||||
}
|
||||
|
||||
public void addedMember(Player target, AbstractStorage storage, String added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.ADDED_MEMBER.getString(ChatColor.WHITE+added+ChatColor.GREEN, getStorageName(), ChatColor.WHITE+storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.CURRENT_MEMBERS.getString(Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers())));
|
||||
public void addedMember(Player target, AbstractStorage storage, String added) {
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + TAG + " " + Message.ADDED_MEMBER.getString(ChatColor.WHITE + added + ChatColor.GREEN, getStorageName(), ChatColor.WHITE + storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + TAG + " " + Message.CURRENT_MEMBERS.getString(Utils.prettyPrintPlayers(ChatColor.GREEN, storage.getMembers())));
|
||||
}
|
||||
|
||||
public void addMemberToAll(Player target, OfflinePlayer added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.ADDED_MEMBER_TO_ALL.getString(ChatColor.WHITE+added.getName()+ChatColor.GREEN, getStorageName()));
|
||||
public void addMemberToAll(Player target, OfflinePlayer added) {
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + TAG + " " + Message.ADDED_MEMBER_TO_ALL.getString(ChatColor.WHITE + added.getName() + ChatColor.GREEN, getStorageName()));
|
||||
}
|
||||
|
||||
public void unableToAddMember(Player target, String toAdd){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.UNABLE_TO_ADD_MEMBER_TO_ALL.getString(toAdd, getStorageName()));
|
||||
public void unableToAddMember(Player target, String toAdd) {
|
||||
target.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + TAG + " " + Message.UNABLE_TO_ADD_MEMBER_TO_ALL.getString(toAdd, getStorageName()));
|
||||
}
|
||||
|
||||
public void removedMember(Player target, AbstractStorage storage, String added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.REMOVED_MEMBER.getString(ChatColor.WHITE+added+ChatColor.GREEN, getStorageName(), ChatColor.WHITE+storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.CURRENT_MEMBERS.getString(Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers())));
|
||||
public void removedMember(Player target, AbstractStorage storage, String added) {
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + TAG + " " + Message.REMOVED_MEMBER.getString(ChatColor.WHITE + added + ChatColor.GREEN, getStorageName(), ChatColor.WHITE + storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + TAG + " " + Message.CURRENT_MEMBERS.getString(Utils.prettyPrintPlayers(ChatColor.GREEN, storage.getMembers())));
|
||||
}
|
||||
|
||||
public void removeMemberFromAll(Player target, OfflinePlayer added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.REMOVE_MEMBER_FROM_ALL.getString(ChatColor.WHITE+added.getName()+ChatColor.GREEN, getStorageName()));
|
||||
public void removeMemberFromAll(Player target, OfflinePlayer added) {
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + TAG + " " + Message.REMOVE_MEMBER_FROM_ALL.getString(ChatColor.WHITE + added.getName() + ChatColor.GREEN, getStorageName()));
|
||||
}
|
||||
|
||||
public void unableToRemoveMember(Player target, String toAdd){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.UNABLE_TO_REMOVE_MEMBER.getString(toAdd, getStorageName()));
|
||||
public void unableToRemoveMember(Player target, String toAdd) {
|
||||
target.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + TAG + " " + Message.UNABLE_TO_REMOVE_MEMBER.getString(toAdd, getStorageName()));
|
||||
}
|
||||
|
||||
public void listMembers(Player target, AbstractStorage storage){
|
||||
if(storage.getMembers() != null){
|
||||
target.sendMessage(ChatColor.GREEN+Message.LIST_MEMBERS_OF_GROUP.getString(getStorageName(), ChatColor.WHITE+storage.getIdentifier(), Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers())));
|
||||
public void listMembers(Player target, AbstractStorage storage) {
|
||||
if (storage.getMembers() != null) {
|
||||
target.sendMessage(ChatColor.GREEN + Message.LIST_MEMBERS_OF_GROUP.getString(getStorageName(), ChatColor.WHITE + storage.getIdentifier(), Utils.prettyPrintPlayers(ChatColor.GREEN, storage.getMembers())));
|
||||
} else {
|
||||
target.sendMessage(ChatColor.YELLOW+Message.NO_ADDITIONAL_MEMBERS.getString(ChatColor.WHITE+storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.YELLOW + Message.NO_ADDITIONAL_MEMBERS.getString(ChatColor.WHITE + storage.getIdentifier()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setPublic(Player target, AbstractStorage storage){
|
||||
target.sendMessage(ChatColor.GREEN+Message.SET_PUBLICITY.getString(getStorageName(), storage.getIdentifier(), ChatColor.WHITE+""+storage.isPublic()));
|
||||
public void setPublic(Player target, AbstractStorage storage) {
|
||||
target.sendMessage(ChatColor.GREEN + Message.SET_PUBLICITY.getString(getStorageName(), storage.getIdentifier(), ChatColor.WHITE + "" + storage.isPublic()));
|
||||
}
|
||||
|
||||
public abstract void invalidID(Player target);
|
||||
|
||||
public abstract void listStorageGroups(Player target);
|
||||
|
||||
public abstract void mustLookAtBlock(Player player);
|
||||
|
||||
public abstract void invalidSignPlacement(Player player);
|
||||
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ import java.util.stream.Collectors;
|
||||
|
||||
public abstract class StorageType<T extends AbstractStorage> {
|
||||
|
||||
private ConfigStorage store;
|
||||
private StorageUtils<StorageInfo<T>, T> storageUtils;
|
||||
private HashMap<Location, T> storageCache;
|
||||
private final ConfigStorage store;
|
||||
private final StorageUtils<StorageInfo<T>, T> storageUtils;
|
||||
private final HashMap<Location, T> storageCache;
|
||||
|
||||
protected StorageType(ConfigStorage store){
|
||||
protected StorageType(ConfigStorage store) {
|
||||
this.store = store;
|
||||
storageUtils = new StorageUtils<>(this);
|
||||
storageCache = new HashMap<>();
|
||||
@ -57,12 +57,13 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
|
||||
public abstract T createNewStorageInstance(OfflinePlayer player, String inventoryName, Location location, Location signLocation);
|
||||
|
||||
public HashMap<String, HashMap<String, T>> getStorageMap(){
|
||||
public HashMap<String, HashMap<String, T>> getStorageMap() {
|
||||
return getStorageMap(store);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the tag used in Signs such as [ChestLink] or [AutoCraft]
|
||||
*
|
||||
* @return String value of the sign tag.
|
||||
*/
|
||||
public abstract String getSignTag();
|
||||
@ -70,6 +71,7 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
/**
|
||||
* This method should check if a block type is a valid type for this Storage.
|
||||
* E.g A Chest, or Crafting table etc.
|
||||
*
|
||||
* @param block - the block being checked
|
||||
* @return true if the block is valid.
|
||||
*/
|
||||
@ -77,19 +79,22 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
|
||||
/**
|
||||
* This gets called when a block is removed from the storage system but is still present in the world.
|
||||
*
|
||||
* @param block - the block that was removed (Not the sign)
|
||||
*/
|
||||
public abstract void onSignRemoval(Block block);
|
||||
|
||||
public abstract boolean hasPermissionToAdd(Player player);
|
||||
|
||||
public void createStorage(Player player, Block block, String identifier, boolean requireSign){
|
||||
public void createStorage(Player player, Block block, String identifier, boolean requireSign) {
|
||||
createStorage(player, player, block, identifier, requireSign);
|
||||
}
|
||||
|
||||
public abstract void createStorage(Player player, OfflinePlayer owner, Block block, String identifier, boolean requireSign);
|
||||
|
||||
public abstract void createStorageFacing(Player player, OfflinePlayer owner, Block block, String identifier, BlockFace facing, boolean requireSign);
|
||||
public void createStorageFacing(Player player, Block block, String identifier, BlockFace facing, boolean requireSign){
|
||||
|
||||
public void createStorageFacing(Player player, Block block, String identifier, BlockFace facing, boolean requireSign) {
|
||||
createStorageFacing(player, player, block, identifier, facing, requireSign);
|
||||
}
|
||||
|
||||
@ -118,7 +123,7 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
STORAGE MAP SECTION
|
||||
*/
|
||||
|
||||
private HashMap<String, HashMap<String, T>> getMap(){
|
||||
private HashMap<String, HashMap<String, T>> getMap() {
|
||||
return getStorageMap(store);
|
||||
}
|
||||
|
||||
@ -142,19 +147,19 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
}
|
||||
}
|
||||
|
||||
public T getStorage(UUID playerUUID, String identifier){
|
||||
public T getStorage(UUID playerUUID, String identifier) {
|
||||
HashMap<String, T> map = getStorageMap(playerUUID);
|
||||
return map.getOrDefault(identifier, null);
|
||||
}
|
||||
|
||||
public T getStorage(Location location) {
|
||||
T storage = storageCache.get(location);
|
||||
if(storage != null) return storage;
|
||||
if (storage != null) return storage;
|
||||
if (location != null) {
|
||||
Block block = location.getBlock();
|
||||
if (isValidBlockType(block)) {
|
||||
StorageInfo<T> storageInfo = storageUtils.getStorageInfo(location);
|
||||
if(storageInfo != null){
|
||||
if (storageInfo != null) {
|
||||
return storageInfo.getStorage(location);
|
||||
}
|
||||
}
|
||||
@ -214,8 +219,9 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
|
||||
/**
|
||||
* Removes a block from the given storage system.
|
||||
* @param storage - @{@link AbstractStorage}
|
||||
* @param location - the @{@link Location} to remove
|
||||
*
|
||||
* @param storage - @{@link AbstractStorage}
|
||||
* @param location - the @{@link Location} to remove
|
||||
* @param hasPickedUp - true if the player Silk Touched the block.
|
||||
* @return
|
||||
*/
|
||||
@ -252,7 +258,7 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
});
|
||||
storage.dropInventory(player.getLocation());
|
||||
getStorageMap(player.getUniqueId()).remove(group);
|
||||
getMessages().removedGroup(player,group);
|
||||
getMessages().removedGroup(player, group);
|
||||
} else {
|
||||
getMessages().groupDoesntExist(player, group);
|
||||
}
|
||||
@ -289,12 +295,12 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
|
||||
/* HELPER UTILS */
|
||||
|
||||
protected void placeSign(Block placedAgainst, Block toReplace, BlockFace facing, Player player, OfflinePlayer ownerPlayer, String identifier, String linkTag, boolean requireSign){
|
||||
if(Utils.isAir(toReplace)){
|
||||
protected void placeSign(Block placedAgainst, Block toReplace, BlockFace facing, Player player, OfflinePlayer ownerPlayer, String identifier, String linkTag, boolean requireSign) {
|
||||
if (Utils.isAir(toReplace)) {
|
||||
BlockState replacedBlockState = toReplace.getState();
|
||||
|
||||
Material signMaterial = Material.OAK_WALL_SIGN;
|
||||
if(player.getGameMode() != GameMode.CREATIVE && requireSign) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE && requireSign) {
|
||||
if (player.getEquipment() != null) {
|
||||
if (!Tag.SIGNS.isTagged(player.getEquipment().getItemInMainHand().getType())) {
|
||||
Messages.MUST_HOLD_SIGN(player);
|
||||
@ -309,12 +315,12 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
}
|
||||
|
||||
String uuid, group, owner = null;
|
||||
if(identifier.contains(":")){
|
||||
if (identifier.contains(":")) {
|
||||
String[] args = identifier.split(":");
|
||||
owner = args[0];
|
||||
group = args[1];
|
||||
ownerPlayer = Config.getOfflinePlayer(owner);
|
||||
if(ownerPlayer != null){
|
||||
if (ownerPlayer != null) {
|
||||
uuid = ownerPlayer.getUniqueId().toString();
|
||||
} else {
|
||||
getMessages().invalidID(player);
|
||||
@ -329,7 +335,7 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
lines[0] = linkTag;
|
||||
lines[1] = Values.identifier(group);
|
||||
lines[3] = "";
|
||||
if(owner != null) lines[2] = owner;
|
||||
if (owner != null) lines[2] = owner;
|
||||
else lines[2] = "";
|
||||
|
||||
Material airType = toReplace.getType();
|
||||
@ -342,45 +348,45 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
sign.getPersistentDataContainer().set(Values.playerUUID, PersistentDataType.STRING, uuid);
|
||||
sign.update();
|
||||
|
||||
BlockPlaceEvent event = new BlockPlaceEvent(sign.getBlock(),replacedBlockState,placedAgainst,new ItemStack(Material.AIR),player,true, EquipmentSlot.HAND);
|
||||
BlockPlaceEvent event = new BlockPlaceEvent(sign.getBlock(), replacedBlockState, placedAgainst, new ItemStack(Material.AIR), player, true, EquipmentSlot.HAND);
|
||||
ChestsPlusPlus.PLUGIN.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()){
|
||||
if (event.isCancelled()) {
|
||||
sign.setType(airType);
|
||||
return;
|
||||
}
|
||||
|
||||
SignChangeEvent signChangeEvent = new SignChangeEvent(sign.getBlock(),player,lines);
|
||||
SignChangeEvent signChangeEvent = new SignChangeEvent(sign.getBlock(), player, lines);
|
||||
ChestsPlusPlus.PLUGIN.getServer().getPluginManager().callEvent(signChangeEvent);
|
||||
} else {
|
||||
getMessages().invalidSignPlacement(player);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getStorageList(Player player, String searchedArg){
|
||||
public List<String> getStorageList(Player player, String searchedArg) {
|
||||
return getStorageMap(player.getUniqueId()).values().stream().filter(t -> t.getIdentifier().contains(searchedArg)).map(AbstractStorage::getIdentifier).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<String> getOpenableStorageList(Player player, String searchedArg){
|
||||
public List<String> getOpenableStorageList(Player player, String searchedArg) {
|
||||
List<String> playerList = getStorageList(player, searchedArg);
|
||||
List<String> memberList = getStorageMemberOf(player).stream().filter(t -> t.getIdentifier().contains(searchedArg)).map(storage -> storage.getOwner().getName()+":"+storage.getIdentifier()).collect(Collectors.toList());
|
||||
List<String> memberList = getStorageMemberOf(player).stream().filter(t -> t.getIdentifier().contains(searchedArg)).map(storage -> storage.getOwner().getName() + ":" + storage.getIdentifier()).collect(Collectors.toList());
|
||||
playerList.addAll(memberList);
|
||||
return playerList;
|
||||
}
|
||||
|
||||
public List<LocationInfo> getViewingDistanceStorages(Player player){
|
||||
public List<LocationInfo> getViewingDistanceStorages(Player player) {
|
||||
List<LocationInfo> list = new ArrayList<>();
|
||||
getStorageMap(store).values().forEach(map -> map.values().forEach(abstractStorage -> abstractStorage.getLocations().forEach(locationInfo -> {
|
||||
if(Utils.isLocationInViewDistance(player, locationInfo.getSignLocation())){
|
||||
if (Utils.isLocationInViewDistance(player, locationInfo.getSignLocation())) {
|
||||
list.add(locationInfo);
|
||||
}
|
||||
})));
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<LocationInfo> getLocationsInChunk(Chunk chunk){
|
||||
public List<LocationInfo> getLocationsInChunk(Chunk chunk) {
|
||||
List<LocationInfo> list = new ArrayList<>();
|
||||
getStorageMap().values().forEach(map -> map.values().forEach(abstractStorage -> abstractStorage.getLocations().forEach(locationInfo -> {
|
||||
if(locationInfo.getSignLocation().getChunk().equals(chunk)){
|
||||
if (locationInfo.getSignLocation().getChunk().equals(chunk)) {
|
||||
list.add(locationInfo);
|
||||
}
|
||||
})));
|
||||
@ -391,7 +397,7 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
POST LOAD
|
||||
*/
|
||||
|
||||
public void onConfigLoad(){
|
||||
public void onConfigLoad() {
|
||||
getMap().values().forEach(stringTHashMap -> stringTHashMap.values().forEach(AbstractStorage::postConfigLoad));
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,13 @@ import org.bukkit.inventory.ShapelessRecipe;
|
||||
import java.util.Map;
|
||||
|
||||
@SerializableAs("AutoCraftingStorage")
|
||||
public class AutoCraftingStorage extends AbstractStorage implements ConfigurationSerializable {
|
||||
public class AutoCraftingStorage extends AbstractStorage implements ConfigurationSerializable {
|
||||
|
||||
private RecipeSerializable recipeSerializable;
|
||||
private String identifier;
|
||||
private VirtualCraftingHolder virtualCraftingHolder;
|
||||
|
||||
public AutoCraftingStorage(Map<String, Object> map){
|
||||
public AutoCraftingStorage(Map<String, Object> map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public class AutoCraftingStorage extends AbstractStorage implements Configuratio
|
||||
return Config.getAutoCraft();
|
||||
}
|
||||
|
||||
public AutoCraftingStorage(OfflinePlayer player, String identifier, Location location, Location signLocation){
|
||||
public AutoCraftingStorage(OfflinePlayer player, String identifier, Location location, Location signLocation) {
|
||||
super(player, identifier, location, signLocation);
|
||||
this.identifier = identifier;
|
||||
initInventory();
|
||||
@ -42,7 +42,7 @@ public class AutoCraftingStorage extends AbstractStorage implements Configuratio
|
||||
|
||||
@Override
|
||||
protected void serialize(Map<String, Object> hashMap) {
|
||||
hashMap.put("recipe",recipeSerializable);
|
||||
hashMap.put("recipe", recipeSerializable);
|
||||
hashMap.put("identifier", identifier);
|
||||
}
|
||||
|
||||
@ -58,8 +58,8 @@ public class AutoCraftingStorage extends AbstractStorage implements Configuratio
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRecipe(Recipe recipe){
|
||||
if(recipe == null){
|
||||
public void setRecipe(Recipe recipe) {
|
||||
if (recipe == null) {
|
||||
recipeSerializable = null;
|
||||
return;
|
||||
}
|
||||
@ -91,10 +91,10 @@ public class AutoCraftingStorage extends AbstractStorage implements Configuratio
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Inventory initInventory(){
|
||||
if(virtualCraftingHolder == null) virtualCraftingHolder = new VirtualCraftingHolder(this);
|
||||
protected Inventory initInventory() {
|
||||
if (virtualCraftingHolder == null) virtualCraftingHolder = new VirtualCraftingHolder(this);
|
||||
|
||||
if(recipeSerializable != null) {
|
||||
if (recipeSerializable != null) {
|
||||
Recipe recipe = recipeSerializable.getRecipe();
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
@ -125,6 +125,7 @@ public class AutoCraftingStorage extends AbstractStorage implements Configuratio
|
||||
@Override
|
||||
public void postConfigLoad() {
|
||||
super.postConfigLoad();
|
||||
if(recipeSerializable != null && recipeSerializable.getRecipe() != null) onItemDisplayUpdate(recipeSerializable.getRecipe().getResult());
|
||||
if (recipeSerializable != null && recipeSerializable.getRecipe() != null)
|
||||
onItemDisplayUpdate(recipeSerializable.getRecipe().getResult());
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ public class AutoCraftingStorageType extends StorageType<AutoCraftingStorage> {
|
||||
|
||||
@Override
|
||||
public void createStorage(Player player, OfflinePlayer owner, Block block, String identifier, boolean requireSign) {
|
||||
if(isValidBlockType(block)){
|
||||
if (isValidBlockType(block)) {
|
||||
BlockFace facing = Utils.getBlockFace(player);
|
||||
if(facing != null) {
|
||||
if (facing != null) {
|
||||
createStorageFacing(player, owner, block, identifier, facing, requireSign);
|
||||
}
|
||||
}
|
||||
@ -73,27 +73,27 @@ public class AutoCraftingStorageType extends StorageType<AutoCraftingStorage> {
|
||||
|
||||
@Override
|
||||
public void createStorageFacing(Player player, OfflinePlayer owner, Block block, String identifier, BlockFace facing, boolean requireSign) {
|
||||
if(Utils.isSideFace(facing)) {
|
||||
if (Utils.isSideFace(facing)) {
|
||||
Block toReplace = block.getRelative(facing);
|
||||
StorageInfo info = getStorageUtils().getStorageInfo(block.getLocation());
|
||||
if(info != null){
|
||||
Messages.ALREADY_PART_OF_GROUP(player,"Crafting Table");
|
||||
if (info != null) {
|
||||
Messages.ALREADY_PART_OF_GROUP(player, "Crafting Table");
|
||||
return;
|
||||
}
|
||||
placeSign(block, toReplace, facing, player, owner, identifier, Values.AutoCraftTag,requireSign);
|
||||
placeSign(block, toReplace, facing, player, owner, identifier, Values.AutoCraftTag, requireSign);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace onStoragePlacedBlockFace(Player player, Block placed) {
|
||||
return Utils.getNearestBlockFace(player,placed.getLocation());
|
||||
return Utils.getNearestBlockFace(player, placed.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getStorageFacing(Block block) {
|
||||
for(BlockFace face : blockfaces){
|
||||
for (BlockFace face : blockfaces) {
|
||||
Block sign = block.getRelative(face);
|
||||
if(sign.getState() instanceof Sign) {
|
||||
if (sign.getState() instanceof Sign) {
|
||||
StorageInfo<AutoCraftingStorage> info = Config.getAutoCraft().getStorageUtils().getStorageInfo((Sign) sign.getState());
|
||||
if (info != null) return face;
|
||||
}
|
||||
@ -116,7 +116,7 @@ public class AutoCraftingStorageType extends StorageType<AutoCraftingStorage> {
|
||||
return messages;
|
||||
}
|
||||
|
||||
private static AutoCraftMessages messages = new AutoCraftMessages();
|
||||
private static final AutoCraftMessages messages = new AutoCraftMessages();
|
||||
|
||||
private static class AutoCraftMessages extends StorageMessages {
|
||||
|
||||
@ -127,28 +127,28 @@ public class AutoCraftingStorageType extends StorageType<AutoCraftingStorage> {
|
||||
|
||||
@Override
|
||||
public void invalidID(Player target) {
|
||||
target.sendMessage(ChatColor.RED+ Message.INVALID_ID.getString(getStorageName()));
|
||||
target.sendMessage(ChatColor.RED+"/autocraft add <owner>:<group>");
|
||||
target.sendMessage(ChatColor.RED + Message.INVALID_ID.getString(getStorageName()));
|
||||
target.sendMessage(ChatColor.RED + "/autocraft add <owner>:<group>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listStorageGroups(Player target) {
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+Message.LIST_OF_AUTOCRAFTERS);
|
||||
for(AutoCraftingStorage storage : Config.getAutoCraft().getStorageMap(target.getUniqueId()).values()){
|
||||
if(storage != null){
|
||||
target.sendMessage(ChatColor.GREEN+storage.getIdentifier()+ChatColor.WHITE);
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + Message.LIST_OF_AUTOCRAFTERS);
|
||||
for (AutoCraftingStorage storage : Config.getAutoCraft().getStorageMap(target.getUniqueId()).values()) {
|
||||
if (storage != null) {
|
||||
target.sendMessage(ChatColor.GREEN + storage.getIdentifier() + ChatColor.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mustLookAtBlock(Player player) {
|
||||
player.sendMessage(ChatColor.RED+TAG+" "+Message.MUST_LOOK_AT_CRAFTING_TABLE);
|
||||
player.sendMessage(ChatColor.RED + TAG + " " + Message.MUST_LOOK_AT_CRAFTING_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidSignPlacement(Player player) {
|
||||
player.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+TAG+" "+Message.INVALID_AUTOCRAFTER);
|
||||
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + TAG + " " + Message.INVALID_AUTOCRAFTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,17 +39,17 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
private String inventoryName;
|
||||
private SortMethod sortMethod;
|
||||
|
||||
public ChestLinkStorage(Map<String, Object> map){
|
||||
public ChestLinkStorage(Map<String, Object> map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
public ChestLinkStorage(OfflinePlayer player, String group, Location location, Location signLocation){
|
||||
public ChestLinkStorage(OfflinePlayer player, String group, Location location, Location signLocation) {
|
||||
super(player, group, location, signLocation);
|
||||
this.inventoryName = group;
|
||||
this.sortMethod = SortMethod.OFF;
|
||||
|
||||
Block block = location.getBlock();
|
||||
if(block.getState() instanceof Container) {
|
||||
if (block.getState() instanceof Container) {
|
||||
Container container = (Container) block.getState();
|
||||
getInventory().setContents(container.getInventory().getContents());
|
||||
container.getInventory().clear();
|
||||
@ -60,22 +60,22 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
|
||||
@Override
|
||||
protected void serialize(Map<String, Object> hashMap) {
|
||||
hashMap.put("inventoryName",inventoryName);
|
||||
hashMap.put("inventoryName", inventoryName);
|
||||
hashMap.put("sortMethod", sortMethod.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deserialize(Map<String, Object> map) {
|
||||
String tempName = (String) map.get("inventoryName");
|
||||
if(tempName != null) inventoryName = tempName;
|
||||
if (tempName != null) inventoryName = tempName;
|
||||
|
||||
if(map.containsKey("sortMethod")) sortMethod = Enum.valueOf(SortMethod.class, (String) map.get("sortMethod"));
|
||||
if (map.containsKey("sortMethod")) sortMethod = Enum.valueOf(SortMethod.class, (String) map.get("sortMethod"));
|
||||
else sortMethod = SortMethod.OFF;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init(){
|
||||
private void init() {
|
||||
VirtualChestToHopper chestToHopper = new VirtualChestToHopper(this);
|
||||
chestToHopper.start();
|
||||
}
|
||||
@ -91,8 +91,8 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Inventory initInventory(){
|
||||
return Bukkit.createInventory(new VirtualInventoryHolder(this), 54,inventoryName);
|
||||
protected Inventory initInventory() {
|
||||
return Bukkit.createInventory(new VirtualInventoryHolder(this), 54, inventoryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,7 +103,7 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
@Override
|
||||
public void onStorageAdded(Block block, Player player) {
|
||||
//Migrates that chest into InventoryStorage and if full drops it at the chest location.
|
||||
if(block.getState() instanceof Container) {
|
||||
if (block.getState() instanceof Container) {
|
||||
Container chest = (Container) block.getState();
|
||||
boolean hasOverflow = false;
|
||||
for (ItemStack chestItem : chest.getInventory().getContents()) {
|
||||
@ -121,22 +121,22 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getIventoryIcon(Player player){
|
||||
public ItemStack getIventoryIcon(Player player) {
|
||||
ItemStack mostCommon = InventorySorter.getMostCommonItem(getInventory());
|
||||
ItemStack toReturn;
|
||||
if(mostCommon == null) toReturn = new ItemStack(Material.CHEST);
|
||||
if (mostCommon == null) toReturn = new ItemStack(Material.CHEST);
|
||||
else toReturn = mostCommon.clone();
|
||||
|
||||
ItemMeta meta = toReturn.getItemMeta();
|
||||
if(meta != null) {
|
||||
String dispName = ChatColor.GREEN + "" + getIdentifier() + ": " +ChatColor.WHITE+ ""+getTotalItems()+" items";
|
||||
if(player.getUniqueId().equals(getPlayerUUID())) meta.setDisplayName(dispName);
|
||||
else meta.setDisplayName(getOwner().getName()+": "+dispName);
|
||||
if (meta != null) {
|
||||
String dispName = ChatColor.GREEN + "" + getIdentifier() + ": " + ChatColor.WHITE + "" + getTotalItems() + " items";
|
||||
if (player.getUniqueId().equals(getPlayerUUID())) meta.setDisplayName(dispName);
|
||||
else meta.setDisplayName(getOwner().getName() + ": " + dispName);
|
||||
|
||||
if(getMembers() != null) {
|
||||
if (getMembers() != null) {
|
||||
List<String> memberNames = new ArrayList<>();
|
||||
if(isPublic()) memberNames.add(ChatColor.WHITE+"Public Chest");
|
||||
memberNames.add(ChatColor.BOLD+""+ChatColor.UNDERLINE+"Members:");
|
||||
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);
|
||||
}
|
||||
@ -149,39 +149,39 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
public ClickableItem getClickableItem(Player player) {
|
||||
return ClickableItem.from(getIventoryIcon(player), event -> {
|
||||
InventoryHolder inventoryHolder = getInventory().getHolder();
|
||||
if(inventoryHolder instanceof VirtualInventoryHolder){
|
||||
if (inventoryHolder instanceof VirtualInventoryHolder) {
|
||||
((VirtualInventoryHolder) inventoryHolder).setPreviousInventory(() -> {
|
||||
Bukkit.getScheduler().runTask(ChestsPlusPlus.PLUGIN, () -> ChestLinkMenu.getMenu(player).open(player));
|
||||
});
|
||||
}
|
||||
Utils.openChestInventory(player,getInventory());
|
||||
Utils.openChestInventory(player, getInventory());
|
||||
});
|
||||
}
|
||||
|
||||
public int getTotalItems(){
|
||||
public int getTotalItems() {
|
||||
int total = 0;
|
||||
if(getInventory() != null) {
|
||||
for(ItemStack itemStack : getInventory().getContents()){
|
||||
if(itemStack != null) total += itemStack.getAmount();
|
||||
if (getInventory() != null) {
|
||||
for (ItemStack itemStack : getInventory().getContents()) {
|
||||
if (itemStack != null) total += itemStack.getAmount();
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setSortMethod(SortMethod sortMethod){
|
||||
public void setSortMethod(SortMethod sortMethod) {
|
||||
this.sortMethod = sortMethod;
|
||||
}
|
||||
|
||||
public SortMethod getSortMethod(){
|
||||
public SortMethod getSortMethod() {
|
||||
return sortMethod;
|
||||
}
|
||||
|
||||
public void sort(){
|
||||
public void sort() {
|
||||
ItemStack[] sortedInventory = InventorySorter.sort(getInventory(), sortMethod);
|
||||
getInventory().setContents(sortedInventory);
|
||||
}
|
||||
|
||||
public void updateDisplayItem(){
|
||||
public void updateDisplayItem() {
|
||||
onItemDisplayUpdate(InventorySorter.getMostCommonItem(getInventory()));
|
||||
}
|
||||
|
||||
@ -208,13 +208,13 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
|
||||
@Override
|
||||
public double getBlockOffset(Block block) {
|
||||
if(block.getState() instanceof Chest) return 0;
|
||||
//Barrel is full block.
|
||||
if (block.getState() instanceof Chest) return 0;
|
||||
//Barrel is full block.
|
||||
else return -0.07;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return inventoryName+": "+getLocations().toString();
|
||||
return inventoryName + ": " + getLocations().toString();
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public void onSignRemoval(Block block) {
|
||||
if(block.getState() instanceof Container){
|
||||
if (block.getState() instanceof Container) {
|
||||
((Container) block.getState()).getInventory().clear();
|
||||
}
|
||||
}
|
||||
@ -59,30 +59,30 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public void createStorage(Player player, OfflinePlayer owner, Block block, String identifier, boolean requireSign) {
|
||||
if(block.getState() instanceof Chest) {
|
||||
if (block.getState() instanceof Chest) {
|
||||
new ChestLinkVerifier(block).withDelay(0).check();
|
||||
}
|
||||
createStorageForBlock(player, owner, block, identifier, requireSign);
|
||||
}
|
||||
|
||||
private void createStorageForBlock(Player player, OfflinePlayer owner, Block block, String identifier, boolean requireSign){
|
||||
if(block.getBlockData() instanceof Directional) {
|
||||
private void createStorageForBlock(Player player, OfflinePlayer owner, Block block, String identifier, boolean requireSign) {
|
||||
if (block.getBlockData() instanceof Directional) {
|
||||
Directional chest = (Directional) block.getBlockData();
|
||||
BlockFace facing = chest.getFacing();
|
||||
Block toReplace = block.getRelative(facing);
|
||||
placeSign(block,toReplace,facing,player,owner,identifier,Values.ChestLinkTag, requireSign);
|
||||
placeSign(block, toReplace, facing, player, owner, identifier, Values.ChestLinkTag, requireSign);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createStorageFacing(Player player, OfflinePlayer owner, Block block, String identifier, BlockFace facing, boolean requireSign) {
|
||||
//Chests already get placed facing in the correct direction.
|
||||
createStorage(player,owner,block,identifier,requireSign);
|
||||
createStorage(player, owner, block, identifier, requireSign);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace onStoragePlacedBlockFace(Player player, Block placed) {
|
||||
if(placed.getBlockData() instanceof Directional){
|
||||
if (placed.getBlockData() instanceof Directional) {
|
||||
return ((Directional) placed.getBlockData()).getFacing();
|
||||
}
|
||||
return null;
|
||||
@ -96,7 +96,7 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public BlockFace getStorageFacing(Block block) {
|
||||
if(block.getBlockData() instanceof Directional) {
|
||||
if (block.getBlockData() instanceof Directional) {
|
||||
Directional chest = (Directional) block.getBlockData();
|
||||
return chest.getFacing();
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public void validate(Block block) {
|
||||
if(block.getState() instanceof Chest) new ChestLinkVerifier(block).withDelay(0).check();
|
||||
if (block.getState() instanceof Chest) new ChestLinkVerifier(block).withDelay(0).check();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -118,7 +118,7 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
return messages;
|
||||
}
|
||||
|
||||
private static ChestLinkMessages messages = new ChestLinkMessages();
|
||||
private static final ChestLinkMessages messages = new ChestLinkMessages();
|
||||
|
||||
private static class ChestLinkMessages extends StorageMessages {
|
||||
|
||||
@ -129,28 +129,28 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public void invalidID(Player target) {
|
||||
target.sendMessage(ChatColor.RED+ Message.INVALID_ID.getString(getStorageName()));
|
||||
target.sendMessage(ChatColor.RED+"/chestlink add <owner>:<group>");
|
||||
target.sendMessage(ChatColor.RED + Message.INVALID_ID.getString(getStorageName()));
|
||||
target.sendMessage(ChatColor.RED + "/chestlink add <owner>:<group>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listStorageGroups(Player target) {
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+Message.LIST_OF_CHESTLINK);
|
||||
for(ChestLinkStorage storage : Config.getChestLink().getStorageMap(target.getUniqueId()).values()){
|
||||
if(storage != null){
|
||||
target.sendMessage(ChatColor.GREEN+storage.getIdentifier()+ChatColor.WHITE+" - "+storage.getTotalItems()+" items");
|
||||
target.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + Message.LIST_OF_CHESTLINK);
|
||||
for (ChestLinkStorage storage : Config.getChestLink().getStorageMap(target.getUniqueId()).values()) {
|
||||
if (storage != null) {
|
||||
target.sendMessage(ChatColor.GREEN + storage.getIdentifier() + ChatColor.WHITE + " - " + storage.getTotalItems() + " items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mustLookAtBlock(Player player) {
|
||||
player.sendMessage(ChatColor.RED+TAG+" "+Message.MUST_LOOK_AT_CHEST);
|
||||
player.sendMessage(ChatColor.RED + TAG + " " + Message.MUST_LOOK_AT_CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidSignPlacement(Player player) {
|
||||
player.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+TAG+" "+Message.INVALID_CHESTLINK);
|
||||
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + TAG + " " + Message.INVALID_CHESTLINK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,12 +130,11 @@ public final class UpdateChecker {
|
||||
* of UpdateChecker has already been initialized, this method will act similarly to {@link #get()}
|
||||
* (which is recommended after initialization).
|
||||
*
|
||||
* @param plugin the plugin for which to check updates. Cannot be null
|
||||
* @param pluginID the ID of the plugin as identified in the SpigotMC resource link. For example,
|
||||
* "https://www.spigotmc.org/resources/veinminer.<b>12038</b>/" would expect "12038" as a value. The
|
||||
* value must be greater than 0
|
||||
* @param plugin the plugin for which to check updates. Cannot be null
|
||||
* @param pluginID the ID of the plugin as identified in the SpigotMC resource link. For example,
|
||||
* "https://www.spigotmc.org/resources/veinminer.<b>12038</b>/" would expect "12038" as a value. The
|
||||
* value must be greater than 0
|
||||
* @param versionScheme a custom version scheme parser. Cannot be null
|
||||
*
|
||||
* @return the UpdateChecker instance
|
||||
*/
|
||||
public static UpdateChecker init(JavaPlugin plugin, int pluginID, VersionScheme versionScheme) {
|
||||
@ -151,11 +150,10 @@ public final class UpdateChecker {
|
||||
* of UpdateChecker has already been initialized, this method will act similarly to {@link #get()}
|
||||
* (which is recommended after initialization).
|
||||
*
|
||||
* @param plugin the plugin for which to check updates. Cannot be null
|
||||
* @param plugin the plugin for which to check updates. Cannot be null
|
||||
* @param pluginID the ID of the plugin as identified in the SpigotMC resource link. For example,
|
||||
* "https://www.spigotmc.org/resources/veinminer.<b>12038</b>/" would expect "12038" as a value. The
|
||||
* value must be greater than 0
|
||||
*
|
||||
* "https://www.spigotmc.org/resources/veinminer.<b>12038</b>/" would expect "12038" as a value. The
|
||||
* value must be greater than 0
|
||||
* @return the UpdateChecker instance
|
||||
*/
|
||||
public static UpdateChecker init(JavaPlugin plugin, int pluginID) {
|
||||
@ -188,25 +186,24 @@ public final class UpdateChecker {
|
||||
* A functional interface to compare two version Strings with similar version schemes.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public static interface VersionScheme {
|
||||
public interface VersionScheme {
|
||||
|
||||
/**
|
||||
* Compare two versions and return the higher of the two. If null is returned, it is assumed
|
||||
* that at least one of the two versions are unsupported by this version scheme parser.
|
||||
*
|
||||
* @param first the first version to check
|
||||
* @param first the first version to check
|
||||
* @param second the second version to check
|
||||
*
|
||||
* @return the greater of the two versions. null if unsupported version schemes
|
||||
*/
|
||||
public String compareVersions(String first, String second);
|
||||
String compareVersions(String first, String second);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A constant reason for the result of {@link UpdateResult}.
|
||||
*/
|
||||
public static enum UpdateReason {
|
||||
public enum UpdateReason {
|
||||
|
||||
/**
|
||||
* A new update is available for download on SpigotMC.
|
||||
@ -248,7 +245,7 @@ public final class UpdateChecker {
|
||||
/**
|
||||
* The plugin is up to date with the version released on SpigotMC's resources section.
|
||||
*/
|
||||
UP_TO_DATE;
|
||||
UP_TO_DATE
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,49 +4,49 @@
|
||||
# Die Sprachdatei sollte sich anschließend im 'lang'-Ordner befinden
|
||||
# Dann in config.yml würde 'language-file: default' in z.B 'language-file: en_US' umbennannt werden
|
||||
# Um der Entwicklung des plug-ins beizutragen und neue Sprachdateien bereitzustellen kannst du einen pull-request auf https://github.com/JamesPeters98/ChestsPlusPlus erstellen oder unserem Discord-Server beitreten: https://discord.gg/YRs3mP5
|
||||
STORAGE_REMOVED = {storage_type} wurde für {player_name} erfolgreich von der Gruppe {storage_group} entfernt
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST = Fehler beim umbenennen der Gruppe\! {storage_identifier} existiert nicht\!
|
||||
LIST_MEMBERS_OF_GROUP = Mitglieder der {storage_type}-Gruppe {storage_identifier}\: {player_list}
|
||||
SORT = Sortiermethode für {storage_identifier} wurde zu {sort_method} gesetzt
|
||||
LIST_OF_CHESTLINK = Liste deiner ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS = Liste deiner AutoCraft-Stationen\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS = Eigentümer {player_name} hat die Obergrenze der erlaubten Gruppen überschritten\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE = Du musst die Werkbank anschauen, mit der du AutoCraft verwenden möchtest\!
|
||||
CHEST_HAD_OVERFLOW = Nicht alle Gegenstände der Truhe würden in den ChestLink passen\!
|
||||
GROUP_DOESNT_EXIST = {storage_group} ist keine gültige zu Entfernende {storage_type}-Gruppe\!
|
||||
INVALID_ID = Ungültige {storage_type} ID\! Darf keinen Doppelpunkt '\:' enthalten, es sei denn, du verweist auf die Gruppe eines anderen Spielers, der du angehörst.
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL = Kann Spieler {player_name} nicht zu {storage_type} hinzufügen\!
|
||||
REMOVED_MEMBER = Spieler {player_name} erfolgreich von {storage_type}-Gruppe {storage_identifier} entfernt
|
||||
STORAGE_ADDED = {storage_type} erfolgreich zu Gruppe\: {storage_group} für {player_name} hinzugefügt
|
||||
NO_ADDITIONAL_MEMBERS = Es gibt keine weiteren Mitglieder in dieser Gruppe\: {storage_identifier}
|
||||
REMOVE_MEMBER_FROM_ALL = Spieler {player_name} erfolgreich von allen {storage_type}-Gruppen entfernt
|
||||
CURRENT_MEMBERS = Derzeitige Mitglieder\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS = Fehler beim umbenennen der Gruppe\! {storage_identifier} existiert bereits\!
|
||||
ADDED_MEMBER = Spieler {player_name} erfolgreich zur {storage_type}-Gruppe {storage_identifier} hinzugefügt
|
||||
UNABLE_TO_REMOVE_MEMBER = Kann den Spieler {player_name} nicht von {storage_type} entfernen\! Wurde jener bereits entfernt?
|
||||
INVALID_AUTOCRAFTER = Ungültiger AutoCrafter - Du musst ein Schild auf irgendeiner Seite der Werkbank platzieren, und sie darf nicht bereits Teil einer anderen Gruppe sein\!
|
||||
NO_PERMISSION = Du hast keine Erlaubnis, dies zu tun\!
|
||||
MUST_LOOK_AT_CHEST = Du musst die Kiste anschauen, die du verknüpfen möchtest\!
|
||||
FOUND_UNLINKED_STORAGE = Dieser {storage_type} wurde nicht mit deinem system verknüpft\! Es wurde zur {storage_identifier} Gruppe hinzugefügt\!
|
||||
INVALID_CHESTLINK = Ungültiger ChestLink - Du musst ein Schild auf der Vorderseite einer Truhe platzieren / Stelle sicher, dass genug Platz für ein Schild auf der Vorderseite vorhanden ist\!
|
||||
ADDED_MEMBER_TO_ALL = {player_name} erfolgreich zu allen {storage_type}-Gruppen hinzugefügt
|
||||
SET_PUBLICITY = Es gibt keine weiteren Spieler in der Gruppe {storage_identifier}
|
||||
REMOVED_GROUP = Die Gruppe {storage_group} wurde erfolgeich von deinen {storage_type}s entfernt\!
|
||||
MUST_HOLD_SIGN = Du musst ein Schild in der Hand halten, um dies zu tun
|
||||
ALREADY_PART_OF_GROUP = Dieser {storage_type} ist bereits Teil einer Gruppe\!
|
||||
COMMAND_CHESTLINK_LIST = Listet alle ChestLinks auf, die du besitzt
|
||||
COMMAND_MEMBER = Mitglieder einer Gruppe hinzufügen, entfernen oder auflisten
|
||||
COMMAND_AUTOCRAFT_LIST = Listet alle dir zu Eigen seienden AutoCraft-Gruppen auf
|
||||
COMMAND_CHESTLINK_OPEN = Öffnet das Inventar einer ChestLink-Gruppe
|
||||
COMMAND_AUTOCRAFT_OPEN = Öffnet die Werkbank einer AutoCraft-Gruppe
|
||||
COMMAND_CHESTLINK_SETPUBLIC = Stellt einen ChestLink so ein, dass jeder darauf zugreifen kann.
|
||||
COMMAND_CHESTLINK_RENAME = Benennt einen ChestLink um.
|
||||
COMMAND_CHESTLINK_REMOVE = Löscht einen ChestLink und lässt dessen Inventar vor deine Füße fallen\!
|
||||
COMMAND_CHESTLINK_MENU = Öffne das ChestLink-Menü, um alle Gruppen anzuzeigen\!
|
||||
COMMAND_CHESTLINK_SORT = Legt eine Sortiermethode für den vorliegenden ChestLink fest.
|
||||
COMMAND_AUTOCRAFT_ADD = Erstellen / hinzufügen einer Werkbank zu einer AutoCraft-Gruppe
|
||||
COMMAND_CHESTLINK_ADD = Erstellen / hinzufügen einer Truhe zu einer ChestLink Gruppe
|
||||
COMMAND_HELP = Liste aller Befehle und ihrer Verwendung
|
||||
COMMAND_AUTOCRAFT_RENAME = Umbenennen einer AutoCraft-Gruppe
|
||||
COMMAND_AUTOCRAFT_REMOVE = Löscht eine AutoCraft-Gruppe und lässt alle Werkbanken fallen
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC = Stellt eine AutoCraft Gruppe so ein, dass jeder darauf zugreifen kann.
|
||||
STORAGE_REMOVED={storage_type} wurde für {player_name} erfolgreich von der Gruppe {storage_group} entfernt
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST=Fehler beim umbenennen der Gruppe\! {storage_identifier} existiert nicht\!
|
||||
LIST_MEMBERS_OF_GROUP=Mitglieder der {storage_type}-Gruppe {storage_identifier}\: {player_list}
|
||||
SORT=Sortiermethode für {storage_identifier} wurde zu {sort_method} gesetzt
|
||||
LIST_OF_CHESTLINK=Liste deiner ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS=Liste deiner AutoCraft-Stationen\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS=Eigentümer {player_name} hat die Obergrenze der erlaubten Gruppen überschritten\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE=Du musst die Werkbank anschauen, mit der du AutoCraft verwenden möchtest\!
|
||||
CHEST_HAD_OVERFLOW=Nicht alle Gegenstände der Truhe würden in den ChestLink passen\!
|
||||
GROUP_DOESNT_EXIST={storage_group} ist keine gültige zu Entfernende {storage_type}-Gruppe\!
|
||||
INVALID_ID=Ungültige {storage_type} ID\! Darf keinen Doppelpunkt '\:' enthalten, es sei denn, du verweist auf die Gruppe eines anderen Spielers, der du angehörst.
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL=Kann Spieler {player_name} nicht zu {storage_type} hinzufügen\!
|
||||
REMOVED_MEMBER=Spieler {player_name} erfolgreich von {storage_type}-Gruppe {storage_identifier} entfernt
|
||||
STORAGE_ADDED={storage_type} erfolgreich zu Gruppe\: {storage_group} für {player_name} hinzugefügt
|
||||
NO_ADDITIONAL_MEMBERS=Es gibt keine weiteren Mitglieder in dieser Gruppe\: {storage_identifier}
|
||||
REMOVE_MEMBER_FROM_ALL=Spieler {player_name} erfolgreich von allen {storage_type}-Gruppen entfernt
|
||||
CURRENT_MEMBERS=Derzeitige Mitglieder\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS=Fehler beim umbenennen der Gruppe\! {storage_identifier} existiert bereits\!
|
||||
ADDED_MEMBER=Spieler {player_name} erfolgreich zur {storage_type}-Gruppe {storage_identifier} hinzugefügt
|
||||
UNABLE_TO_REMOVE_MEMBER=Kann den Spieler {player_name} nicht von {storage_type} entfernen\! Wurde jener bereits entfernt?
|
||||
INVALID_AUTOCRAFTER=Ungültiger AutoCrafter - Du musst ein Schild auf irgendeiner Seite der Werkbank platzieren, und sie darf nicht bereits Teil einer anderen Gruppe sein\!
|
||||
NO_PERMISSION=Du hast keine Erlaubnis, dies zu tun\!
|
||||
MUST_LOOK_AT_CHEST=Du musst die Kiste anschauen, die du verknüpfen möchtest\!
|
||||
FOUND_UNLINKED_STORAGE=Dieser {storage_type} wurde nicht mit deinem system verknüpft\! Es wurde zur {storage_identifier} Gruppe hinzugefügt\!
|
||||
INVALID_CHESTLINK=Ungültiger ChestLink - Du musst ein Schild auf der Vorderseite einer Truhe platzieren / Stelle sicher, dass genug Platz für ein Schild auf der Vorderseite vorhanden ist\!
|
||||
ADDED_MEMBER_TO_ALL={player_name} erfolgreich zu allen {storage_type}-Gruppen hinzugefügt
|
||||
SET_PUBLICITY=Es gibt keine weiteren Spieler in der Gruppe {storage_identifier}
|
||||
REMOVED_GROUP=Die Gruppe {storage_group} wurde erfolgeich von deinen {storage_type}s entfernt\!
|
||||
MUST_HOLD_SIGN=Du musst ein Schild in der Hand halten, um dies zu tun
|
||||
ALREADY_PART_OF_GROUP=Dieser {storage_type} ist bereits Teil einer Gruppe\!
|
||||
COMMAND_CHESTLINK_LIST=Listet alle ChestLinks auf, die du besitzt
|
||||
COMMAND_MEMBER=Mitglieder einer Gruppe hinzufügen, entfernen oder auflisten
|
||||
COMMAND_AUTOCRAFT_LIST=Listet alle dir zu Eigen seienden AutoCraft-Gruppen auf
|
||||
COMMAND_CHESTLINK_OPEN=Öffnet das Inventar einer ChestLink-Gruppe
|
||||
COMMAND_AUTOCRAFT_OPEN=Öffnet die Werkbank einer AutoCraft-Gruppe
|
||||
COMMAND_CHESTLINK_SETPUBLIC=Stellt einen ChestLink so ein, dass jeder darauf zugreifen kann.
|
||||
COMMAND_CHESTLINK_RENAME=Benennt einen ChestLink um.
|
||||
COMMAND_CHESTLINK_REMOVE=Löscht einen ChestLink und lässt dessen Inventar vor deine Füße fallen\!
|
||||
COMMAND_CHESTLINK_MENU=Öffne das ChestLink-Menü, um alle Gruppen anzuzeigen\!
|
||||
COMMAND_CHESTLINK_SORT=Legt eine Sortiermethode für den vorliegenden ChestLink fest.
|
||||
COMMAND_AUTOCRAFT_ADD=Erstellen / hinzufügen einer Werkbank zu einer AutoCraft-Gruppe
|
||||
COMMAND_CHESTLINK_ADD=Erstellen / hinzufügen einer Truhe zu einer ChestLink Gruppe
|
||||
COMMAND_HELP=Liste aller Befehle und ihrer Verwendung
|
||||
COMMAND_AUTOCRAFT_RENAME=Umbenennen einer AutoCraft-Gruppe
|
||||
COMMAND_AUTOCRAFT_REMOVE=Löscht eine AutoCraft-Gruppe und lässt alle Werkbanken fallen
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC=Stellt eine AutoCraft Gruppe so ein, dass jeder darauf zugreifen kann.
|
@ -4,49 +4,49 @@
|
||||
# Debe ser colocado en la carpeta 'lang'
|
||||
# Luego en config.yml 'language-file: default' debe ser renombrado a 'language-file: en_US'
|
||||
# Para ayudar a contribuir al plugin y proveer nuevos archivos de idioma puede crear un "pull-request" en https://github.com/JamesPeters98/ChestsPlusPlus o unete a nuestro servidor de discord https://discord.gg/YRs3mP5
|
||||
STORAGE_REMOVED = Eliminado correctamente {storage_type} del grupo\: {storage_group} por {player_name}
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST = ¡Error al renombrar el grupo\! ¡{storage_identifier} no existe\!
|
||||
LIST_MEMBERS_OF_GROUP = Los miembros de {storage_type} del grupo {storage_identifier}\: {player_list}
|
||||
SORT = El modo de ordenación para {storage_identifier} se ha cambiado a {sort_method}
|
||||
LIST_OF_CHESTLINK = Lista de tus ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS = Lista de tus estaciones de AutoCraft
|
||||
OWNER_HAS_TOO_MANY_CHESTS = ¡El dueño {player_name} ha alcanzado el límite de grupos permitidos\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE = ¡Debes estar mirando a una mesa de trabajo para crear un AutoCraft\!
|
||||
CHEST_HAD_OVERFLOW = ¡Los objetos del cofre podrían no entrar en el ChestLink\!
|
||||
GROUP_DOESNT_EXIST = ¡{storage_group} no es un grupo válido {storage_type} para eliminar\!
|
||||
INVALID_ID = ¡ID de {storage_type} no válido\! No puede contener dos puntos '\:' a menos que te refieras a otro grupo de jugadores donde eres miembro
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL = ¡No se puede añadir al jugador {player_name} a {storage_type}\!
|
||||
REMOVED_MEMBER = Se ha eliminado correctamente a {player_name} del grupo {storage_type}\: {storage_identifier}
|
||||
STORAGE_ADDED = Se ha añadido correctamente {storage_type} al grupo\: {storage_group} por {player_name}
|
||||
NO_ADDITIONAL_MEMBERS = No hay miembros adicionales en el grupo\: {storage_identifier}
|
||||
REMOVE_MEMBER_FROM_ALL = Se ha eliminado correctamente a {player_name} de todos los grupos de {storage_type}
|
||||
CURRENT_MEMBERS = Miembros actuales\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS = ¡Error al renombrar el grupo\! ¡{storage_identifier} ya existe\!
|
||||
ADDED_MEMBER = Se ha añadido correctamente al jugador {player_name} al grupo {storage_type} {storage_identifier}
|
||||
UNABLE_TO_REMOVE_MEMBER = ¡No se puede eliminar al jugador {player_name} de {storage_type}\! ¿Puede que ya lo hayas eliminado?
|
||||
INVALID_AUTOCRAFTER = AutoCrafter inválido - ¡Debes colocar un cartel en cualquier lado de la mesa de trabajo, no debe estar separado de un grupo\!
|
||||
NO_PERMISSION = ¡No tienes permisos para hacer esto\!
|
||||
MUST_LOOK_AT_CHEST = ¡Debes mirar al cofre que deseas para crear un ChestLink\!
|
||||
FOUND_UNLINKED_STORAGE = Este {storage_type} no estaba enlazado a tu sistema\! Ha sido agregado al grupo {storage_identifier}
|
||||
INVALID_CHESTLINK = ChestLink inválido - ¡Debes colocar un cartel al frente del cofre o asegúrate de que hay un espacio frente al cofre\!
|
||||
ADDED_MEMBER_TO_ALL = Se ha añadido correctamente al jugador {player_name} a todos los grupos de {storage_type}
|
||||
SET_PUBLICITY = No hay miembros adicionales en el grupo\: {storage_identifier}
|
||||
REMOVED_GROUP = Se ha eliminado correctamente el grupo {storage_group} de tus {storage_type}\!
|
||||
MUST_HOLD_SIGN = ¡Debes tener un cartel en la mano para hacer esto\!
|
||||
ALREADY_PART_OF_GROUP = ¡Este {storage_type} ya es parte de un grupo\!
|
||||
COMMAND_CHESTLINK_LIST = ¡Lista de todos los ChestLinks que posees\!
|
||||
COMMAND_MEMBER = Agrega, elimina o muestra una lista de miembros de un grupo.
|
||||
COMMAND_AUTOCRAFT_LIST = ¡Lista de todos los grupos AutoCraft que posees\!
|
||||
COMMAND_CHESTLINK_OPEN = Abre el inventario de un grupo de ChestLink.
|
||||
COMMAND_AUTOCRAFT_OPEN = Abre la mesa de trabajo de un grupo de AutoCraft.
|
||||
COMMAND_CHESTLINK_SETPUBLIC = Configura un ChestLink para que sea accesible para todos.
|
||||
COMMAND_CHESTLINK_RENAME = Renombra un ChestLink
|
||||
COMMAND_CHESTLINK_REMOVE = ¡Elimina un ChestLink y suelta su inventario\!
|
||||
COMMAND_CHESTLINK_MENU = ¡Abre el menú de ChestLink para mostrar todos los grupos\!
|
||||
COMMAND_CHESTLINK_SORT = Establece un modo de ordenación para un ChestLink.
|
||||
COMMAND_AUTOCRAFT_ADD = Crea/agrega una mesa de trabajo a un grupo de AutoCraft
|
||||
COMMAND_CHESTLINK_ADD = Crea/agrega un cofre a un grupo de ChestLink
|
||||
COMMAND_HELP = ¡Lista de comandos y sus usos\!
|
||||
COMMAND_AUTOCRAFT_RENAME = Renombra un grupo de AutoCraft
|
||||
COMMAND_AUTOCRAFT_REMOVE = Elimina un grupo de AutoCraft y suelta todas las mesas de trabajo\!
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC = Establece un grupo de AutoCraft para que sea accesibles para todos.
|
||||
STORAGE_REMOVED=Eliminado correctamente {storage_type} del grupo\: {storage_group} por {player_name}
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST=¡Error al renombrar el grupo\! ¡{storage_identifier} no existe\!
|
||||
LIST_MEMBERS_OF_GROUP=Los miembros de {storage_type} del grupo {storage_identifier}\: {player_list}
|
||||
SORT=El modo de ordenación para {storage_identifier} se ha cambiado a {sort_method}
|
||||
LIST_OF_CHESTLINK=Lista de tus ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS=Lista de tus estaciones de AutoCraft
|
||||
OWNER_HAS_TOO_MANY_CHESTS=¡El dueño {player_name} ha alcanzado el límite de grupos permitidos\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE=¡Debes estar mirando a una mesa de trabajo para crear un AutoCraft\!
|
||||
CHEST_HAD_OVERFLOW=¡Los objetos del cofre podrían no entrar en el ChestLink\!
|
||||
GROUP_DOESNT_EXIST=¡{storage_group} no es un grupo válido {storage_type} para eliminar\!
|
||||
INVALID_ID=¡ID de {storage_type} no válido\! No puede contener dos puntos '\:' a menos que te refieras a otro grupo de jugadores donde eres miembro
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL=¡No se puede añadir al jugador {player_name} a {storage_type}\!
|
||||
REMOVED_MEMBER=Se ha eliminado correctamente a {player_name} del grupo {storage_type}\: {storage_identifier}
|
||||
STORAGE_ADDED=Se ha añadido correctamente {storage_type} al grupo\: {storage_group} por {player_name}
|
||||
NO_ADDITIONAL_MEMBERS=No hay miembros adicionales en el grupo\: {storage_identifier}
|
||||
REMOVE_MEMBER_FROM_ALL=Se ha eliminado correctamente a {player_name} de todos los grupos de {storage_type}
|
||||
CURRENT_MEMBERS=Miembros actuales\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS=¡Error al renombrar el grupo\! ¡{storage_identifier} ya existe\!
|
||||
ADDED_MEMBER=Se ha añadido correctamente al jugador {player_name} al grupo {storage_type} {storage_identifier}
|
||||
UNABLE_TO_REMOVE_MEMBER=¡No se puede eliminar al jugador {player_name} de {storage_type}\! ¿Puede que ya lo hayas eliminado?
|
||||
INVALID_AUTOCRAFTER=AutoCrafter inválido - ¡Debes colocar un cartel en cualquier lado de la mesa de trabajo, no debe estar separado de un grupo\!
|
||||
NO_PERMISSION=¡No tienes permisos para hacer esto\!
|
||||
MUST_LOOK_AT_CHEST=¡Debes mirar al cofre que deseas para crear un ChestLink\!
|
||||
FOUND_UNLINKED_STORAGE=Este {storage_type} no estaba enlazado a tu sistema\! Ha sido agregado al grupo {storage_identifier}
|
||||
INVALID_CHESTLINK=ChestLink inválido - ¡Debes colocar un cartel al frente del cofre o asegúrate de que hay un espacio frente al cofre\!
|
||||
ADDED_MEMBER_TO_ALL=Se ha añadido correctamente al jugador {player_name} a todos los grupos de {storage_type}
|
||||
SET_PUBLICITY=No hay miembros adicionales en el grupo\: {storage_identifier}
|
||||
REMOVED_GROUP=Se ha eliminado correctamente el grupo {storage_group} de tus {storage_type}\!
|
||||
MUST_HOLD_SIGN=¡Debes tener un cartel en la mano para hacer esto\!
|
||||
ALREADY_PART_OF_GROUP=¡Este {storage_type} ya es parte de un grupo\!
|
||||
COMMAND_CHESTLINK_LIST=¡Lista de todos los ChestLinks que posees\!
|
||||
COMMAND_MEMBER=Agrega, elimina o muestra una lista de miembros de un grupo.
|
||||
COMMAND_AUTOCRAFT_LIST=¡Lista de todos los grupos AutoCraft que posees\!
|
||||
COMMAND_CHESTLINK_OPEN=Abre el inventario de un grupo de ChestLink.
|
||||
COMMAND_AUTOCRAFT_OPEN=Abre la mesa de trabajo de un grupo de AutoCraft.
|
||||
COMMAND_CHESTLINK_SETPUBLIC=Configura un ChestLink para que sea accesible para todos.
|
||||
COMMAND_CHESTLINK_RENAME=Renombra un ChestLink
|
||||
COMMAND_CHESTLINK_REMOVE=¡Elimina un ChestLink y suelta su inventario\!
|
||||
COMMAND_CHESTLINK_MENU=¡Abre el menú de ChestLink para mostrar todos los grupos\!
|
||||
COMMAND_CHESTLINK_SORT=Establece un modo de ordenación para un ChestLink.
|
||||
COMMAND_AUTOCRAFT_ADD=Crea/agrega una mesa de trabajo a un grupo de AutoCraft
|
||||
COMMAND_CHESTLINK_ADD=Crea/agrega un cofre a un grupo de ChestLink
|
||||
COMMAND_HELP=¡Lista de comandos y sus usos\!
|
||||
COMMAND_AUTOCRAFT_RENAME=Renombra un grupo de AutoCraft
|
||||
COMMAND_AUTOCRAFT_REMOVE=Elimina un grupo de AutoCraft y suelta todas las mesas de trabajo\!
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC=Establece un grupo de AutoCraft para que sea accesibles para todos.
|
@ -1,48 +1,48 @@
|
||||
# Chests++ Magyar - hu_HU
|
||||
# Megjegyzés: Ez a fájl felülíródik minden alkalommal amikor a plugin elindul. Ha módosítani szeretnél a fájl tartalmán csinálj egy másolatot egy másik névvel!
|
||||
STORAGE_REMOVED = {storage_type} sikeresen eltávolítva a {storage_group} csoportból {player_name} játékosnak.
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST = Hiba az átnevezés közben\!\n{storage_identifier} nem létezik\!
|
||||
LIST_MEMBERS_OF_GROUP = {storage_type} tipusú {storage_identifier} nevű csoport tagjai\: {player_list}
|
||||
SORT = Szelektálási forma a {storage_identifier} csoport számára beállítva\: {sort_method}
|
||||
LIST_OF_CHESTLINK = A ChestLink-eid listája\:
|
||||
LIST_OF_AUTOCRAFTERS = Az AutoCraft állomásaid listája\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS = {player_name} elérte a maximális csoportmennyiséget\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE = Rá kell nézned arra a barkácsasztalra amiből AutoCraft állomást szeretnél készíteni\!
|
||||
CHEST_HAD_OVERFLOW = A láda tartalma nem fért bele ebbe a ChestLink-be\!
|
||||
GROUP_DOESNT_EXIST = {storage_group} nem egy létező {storage_type}. Nem lehet eltávolítani\!
|
||||
INVALID_ID = Hibás {storage_type} név\! A név nem tartalmazhat kettőspontot(\:)\!
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL = Nem lehet hozzáadni {player_name} játékost a következő tipushoz\: {storage_type}\!
|
||||
REMOVED_MEMBER = {player_name} sikeresen eltávolítva a/az {storage_type} tipusú {storage_identifier} nevű csoportból.
|
||||
STORAGE_ADDED = {player_name} sikeresen hozzáadva a/az {storage_type} tipusú {storage_group} nevű csoporthoz.
|
||||
NO_ADDITIONAL_MEMBERS = {storage_identifier} nevű csoportnak nincsenek további tagjai.
|
||||
REMOVE_MEMBER_FROM_ALL = {player_name} sikeresen eltávolítva minden {storage_type} tipusú csoportból.
|
||||
CURRENT_MEMBERS = Jelenlegi tagok\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS = Hiba a csoport átnevezésekor\! {storage_identifier} nevű csoport már létezik\!
|
||||
ADDED_MEMBER = {player_name} sikeresen hozzáadva a/az {storage_type} tipusú {storage_identifier} nevű csoporthoz.
|
||||
UNABLE_TO_REMOVE_MEMBER = {storage_type} tipusú csoportból nem lehet eltávolítani {player_name} játékost\! Már eltávolítottad?
|
||||
INVALID_AUTOCRAFTER = Nem érvényes AutoCrafter\! A táblát muszáj egy barkácsasztal bármely oldalára tenned és a barkácsasztalon nem lehet másik csoport\!
|
||||
NO_PERMISSION = Nincs jogod\!
|
||||
MUST_LOOK_AT_CHEST = Muszáj a ládára nézned hogyha hozzá akarod adni egy ChestLink-hez\!
|
||||
FOUND_UNLINKED_STORAGE = Ez a {storage_type} tipusú elem nem volt regisztrálva. Regisztrálva lett a {storage_identifier} nevű csoporthoz\!
|
||||
INVALID_CHESTLINK = Nem érvényes ChestLink\! Muszáj a láda elejére raknod a táblát vagy bizonyosodj meg hogy a láda előtt van hely\!
|
||||
ADDED_MEMBER_TO_ALL = {player_name} sikeresen hozzáadva az összes {storage_type} tipusú csoporthoz\!
|
||||
SET_PUBLICITY = Nincs több tagja az adott csoportnak\: {storage_identifier}
|
||||
REMOVED_GROUP = {storage_type} tipusú {storage_identifier} nevű csoportból sikeresen eltávolítva\!
|
||||
MUST_HOLD_SIGN = Muszáj a kezedben egy táblát fognod hogy ezt megtehesd\!
|
||||
ALREADY_PART_OF_GROUP = Ez a {storage_type} tipusú elem már egy csoport tagja\!
|
||||
COMMAND_CHESTLINK_LIST = Kilistázza az összes ChestLink csoportodat.
|
||||
COMMAND_MEMBER = Hozzáad, elvesz vagy kilistázza egy csoport tagjait.
|
||||
COMMAND_AUTOCRAFT_LIST = Kilistázza az összes AutoCraft csoportodat.
|
||||
COMMAND_CHESTLINK_OPEN = Megnyitja a tartalmát egy ChestLink csoportodnak.
|
||||
COMMAND_AUTOCRAFT_OPEN = Megnyitja egy AutoCraft barkácsolási menüjét.
|
||||
COMMAND_CHESTLINK_SETPUBLIC = Mindenki számára elérhetővé teszi a ChestLink csoportodat.
|
||||
COMMAND_CHESTLINK_RENAME = Átnevezi a ChestLink csoportodat.
|
||||
COMMAND_CHESTLINK_REMOVE = Kitöröl egy ChestLink csoportot és a tartalmát magad alá dobja.
|
||||
COMMAND_CHESTLINK_MENU = Megynitja a ChestLink menüt ahol eléred az összes csoportodat.
|
||||
COMMAND_CHESTLINK_SORT = Beálítja a szelektáló opciót a megadott ChestLink csoportodnak.
|
||||
COMMAND_AUTOCRAFT_ADD = Létrehoz vagy hozzáad egy AutoCraft tipusú csoportot.
|
||||
COMMAND_CHESTLINK_ADD = Létrehoz vagy hozzáad egy ChestLink tipusú csoportot.
|
||||
COMMAND_HELP = A Parancsok és a leírásuk kilistázása.
|
||||
COMMAND_AUTOCRAFT_RENAME = Átnevez egy AutoCraft csoportot.
|
||||
COMMAND_AUTOCRAFT_REMOVE = Kitöröl egy AutoCraft csoportot és a lábadhoz dobja a barkácsasztalokat.
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC = Mindenki számára elérhetővé teszi az AutoCraft csoportodat.
|
||||
STORAGE_REMOVED={storage_type} sikeresen eltávolítva a {storage_group} csoportból {player_name} játékosnak.
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST=Hiba az átnevezés közben\!\n{storage_identifier} nem létezik\!
|
||||
LIST_MEMBERS_OF_GROUP={storage_type} tipusú {storage_identifier} nevű csoport tagjai\: {player_list}
|
||||
SORT=Szelektálási forma a {storage_identifier} csoport számára beállítva\: {sort_method}
|
||||
LIST_OF_CHESTLINK=A ChestLink-eid listája\:
|
||||
LIST_OF_AUTOCRAFTERS=Az AutoCraft állomásaid listája\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS={player_name} elérte a maximális csoportmennyiséget\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE=Rá kell nézned arra a barkácsasztalra amiből AutoCraft állomást szeretnél készíteni\!
|
||||
CHEST_HAD_OVERFLOW=A láda tartalma nem fért bele ebbe a ChestLink-be\!
|
||||
GROUP_DOESNT_EXIST={storage_group} nem egy létező {storage_type}. Nem lehet eltávolítani\!
|
||||
INVALID_ID=Hibás {storage_type} név\! A név nem tartalmazhat kettőspontot(\:)\!
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL=Nem lehet hozzáadni {player_name} játékost a következő tipushoz\: {storage_type}\!
|
||||
REMOVED_MEMBER={player_name} sikeresen eltávolítva a/az {storage_type} tipusú {storage_identifier} nevű csoportból.
|
||||
STORAGE_ADDED={player_name} sikeresen hozzáadva a/az {storage_type} tipusú {storage_group} nevű csoporthoz.
|
||||
NO_ADDITIONAL_MEMBERS={storage_identifier} nevű csoportnak nincsenek további tagjai.
|
||||
REMOVE_MEMBER_FROM_ALL={player_name} sikeresen eltávolítva minden {storage_type} tipusú csoportból.
|
||||
CURRENT_MEMBERS=Jelenlegi tagok\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS=Hiba a csoport átnevezésekor\! {storage_identifier} nevű csoport már létezik\!
|
||||
ADDED_MEMBER={player_name} sikeresen hozzáadva a/az {storage_type} tipusú {storage_identifier} nevű csoporthoz.
|
||||
UNABLE_TO_REMOVE_MEMBER={storage_type} tipusú csoportból nem lehet eltávolítani {player_name} játékost\! Már eltávolítottad?
|
||||
INVALID_AUTOCRAFTER=Nem érvényes AutoCrafter\! A táblát muszáj egy barkácsasztal bármely oldalára tenned és a barkácsasztalon nem lehet másik csoport\!
|
||||
NO_PERMISSION=Nincs jogod\!
|
||||
MUST_LOOK_AT_CHEST=Muszáj a ládára nézned hogyha hozzá akarod adni egy ChestLink-hez\!
|
||||
FOUND_UNLINKED_STORAGE=Ez a {storage_type} tipusú elem nem volt regisztrálva. Regisztrálva lett a {storage_identifier} nevű csoporthoz\!
|
||||
INVALID_CHESTLINK=Nem érvényes ChestLink\! Muszáj a láda elejére raknod a táblát vagy bizonyosodj meg hogy a láda előtt van hely\!
|
||||
ADDED_MEMBER_TO_ALL={player_name} sikeresen hozzáadva az összes {storage_type} tipusú csoporthoz\!
|
||||
SET_PUBLICITY=Nincs több tagja az adott csoportnak\: {storage_identifier}
|
||||
REMOVED_GROUP={storage_type} tipusú {storage_identifier} nevű csoportból sikeresen eltávolítva\!
|
||||
MUST_HOLD_SIGN=Muszáj a kezedben egy táblát fognod hogy ezt megtehesd\!
|
||||
ALREADY_PART_OF_GROUP=Ez a {storage_type} tipusú elem már egy csoport tagja\!
|
||||
COMMAND_CHESTLINK_LIST=Kilistázza az összes ChestLink csoportodat.
|
||||
COMMAND_MEMBER=Hozzáad, elvesz vagy kilistázza egy csoport tagjait.
|
||||
COMMAND_AUTOCRAFT_LIST=Kilistázza az összes AutoCraft csoportodat.
|
||||
COMMAND_CHESTLINK_OPEN=Megnyitja a tartalmát egy ChestLink csoportodnak.
|
||||
COMMAND_AUTOCRAFT_OPEN=Megnyitja egy AutoCraft barkácsolási menüjét.
|
||||
COMMAND_CHESTLINK_SETPUBLIC=Mindenki számára elérhetővé teszi a ChestLink csoportodat.
|
||||
COMMAND_CHESTLINK_RENAME=Átnevezi a ChestLink csoportodat.
|
||||
COMMAND_CHESTLINK_REMOVE=Kitöröl egy ChestLink csoportot és a tartalmát magad alá dobja.
|
||||
COMMAND_CHESTLINK_MENU=Megynitja a ChestLink menüt ahol eléred az összes csoportodat.
|
||||
COMMAND_CHESTLINK_SORT=Beálítja a szelektáló opciót a megadott ChestLink csoportodnak.
|
||||
COMMAND_AUTOCRAFT_ADD=Létrehoz vagy hozzáad egy AutoCraft tipusú csoportot.
|
||||
COMMAND_CHESTLINK_ADD=Létrehoz vagy hozzáad egy ChestLink tipusú csoportot.
|
||||
COMMAND_HELP=A Parancsok és a leírásuk kilistázása.
|
||||
COMMAND_AUTOCRAFT_RENAME=Átnevez egy AutoCraft csoportot.
|
||||
COMMAND_AUTOCRAFT_REMOVE=Kitöröl egy AutoCraft csoportot és a lábadhoz dobja a barkácsasztalokat.
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC=Mindenki számára elérhetővé teszi az AutoCraft csoportodat.
|
@ -4,49 +4,49 @@
|
||||
# Zorg dat dit bestand zich in de 'lang' map bevindt.
|
||||
# In de config.yml wijzigt u de waarde van 'language-file: default' naar 'language-file: nl_NL'
|
||||
# Als u wilt bijdragen aan deze plugin en nieuwe taalbestanden wilt aanbieden can u een pull-request aanmaken op https://github.com/JamesPeters98/ChestsPlusPlus of join onze Discord server https://discord.gg/YRs3mP5
|
||||
STORAGE_REMOVED = U hebt succesvol {storage_type} van groep {storage_group} verwijderd voor {player_name}.
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST = Er is iets misgelopen, {storage_identifier} bestaat niet\!
|
||||
LIST_MEMBERS_OF_GROUP = Leden van {storage_type} uit de groep {storage_identifier}\: {player_list}.
|
||||
SORT = Sorteermethode voor {storage_identifier} werd gewijzigd naar {sort_method}.
|
||||
LIST_OF_CHESTLINK = Lijst van jou ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS = Lijst van jou AutoCraft Stations\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS = Eigenaar {player_name} heeft het limiet voor het aantal groepen bereikt\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE = U moet naar de werkbank kijken waarmee u wilt AutoCraften.
|
||||
CHEST_HAD_OVERFLOW = Kist item's pasten niet in de ChestLink.
|
||||
GROUP_DOESNT_EXIST = {storage_group} is geen geldige {storage_type} om te verwijderen.
|
||||
INVALID_ID = Ongeldige {storage_type} ID\! Moet geen dubbelepunt '\:' bevatten tenzij je naar een groep verwijst waar u lid van bent.
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL = Kan {player_name} niet aan {storage_type} toevoegen\!
|
||||
REMOVED_MEMBER = U hebt succesvol {player_name} verwijderd uit de {storage_group} groep {storage_identifier}
|
||||
STORAGE_ADDED = U hebt succesvol {storage_type} toegevoegd aan de groep {storage_group} voor {player_name}.
|
||||
NO_ADDITIONAL_MEMBERS = Er zijn geen andere leden in de groep {storage_identifier}.
|
||||
REMOVE_MEMBER_FROM_ALL = U hebt succesvol {player_name} van alle {storage_type} groepen verwijderd.
|
||||
CURRENT_MEMBERS = Leden\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS = Er is iets misgelopen, {storage_identifier} bestaat al\!
|
||||
ADDED_MEMBER = U hebt succesvol {player_name} aan {storage_type} groep {storage_identifier} toegevoegd.
|
||||
UNABLE_TO_REMOVE_MEMBER = Kon speler {player_name} niet verwijderen van {storage_type}, deze speler is mogelijk al verwijderd.
|
||||
INVALID_AUTOCRAFTER = Ongeldige AutoCrafter - U moet de sign op een zijde van de werkbank plaatsen en de werkbank mag nog niet deel uitmaken van een groep.
|
||||
NO_PERMISSION = U mag dit commando niet uitvoeren.
|
||||
MUST_LOOK_AT_CHEST = U moet naar de kist kijken die u wilt ChestLinken.
|
||||
FOUND_UNLINKED_STORAGE = Deze {storage_type} was nog niet aan jouw systeem gekoppeld, het werd toegevoegd aan de {storage_identifier} groep.
|
||||
INVALID_CHESTLINK = Ongeldige ChestLink - U moet de sign op de voorkant van de kist plaatsen, zorg dat er genoeg ruimte is voor een sign op de voorkant van een kist.
|
||||
ADDED_MEMBER_TO_ALL = U hebt succesvol {player_name} toegevoegd aan alle {storage_type} groepen.
|
||||
SET_PUBLICITY = Er zijn geen andere leden in de groep {storage_identifier}.
|
||||
REMOVED_GROUP = U hebt succesvol {storage_group} verwijderd van uw {storage_type}'s.
|
||||
MUST_HOLD_SIGN = U moet een sign in uw hand hebben om dit uit te voeren.
|
||||
ALREADY_PART_OF_GROUP = Deze {storage_type} is maakt al deel uit van een groep.
|
||||
COMMAND_CHESTLINK_LIST = Toont alle ChestLinks die jij bezit.
|
||||
COMMAND_MEMBER = Voeg leden toe aan een groep, verwijder ze of verkrijg een lijst van een groep.
|
||||
COMMAND_AUTOCRAFT_LIST = Toon een lijst met alle AutoCraft groepen die jij bezit.
|
||||
COMMAND_CHESTLINK_OPEN = Open de inventory van een ChestLink groep.
|
||||
COMMAND_AUTOCRAFT_OPEN = Open de werkbank van een AutoCraft groep.
|
||||
COMMAND_CHESTLINK_SETPUBLIC = Maak een ChestLink toegankelijk voor iedereen.
|
||||
COMMAND_CHESTLINK_RENAME = Wijzig de naam van een ChestLink.
|
||||
COMMAND_CHESTLINK_REMOVE = Verwijder een ChestLink en laat de inhoud op de vloer vallen\!
|
||||
COMMAND_CHESTLINK_MENU = Open het ChestLink menu om alle groepen weer te geven\!
|
||||
COMMAND_CHESTLINK_SORT = Stel de sorteer optie in voor de opgegeven ChestLink.
|
||||
COMMAND_AUTOCRAFT_ADD = Creëer een werkbank en voeg hem toe aan een AutoCraft groep.
|
||||
COMMAND_CHESTLINK_ADD = Creëer een kist en voeg hem toe aan een ChestLink groep.
|
||||
COMMAND_HELP = Geeft een lijst weer met alle commando's die jij kan gebruiken.
|
||||
COMMAND_AUTOCRAFT_RENAME = Wijzig de naam van een AutoCraft groep.
|
||||
COMMAND_AUTOCRAFT_REMOVE = Verwijder een AutoCraft groep en laat alle werkbanken op de vloer vallen\!
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC = Maak een AutoCraft groep toegankelijk voor iedereen.
|
||||
STORAGE_REMOVED=U hebt succesvol {storage_type} van groep {storage_group} verwijderd voor {player_name}.
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST=Er is iets misgelopen, {storage_identifier} bestaat niet\!
|
||||
LIST_MEMBERS_OF_GROUP=Leden van {storage_type} uit de groep {storage_identifier}\: {player_list}.
|
||||
SORT=Sorteermethode voor {storage_identifier} werd gewijzigd naar {sort_method}.
|
||||
LIST_OF_CHESTLINK=Lijst van jou ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS=Lijst van jou AutoCraft Stations\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS=Eigenaar {player_name} heeft het limiet voor het aantal groepen bereikt\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE=U moet naar de werkbank kijken waarmee u wilt AutoCraften.
|
||||
CHEST_HAD_OVERFLOW=Kist item's pasten niet in de ChestLink.
|
||||
GROUP_DOESNT_EXIST={storage_group} is geen geldige {storage_type} om te verwijderen.
|
||||
INVALID_ID=Ongeldige {storage_type} ID\! Moet geen dubbelepunt '\:' bevatten tenzij je naar een groep verwijst waar u lid van bent.
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL=Kan {player_name} niet aan {storage_type} toevoegen\!
|
||||
REMOVED_MEMBER=U hebt succesvol {player_name} verwijderd uit de {storage_group} groep {storage_identifier}
|
||||
STORAGE_ADDED=U hebt succesvol {storage_type} toegevoegd aan de groep {storage_group} voor {player_name}.
|
||||
NO_ADDITIONAL_MEMBERS=Er zijn geen andere leden in de groep {storage_identifier}.
|
||||
REMOVE_MEMBER_FROM_ALL=U hebt succesvol {player_name} van alle {storage_type} groepen verwijderd.
|
||||
CURRENT_MEMBERS=Leden\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS=Er is iets misgelopen, {storage_identifier} bestaat al\!
|
||||
ADDED_MEMBER=U hebt succesvol {player_name} aan {storage_type} groep {storage_identifier} toegevoegd.
|
||||
UNABLE_TO_REMOVE_MEMBER=Kon speler {player_name} niet verwijderen van {storage_type}, deze speler is mogelijk al verwijderd.
|
||||
INVALID_AUTOCRAFTER=Ongeldige AutoCrafter - U moet de sign op een zijde van de werkbank plaatsen en de werkbank mag nog niet deel uitmaken van een groep.
|
||||
NO_PERMISSION=U mag dit commando niet uitvoeren.
|
||||
MUST_LOOK_AT_CHEST=U moet naar de kist kijken die u wilt ChestLinken.
|
||||
FOUND_UNLINKED_STORAGE=Deze {storage_type} was nog niet aan jouw systeem gekoppeld, het werd toegevoegd aan de {storage_identifier} groep.
|
||||
INVALID_CHESTLINK=Ongeldige ChestLink - U moet de sign op de voorkant van de kist plaatsen, zorg dat er genoeg ruimte is voor een sign op de voorkant van een kist.
|
||||
ADDED_MEMBER_TO_ALL=U hebt succesvol {player_name} toegevoegd aan alle {storage_type} groepen.
|
||||
SET_PUBLICITY=Er zijn geen andere leden in de groep {storage_identifier}.
|
||||
REMOVED_GROUP=U hebt succesvol {storage_group} verwijderd van uw {storage_type}'s.
|
||||
MUST_HOLD_SIGN=U moet een sign in uw hand hebben om dit uit te voeren.
|
||||
ALREADY_PART_OF_GROUP=Deze {storage_type} is maakt al deel uit van een groep.
|
||||
COMMAND_CHESTLINK_LIST=Toont alle ChestLinks die jij bezit.
|
||||
COMMAND_MEMBER=Voeg leden toe aan een groep, verwijder ze of verkrijg een lijst van een groep.
|
||||
COMMAND_AUTOCRAFT_LIST=Toon een lijst met alle AutoCraft groepen die jij bezit.
|
||||
COMMAND_CHESTLINK_OPEN=Open de inventory van een ChestLink groep.
|
||||
COMMAND_AUTOCRAFT_OPEN=Open de werkbank van een AutoCraft groep.
|
||||
COMMAND_CHESTLINK_SETPUBLIC=Maak een ChestLink toegankelijk voor iedereen.
|
||||
COMMAND_CHESTLINK_RENAME=Wijzig de naam van een ChestLink.
|
||||
COMMAND_CHESTLINK_REMOVE=Verwijder een ChestLink en laat de inhoud op de vloer vallen\!
|
||||
COMMAND_CHESTLINK_MENU=Open het ChestLink menu om alle groepen weer te geven\!
|
||||
COMMAND_CHESTLINK_SORT=Stel de sorteer optie in voor de opgegeven ChestLink.
|
||||
COMMAND_AUTOCRAFT_ADD=Creëer een werkbank en voeg hem toe aan een AutoCraft groep.
|
||||
COMMAND_CHESTLINK_ADD=Creëer een kist en voeg hem toe aan een ChestLink groep.
|
||||
COMMAND_HELP=Geeft een lijst weer met alle commando's die jij kan gebruiken.
|
||||
COMMAND_AUTOCRAFT_RENAME=Wijzig de naam van een AutoCraft groep.
|
||||
COMMAND_AUTOCRAFT_REMOVE=Verwijder een AutoCraft groep en laat alle werkbanken op de vloer vallen\!
|
||||
COMMAND_AUTOCRAFT_SETPUBLIC=Maak een AutoCraft groep toegankelijk voor iedereen.
|
Loading…
Reference in New Issue
Block a user