Skip to content

Commit

Permalink
Fix cosmic crate (#716)
Browse files Browse the repository at this point in the history
## Fixes:
* fix default casino crate
* update fallback sound
  • Loading branch information
ryderbelserion authored May 16, 2024
1 parent 46e6dba commit d9a9f49
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ public final int getSlot() {
public @NotNull final ItemStack getTierItem(final @Nullable Player target) {
if (target != null) this.item.setPlayer(target);

return this.item.setDisplayName(this.coloredName).setDisplayLore(this.lore).setPersistentString(PersistentKeys.preview_tier_button.getNamespacedKey(), this.name).getStack();
return this.item.setDisplayName(this.coloredName).setDisplayLore(this.lore).setPersistentString(PersistentKeys.crate_tier.getNamespacedKey(), this.name).getStack();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void onInventoryClose(InventoryCloseEvent event) {
final ItemStack item = inventory.getItem(key);

if (item != null) {
Tier tier = getTier(crate, item);
final Tier tier = getTier(crate, item);

if (tier != null) {
Prize prize = crate.pickPrize(player, tier);
Expand All @@ -98,7 +98,7 @@ public void onInventoryClose(InventoryCloseEvent event) {
}

// Play sound.
if (playSound) crate.playSound(player, player.getLocation(), "click-sound", "UI_BUTTON_CLICK", Sound.Source.PLAYER);
if (playSound) crate.playSound(player, player.getLocation(), "click-sound", "ui.button.click", Sound.Source.PLAYER);

// Remove opening stuff.
this.crateManager.removePlayerFromOpeningList(player);
Expand Down Expand Up @@ -392,7 +392,7 @@ public void run() {
// Check if event is cancelled.
if (!event.isCancelled()) {
// Add the keys
userManager.addKeys(uuid, crateName, type, 1);
userManager.addKeys(uuid, crateName, type == null ? KeyType.virtual_key : type, 1);

// Remove opening stuff.
crateManager.removePlayerFromOpeningList(player);
Expand Down Expand Up @@ -493,8 +493,14 @@ public void run() {
}

private Tier getTier(final Crate crate, final ItemStack item) {
for (Tier tier : crate.getTiers()) {
if (tier.getTierItem(null).isSimilar(item)) return tier;
if (!item.hasItemMeta()) return null;

ItemMeta itemMeta = item.getItemMeta();

PersistentDataContainer container = itemMeta.getPersistentDataContainer();

if (container.has(PersistentKeys.crate_tier.getNamespacedKey())) {
return crate.getTier(container.get(PersistentKeys.crate_tier.getNamespacedKey(), PersistentDataType.STRING));
}

return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package com.badbones69.crazycrates.tasks.crates.other;

public abstract class AbstractCrateManager {}
import com.badbones69.crazycrates.CrazyCrates;
import org.bukkit.plugin.java.JavaPlugin;

public abstract class AbstractCrateManager {

protected final CrazyCrates plugin = JavaPlugin.getPlugin(CrazyCrates.class);

}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void run() {

this.tickTillSpawn++;
} else {
crate.playSound(player, player.getLocation(), "cycle-sound", "BLOCK_STONE_STEP", Sound.Source.PLAYER);
crate.playSound(player, player.getLocation(), "cycle-sound", "block.stone.step", Sound.Source.PLAYER);

Block chest = crateLocations.get(crateNumber).getBlock();

Expand Down
155 changes: 153 additions & 2 deletions paper/src/main/resources/crates/types/CasinoCrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Crate:
- "<bold><dark_blue>Casino Crate</bold>"
# All the prizes that can be obtained in the Crate.
Prizes:
'1':
"1":
# The name of the item to display in the gui.
DisplayName: "<gold>BadBones69"
# The item to display in the gui.
Expand All @@ -216,4 +216,155 @@ Crate:
# An example of a custom player head.
# This can be a player head as well.
# https://minecraft-heads.com/
Player: "1ee3126ff2c343da525eef2b93272b9fed36273d0ea08c2616b80009948ad57e"
Player: "1ee3126ff2c343da525eef2b93272b9fed36273d0ea08c2616b80009948ad57e"
"2":
# The name of the item to display in the gui.
DisplayName: "<bold><dark_red>Warlord's Set</bold>"
# The item to display in the gui.
DisplayItem: "netherite_helmet"
# The enchants on the item.
DisplayEnchantments:
- "protection:5"
- "unbreaking:3"
# https://docs.crazycrew.us/docs/plugins/crazycrates/guides/prizes/items/armor-trim
DisplayTrim:
# The list of materials to use can be found on the link above
Material: "redstone"
# The list of patterns to use can be found on the link above
Pattern: "sentry"
# The amount to display in the gui.
DisplayAmount: 1
# The lore of the item.
Lore:
- "<gray>Win the warlord's set."
- "<bold><gold>Chance: <red>40%</bold>"
# The max range i.e. 40/100 = 40% chance to win.
MaxRange: 100
# The chance to win i.e. 40%
Chance: 40
# Tiers are available in Cosmic and Casino crate types.
# The Tiers the rewards can be found in.
Tiers:
- "UnCommon"
# A list of commands to run when they roll this prize.
Commands:
# This adds the blacklist permission to the player when they win the prize,
# After this, they will no longer be able to use this prize.
- "lp user %player% permission set crazycrates.blacklist.warlord"
# The list of items to give.
Items:
- "Item:netherite_helmet, Amount:1, Damage:25, Trim-Pattern:sentry, Trim-Material:redstone, Name:<bold><dark_red>Warlord's Helmet</bold>, protection:5, unbreaking:3"
- "Item:netherite_chestplate, Amount:1, Damage:25, Trim-Pattern:sentry, Trim-Material:redstone, Name:<bold><dark_red>Warlord's Chestplate</bold>, protection:5, unbreaking:3"
- "Item:netherite_leggings, Amount:1, Damage:25, Trim-Pattern:sentry, Trim-Material:redstone, Name:<bold><dark_red>Warlord's Leggings</bold>, protection:5, unbreaking:3"
- "Item:netherite_boots, Amount:1, Damage:25, Trim-Pattern:sentry, Trim-Material:redstone, Name:<bold><dark_red>Warlord's Boots</bold>, protection:5, unbreaking:3"
# A list of permissions, If a player has any of these permissions. they cannot win this prize again!
BlackListed-Permissions:
- "crazycrates.blacklist.warlord"
# The alternative prize.
Alternative-Prize:
# if it should be enabled.
Toggle: true
# The message to send.
Messages:
- "<reset> <dark_gray>[<blue>CrazyCrates<dark_gray>]: <gray>You have already won that prize, so enjoy some gold nuggets."
# A list of commands to run.
Commands:
- "give %player% gold_nugget 16"
# Alternatively, instead of commands. You can have an Items section which functions the same as the Items section above.
Items:
- "Item:gold_nugget, Amount:16"
"3":
# The enchants to be stored on the book.
DisplayEnchantments:
- "protection:5"
- "unbreaking:3"
# The item to display in the gui.
# The enchanted book will function with the enchants properly in an anvil.
DisplayItem: "enchanted_book"
# The amount to display in the gui.
DisplayAmount: 3
# The lore of the item.
Lore:
- "<gradient:#8fcfa0:#32a852>A gradient lore!"
# The max range i.e. 25/100 = 15% chance to win.
MaxRange: 100
# The chance to win i.e. 25%
Chance: 25
# Tiers are available in Cosmic and Casino crate types.
# The Tiers the rewards can be found in.
Tiers:
- "Rare"
"4":
# The name of the item to display in the gui.
DisplayName: "<bold><green>Fancy Pants</bold>"
# The item to display in the gui.
DisplayItem: "chainmail_leggings"
# The enchants on the item.
DisplayEnchantments:
- "protection:2"
# 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 75.
# It cannot be 0.
DisplayDamage: 75
# https://docs.crazycrew.us/docs/plugins/crazycrates/guides/prizes/items/armor-trim
DisplayTrim:
# The list of materials to use can be found on the link above
Material: "lapis"
# The list of patterns to use can be found on the link above
Pattern: "sentry"
# The amount to display in the gui.
DisplayAmount: 1
# The max range i.e. 40/1000 = 4% chance to win.
MaxRange: 1000
# The chance to win i.e. 4%
Chance: 40
# Tiers are available in Cosmic and Casino crate types.
# The Tiers the rewards can be found in.
Tiers:
- "Basic"
- "UnCommon"
# The lore of the item.
Lore:
- "<gray>Win a fancy pair of pants."
- "<bold><gold>Chance: <red>4%</bold>"
# The items to win.
Items:
- "Item:chainmail_leggings, Amount:1, Damage:75, Trim-Pattern:sentry, Trim-Material:lapis, Name:<bold><green>Fancy Pants</bold>, protection:2"
# The messages to send.
Messages:
- "<gray>You just won a <reset>%reward%."
"5":
# The name of the item to display in the gui.
DisplayName: "<bold><blue>Classic Sword</bold>"
# The item to display in the gui.
DisplayItem: "diamond_sword"
# The enchants on the item.
DisplayEnchantments:
- "sharpness:2"
- "fire_aspect:1"
# 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 7.
# It cannot be 0.
DisplayDamage: 7
# The amount to display in the gui.
DisplayAmount: 1
# The lore of the item.
Lore:
- "<gray>Win a old classic sword."
- "<bold><gold>Chance: <red>3.5%</bold>"
# The max range i.e. 35/1000 = 3.5% chance to win.
MaxRange: 1000
# The chance to win i.e. 3.5%.
Chance: 35
# Tiers are available in Cosmic and Casino crate types.
# The Tiers the rewards can be found in.
Tiers:
- "Basic"
- "UnCommon"
- "Rare"
# The items to win.
Items:
- "Item:diamond_sword, Amount:1, Damage:7, Name:<bold><blue>Classic Sword</bold>, sharpness:2, fire_aspect:1"
# The messages to send.
Messages:
- "<gray>You just won <reset>%reward%."

0 comments on commit d9a9f49

Please sign in to comment.