Skip to content

Commit

Permalink
Merge pull request #693 from Crazy-Crew/fix-inconsistences
Browse files Browse the repository at this point in the history
Fix a few inconsistences
  • Loading branch information
ryderbelserion authored Apr 17, 2024
2 parents 905e098 + cee8299 commit d88f4f1
Show file tree
Hide file tree
Showing 32 changed files with 1,814 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
Please read the previous changelog https://modrinth.com/plugin/crazycrates/version/2.0

## Fixes:
* Fixed an issue where setting crate type menu tried to create a hologram.
* Fixed a placeholder issue in commands like /key by using the right config path
* Fixed the `examples` folder not generating

## Pull Requests Merged:
* https://github.com/Crazy-Crew/CrazyCrates/pull/692 -> Adds null safety to the key name if not found in config.

## Other:
* [Feature Requests](https://github.com/Crazy-Crew/CrazyCrates/discussions/categories/features)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ issues = https://github.com/Crazy-Crew/CrazyCrates/issues

group = com.badbones69.crazycrates
description = Add unlimited crates to your server with 10 different crate types to choose from!
version = 2.0.1
version = 2.0.2
apiVersion = 1.20

mcVersion = 1.20.4
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ oraxen-api = { group = "io.th0rgal", name = "oraxen", version = "1.171.0" }
placeholder-api = { group = "me.clip", name = "placeholderapi", version = "2.11.5" }
head-database-api = { group = "com.arcaniax", name = "HeadDatabase-API", version = "1.3.1" }

vital = { group = "com.ryderbelserion.vital", name = "vital", version = "1.0-snapshot" }
vital = { group = "com.ryderbelserion.vital", name = "paper", version = "1.0" }

decent-holograms = { group = "com.github.decentsoftware-eu", name = "decentholograms", version = "2.8.6" }

Expand Down
22 changes: 4 additions & 18 deletions paper/src/main/java/com/badbones69/crazycrates/CrazyCrates.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.badbones69.crazycrates.tasks.InventoryManager;
import com.badbones69.crazycrates.tasks.MigrationManager;
import com.badbones69.crazycrates.tasks.crates.CrateManager;
import com.ryderbelserion.vital.VitalPlugin;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.VitalPaper;
import com.ryderbelserion.vital.enums.Support;
import net.minecraft.server.dedicated.DedicatedServer;
import org.bukkit.plugin.java.JavaPlugin;
import com.badbones69.crazycrates.api.FileManager;
Expand Down Expand Up @@ -83,13 +83,9 @@ public void onLoad() {
.setup();
}

private VitalPlugin plugin;

@Override
public void onEnable() {
this.plugin = new VitalPlugin(this);
this.plugin.setLogging(MiscUtils.isLogging());
this.plugin.start();
new VitalPaper(this);

int radius = DedicatedServer.getServer().getSpawnProtectionRadius();

Expand Down Expand Up @@ -180,13 +176,7 @@ public void onEnable() {
@Override
public void onDisable() {
// Cancel the timer task.
if (this.timer != null) {
this.timer.cancel();
}

if (this.plugin != null) {
this.plugin.stop();
}
this.timer.cancel();

// Clean up any mess we may have left behind.
if (this.crateManager != null) {
Expand All @@ -204,10 +194,6 @@ public void onDisable() {
}
}

public @NotNull VitalPlugin getPlugin() {
return this.plugin;
}

public @NotNull InventoryManager getInventoryManager() {
return this.inventoryManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.badbones69.crazycrates.api.objects.Tier;
import com.badbones69.crazycrates.api.builders.ItemBuilder;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.enums.Support;
import org.apache.commons.lang.WordUtils;
import com.badbones69.crazycrates.CrazyCrates;
import com.badbones69.crazycrates.api.events.PlayerPrizeEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.badbones69.crazycrates.api.objects.Crate;
import com.badbones69.crazycrates.api.objects.Tier;
import com.badbones69.crazycrates.api.utils.MiscUtils;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.enums.Support;
import org.bukkit.plugin.java.JavaPlugin;
import us.crazycrew.crazycrates.platform.config.ConfigManager;
import us.crazycrew.crazycrates.platform.config.impl.ConfigKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.badbones69.crazycrates.api.utils.MsgUtils;
import com.badbones69.crazycrates.support.SkullCreator;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.utils.DyeUtils;
import com.ryderbelserion.vital.enums.Support;
import com.ryderbelserion.vital.util.DyeUtil;
import io.th0rgal.oraxen.api.OraxenItems;
import me.clip.placeholderapi.PlaceholderAPI;
import net.minecraft.nbt.TagParser;
Expand Down Expand Up @@ -583,10 +583,10 @@ public ItemBuilder setMaterial(String type) {
} else {
this.potionType = getPotionType(PotionEffectType.getByName(metaData)).getEffectType();

this.potionColor = DyeUtils.getColor(metaData);
this.armorColor = DyeUtils.getColor(metaData);
this.mapColor = DyeUtils.getColor(metaData);
this.fireworkColor = DyeUtils.getColor(metaData);
this.potionColor = DyeUtil.getColor(metaData);
this.armorColor = DyeUtil.getColor(metaData);
this.mapColor = DyeUtil.getColor(metaData);
this.fireworkColor = DyeUtil.getColor(metaData);
}
} else if (type.contains("#")) {
String[] section = type.split("#");
Expand Down Expand Up @@ -1160,7 +1160,7 @@ public static ItemBuilder convertString(String itemString, String placeHolder) {
try {
for (PatternType pattern : PatternType.values()) {
if (option.equalsIgnoreCase(pattern.name()) || value.equalsIgnoreCase(pattern.getIdentifier())) {
DyeColor color = DyeUtils.getDyeColor(value);
DyeColor color = DyeUtil.getDyeColor(value);
if (color != null) itemBuilder.addPattern(new Pattern(color, pattern));
break;
}
Expand Down Expand Up @@ -1363,7 +1363,7 @@ private void addPatterns(String stringPattern) {
for (PatternType pattern : PatternType.values()) {

if (split[0].equalsIgnoreCase(pattern.name()) || split[0].equalsIgnoreCase(pattern.getIdentifier())) {
DyeColor color = DyeUtils.getDyeColor(split[1]);
DyeColor color = DyeUtil.getDyeColor(split[1]);

if (color != null) addPattern(new Pattern(color, pattern));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import ch.jalu.configme.SettingsManager;
import ch.jalu.configme.properties.Property;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.utils.MiscUtils;
import com.ryderbelserion.vital.common.util.StringUtil;
import com.ryderbelserion.vital.enums.Support;
import org.bukkit.command.CommandSender;
import us.crazycrew.crazycrates.platform.config.ConfigManager;
import us.crazycrew.crazycrates.platform.config.impl.messages.CommandKeys;
Expand Down Expand Up @@ -159,7 +159,7 @@ public String getMessage(Map<String, String> placeholders, CommandSender sender)
String message;

if (isList()) {
message = MiscUtils.convertList(getPropertyList(this.listProperty));
message = StringUtil.convertList(getPropertyList(this.listProperty));
} else {
message = getProperty(this.property);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.badbones69.crazycrates.api.builders.types.CrateTierMenu;
import com.badbones69.crazycrates.api.enums.PersistentKeys;
import com.badbones69.crazycrates.tasks.crates.effects.SoundEffect;
import com.ryderbelserion.vital.utils.DyeUtils;
import com.ryderbelserion.vital.util.DyeUtil;
import org.bukkit.Color;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
Expand Down Expand Up @@ -97,7 +97,7 @@ public class Crate {
public Crate(String name, String previewName, CrateType crateType, ItemStack key, String keyName, List<Prize> prizes, FileConfiguration file, int newPlayerKeys, List<Tier> tiers, int maxMassOpen, int requiredKeys, List<String> prizeMessage, List<String> prizeCommands, CrateHologram hologram) {
this.emptyKey = ItemBuilder.convertItemStack(key);
this.keyBuilder = ItemBuilder.convertItemStack(key).setCrateName(name);
this.keyName = keyName;
this.keyName = keyName != null ? keyName : "Crate.PhysicalKey.Name is not in the " + name + ".yml";

this.file = file;
this.name = name;
Expand Down Expand Up @@ -138,7 +138,7 @@ public Crate(String name, String previewName, CrateType crateType, ItemStack key
if (crateType == CrateType.quad_crate) {
this.particle = Registry.PARTICLE_TYPE.get(NamespacedKey.minecraft(file != null ? file.getString("Crate.particles.type", "dust") : "dust"));

this.color = DyeUtils.getColor(file != null ? file.getString("Crate.particles.color", "235,64,52") : "235,64,52");
this.color = DyeUtil.getColor(file != null ? file.getString("Crate.particles.color", "235,64,52") : "235,64,52");
}

this.hologram = hologram != null ? hologram : new CrateHologram();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.badbones69.crazycrates.CrazyCrates;
import com.badbones69.crazycrates.api.objects.Crate;
import com.google.common.collect.Lists;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.enums.Support;
import dev.triumphteam.cmd.bukkit.annotation.Permission;
import dev.triumphteam.cmd.core.BaseCommand;
import dev.triumphteam.cmd.core.annotation.*;
Expand Down Expand Up @@ -84,7 +84,7 @@ private void getKeys(Player player, CommandSender sender, String header, String

hasKeys = true;

placeholders.put("{crate}", crate.getFile().getString("Crate.Name"));
placeholders.put("{crate}", crate.getCrateInventoryName());
placeholders.put("{keys}", String.valueOf(amount));
placeholders.put("{crate_opened}", String.valueOf(this.userManager.getCrateOpened(player.getUniqueId(), crate.getName())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ public void onReload(CommandSender sender) {
this.plugin.getMetrics().start();
}

this.plugin.getPlugin().setLogging(MiscUtils.isLogging());

FileUtils.cleanFiles();

// Close previews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void onInventoryClick(InventoryClickEvent event) {
}

// Get new name.
String shufflingName = crate.getFile().getString("Crate.CrateName") + " - Shuffling";
String shufflingName = crate.getCrateInventoryName() + " - Shuffling";

// Update the cosmic name.
holder.title(shufflingName);
Expand Down Expand Up @@ -432,7 +432,7 @@ private void startRollingAnimation(Player player, InventoryView view, CratePrize
}

private void showRewards(Player player, InventoryView view, CratePrizeMenu cosmic, CosmicCrateManager crateManager) {
String rewardsName = cosmic.getCrate().getFile().getString("Crate.CrateName") + " - Prizes";
String rewardsName = cosmic.getCrate().getCrateInventoryName() + " - Prizes";

cosmic.title(rewardsName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.badbones69.crazycrates.api.enums.Messages;
import com.badbones69.crazycrates.api.events.CrateOpenEvent;
import com.badbones69.crazycrates.api.objects.Crate;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.enums.Support;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import com.badbones69.crazycrates.tasks.crates.types.*;
import com.badbones69.crazycrates.tasks.crates.types.CasinoCrate;
import com.badbones69.crazycrates.tasks.crates.types.CsgoCrate;
import com.ryderbelserion.vital.api.enums.Support;
import com.ryderbelserion.vital.common.util.FileUtil;
import com.ryderbelserion.vital.enums.Support;
import org.apache.commons.lang.WordUtils;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -165,6 +166,8 @@ public void loadHolograms() {
* Loads the crates.
*/
public void loadCrates() {
FileUtil.extracts(this.plugin.getClass(), "/examples/", this.plugin.getDataFolder().toPath().resolve("examples"), true);

this.giveNewPlayersKeys = false;

purge();
Expand All @@ -184,7 +187,7 @@ public void loadCrates() {
List<Prize> prizes = new ArrayList<>();
List<Tier> tiers = new ArrayList<>();

String previewName = file.contains("Crate.Preview-Name") ? file.getString("Crate.Preview-Name") : file.getString("Crate.Name");
String previewName = file.contains("Crate.Preview-Name") ? file.getString("Crate.Preview-Name") : file.getString("Crate.CrateName");
int maxMassOpen = file.getInt("Crate.Max-Mass-Open", 10);
int requiredKeys = file.getInt("Crate.RequiredKeys", 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CosmicCrate extends CrateBuilder {
private final CrateManager crateManager = this.plugin.getCrateManager();

public CosmicCrate(Crate crate, Player player, int size) {
super(crate, player, size, crate.getFile().getString("Crate.CrateName") + " - Choose");
super(crate, player, size, crate.getCrateInventoryName() + " - Choose");
}

@Override
Expand Down
Loading

0 comments on commit d88f4f1

Please sign in to comment.