From 1f83b3989b29b28ed7d2e7b39b8fb7809d9963c9 Mon Sep 17 00:00:00 2001 From: TheTealViper Date: Thu, 2 Apr 2020 13:55:41 -0700 Subject: [PATCH] [1.15.2.a.4] Add /ec support + ec in sightline for search toggle --- config.yml | 8 +++++++- plugin.yml | 2 +- src/me/TheTealViper/enderbank/EnderBank.java | 19 ++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config.yml b/config.yml index 114a463..5038902 100644 --- a/config.yml +++ b/config.yml @@ -13,9 +13,15 @@ Page_Price_Addition: 0 #This is how much the bank page cost will be increased #by for every additional page. +Must_Look_At_Chest_To_Search: true +#This makes it so players must be looking at an EnderChest +#to utilize the search feature, resulting in a "never left +#the chest" experience despite actually exiting their bank +#to enter their search term in the chat. + ########################################################## # Version # ########################################################## -VERSION: 1 +VERSION: 2 #Do not touch this. No touchy. \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 96e5ef8..71cc6ac 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: "EnderBank" author: TheTealViper -version: "1.15.2.a.3" +version: "1.15.2.a.4" api-version: 1.13 description: "Bank system from popular RPG's." main: me.TheTealViper.enderbank.EnderBank diff --git a/src/me/TheTealViper/enderbank/EnderBank.java b/src/me/TheTealViper/enderbank/EnderBank.java index 48f7dbc..86c8b62 100644 --- a/src/me/TheTealViper/enderbank/EnderBank.java +++ b/src/me/TheTealViper/enderbank/EnderBank.java @@ -19,6 +19,8 @@ import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; @@ -313,28 +315,31 @@ public class EnderBank extends JavaPlugin implements Listener { } - /**[1.15.2.a.3] Using "onChestClick()" instead as the method below forces chest animation to stay open + //[1.15.2.a.3] Using "onChestClick()" instead as the method below forces chest animation to stay open + //[1.15.2.a.4] This is still here to handle the command /ec as that would open vanilla chest @EventHandler public void onInventoryOpen(InventoryOpenEvent e) { if(e.getInventory().getType().equals(InventoryType.ENDER_CHEST)) { e.setCancelled(true); Player p = (Player) e.getPlayer(); - BankStorage bank = BankStorage.getBank(p); - bank.openPage(1, p); + openEnderBank(p); } } - **/ @EventHandler public void onChestClick(PlayerInteractEvent e) { if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.ENDER_CHEST)) { e.setCancelled(true); Player p = (Player) e.getPlayer(); - BankStorage bank = BankStorage.getBank(p); - bank.openPage(1, p); + openEnderBank(p); } } + public void openEnderBank(Player p) { + BankStorage bank = BankStorage.getBank(p); + bank.openPage(1, p); + } + @EventHandler public void onChat(AsyncPlayerChatEvent e) { Player p = e.getPlayer(); @@ -354,7 +359,7 @@ public class EnderBank extends JavaPlugin implements Listener { queue.remove(queue.size() - 1); e.setCancelled(true); Block b = p.getTargetBlock(null, 10); - if(b.getType().equals(Material.ENDER_CHEST)) { + if(!getConfig().getBoolean("Must_Look_At_Chest_To_Search") || b.getType().equals(Material.ENDER_CHEST)) { String search = e.getMessage(); BankStorage bank = BankStorage.searchDatabase.get(p); bank.openSearch(search, p);