mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Added configuration values
You can now set whether a shop should be removed from the database if an error occurred when loading it, and you can set whether the floating shop item should be shown/enabled.
This commit is contained in:
parent
47414009bf
commit
1d22e28954
@ -84,6 +84,15 @@ public class Config {
|
|||||||
/** Whether admin shops should be excluded of the shop limits **/
|
/** Whether admin shops should be excluded of the shop limits **/
|
||||||
public boolean exclude_admin_shops;
|
public boolean exclude_admin_shops;
|
||||||
|
|
||||||
|
/** Whether the shop items should be shown **/
|
||||||
|
public boolean show_shop_items;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <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)
|
||||||
|
*/
|
||||||
|
public boolean remove_shop_on_error;
|
||||||
|
|
||||||
/** The maximum distance between a player and a shop to see the hologram **/
|
/** The maximum distance between a player and a shop to see the hologram **/
|
||||||
public double maximal_distance;
|
public double maximal_distance;
|
||||||
|
|
||||||
@ -257,6 +266,8 @@ public class Config {
|
|||||||
hopper_protection = plugin.getConfig().getBoolean("hopper-protection");
|
hopper_protection = plugin.getConfig().getBoolean("hopper-protection");
|
||||||
explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
|
explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
|
||||||
exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
|
exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
|
||||||
|
show_shop_items = plugin.getConfig().getBoolean("show-shop-items");
|
||||||
|
remove_shop_on_error = plugin.getConfig().getBoolean("remove-shop-on-error");
|
||||||
maximal_distance = plugin.getConfig().getDouble("maximal-distance");
|
maximal_distance = plugin.getConfig().getDouble("maximal-distance");
|
||||||
shop_creation_price_normal = plugin.getConfig().getDouble("shop-creation-price.normal");
|
shop_creation_price_normal = plugin.getConfig().getDouble("shop-creation-price.normal");
|
||||||
shop_creation_price_admin = plugin.getConfig().getDouble("shop-creation-price.admin");
|
shop_creation_price_admin = plugin.getConfig().getDouble("shop-creation-price.admin");
|
||||||
|
@ -5,6 +5,7 @@ import de.epiceric.shopchest.config.Regex;
|
|||||||
import de.epiceric.shopchest.language.LanguageUtils;
|
import de.epiceric.shopchest.language.LanguageUtils;
|
||||||
import de.epiceric.shopchest.language.LocalizedMessage;
|
import de.epiceric.shopchest.language.LocalizedMessage;
|
||||||
import de.epiceric.shopchest.nms.IHologram;
|
import de.epiceric.shopchest.nms.IHologram;
|
||||||
|
import de.epiceric.shopchest.utils.ShopUtils;
|
||||||
import de.epiceric.shopchest.utils.Utils;
|
import de.epiceric.shopchest.utils.Utils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -52,6 +53,9 @@ public class Shop {
|
|||||||
this.chest = (Chest) b.getState();
|
this.chest = (Chest) b.getState();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
if (plugin.getShopChestConfig().remove_shop_on_error)
|
||||||
|
ShopUtils.removeShop(this, true);
|
||||||
|
|
||||||
throw new Exception("No Chest found at specified Location: " + b.getX() + "; " + b.getY() + "; " + b.getZ());
|
throw new Exception("No Chest found at specified Location: " + b.getX() + "; " + b.getY() + "; " + b.getZ());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -99,24 +103,26 @@ public class Shop {
|
|||||||
* <b>Call this after {@link #createHologram()}, because it depends on the hologram's location</b>
|
* <b>Call this after {@link #createHologram()}, because it depends on the hologram's location</b>
|
||||||
*/
|
*/
|
||||||
private void createItem() {
|
private void createItem() {
|
||||||
Item item;
|
if (plugin.getShopChestConfig().show_shop_items) {
|
||||||
Location itemLocation;
|
Item item;
|
||||||
ItemStack itemStack;
|
Location itemLocation;
|
||||||
ItemMeta itemMeta = product.getItemMeta();
|
ItemStack itemStack;
|
||||||
itemMeta.setDisplayName(UUID.randomUUID().toString());
|
ItemMeta itemMeta = product.getItemMeta();
|
||||||
|
itemMeta.setDisplayName(UUID.randomUUID().toString());
|
||||||
|
|
||||||
itemLocation = new Location(location.getWorld(), hologram.getLocation().getX(), location.getY() + 1, hologram.getLocation().getZ());
|
itemLocation = new Location(location.getWorld(), hologram.getLocation().getX(), location.getY() + 1, hologram.getLocation().getZ());
|
||||||
itemStack = new ItemStack(product);
|
itemStack = new ItemStack(product);
|
||||||
itemStack.setAmount(1);
|
itemStack.setAmount(1);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
|
||||||
item = location.getWorld().dropItem(itemLocation, itemStack);
|
item = location.getWorld().dropItem(itemLocation, itemStack);
|
||||||
item.setVelocity(new Vector(0, 0, 0));
|
item.setVelocity(new Vector(0, 0, 0));
|
||||||
item.setMetadata("shopItem", new FixedMetadataValue(plugin, true));
|
item.setMetadata("shopItem", new FixedMetadataValue(plugin, true));
|
||||||
item.setCustomNameVisible(false);
|
item.setCustomNameVisible(false);
|
||||||
item.setPickupDelay(Integer.MAX_VALUE);
|
item.setPickupDelay(Integer.MAX_VALUE);
|
||||||
|
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,7 +265,7 @@ public class Shop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return IHologram of the shop
|
* @return Hologram of the shop
|
||||||
*/
|
*/
|
||||||
public IHologram getHologram() {
|
public IHologram getHologram() {
|
||||||
return hologram;
|
return hologram;
|
||||||
|
@ -11,6 +11,14 @@ main-command-name: "shop"
|
|||||||
# The value must equal to the name of one of a file in the 'lang' folder (without the '.lang' extension)
|
# The value must equal to the name of one of a file in the 'lang' folder (without the '.lang' extension)
|
||||||
language-file: "en_US"
|
language-file: "en_US"
|
||||||
|
|
||||||
|
# Set whether the floating shop items on top of the chest should be shown
|
||||||
|
show-shop-items: true
|
||||||
|
|
||||||
|
# Set whether shops should automatically be removed from the database if an error occurred while loading
|
||||||
|
# e.g. when no chest is found at a shop's location
|
||||||
|
# This might be useful if you're removing shop chests with WorldEdit, resetting plots, or similar
|
||||||
|
remove-shop-on-error: false
|
||||||
|
|
||||||
# Set the maximal distance to the shop where the player can see the hologram.
|
# Set the maximal distance to the shop where the player can see the hologram.
|
||||||
# Value MUST be a number (e.g. 1, 1.5, 2.75, ...)
|
# Value MUST be a number (e.g. 1, 1.5, 2.75, ...)
|
||||||
maximal-distance: 1.75
|
maximal-distance: 1.75
|
||||||
|
Loading…
Reference in New Issue
Block a user