Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	paper/src/main/java/com/badbones69/crazycrates/CrazyCrates.java
#	paper/src/main/java/com/badbones69/crazycrates/api/builders/types/CratePreviewMenu.java
#	paper/src/main/java/com/badbones69/crazycrates/api/builders/types/CrateTierMenu.java
#	paper/src/main/java/com/badbones69/crazycrates/api/objects/Crate.java
#	paper/src/main/java/com/badbones69/crazycrates/tasks/InventoryManager.java
  • Loading branch information
dan28000 committed Sep 16, 2024
2 parents f4220f7 + f10fd53 commit 5c75dec
Show file tree
Hide file tree
Showing 43 changed files with 778 additions and 804 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### Big Changes:
#### If you DO not change this, all your previews will look weird.
- config.yml has had a chance that cannot be automatically done.
- the customizer specifically the `slot` option, due to recent inventory changes.
- you must subtract 1 from each option, and start from `slot:0` instead of `slot:1`
- Similar tweaks have to be made with subtracting `1` from each option in the `crate` files
- Specifically, related to the position of the crates in `/crates` and the position of the tiers in the tier previews
- Why did this change? Inventories naturally start from `0`, and the gui framework I switched to does start from `0`
- This change allows for much easier inventory management and future features.

### Added:
- Added a new feature to prizes, The ability to set a limit on prizes.
- If a prize has Max-Pulls set to any number i.e. 1 or higher.
Expand Down Expand Up @@ -45,6 +55,8 @@ An example of what a prize would look like with the `Max-Pulls` option
- Fixed spacing in migrate command usage.

### Changes:
- Slots in `config.yml`, and slots in each crate file that define the position of the tiers in the tier preview or the buttons in /crates have been changed, so existing gui's will look very weird.
- All initial configs, You must subtract 1 from each slot. 14 would become 13 as an example. It's a very easy change (there is no real way to migrate your configurations with this)
- Improved /crazycrates migrate internally.
- ExcellentCrates Migrator has changed significantly, report any bugs you might find. It will convert legacy color codes to MiniMessage.
- Properly warn the player/sender if the inputted migration type is not valid.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

val buildNumber: String? = System.getenv("BUILD_NUMBER")

rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.7.5"
rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.8"

val isSnapshot = false

Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/java-plugin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ plugins {
}

