1.14-pre5

Former-commit-id: bb7cc421f9c895746edd230c15f8ab495265fe96 [formerly ecdfdef0a5c4f20d23dd50e57446140015eb2561]
Former-commit-id: 3cdfd0ea3c7884edf78955be1e1377844827d784
This commit is contained in:
Ghost_chu committed 2019-04-23 13:04:27 +08:00
1 parent d70b4d5406
commit 25ce3e7391
7 files changed
+2528 -2510

No files matched your search

@@ -1,276 +1,276 @@
package org.maxgamer.quickshop.Listeners;
import java.sql.SQLException;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.DoubleChest;
import org.bukkit.block.Hopper;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Database.DatabaseHelper;
import org.maxgamer.quickshop.Shop.Info;
import org.maxgamer.quickshop.Shop.Shop;
import org.maxgamer.quickshop.Shop.ShopAction;
import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Util;
public class BlockListener implements Listener {
private QuickShop plugin;
public BlockListener(QuickShop plugin) {
this.plugin = plugin;
}
/**
* Listens for chest placement, so a doublechest shop can't be created.
*/
@EventHandler(ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
BlockState bs = e.getBlock().getState();
if (bs instanceof DoubleChest == false)
return;
Block b = e.getBlock();
Player p = e.getPlayer();
Block chest = Util.getSecondHalf(b);
if (chest != null && plugin.getShopManager().getShop(chest.getLocation()) != null && !p.hasPermission("quickshop.create.double")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
}
}
/**
* Removes chests when they're destroyed.
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBreak(BlockBreakEvent e) {
Block b = e.getBlock();
if(b.getState() instanceof Sign) {
Sign sign = (Sign)b.getState();
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette or other sign-lock plugin)");
return;
}
}
Player p = e.getPlayer();
// If the shop was a chest
if (Util.canBeShop(b,null,true)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
// If they're either survival or the owner, they can break it
if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-creative-break"));
return;
}
// Cancel their current menu... Doesnt cancel other's menu's.
Info action = plugin.getShopManager().getActions().get(p.getUniqueId());
if (action != null) {
action.setAction(ShopAction.CANCELLED);
}
shop.delete();
try {
DatabaseHelper.removeShop(plugin.getDB(), shop.getLocation().getBlockX(), shop.getLocation().getBlockY(), shop.getLocation().getBlockZ(), shop.getLocation().getWorld().getName());
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
p.sendMessage(MsgUtil.getMessage("success-removed-shop"));
} else if (b.getType() == Material.WALL_SIGN) {
if(b instanceof Sign) {
Sign sign = (Sign)b;
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette)");
return;
}
}
Shop shop = getShopNextTo(b.getLocation());
if (shop == null)
return;
// If they're in creative and not the owner, don't let them
// (accidents happen)
if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) {
//Check SuperTool
if(p.getInventory().getItemInMainHand().getType()==Material.GOLDEN_AXE) {
p.sendMessage(MsgUtil.getMessage("break-shop-use-supertool"));
return;
}
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-creative-break",MsgUtil.getItemi18n(Material.GOLDEN_AXE.name())));
return;
}
if (e.isCancelled()) {
return;
}
e.setCancelled(true);
// Cancel the event so that the sign does not
// drop.. TODO: Find a better way.
//b.setType(Material.AIR);
}
}
//Protect Minecart steal shop
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryMove(InventoryMoveItemEvent event){
if (plugin.getConfig().getBoolean("protect.minecart")){
// Additional Hopper Minecart Check
if (event.getDestination().getHolder() instanceof HopperMinecart) {
HopperMinecart hm = (HopperMinecart) event.getDestination().getHolder();
Location minecartLoc = new Location(hm.getWorld(), hm.getLocation().getBlockX(), hm.getLocation().getBlockY()+1, hm.getLocation().getBlockZ());
Shop shop = plugin.getShopManager().getShop(minecartLoc);
if (shop == null) {
return;
}
event.setCancelled(true);
hm.remove();
plugin.getLogger().warning("[Exploit Alert] a HopperMinecart tried to move the item of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A HopperMinecart tried to move the item of "+shop);
}
}
if(plugin.getConfig().getBoolean("protect.hopper")) {
if (event.getDestination().getHolder() instanceof Hopper) {
Hopper h = (Hopper) event.getDestination().getHolder();
Location minecartLoc = new Location(h.getWorld(), h.getLocation().getBlockX(), h.getLocation().getBlockY()+1, h.getLocation().getBlockZ());
Shop shop = plugin.getShopManager().getShop(minecartLoc);
if (shop == null) {
return;
}
event.setCancelled(true);
}
}
}
//Protect Entity pickup shop
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMobChangeBlock(EntityChangeBlockEvent event) {
Shop shop = plugin.getShopManager().getShop(event.getBlock().getLocation());
if (shop == null) {
return;
}
if (shop !=null){
if(plugin.getConfig().getBoolean("protect.entity")) {
event.setCancelled(true);
event.getEntity().remove();
plugin.getLogger().warning("[Exploit Alert] a Entity tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A Entity tried to break the shop of "+shop);
}else {
shop.delete();
}
}
}
//Protect Redstone active shop
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockRedstoneChange(BlockRedstoneEvent event){
if (!plugin.getConfig().getBoolean("protect.redstone")){
return;
}
Shop shop = plugin.getShopManager().getShop(event.getBlock().getLocation());
if (shop == null) {
return;
}
if (shop != null){
event.setNewCurrent(event.getOldCurrent());
plugin.getLogger().warning("[Exploit Alert] a Redstone tried to active of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A Redstone tried to active of "+shop);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event){
if (!plugin.getConfig().getBoolean("protect.structuregrow")) {
return;
}
for (BlockState blockstate : event.getBlocks()){
Shop shop = plugin.getShopManager().getShop(blockstate.getLocation());
if (shop == null) {
return;
}
if(shop !=null) {
event.setCancelled(true);
plugin.getLogger().warning("[Exploit Alert] a StructureGrowing tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A StructureGrowing tried to break the shop of "+shop);
}
}
}
/**
* Handles shops breaking through explosions
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplode(EntityExplodeEvent e) {
for (int i = 0; i < e.blockList().size(); i++) {
Block b = e.blockList().get(i);
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if(plugin.getConfig().getBoolean("protect.explode")) {
e.setCancelled(true);
plugin.getLogger().warning("[Exploit Alert] a EntityExplode tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A EntityExplode tried to break the shop of "+shop);
}else {
shop.delete();
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent e) {
for (int i = 0; i < e.blockList().size(); i++) {
Block b = e.blockList().get(i);
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if(plugin.getConfig().getBoolean("protect.explode")) {
e.setCancelled(true);
plugin.getLogger().warning("[Exploit Alert] a BlockExplode tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A BlockExplode tried to break the shop of "+shop);
}else {
shop.delete();
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent e) {
Block newBlock = e.getNewState().getBlock();
Shop thisBlockShop = plugin.getShopManager().getShop(newBlock.getLocation());
Shop underBlockShop = plugin.getShopManager().getShop(newBlock.getRelative(BlockFace.DOWN).getLocation());
if(thisBlockShop == null && underBlockShop == null)
return;
e.setCancelled(true);
}
/**
* Gets the shop a sign is attached to
*
* @param loc
* The location of the sign
* @return The shop
*/
private Shop getShopNextTo(Location loc) {
Block b = Util.getAttached(loc.getBlock());
// Util.getAttached(b)
if (b == null)
return null;
return plugin.getShopManager().getShop(b.getLocation());
}
package org.maxgamer.quickshop.Listeners;
import java.sql.SQLException;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.DoubleChest;
import org.bukkit.block.Hopper;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Database.DatabaseHelper;
import org.maxgamer.quickshop.Shop.Info;
import org.maxgamer.quickshop.Shop.Shop;
import org.maxgamer.quickshop.Shop.ShopAction;
import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Util;
public class BlockListener implements Listener {
private QuickShop plugin;
public BlockListener(QuickShop plugin) {
this.plugin = plugin;
}
/**
* Listens for chest placement, so a doublechest shop can't be created.
*/
@EventHandler(ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
BlockState bs = e.getBlock().getState();
if (bs instanceof DoubleChest == false)
return;
Block b = e.getBlock();
Player p = e.getPlayer();
Block chest = Util.getSecondHalf(b);
if (chest != null && plugin.getShopManager().getShop(chest.getLocation()) != null && !p.hasPermission("quickshop.create.double")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
}
}
/**
* Removes chests when they're destroyed.
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBreak(BlockBreakEvent e) {
Block b = e.getBlock();
if(b.getState() instanceof Sign) {
Sign sign = (Sign)b.getState();
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette or other sign-lock plugin)");
return;
}
}
Player p = e.getPlayer();
// If the shop was a chest
if (Util.canBeShop(b,null,true)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
// If they're either survival or the owner, they can break it
if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-creative-break"));
return;
}
// Cancel their current menu... Doesnt cancel other's menu's.
Info action = plugin.getShopManager().getActions().get(p.getUniqueId());
if (action != null) {
action.setAction(ShopAction.CANCELLED);
}
shop.delete();
try {
DatabaseHelper.removeShop(plugin.getDB(), shop.getLocation().getBlockX(), shop.getLocation().getBlockY(), shop.getLocation().getBlockZ(), shop.getLocation().getWorld().getName());
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
p.sendMessage(MsgUtil.getMessage("success-removed-shop"));
} else if (Util.isWallSign(b.getType())) {
if(b instanceof Sign) {
Sign sign = (Sign)b;
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette)");
return;
}
}
Shop shop = getShopNextTo(b.getLocation());
if (shop == null)
return;
// If they're in creative and not the owner, don't let them
// (accidents happen)
if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) {
//Check SuperTool
if(p.getInventory().getItemInMainHand().getType()==Material.GOLDEN_AXE) {
p.sendMessage(MsgUtil.getMessage("break-shop-use-supertool"));
return;
}
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-creative-break",MsgUtil.getItemi18n(Material.GOLDEN_AXE.name())));
return;
}
if (e.isCancelled()) {
return;
}
e.setCancelled(true);
// Cancel the event so that the sign does not
// drop.. TODO: Find a better way.
//b.setType(Material.AIR);
}
}
//Protect Minecart steal shop
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryMove(InventoryMoveItemEvent event){
if (plugin.getConfig().getBoolean("protect.minecart")){
// Additional Hopper Minecart Check
if (event.getDestination().getHolder() instanceof HopperMinecart) {
HopperMinecart hm = (HopperMinecart) event.getDestination().getHolder();
Location minecartLoc = new Location(hm.getWorld(), hm.getLocation().getBlockX(), hm.getLocation().getBlockY()+1, hm.getLocation().getBlockZ());
Shop shop = plugin.getShopManager().getShop(minecartLoc);
if (shop == null) {
return;
}
event.setCancelled(true);
hm.remove();
plugin.getLogger().warning("[Exploit Alert] a HopperMinecart tried to move the item of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A HopperMinecart tried to move the item of "+shop);
}
}
if(plugin.getConfig().getBoolean("protect.hopper")) {
if (event.getDestination().getHolder() instanceof Hopper) {
Hopper h = (Hopper) event.getDestination().getHolder();
Location minecartLoc = new Location(h.getWorld(), h.getLocation().getBlockX(), h.getLocation().getBlockY()+1, h.getLocation().getBlockZ());
Shop shop = plugin.getShopManager().getShop(minecartLoc);
if (shop == null) {
return;
}
event.setCancelled(true);
}
}
}
//Protect Entity pickup shop
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMobChangeBlock(EntityChangeBlockEvent event) {
Shop shop = plugin.getShopManager().getShop(event.getBlock().getLocation());
if (shop == null) {
return;
}
if (shop !=null){
if(plugin.getConfig().getBoolean("protect.entity")) {
event.setCancelled(true);
event.getEntity().remove();
plugin.getLogger().warning("[Exploit Alert] a Entity tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A Entity tried to break the shop of "+shop);
}else {
shop.delete();
}
}
}
//Protect Redstone active shop
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockRedstoneChange(BlockRedstoneEvent event){
if (!plugin.getConfig().getBoolean("protect.redstone")){
return;
}
Shop shop = plugin.getShopManager().getShop(event.getBlock().getLocation());
if (shop == null) {
return;
}
if (shop != null){
event.setNewCurrent(event.getOldCurrent());
plugin.getLogger().warning("[Exploit Alert] a Redstone tried to active of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A Redstone tried to active of "+shop);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event){
if (!plugin.getConfig().getBoolean("protect.structuregrow")) {
return;
}
for (BlockState blockstate : event.getBlocks()){
Shop shop = plugin.getShopManager().getShop(blockstate.getLocation());
if (shop == null) {
return;
}
if(shop !=null) {
event.setCancelled(true);
plugin.getLogger().warning("[Exploit Alert] a StructureGrowing tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A StructureGrowing tried to break the shop of "+shop);
}
}
}
/**
* Handles shops breaking through explosions
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplode(EntityExplodeEvent e) {
for (int i = 0; i < e.blockList().size(); i++) {
Block b = e.blockList().get(i);
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if(plugin.getConfig().getBoolean("protect.explode")) {
e.setCancelled(true);
plugin.getLogger().warning("[Exploit Alert] a EntityExplode tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A EntityExplode tried to break the shop of "+shop);
}else {
shop.delete();
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent e) {
for (int i = 0; i < e.blockList().size(); i++) {
Block b = e.blockList().get(i);
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if(plugin.getConfig().getBoolean("protect.explode")) {
e.setCancelled(true);
plugin.getLogger().warning("[Exploit Alert] a BlockExplode tried to break the shop of "+shop);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A BlockExplode tried to break the shop of "+shop);
}else {
shop.delete();
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent e) {
Block newBlock = e.getNewState().getBlock();
Shop thisBlockShop = plugin.getShopManager().getShop(newBlock.getLocation());
Shop underBlockShop = plugin.getShopManager().getShop(newBlock.getRelative(BlockFace.DOWN).getLocation());
if(thisBlockShop == null && underBlockShop == null)
return;
e.setCancelled(true);
}
/**
* Gets the shop a sign is attached to
*
* @param loc
* The location of the sign
* @return The shop
*/
private Shop getShopNextTo(Location loc) {
Block b = Util.getAttached(loc.getBlock());
// Util.getAttached(b)
if (b == null)
return null;
return plugin.getShopManager().getShop(b.getLocation());
}
}
@@ -1,147 +1,147 @@
package org.maxgamer.quickshop.Listeners;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.Shop;
import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Util;
public class LockListener implements Listener {
private QuickShop plugin;
public LockListener(QuickShop plugin) {
this.plugin = plugin;
}
@EventHandler(ignoreCancelled = true)
public void onClick(PlayerInteractEvent e) {
Block b = e.getClickedBlock();
Player p = e.getPlayer();
if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
return; // Didn't right click it, we dont care.
if (!Util.canBeShop(b,null,true))
return; // Interacted with air
Shop shop = plugin.getShopManager().getShop(b.getLocation());
// Make sure they're not using the non-shop half of a double chest.
if (shop == null) {
b = Util.getSecondHalf(b);
if (b == null)
return;
shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
}
if (!shop.getOwner().equals(p.getUniqueId())) {
if (p.hasPermission("quickshop.other.open")) {
p.sendMessage(MsgUtil.getMessage("bypassing-lock"));
return;
}
p.sendMessage(MsgUtil.getMessage("that-is-locked"));
e.setCancelled(true);
return;
}
}
/**
* Handles hopper placement
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
Block b = e.getBlock();
try {
if (b.getType() != Material.HOPPER)
return;
} catch (NoSuchFieldError er) {
return; // Your server doesn't have hoppers
}
Player p = e.getPlayer();
if (Util.isOtherShopWithinHopperReach(b, p) == false)
return;
if (p.hasPermission("quickshop.other.open")) {
p.sendMessage(MsgUtil.getMessage("bypassing-lock"));
return;
}
p.sendMessage(MsgUtil.getMessage("that-is-locked"));
e.setCancelled(true);
}
/**
* Removes chests when they're destroyed.
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBreak(BlockBreakEvent e) {
Block b = e.getBlock();
if(b.getState() instanceof Sign) {
Sign sign = (Sign)b.getState();
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette or other sign-lock plugin)");
return;
}
}
Player p = e.getPlayer();
// If the chest was a chest
if (Util.canBeShop(b,null,true)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return; // Wasn't a shop
// If they owned it or have bypass perms, they can destroy it
if (!shop.getOwner().equals(p.getUniqueId()) && !p.hasPermission("quickshop.other.destroy")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
} else if (b.getType() == Material.WALL_SIGN) {
if(b instanceof Sign) {
Sign sign = (Sign)b;
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette)");
return;
}
}
b = Util.getAttached(b);
if (b == null)
return;
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
// If they're the shop owner or have bypass perms, they can destroy
// it.
if (!shop.getOwner().equals(p.getUniqueId()) && !p.hasPermission("quickshop.other.destroy")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
}
}
/**
* Handles shops breaking through explosions
*/
@EventHandler(priority = EventPriority.LOW,ignoreCancelled=true)
public void onExplode(EntityExplodeEvent e) {
if (e.isCancelled())
return;
for (int i = 0; i < e.blockList().size(); i++) {
Block b = e.blockList().get(i);
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
// ToDo: Shouldn't I be decrementing 1 here? Concurrency and
// all..
e.blockList().remove(b);
}
}
}
package org.maxgamer.quickshop.Listeners;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.Shop;
import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Util;
public class LockListener implements Listener {
private QuickShop plugin;
public LockListener(QuickShop plugin) {
this.plugin = plugin;
}
@EventHandler(ignoreCancelled = true)
public void onClick(PlayerInteractEvent e) {
Block b = e.getClickedBlock();
Player p = e.getPlayer();
if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
return; // Didn't right click it, we dont care.
if (!Util.canBeShop(b,null,true))
return; // Interacted with air
Shop shop = plugin.getShopManager().getShop(b.getLocation());
// Make sure they're not using the non-shop half of a double chest.
if (shop == null) {
b = Util.getSecondHalf(b);
if (b == null)
return;
shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
}
if (!shop.getOwner().equals(p.getUniqueId())) {
if (p.hasPermission("quickshop.other.open")) {
p.sendMessage(MsgUtil.getMessage("bypassing-lock"));
return;
}
p.sendMessage(MsgUtil.getMessage("that-is-locked"));
e.setCancelled(true);
return;
}
}
/**
* Handles hopper placement
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
Block b = e.getBlock();
try {
if (b.getType() != Material.HOPPER)
return;
} catch (NoSuchFieldError er) {
return; // Your server doesn't have hoppers
}
Player p = e.getPlayer();
if (Util.isOtherShopWithinHopperReach(b, p) == false)
return;
if (p.hasPermission("quickshop.other.open")) {
p.sendMessage(MsgUtil.getMessage("bypassing-lock"));
return;
}
p.sendMessage(MsgUtil.getMessage("that-is-locked"));
e.setCancelled(true);
}
/**
* Removes chests when they're destroyed.
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBreak(BlockBreakEvent e) {
Block b = e.getBlock();
if(b.getState() instanceof Sign) {
Sign sign = (Sign)b.getState();
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette or other sign-lock plugin)");
return;
}
}
Player p = e.getPlayer();
// If the chest was a chest
if (Util.canBeShop(b,null,true)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return; // Wasn't a shop
// If they owned it or have bypass perms, they can destroy it
if (!shop.getOwner().equals(p.getUniqueId()) && !p.hasPermission("quickshop.other.destroy")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
} else if (Util.isWallSign(b.getType())) {
if(b instanceof Sign) {
Sign sign = (Sign)b;
if(sign.getLine(0).equals(plugin.getConfig().getString("lockette.private"))||sign.getLine(0).equals(plugin.getConfig().getString("lockette.more_users"))){
//Ignore break lockette sign
plugin.getLogger().info("Skipped a dead-lock shop sign.(Lockette)");
return;
}
}
b = Util.getAttached(b);
if (b == null)
return;
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
// If they're the shop owner or have bypass perms, they can destroy
// it.
if (!shop.getOwner().equals(p.getUniqueId()) && !p.hasPermission("quickshop.other.destroy")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
}
}
/**
* Handles shops breaking through explosions
*/
@EventHandler(priority = EventPriority.LOW,ignoreCancelled=true)
public void onExplode(EntityExplodeEvent e) {
if (e.isCancelled())
return;
for (int i = 0; i < e.blockList().size(); i++) {
Block b = e.blockList().get(i);
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
// ToDo: Shouldn't I be decrementing 1 here? Concurrency and
// all..
e.blockList().remove(b);
}
}
}
}
@@ -1,253 +1,253 @@
package org.maxgamer.quickshop.Listeners;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.BlockIterator;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.Info;
import org.maxgamer.quickshop.Shop.Shop;
import org.maxgamer.quickshop.Shop.ShopAction;
import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Util;
//import com.griefcraft.lwc.LWC;
//import com.griefcraft.lwc.LWCPlugin;
import java.util.HashMap;
import java.util.UUID;
public class PlayerListener implements Listener {
private QuickShop plugin;
public PlayerListener(QuickShop plugin) {
this.plugin = plugin;
}
/*
* Could be useful one day private LinkedList<String> getParents(Class<?>
* clazz){ LinkedList<String> classes = new LinkedList<String>();
*
* while(clazz != null){ classes.add("Extends " + ChatColor.GREEN +
* clazz.getCanonicalName()); for(Class<?> iface : clazz.getInterfaces()){
* classes.add("Implements " + ChatColor.RED + iface.getCanonicalName());
* classes.addAll(getParents(iface)); }
*
* clazz = clazz.getSuperclass(); } return classes; }
*/
/**
* Handles players left clicking a chest. Left click a NORMAL chest with item :
* Send creation menu Left click a SHOP chest : Send purchase menu
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onClick(PlayerInteractEvent e) {
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
Block b = e.getClickedBlock();
if (!Util.canBeShop(b,null,true) && b.getType() != Material.WALL_SIGN) {
return;
}
Player p = e.getPlayer();
Location loc = b.getLocation();
ItemStack item = e.getItem();
// Get the shop
Shop shop = plugin.getShopManager().getShop(loc);
// If that wasn't a shop, search nearby shops
if (shop == null) {
Block attached = null;
if (b.getType() == Material.WALL_SIGN) {
attached = Util.getAttached(b);
if (attached != null) {
shop = plugin.getShopManager().getShop(attached.getLocation());
}
} else if (b.getType() == Material.CHEST || b.getType() == Material.TRAPPED_CHEST) {
attached = Util.getSecondHalf(b);
if (attached != null) {
Shop secondHalfShop = plugin.getShopManager().getShop(attached.getLocation());
if (secondHalfShop != null && !p.getUniqueId().equals(secondHalfShop.getOwner())) {
// If player not the owner of the shop, make him select the second half of the
// shop
// Otherwise owner will be able to create new double chest shop
shop = secondHalfShop;
}
}
}
}
// Purchase handling
if (shop != null && p.hasPermission("quickshop.use")) {
if(plugin.getConfig().getBoolean("shop.sneak-to-trade")&&!p.isSneaking())
return;
shop.onClick();
// Text menu
MsgUtil.sendShopInfo(p, shop);
shop.setSignText();
if (shop.isSelling()) {
p.sendMessage(MsgUtil.getMessage("how-many-buy"));
} else {
int items = Util.countItems(p.getInventory(), shop.getItem());
p.sendMessage(MsgUtil.getMessage("how-many-sell", "" + items));
}
// Add the new action
HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
actions.put(p.getUniqueId(), info);
return;
}
// Handles creating shops
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR
&& p.hasPermission("quickshop.create.sell") && Util.canBeShop(b,null,true)
&& p.getGameMode() != GameMode.CREATIVE) {
if(e.isCancelled())
return;
if(plugin.getConfig().getBoolean("shop.sneak-to-create")&&!p.isSneaking())
return;
if (!plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
// As of the new checking system, most plugins will tell the
// player why they can't create a shop there.
// So telling them a message would cause spam etc.
Util.debugLog("Can't be shop");
return;
}
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
return;
}
if (Util.isBlacklisted(item.getType())
&& !p.hasPermission("quickshop.bypass." + item.getType().name())) {
p.sendMessage(MsgUtil.getMessage("blacklisted-item"));
return;
}
if (b.getType()==Material.ENDER_CHEST) {
if(!p.hasPermission("quickshop.create.enderchest")) {
Util.debugLog("No permission");
Util.debugLog(""+p.hasPermission("quickshop.create.enderchest"));
return;
}
}
if (!Util.canBeShop(b,e.getPlayer().getUniqueId(),false) && b.getType() != Material.WALL_SIGN) {
Util.debugLog("Can't create shop there");
return;
}
// Finds out where the sign should be placed for the shop
Block last = null;
Location from = p.getLocation().clone();
from.setY(b.getY());
from.setPitch(0);
BlockIterator bIt = new BlockIterator(from, 0, 7);
while (bIt.hasNext()) {
Block n = bIt.next();
if (n.equals(b))
break;
last = n;
}
// Send creation menu.
Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
p.sendMessage(
MsgUtil.getMessage("how-much-to-trade-for", MsgUtil.getItemi18n(Util.getName(info.getItem()))));
}
} else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& e.getClickedBlock().getType() == Material.WALL_SIGN) {
Block block;
if (e.getClickedBlock().getType() == Material.WALL_SIGN) {
block = Util.getAttached(e.getClickedBlock());
} else {
block = e.getClickedBlock();
}
if (plugin.getShopManager().getShop(block.getLocation()) != null && plugin.getShopManager().getShop(block.getLocation()).getOwner().equals(e.getPlayer().getUniqueId())) {
if(plugin.getConfig().getBoolean("shop.sneak-to-control")&&!e.getPlayer().isSneaking())
return;
MsgUtil.sendControlPanelInfo((CommandSender) e.getPlayer(),
plugin.getShopManager().getShop(block.getLocation()));
plugin.getShopManager().getShop(block.getLocation()).setSignText();
}
}
}
@EventHandler(priority = EventPriority.HIGH,ignoreCancelled=true)
/**
* Waits for a player to move too far from a shop, then cancels the menu.
*/
public void onMove(PlayerMoveEvent e) {
if (e.isCancelled())
return;
Info info = plugin.getShopManager().getActions().get(e.getPlayer().getUniqueId());
if (info != null) {
Player p = e.getPlayer();
Location loc1 = info.getLocation();
Location loc2 = p.getLocation();
if (loc1.getWorld() != loc2.getWorld() || loc1.distanceSquared(loc2) > 25) {
if (info.getAction() == ShopAction.CREATE) {
p.sendMessage(MsgUtil.getMessage("shop-creation-cancelled"));
} else if (info.getAction() == ShopAction.BUY) {
p.sendMessage(MsgUtil.getMessage("shop-purchase-cancelled"));
}
plugin.getShopManager().getActions().remove(p.getUniqueId());
return;
}
}
}
@EventHandler(ignoreCancelled=true)
public void onTeleport(PlayerTeleportEvent e) {
PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo());
onMove(me);
Util.inventoryCheck(e.getPlayer().getInventory());
}
@EventHandler(ignoreCancelled=true)
public void onJoin(PlayerJoinEvent e) {
// Notify the player any messages they were sent
if(plugin.getConfig().getBoolean("shop.auto-fetch-shop-messages")) {
Bukkit.getScheduler().runTaskLater(QuickShop.instance, new Runnable() {
@Override
public void run() {
MsgUtil.flush(e.getPlayer());
Util.inventoryCheck(e.getPlayer().getInventory());
}
}, 60);
}
}
@EventHandler(ignoreCancelled=true)
public void onPlayerQuit(PlayerQuitEvent e) {
// Remove them from the menu
plugin.getShopManager().getActions().remove(e.getPlayer().getUniqueId());
}
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true)
public void onInventoryClose(InventoryCloseEvent e) {
try {
Inventory inventory = e.getInventory();
if (inventory == null) {
Util.debugLog("Inventory: null");
return;
}
Location location = inventory.getLocation();
if (location == null) {
Util.debugLog("Location: null");
return;
}
Shop shop = plugin.getShopManager().getShop(location);
if (shop == null) {
return;
}
Util.debugLog("Shop: "+shop.toString());
Util.debugLog("Updateing shops..");
shop.setSignText();
} catch (Throwable t) {
}
}
}
package org.maxgamer.quickshop.Listeners;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.BlockIterator;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.Info;
import org.maxgamer.quickshop.Shop.Shop;
import org.maxgamer.quickshop.Shop.ShopAction;
import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Util;
//import com.griefcraft.lwc.LWC;
//import com.griefcraft.lwc.LWCPlugin;
import java.util.HashMap;
import java.util.UUID;
public class PlayerListener implements Listener {
private QuickShop plugin;
public PlayerListener(QuickShop plugin) {
this.plugin = plugin;
}
/*
* Could be useful one day private LinkedList<String> getParents(Class<?>
* clazz){ LinkedList<String> classes = new LinkedList<String>();
*
* while(clazz != null){ classes.add("Extends " + ChatColor.GREEN +
* clazz.getCanonicalName()); for(Class<?> iface : clazz.getInterfaces()){
* classes.add("Implements " + ChatColor.RED + iface.getCanonicalName());
* classes.addAll(getParents(iface)); }
*
* clazz = clazz.getSuperclass(); } return classes; }
*/
/**
* Handles players left clicking a chest. Left click a NORMAL chest with item :
* Send creation menu Left click a SHOP chest : Send purchase menu
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onClick(PlayerInteractEvent e) {
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
Block b = e.getClickedBlock();
if (!Util.canBeShop(b,null,true) && Util.isWallSign(b.getType())) {
return;
}
Player p = e.getPlayer();
Location loc = b.getLocation();
ItemStack item = e.getItem();
// Get the shop
Shop shop = plugin.getShopManager().getShop(loc);
// If that wasn't a shop, search nearby shops
if (shop == null) {
Block attached = null;
if (Util.isWallSign(b.getType())) {
attached = Util.getAttached(b);
if (attached != null) {
shop = plugin.getShopManager().getShop(attached.getLocation());
}
} else if (b.getType() == Material.CHEST || b.getType() == Material.TRAPPED_CHEST) {
attached = Util.getSecondHalf(b);
if (attached != null) {
Shop secondHalfShop = plugin.getShopManager().getShop(attached.getLocation());
if (secondHalfShop != null && !p.getUniqueId().equals(secondHalfShop.getOwner())) {
// If player not the owner of the shop, make him select the second half of the
// shop
// Otherwise owner will be able to create new double chest shop
shop = secondHalfShop;
}
}
}
}
// Purchase handling
if (shop != null && p.hasPermission("quickshop.use")) {
if(plugin.getConfig().getBoolean("shop.sneak-to-trade")&&!p.isSneaking())
return;
shop.onClick();
// Text menu
MsgUtil.sendShopInfo(p, shop);
shop.setSignText();
if (shop.isSelling()) {
p.sendMessage(MsgUtil.getMessage("how-many-buy"));
} else {
int items = Util.countItems(p.getInventory(), shop.getItem());
p.sendMessage(MsgUtil.getMessage("how-many-sell", "" + items));
}
// Add the new action
HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
actions.put(p.getUniqueId(), info);
return;
}
// Handles creating shops
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR
&& p.hasPermission("quickshop.create.sell") && Util.canBeShop(b,null,true)
&& p.getGameMode() != GameMode.CREATIVE) {
if(e.isCancelled())
return;
if(plugin.getConfig().getBoolean("shop.sneak-to-create")&&!p.isSneaking())
return;
if (!plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
// As of the new checking system, most plugins will tell the
// player why they can't create a shop there.
// So telling them a message would cause spam etc.
Util.debugLog("Can't be shop");
return;
}
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
return;
}
if (Util.isBlacklisted(item.getType())
&& !p.hasPermission("quickshop.bypass." + item.getType().name())) {
p.sendMessage(MsgUtil.getMessage("blacklisted-item"));
return;
}
if (b.getType()==Material.ENDER_CHEST) {
if(!p.hasPermission("quickshop.create.enderchest")) {
Util.debugLog("No permission");
Util.debugLog(""+p.hasPermission("quickshop.create.enderchest"));
return;
}
}
if (!Util.canBeShop(b,e.getPlayer().getUniqueId(),false) && Util.isWallSign(b.getType())) {
Util.debugLog("Can't create shop there");
return;
}
// Finds out where the sign should be placed for the shop
Block last = null;
Location from = p.getLocation().clone();
from.setY(b.getY());
from.setPitch(0);
BlockIterator bIt = new BlockIterator(from, 0, 7);
while (bIt.hasNext()) {
Block n = bIt.next();
if (n.equals(b))
break;
last = n;
}
// Send creation menu.
Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
p.sendMessage(
MsgUtil.getMessage("how-much-to-trade-for", MsgUtil.getItemi18n(Util.getName(info.getItem()))));
}
} else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& Util.isWallSign(e.getClickedBlock().getType())) {
Block block;
if (Util.isWallSign(e.getClickedBlock().getType())) {
block = Util.getAttached(e.getClickedBlock());
} else {
block = e.getClickedBlock();
}
if (plugin.getShopManager().getShop(block.getLocation()) != null && plugin.getShopManager().getShop(block.getLocation()).getOwner().equals(e.getPlayer().getUniqueId())) {
if(plugin.getConfig().getBoolean("shop.sneak-to-control")&&!e.getPlayer().isSneaking())
return;
MsgUtil.sendControlPanelInfo((CommandSender) e.getPlayer(),
plugin.getShopManager().getShop(block.getLocation()));
plugin.getShopManager().getShop(block.getLocation()).setSignText();
}
}
}
@EventHandler(priority = EventPriority.HIGH,ignoreCancelled=true)
/**
* Waits for a player to move too far from a shop, then cancels the menu.
*/
public void onMove(PlayerMoveEvent e) {
if (e.isCancelled())
return;
Info info = plugin.getShopManager().getActions().get(e.getPlayer().getUniqueId());
if (info != null) {
Player p = e.getPlayer();
Location loc1 = info.getLocation();
Location loc2 = p.getLocation();
if (loc1.getWorld() != loc2.getWorld() || loc1.distanceSquared(loc2) > 25) {
if (info.getAction() == ShopAction.CREATE) {
p.sendMessage(MsgUtil.getMessage("shop-creation-cancelled"));
} else if (info.getAction() == ShopAction.BUY) {
p.sendMessage(MsgUtil.getMessage("shop-purchase-cancelled"));
}
plugin.getShopManager().getActions().remove(p.getUniqueId());
return;
}
}
}
@EventHandler(ignoreCancelled=true)
public void onTeleport(PlayerTeleportEvent e) {
PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo());
onMove(me);
Util.inventoryCheck(e.getPlayer().getInventory());
}
@EventHandler(ignoreCancelled=true)
public void onJoin(PlayerJoinEvent e) {
// Notify the player any messages they were sent
if(plugin.getConfig().getBoolean("shop.auto-fetch-shop-messages")) {
Bukkit.getScheduler().runTaskLater(QuickShop.instance, new Runnable() {
@Override
public void run() {
MsgUtil.flush(e.getPlayer());
Util.inventoryCheck(e.getPlayer().getInventory());
}
}, 60);
}
}
@EventHandler(ignoreCancelled=true)
public void onPlayerQuit(PlayerQuitEvent e) {
// Remove them from the menu
plugin.getShopManager().getActions().remove(e.getPlayer().getUniqueId());
}
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true)
public void onInventoryClose(InventoryCloseEvent e) {
try {
Inventory inventory = e.getInventory();
if (inventory == null) {
Util.debugLog("Inventory: null");
return;
}
Location location = inventory.getLocation();
if (location == null) {
Util.debugLog("Location: null");
return;
}
Shop shop = plugin.getShopManager().getShop(location);
if (shop == null) {
return;
}
Util.debugLog("Shop: "+shop.toString());
Util.debugLog("Updateing shops..");
shop.setSignText();
} catch (Throwable t) {
}
}
}
@@ -541,7 +541,7 @@ public class ContainerShop implements Shop {
final String signHeader = MsgUtil.getMessage("signs.header", "");
final String signHeader2 = MsgUtil.getMessage("sign.header", this.ownerName());
for (Block b : blocks) {
if (b.getType() != Material.WALL_SIGN)
if (Util.isWallSign(b.getType()))
continue;
if (!isAttached(b))
continue;
@@ -565,7 +565,7 @@ public class ContainerShop implements Shop {
}
public boolean isAttached(Block b) {
if (b.getType() != Material.WALL_SIGN)
if (Util.isWallSign(b.getType()))
new IllegalArgumentException(b + " Is not a sign!").printStackTrace();
return this.getLocation().getBlock().equals(Util.getAttached(b));
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff