[1.15.2.a.4] Add /ec support + ec in sightline for search toggle

This commit is contained in:
TheTealViper 2020-04-02 13:55:41 -07:00
parent 857af88a7c
commit 1f83b3989b
3 changed files with 20 additions and 9 deletions

View File

@ -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.

View File

@ -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

View File

@ -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);