repositories {
maven("https://repo.extendedclip.com/content/repositories/placeholderapi")

maven("https://repo.codemc.io/repository/maven-public")

maven("https://repo.crazycrew.us/libraries")
maven("https://repo.crazycrew.us/releases")

maven("https://repo.oraxen.com/releases")

maven("https://jitpack.io")

flatDir { dirs("libs") }
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/paper-plugin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ repositories {
maven("https://repo.papermc.io/repository/maven-public")

maven("https://repo.triumphteam.dev/snapshots")

maven("https://repo.oraxen.com/releases")
}
12 changes: 5 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ vault = "1.7.1"
triumph-cmd = "2.0.0-ALPHA-10"
jetbrains = "24.1.0"
adventure = "4.17.0"
vital-paper = "0.0.2"

# Modrinth
vital-paper = "0.0.1"

[libraries]
velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" }
Expand All @@ -46,11 +44,11 @@ kyori-api = { module = "net.kyori:adventure-api", version.ref = "adventure" }

# Bukkit Plugins
decent-holograms = { module = "com.github.decentsoftware-eu:decentholograms", version.ref = "decentholograms" }
fancy-holograms = { module = "de.oliver:FancyHolograms", version.ref = "fancyholograms" }
placeholderapi = { module = "com.github.PlaceholderAPI:PlaceholderAPI", version.ref = "placeholderapi" }
headdatabaseapi = { module = "com.arcaniax:HeadDatabase-API", version.ref = "headdatabaseapi" }
placeholderapi = { module = "me.clip:placeholderapi", version.ref = "placeholderapi" }
vault = { module = "com.github.MilkBowl:VaultAPI", version.ref = "vault" }
itemsadder = { module = "com.github.LoneDev6:api-itemsadder", version.ref = "itemsadder" }
fancy-holograms = { module = "de.oliver:FancyHolograms", version.ref = "fancyholograms" }
vault = { module = "com.github.MilkBowl:VaultAPI", version.ref = "vault" }
oraxen = { module = "io.th0rgal:oraxen", version.ref = "oraxen" }

# Crate Plugins
Expand All @@ -66,4 +64,4 @@ jetbrains = { module = "org.jetbrains:annotations", version.ref = "jetbrains" }

[bundles]
holograms = ["decent-holograms", "fancy-holograms"]
items = ["itemsadder", "oraxen"]
items = ["itemsadder", "oraxen"]
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
14 changes: 4 additions & 10 deletions paper/src/main/java/com/badbones69/crazycrates/CrazyCrates.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package com.badbones69.crazycrates;

import com.badbones69.crazycrates.api.builders.types.CrateAdminMenu;
import com.badbones69.crazycrates.api.builders.types.CrateMainMenu;
import com.badbones69.crazycrates.api.builders.types.CratePreviewMenu;
import com.badbones69.crazycrates.api.builders.types.CrateTierMenu;
import com.badbones69.crazycrates.api.objects.other.Server;
import com.badbones69.crazycrates.api.utils.MiscUtils;
import com.badbones69.crazycrates.commands.CommandManager;
import com.badbones69.crazycrates.config.ConfigManager;
import com.badbones69.crazycrates.config.impl.ConfigKeys;
import com.badbones69.crazycrates.listeners.BrokeLocationsListener;
import com.badbones69.crazycrates.listeners.CrateControlListener;
import com.badbones69.crazycrates.listeners.MiscListener;
import com.badbones69.crazycrates.listeners.crates.CosmicCrateListener;
import com.badbones69.crazycrates.listeners.crates.types.CosmicCrateListener;
import com.badbones69.crazycrates.listeners.crates.CrateOpenListener;
import com.badbones69.crazycrates.listeners.crates.MobileCrateListener;
import com.badbones69.crazycrates.listeners.crates.QuadCrateListener;
import com.badbones69.crazycrates.listeners.crates.WarCrateListener;
import com.badbones69.crazycrates.listeners.crates.types.MobileCrateListener;
import com.badbones69.crazycrates.listeners.crates.types.QuadCrateListener;
import com.badbones69.crazycrates.listeners.crates.types.WarCrateListener;
import com.badbones69.crazycrates.listeners.other.EntityDamageListener;
import com.badbones69.crazycrates.support.MetricsWrapper;
import com.badbones69.crazycrates.support.holograms.HologramManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public static void givePrize(@NotNull final Player player, @Nullable Prize prize
}

if (!MiscUtils.isInventoryFull(player)) {
MiscUtils.addItem(player, item.setPlayer(player).getStack());
MiscUtils.addItem(player, item.setPlayer(player).asItemStack());
} else {
player.getWorld().dropItemNaturally(player.getLocation(), item.setPlayer(player).getStack());
player.getWorld().dropItemNaturally(player.getLocation(), item.setPlayer(player).asItemStack());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void setItem(final int slot, @NotNull final ItemStack item) {
* @param lore lore of item
*/
public void setItem(final int slot, @NotNull final Material material, @NotNull final String name, @NotNull final List<String> lore) {
getInventory().setItem(slot, new ItemBuilder(material).setPlayer(getPlayer()).setDisplayName(name).setDisplayLore(lore).getStack());
getInventory().setItem(slot, new ItemBuilder(material).setPlayer(getPlayer()).setDisplayName(name).setDisplayLore(lore).asItemStack());
}

/**
Expand All @@ -288,7 +288,7 @@ public void setItem(final int slot, @NotNull final Material material, @NotNull f
* @param name name of item
*/
public void setItem(final int slot, @NotNull final Material material, @NotNull final String name) {
getInventory().setItem(slot, new ItemBuilder(material).setPlayer(getPlayer()).setDisplayName(name).getStack());
getInventory().setItem(slot, new ItemBuilder(material).setPlayer(getPlayer()).setDisplayName(name).asItemStack());
}

/**
Expand All @@ -304,7 +304,7 @@ public void setCustomGlassPane(final int slot) {
* @return the itemstack
*/
public @NotNull final ItemStack getRandomGlassPane() {
return MiscUtils.getRandomPaneColor().setDisplayName(" ").getStack();
return MiscUtils.getRandomPaneColor().setDisplayName(" ").asItemStack();
}

private final SettingsManager config = ConfigManager.getConfig();
Expand Down Expand Up @@ -410,7 +410,7 @@ public final void populateTiers() {
if (tier != null) {
this.crateManager.addTier(this.player, slot, tier);

getInventory().setItem(getInventory().firstEmpty(), itemBuilder.getStack());
getInventory().setItem(getInventory().firstEmpty(), itemBuilder.asItemStack());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.badbones69.crazycrates.api.builders.gui;

import com.badbones69.crazycrates.api.objects.Crate;
import com.ryderbelserion.vital.paper.api.builders.gui.interfaces.Gui;
import com.ryderbelserion.vital.paper.api.builders.gui.interfaces.GuiItem;
import com.ryderbelserion.vital.paper.api.builders.gui.types.PaginatedGui;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.function.Consumer;

public abstract class DynamicInventoryBuilder extends InventoryBuilder {

private final PaginatedGui gui;
private final Crate crate;

public DynamicInventoryBuilder(final Player player, final Crate crate, final String title, final int rows) {
super(player);

this.gui = Gui.paginated().setTitle(title).setRows(rows).disableInteractions().create();

this.crate = crate;
}

public DynamicInventoryBuilder(final Player player, final String title, final int rows) {
this(player, null, title, rows);
}

/**
* Opens the {@link PaginatedGui}.
*/
public void open() {
open(null);
}

/**
* Opens the {@link PaginatedGui}.
*
* @param consumer {@link Consumer(DynamicInventoryBuilder)}
*/
public void open(@Nullable final Consumer<DynamicInventoryBuilder> consumer) {
if (consumer != null) {
consumer.accept(this);
}
}

/**
* Gets the {@link Player}.
*
* @return {@link Player}
*/
public final Player getPlayer() {
return this.player;
}

/**
* Gets the {@link Crate}.
*
* @return {@link Crate}
*/
public @Nullable Crate getCrate() {
return this.crate;
}

/**
* Gets the {@link PaginatedGui}.
*
* @return {@link PaginatedGui}
*/
public final PaginatedGui getGui() {
return this.gui;
}

// Adds the back button
public void setBackButton(final int row, final int column) {
if (this.gui.getCurrentPageNumber() <= 1) {
return;
}

this.gui.setItem(row, column, new GuiItem(this.inventoryManager.getBackButton(this.player, this.gui), event -> {
event.setCancelled(true);

this.gui.previous();

final int page = this.gui.getCurrentPageNumber();

if (page <= 1) {
if (this.crate != null && this.crate.isBorderToggle()) {
this.gui.setItem(row, column, this.crate.getBorderItem().asGuiItem());
} else {
this.gui.removeItem(row, column);

this.gui.setItem(row, column, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
}
} else {
setBackButton(row, column);
}

if (page < this.gui.getMaxPages()) {
setNextButton(6, 6);
}
}));
}

// Adds the next button
public void setNextButton(final int row, final int column) {
if (this.gui.getCurrentPageNumber() >= this.gui.getMaxPages()) {
return;
}

this.gui.setItem(row, column, new GuiItem(this.inventoryManager.getNextButton(this.player, this.gui), event -> {
event.setCancelled(true);

this.gui.next();

final int page = this.gui.getCurrentPageNumber();

if (page >= this.gui.getMaxPages()) {
if (this.crate != null && this.crate.isBorderToggle()) {
this.gui.setItem(row, column, this.crate.getBorderItem().asGuiItem());
} else {
this.gui.removeItem(row, column);

this.gui.setItem(row, column, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
}
} else {
setNextButton(row, column);
}

if (page <= 1) {
if (this.crate != null && this.crate.isBorderToggle()) {
this.gui.setItem(6, 4, this.crate.getBorderItem().asGuiItem());
} else {
this.gui.removeItem(6, 4);

this.gui.setItem(6, 4, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
}
} else {
setBackButton(6, 4);
}
}));
}
}
Loading

0 comments on commit 5c75dec

Please sign in to comment.