Skip to content

Commit

Permalink
Update casino crate again
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Feb 11, 2024
1 parent 1675d6b commit 437face
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 20 deletions.
Expand Up @@ -7,6 +7,7 @@
import com.badbones69.crazycrates.api.objects.Tier;
import com.badbones69.crazycrates.api.utils.MiscUtils;
import org.bukkit.SoundCategory;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -104,19 +105,55 @@ public void open(KeyType type, boolean checkHand) {
return;
}

setDisplayItems(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size())));
setDisplayItems(true);

getPlayer().openInventory(getInventory());
}

private void setDisplayItems(Tier tier) {
for (int index = 0; index <= 26; index++) {
if (index == 2 || index == 4 || index == 6 || index == 11 || index == 13 || index == 15 || index == 20 || index == 22 || index == 24) {
setItem(index, getDisplayItem(tier));
} else {
private void setDisplayItems(boolean isStatic) {
ConfigurationSection section = getCrate().getFile().getConfigurationSection("Crate.random");

if (isStatic) {
for (int index = 0; index < 27; index++) {
setItem(index, getRandomGlassPane());
}
}

if (section != null) {
boolean isRandom = section.getBoolean("toggle", false);

String row_uno = section.getString("types.row-1");
String row_dos = section.getString("types.row-2");
String row_tres = section.getString("types.row-3");

if (isRandom) {
setItem(2, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));
setItem(11, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));
setItem(20, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));

setItem(4, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));
setItem(13, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));
setItem(22, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));

setItem(6, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));
setItem(15, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));
setItem(24, getDisplayItem(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size()))));

return;
}

setItem(2, getDisplayItem(getCrate().getTier(row_uno)));
setItem(11, getDisplayItem(getCrate().getTier(row_uno)));
setItem(20, getDisplayItem(getCrate().getTier(row_uno)));

setItem(4, getDisplayItem(getCrate().getTier(row_dos)));
setItem(13, getDisplayItem(getCrate().getTier(row_dos)));
setItem(22, getDisplayItem(getCrate().getTier(row_dos)));

setItem(6, getDisplayItem(getCrate().getTier(row_tres)));
setItem(15, getDisplayItem(getCrate().getTier(row_tres)));
setItem(24, getDisplayItem(getCrate().getTier(row_tres)));
}
}

private void cycle() {
Expand All @@ -134,6 +171,6 @@ private void cycle() {
}
}

setDisplayItems(getCrate().getTiers().get(new Random().nextInt(getCrate().getTiers().size())));
setDisplayItems(false);
}
}
119 changes: 106 additions & 13 deletions paper/src/main/resources/crates/CasinoExample.yml
Expand Up @@ -108,6 +108,18 @@ Crate:
name: ' '
# The item that shows in the border. Can be glass or any other item.
item: 'RED_STAINED_GLASS_PANE'
# Tier related settings only for Casino.
random:
# If the tiers should be random.
toggle: false
# The rows with pre-defined tiers.
types:
# Row 1
row-1: Basic
# Row 2
row-2: UnCommon
# Row 3
row-3: Rare
# Tiers are available in Cosmic and Casino crate types.
# The Tiers the rewards can be found in.
Tiers:
Expand All @@ -121,7 +133,7 @@ Crate:
# The item used for the secondary gui when you right-click for the preview.
Item: 'CHEST'
# Chance of that item getting picked. It would be 80/100 chance because MaxRange is 100.
Chance: 80
Chance: 50
# The max range that the chance will go though.
MaxRange: 100
# The slot this item will be in the secondary gui.
Expand All @@ -131,15 +143,15 @@ Crate:
Lore:
- '&aAn uncommon tier.'
Item: 'CHEST'
Chance: 55
Chance: 35
MaxRange: 100
Slot: 22
Rare:
Name: '&4Rare Tier'
Lore:
- '&cA rare tier.'
Item: 'ENDER_CHEST'
Chance: 20
Chance: 25
MaxRange: 100
Slot: 24
PhysicalKey:
Expand Down Expand Up @@ -182,8 +194,6 @@ Crate:
# The Tiers the rewards can be found in.
Tiers:
- 'Basic'
- 'UnCommon'
- 'Rare'
# If you do not want a lore, Set the "Lore:" to look like the line below.
# Lore: []

