added availability option to blockshop config conditions
This commit is contained in:
parent
766ae0d176
commit
11ba7404f9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -15,6 +15,7 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class BlockShop implements Listener {
|
||||
@ -102,7 +103,8 @@ public class BlockShop implements Listener {
|
||||
String materialName = config.getString("shop.categories." + category + ".items." + itemKey + ".material");
|
||||
int price = config.getInt("shop.categories." + category + ".items." + itemKey + ".price");
|
||||
String displayName = config.getString("shop.categories." + category + ".items." + itemKey + ".display_name");
|
||||
|
||||
boolean locked = config.getBoolean("shop.categories." + category + ".items." + itemKey + ".available");
|
||||
if (!locked) {
|
||||
if (materialName != null) {
|
||||
Material material = Material.matchMaterial(materialName.toUpperCase());
|
||||
if (material != null) {
|
||||
@ -111,13 +113,18 @@ public class BlockShop implements Listener {
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(ChatColor.GREEN + (displayName != null ? displayName : "Unnamed Item"));
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(ChatColor.GOLD + "Price: $" + price);
|
||||
// Format price with commas
|
||||
NumberFormat formatter = NumberFormat.getInstance(Locale.US);
|
||||
String formattedPrice = formatter.format(price);
|
||||
lore.add(ChatColor.GOLD + "Price: $" + formattedPrice);
|
||||
meta.setLore(lore);
|
||||
itemStack.setItemMeta(meta);
|
||||
items.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
//--non availability logic
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
|
@ -125,10 +125,13 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
|
||||
}
|
||||
if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Anchor Shield Kit")) {
|
||||
// Create a chest item
|
||||
ItemStack chest = new ItemStack(Material.CHEST, 1);
|
||||
ItemStack anchor = new ItemStack(Material.RESPAWN_ANCHOR, 1);
|
||||
ItemStack rod = new ItemStack(Material.LIGHTNING_ROD, 1);
|
||||
ItemStack core = new ItemStack(Material.HEAVY_CORE, 1);
|
||||
ItemStack charge = new ItemStack(Material.GLOWSTONE,4);
|
||||
|
||||
// Give the chest and items to the player
|
||||
player.getInventory().addItem(chest, new ItemStack(Material.RESPAWN_ANCHOR, 1), new ItemStack(Material.LIGHTNING_ROD, 5),new ItemStack(Material.HEAVY_CORE,1));
|
||||
player.getInventory().addItem(anchor,rod,core,charge);
|
||||
}
|
||||
if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Levitation Wand")) {
|
||||
player.getInventory().addItem(MobLevitationWand.createWand());
|
||||
@ -240,7 +243,7 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
|
||||
for (ItemStack item : player.getInventory().getContents()) {
|
||||
if (item != null && item.getType() == Material.KNOWLEDGE_BOOK) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
//player.sendMessage("you have a knowledge book with name: \n"+ meta.getDisplayName() + "\n"+customName+"\n do they match?");
|
||||
//player.sendMessage("[DEBUG] you have a knowledge book with name: \n"+ meta.getDisplayName() + "\n"+customName+"\n do they match?");
|
||||
if (meta != null && meta.hasDisplayName() && meta.getDisplayName().equals(customName)) {
|
||||
player.getInventory().remove(item); // Remove the book
|
||||
return true; // Found and removed
|
||||
|
@ -7,11 +7,13 @@ shop:
|
||||
price: 192
|
||||
quantity: 64
|
||||
display_name: "Stone Block"
|
||||
available: true
|
||||
smooth_stone:
|
||||
material: SMOOTH_STONE
|
||||
price: 320
|
||||
quantity: 64
|
||||
display_name: "Smooth Stone"
|
||||
available: true
|
||||
wood_blocks:
|
||||
items:
|
||||
oak_planks:
|
||||
@ -19,6 +21,7 @@ shop:
|
||||
price: 960
|
||||
quantity: 64
|
||||
display_name: "Oak Planks"
|
||||
available: true
|
||||
pvp:
|
||||
items:
|
||||
iron_helmet:
|
||||
@ -26,41 +29,49 @@ shop:
|
||||
price: 110
|
||||
quantity: 1
|
||||
display_name: "Iron Helmet"
|
||||
available: true
|
||||
iron_chestplate:
|
||||
material: IRON_CHESTPLATE
|
||||
price: 176
|
||||
quantity: 1
|
||||
display_name: "Iron Chestplate"
|
||||
available: true
|
||||
iron_leggings:
|
||||
material: IRON_LEGGINGS
|
||||
price: 154
|
||||
quantity: 1
|
||||
display_name: "Iron Leggings"
|
||||
available: true
|
||||
iron_boots:
|
||||
material: IRON_BOOTS
|
||||
price: 88
|
||||
quantity: 1
|
||||
display_name: "Iron Boots"
|
||||
available: true
|
||||
iron_sword:
|
||||
material: IRON_SWORD
|
||||
price: 44
|
||||
quantity: 1
|
||||
display_name: "Iron Sword"
|
||||
available: true
|
||||
iron_PICKAXE:
|
||||
material: IRON_PICKAXE
|
||||
price: 66
|
||||
quantity: 1
|
||||
display_name: "Iron Pick"
|
||||
available: true
|
||||
iron_axe:
|
||||
material: IRON_AXE
|
||||
price: 66
|
||||
quantity: 1
|
||||
display_name: "Iron Axe"
|
||||
available: true
|
||||
iron_shovel:
|
||||
material: IRON_SHOVEL
|
||||
price: 22
|
||||
quantity: 1
|
||||
display_name: "Iron Spoon"
|
||||
available: true
|
||||
redstone:
|
||||
items:
|
||||
repeater:
|
||||
@ -68,11 +79,13 @@ shop:
|
||||
price: 900
|
||||
quantity: 18
|
||||
display_name: "Repeater"
|
||||
available: true
|
||||
redstone:
|
||||
material: REDSTONE
|
||||
price: 2048
|
||||
quantity: 64
|
||||
display_name: "Redstone Dust"
|
||||
available: true
|
||||
nether:
|
||||
items:
|
||||
obsidian:
|
||||
@ -80,6 +93,7 @@ shop:
|
||||
price: 1300
|
||||
quantity: 10
|
||||
display_name: "Obsidian"
|
||||
available: true
|
||||
utilities:
|
||||
items:
|
||||
ASK:
|
||||
@ -87,26 +101,31 @@ shop:
|
||||
price: 450000
|
||||
quantity: 1
|
||||
display_name: "Anchor Shield Kit"
|
||||
available: true
|
||||
gravity_gauntlet:
|
||||
material: KNOWLEDGE_BOOK
|
||||
price: 200000
|
||||
quantity: 1
|
||||
display_name: "Gravity Gauntlet"
|
||||
available: true
|
||||
levitation_wand:
|
||||
material: KNOWLEDGE_BOOK
|
||||
price: 1000000
|
||||
quantity: 1
|
||||
display_name: "Levitation Wand"
|
||||
available: true
|
||||
launch_stick:
|
||||
material: KNOWLEDGE_BOOK
|
||||
price: 1234567
|
||||
quantity: 1
|
||||
display_name: "Launch Stick"
|
||||
available: true
|
||||
rapid_fire_bow:
|
||||
material: KNOWLEDGE_BOOK
|
||||
price: 9000000
|
||||
quantity: 1
|
||||
display_name: "Rapid Fire Bow"
|
||||
available: true
|
||||
poor: "you're too poor for that, get gooder..."
|
||||
inventory_full: "you got too much clutter, cant fit your purchase into that mess..."
|
||||
pagination:
|
||||
|
Loading…
Reference in New Issue
Block a user