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