Remove a couple config options

- Shop items cannot be hidden
- Hologram interaction had to be removed
- Hopper/Explosion protection cannot be disabled
- Admin shops cannot be counted in shop limit
- Only the nearest shop the player points at is shown
This commit is contained in:
Eric 2019-06-03 15:58:13 +02:00
parent aea88b9f3b
commit 48bb669c01
9 changed files with 31 additions and 211 deletions

View File

@ -234,7 +234,7 @@ class ShopCommandExecutor implements CommandExecutor {
int limit = shopUtils.getShopLimit(p);
if (limit != -1) {
if (shopUtils.getShopAmount(p) >= limit) {
if (shopType != Shop.ShopType.ADMIN || !Config.excludeAdminShops) {
if (shopType != Shop.ShopType.ADMIN) {
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_LIMIT_REACHED, new Replacement(Placeholder.LIMIT, String.valueOf(limit))));
plugin.debug(p.getName() + " has reached the limit");
return;

View File

@ -131,16 +131,6 @@ public class Config {
**/
public static boolean buyGreaterOrEqualSell;
/**
* Whether shops should be protected by hoppers
**/
public static boolean hopperProtection;
/**
* Whether shops should be protected by explosions
**/
public static boolean explosionProtection;
/**
* Whether buys and sells must be confirmed
**/
@ -157,11 +147,6 @@ public class Config {
**/
public static boolean enableUpdateChecker;
/**
* Whether hologram interaction should be enabled
**/
public static boolean enableHologramInteraction;
/**
* Whether the debug log file should be created
**/
@ -229,36 +214,21 @@ public class Config {
**/
public static boolean enableVendorMessages;
/**
* Whether admin shops should be excluded of the shop limits
**/
public static boolean excludeAdminShops;
/**
* Whether the extension of a potion or tipped arrow (if available) should be appended to the item name.
**/
public static boolean appendPotionLevelToItemName;
/**
* Whether the shop items should be shown
**/
public static boolean showShopItems;
/**
* Whether players are allowed to sell/buy broken items
**/
public static boolean allowBrokenItems;
/**
* Whether only the shops a player has in sight should be shown to him
* Whether only the shop a player is pointing at should be shown
**/
public static boolean onlyShowShopsInSight;
/**
* Whether only the shop a player is looking at should be shown to him
**/
public static boolean onlyShowFirstShopInSight;
/**
* <p>Whether shops should automatically be removed from the database if an error occurred while loading</p>
* (e.g. when no chest is found at a shop's location)
@ -494,12 +464,9 @@ public class Config {
creativeSelectItem = plugin.getConfig().getBoolean("creative-select-item");
blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
buyGreaterOrEqualSell = plugin.getConfig().getBoolean("buy-greater-or-equal-sell");
hopperProtection = plugin.getConfig().getBoolean("hopper-protection");
explosionProtection = plugin.getConfig().getBoolean("explosion-protection");
confirmShopping = plugin.getConfig().getBoolean("confirm-shopping");
refundShopCreation = plugin.getConfig().getBoolean("refund-shop-creation");
enableUpdateChecker = plugin.getConfig().getBoolean("enable-update-checker");
enableHologramInteraction = plugin.getConfig().getBoolean("enable-hologram-interaction");
enableDebugLog = plugin.getConfig().getBoolean("enable-debug-log");
enableEconomyLog = plugin.getConfig().getBoolean("enable-economy-log");
cleanupEconomyLogDays = plugin.getConfig().getInt("cleanup-economy-log-days");
@ -514,10 +481,7 @@ public class Config {
enableAreaShopIntegration = plugin.getConfig().getBoolean("enable-areashop-integration");
enableVendorMessages = plugin.getConfig().getBoolean("enable-vendor-messages");
onlyShowShopsInSight = plugin.getConfig().getBoolean("only-show-shops-in-sight");
onlyShowFirstShopInSight = plugin.getConfig().getBoolean("only-show-first-shop-in-sight");
excludeAdminShops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
appendPotionLevelToItemName = plugin.getConfig().getBoolean("append-potion-level-to-item-name");
showShopItems = plugin.getConfig().getBoolean("show-shop-items");
removeShopOnError = plugin.getConfig().getBoolean("remove-shop-on-error");
invertMouseButtons = plugin.getConfig().getBoolean("invert-mouse-buttons");
hologramFixedBottom = plugin.getConfig().getBoolean("hologram-fixed-bottom");

View File

@ -1,7 +1,6 @@
package de.epiceric.shopchest.listeners;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
@ -20,7 +19,6 @@ public class BlockExplodeListener implements Listener {
@EventHandler
public void onBlockExplode(BlockExplodeEvent e) {
if (Config.explosionProtection) {
ArrayList<Block> bl = new ArrayList<>(e.blockList());
for (Block b : bl) {
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
@ -28,6 +26,5 @@ public class BlockExplodeListener implements Listener {
}
}
}
}
}

View File

@ -115,7 +115,6 @@ public class ChestProtectListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent e) {
if (Config.explosionProtection) {
ArrayList<Block> bl = new ArrayList<>(e.blockList());
for (Block b : bl) {
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
@ -123,7 +122,6 @@ public class ChestProtectListener implements Listener {
}
}
}
}
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent e) {
@ -224,7 +222,6 @@ public class ChestProtectListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent e) {
if (Config.hopperProtection) {
if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {
if (e.getSource().getHolder() instanceof DoubleChest) {
@ -239,8 +236,6 @@ public class ChestProtectListener implements Listener {
if (shopUtils.isShop(c.getLocation())) e.setCancelled(true);
}
}
}
}

View File

@ -15,7 +15,6 @@ import de.epiceric.shopchest.external.PlotSquaredShopFlag.GroupFlag;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
import de.epiceric.shopchest.nms.Hologram;
import de.epiceric.shopchest.nms.JsonBuilder;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.shop.ShopProduct;
@ -39,16 +38,12 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
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.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory;
@ -455,79 +450,12 @@ public class ShopInteractListener implements Listener {
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMeApi.getInstance().isAuthenticated(e.getPlayer())) return;
handleInteractEvent(e);
}
@EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent e) {
if (!Config.enableHologramInteraction) return;
Entity entity = e.getRightClicked();
Player p = e.getPlayer();
if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMeApi.getInstance().isAuthenticated(p)) return;
if (Utils.getMajorVersion() == 8 || e.getHand() == EquipmentSlot.HAND) {
if (entity instanceof ArmorStand) {
ArmorStand armorStand = (ArmorStand) entity;
if (Hologram.isPartOfHologram(armorStand)) {
Hologram hologram = Hologram.getHologram(armorStand);
if (hologram != null) {
Block b = null;
for (Shop shop : plugin.getShopUtils().getShops()) {
if (shop.getHologram() != null && shop.getHologram().equals(hologram)) {
b = shop.getLocation().getBlock();
}
}
if (b != null) {
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.RIGHT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null);
handleInteractEvent(interactEvent);
}
}
}
}
}
}
@EventHandler
public void onPlayerDamageEntity(EntityDamageByEntityEvent e) {
if (!Config.enableHologramInteraction) return;
Entity entity = e.getEntity();
Entity damager = e.getDamager();
if (!(damager instanceof Player)) return;
Player p = (Player) damager;
if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMeApi.getInstance().isAuthenticated(p)) return;
if (entity instanceof ArmorStand) {
ArmorStand armorStand = (ArmorStand) entity;
if (Hologram.isPartOfHologram(armorStand)) {
Hologram hologram = Hologram.getHologram(armorStand);
if (hologram != null) {
Block b = null;
for (Shop shop : plugin.getShopUtils().getShops()) {
if (shop.getHologram() != null && shop.getHologram().equals(hologram)) {
b = shop.getLocation().getBlock();
}
}
if (b != null) {
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null);
handleInteractEvent(interactEvent);
e.setCancelled(true);
}
}
}
}
}
/**
* Create a new shop
*

View File

@ -44,7 +44,6 @@ public class Hologram {
private final ShopChest plugin;
private boolean exists;
private ArmorStandWrapper interactArmorStandWrapper;
public Hologram(ShopChest plugin, String[] lines, Location location) {
this.plugin = plugin;
@ -54,14 +53,6 @@ public class Hologram {
addLine(i, lines[i]);
}
if (Config.enableHologramInteraction) {
double y = 0.6;
if (Config.hologramFixedBottom) y = 0.85;
Location loc = getLocation().add(0, y, 0);
interactArmorStandWrapper = new ArmorStandWrapper(plugin, loc, null, true);
}
this.exists = true;
HOLOGRAMS.add(this);
}
@ -90,7 +81,7 @@ public class Hologram {
return true;
}
}
return interactArmorStandWrapper != null && armorStand.getUniqueId().equals(interactArmorStandWrapper.getUuid());
return false;
}
/**
@ -100,13 +91,6 @@ public class Hologram {
return wrappers;
}
/**
* @return The {@link ArmorStandWrapper} of this hologram that is positioned higher to be used for interaction
*/
public ArmorStandWrapper getInteractArmorStandWrapper() {
return interactArmorStandWrapper;
}
/**
* @param p Player to check
* @return Whether the hologram is visible to the player
@ -163,11 +147,6 @@ public class Hologram {
}
wrappers.clear();
if (interactArmorStandWrapper != null) {
interactArmorStandWrapper.remove();
}
interactArmorStandWrapper = null;
exists = false;
HOLOGRAMS.remove(this);
}
@ -185,10 +164,6 @@ public class Hologram {
for (ArmorStandWrapper wrapper : wrappers) {
wrapper.setVisible(p, visible);
}
if (interactArmorStandWrapper != null) {
interactArmorStandWrapper.setVisible(p, visible);
}
}
/**

View File

@ -117,7 +117,7 @@ public class Shop {
plugin.debug("Failed to create shop (#" + id + ")");
plugin.debug(ex);
return false;
} else if ((!ItemUtils.isAir(b.getRelative(BlockFace.UP).getType())) && Config.showShopItems) {
} else if ((!ItemUtils.isAir(b.getRelative(BlockFace.UP).getType()))) {
NotEnoughSpaceException ex = new NotEnoughSpaceException(String.format("No space above chest in world '%s' at location: %d; %d; %d",
b.getWorld().getName(), b.getX(), b.getY(), b.getZ()));
plugin.getShopUtils().removeShop(this, Config.removeShopOnError);
@ -175,7 +175,6 @@ public class Shop {
* <b>Call this after {@link #createHologram()}, because it depends on the hologram's location</b>
*/
private void createItem() {
if (Config.showShopItems) {
plugin.debug("Creating item (#" + id + ")");
Location itemLocation;
@ -183,7 +182,6 @@ public class Shop {
itemLocation = new Location(location.getWorld(), holoLocation.getX(), location.getY() + 0.9, holoLocation.getZ());
item = new ShopItem(plugin, product.getItemStack(), itemLocation);
}
}
/**
* Runs everything that needs to be called synchronously in order

View File

@ -204,7 +204,7 @@ public class ShopUtils {
for (Shop shop : getShops()) {
if (shop.getVendor().equals(p)) {
if (shop.getShopType() != Shop.ShopType.ADMIN || !Config.excludeAdminShops) {
if (shop.getShopType() != Shop.ShopType.ADMIN) {
shopCount++;
InventoryHolder ih = shop.getInventoryHolder();
@ -304,10 +304,8 @@ public class ShopUtils {
private void updateVisibleShops(Player player) {
double itemDistSquared = Math.pow(Config.maximalItemDistance, 2);
boolean firstShopInSight = Config.onlyShowFirstShopInSight;
double maxDist = Config.maximalDistance;
List<Shop> shopsInSight = new ArrayList<>();
double nearestDistSquared = Double.MAX_VALUE;
Shop nearestShop = null;
@ -330,7 +328,6 @@ public class ShopUtils {
}
if (shop != null && shop.hasHologram()) {
shopsInSight.add(shop);
double distSquared = pLoc.distanceSquared(loc);
if (distSquared < nearestDistSquared) {
nearestDistSquared = distSquared;
@ -340,15 +337,9 @@ public class ShopUtils {
}
for (Shop shop : getShops()) {
if (firstShopInSight) {
if (!shop.equals(nearestShop) && shop.hasHologram()) {
shop.getHologram().hidePlayer(player);
}
} else {
if (!shopsInSight.contains(shop)) {
shop.getHologram().hidePlayer(player);
}
}
// Display item based on distance
Location shopLocation = shop.getLocation();
@ -368,12 +359,6 @@ public class ShopUtils {
if (nearestShop != null) {
nearestShop.getHologram().showPlayer(player);
}
if (!firstShopInSight) {
for (Shop otherShop : shopsInSight) {
otherShop.getHologram().showPlayer(player);
}
}
}
private void updateNearestShops(Player p) {

View File

@ -13,9 +13,6 @@ main-command-name: "shop"
# (without the '.lang' extension)
language-file: "en_US"
# Set whether the floating shop items on top of the chest should be shown
show-shop-items: true
# Set the item with which a player can click a shop to retrieve information.
# You can set this to an empty string to disable this feature.
shop-info-item: "STICK"
@ -44,12 +41,6 @@ refund-shop-creation: false
# check for updates.
enable-update-checker: true
# Set whether interaction with the hologram should be enabled.
# If set to true, a player can do the exact same thing with the
# hologram, as with the chest. You can even open the chest if you
# are the vendor or have permission.
enable-hologram-interaction: true
# Set whether buys and sells should be logged in the database.
enable-economy-log: false
@ -107,10 +98,6 @@ enable-vendor-messages: true
# distance) will be shown to him.
only-show-shops-in-sight: true
# Set whether only the shop a player is looking at should be shown to him.
# This only has effect if 'only-show-shops-in-sight' is enabled
only-show-first-shop-in-sight: true
# Set whether the hologram's location should be fixed at the bottom,
# so when it gets more lines, it won't interfere with the item or chest,
# but goes higher.
@ -180,12 +167,6 @@ shop-creation-price:
# ...an admin shop
admin: 0
# Set whether the shop's chest should be protected by hoppers
hopper-protection: true
# Set whether the shop's chest should be protected by explosions
explosion-protection: true
# Set whether the buy price must be greater than or equal sell price.
buy-greater-or-equal-sell: true
@ -248,8 +229,8 @@ towny-shop-plots:
- "COMMERCIAL"
# Configuration of the database, where everything is stored.
# Shops are found in the table 'shop_list', and logged economy
# transactions are found in the table 'shop_log'
# Shops are found in the table 'shopchest_shops', and logged economy
# transactions are found in the table 'shopchest_economy_logs'
database:
# Select the type of database which should be used
@ -287,12 +268,9 @@ database:
# Shop limits are handled with permissions.
# A player with permission "shopchest.limit.X" has a limit of X shops,
# a player with permission "shopchest.limit.*" does not have a shop limit.
# Admin shops are excluded from the shop limit.
shop-limits:
# Set whether admin shops should be excluded of the shop limits.
# If set to true, admin shops won't be added to a player's shop count.
exclude-admin-shops: true
# Set the amount of shops that anyone who doesn't have a
# specific permission may have.
# If you don't want the players to have a limit by default