Expand Down Expand Up @@ -230,7 +240,7 @@ Crate:
# Only works on items with durability. This will make the item appear more damaged.
# It does not set the durability but subtracts this number from the durability is 100, It subtracts 50.
# It cannot be 0.
DisplayDamage: 50
DisplayDamage: 50f
DisplayTrim:
# Available Materials: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimMaterial.html
Material: 'QUARTZ'
Expand All @@ -244,10 +254,8 @@ Crate:
# The Tiers the rewards can be found in.
Tiers:
- 'Basic'
- 'UnCommon'
- 'Rare'
MaxRange: 100
Chance: 60
Chance: 15
Items:
- 'Item:GOLDEN_HELMET, Amount:1, Damage:50, Trim-Pattern:SENTRY, Trim-Material:QUARTZ, Name:&bCheap Helmet, PROTECTION_ENVIRONMENTAL:1, OXYGEN:1'
3:
Expand All @@ -261,10 +269,8 @@ Crate:
# The Tiers the rewards can be found in.
Tiers:
- 'Basic'
- 'UnCommon'
- 'Rare'
MaxRange: 100
Chance: 20
Chance: 35
Firework: true
Commands:
- 'eco give %player% 1000'
Expand All @@ -278,4 +284,91 @@ Crate:
Messages:
- '&r &8[&bCrazyCrates&8]: &7You have already won that prize, so enjoy some gold nuggets.'
Commands:
- 'give %player% gold_nugget 16'
- 'give %player% gold_nugget 16'
4:
DisplayName: '&4&lWarlord''s Helmet'
DisplayItem: 'NETHERITE_HELMET'
DisplayTrim:
# Available Materials: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimMaterial.html
Material: 'REDSTONE'
# Available Patterns: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimPattern.html
Pattern: 'SENTRY'
DisplayAmount: 1
Lore:
- '&7Win the warlord''s helmet.'
- '&6&lChance: &c&l40%'
DisplayEnchantments:
- 'PROTECTION_ENVIRONMENTAL:5'
- 'DURABILITY:3'
Tiers:
- 'UnCommon'
MaxRange: 100
Chance: 10
Items:
- 'Item:NETHERITE_HELMET, Amount:1, Damage:25, Trim-Pattern:SENTRY, Trim-Material:REDSTONE, Name:&4&lWarlord''s Helmet, PROTECTION_ENVIRONMENTAL:5, DURABILITY:3'
5:
DisplayName: '&4&lWarlord''s Chestplate'
DisplayItem: 'NETHERITE_CHESTPLATE'
DisplayTrim:
# Available Materials: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimMaterial.html
Material: 'REDSTONE'
# Available Patterns: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimPattern.html
# Boots and leggings should be in rare. ( row 3 )
# Helmet and chestplate should be in UnCommon ( row 2 )
# Head/Gold/Sunflower should be in basic ( row 1 )
Pattern: 'SENTRY'
DisplayAmount: 1
Lore:
- '&7Win the warlord''s chestplate.'
- '&6&lChance: &c&l40%'
DisplayEnchantments:
- 'PROTECTION_ENVIRONMENTAL:5'
- 'DURABILITY:3'
Tiers:
- 'UnCommon'
MaxRange: 100
Chance: 3
Items:
- 'Item:NETHERITE_CHESTPLATE, Amount:1, Damage:25, Trim-Pattern:SENTRY, Trim-Material:REDSTONE, Name:&4&lWarlord''s Chestplate, PROTECTION_ENVIRONMENTAL:5, DURABILITY:3'
6:
DisplayName: '&4&lWarlord''s Leggings'
DisplayItem: 'NETHERITE_LEGGINGS'
DisplayTrim:
# Available Materials: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimMaterial.html
Material: 'REDSTONE'
# Available Patterns: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimPattern.html
Pattern: 'SENTRY'
DisplayAmount: 1
Lore:
- '&7Win the warlord''s leggings.'
- '&6&lChance: &c&l40%'
DisplayEnchantments:
- 'PROTECTION_ENVIRONMENTAL:5'
- 'DURABILITY:3'
Tiers:
- 'Rare'
MaxRange: 100
Chance: 3
Items:
- 'Item:NETHERITE_LEGGINGS, Amount:1, Damage:25, Trim-Pattern:SENTRY, Trim-Material:REDSTONE, Name:&4&lWarlord''s Leggings, PROTECTION_ENVIRONMENTAL:5, DURABILITY:3'
7:
DisplayName: '&4&lWarlord''s Boots'
DisplayItem: 'NETHERITE_BOOTS'
DisplayTrim:
# Available Materials: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimMaterial.html
Material: 'REDSTONE'
# Available Patterns: https://jd.papermc.io/paper/1.20/org/bukkit/inventory/meta/trim/TrimPattern.html
Pattern: 'SENTRY'
DisplayAmount: 1
Lore:
- '&7Win the warlord''s boots.'
- '&6&lChance: &c&l40%'
DisplayEnchantments:
- 'PROTECTION_ENVIRONMENTAL:5'
- 'DURABILITY:3'
Tiers:
- 'Rare'
MaxRange: 100
Chance: 3
Items:
- 'Item:NETHERITE_BOOTS, Amount:1, Damage:25, Trim-Pattern:SENTRY, Trim-Material:REDSTONE, Name:&4&lWarlord''s Boots, PROTECTION_ENVIRONMENTAL:5, DURABILITY:3'

0 comments on commit 437face

Please sign in to comment.