Skip to content

Commit

Permalink
Fix support for versions <1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
dlsf committed Sep 4, 2024
1 parent d1e5f76 commit bc324a2
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
implementation("org.jetbrains:annotations:24.1.0")
implementation("com.j256.ormlite:ormlite-core:6.1")
implementation("com.j256.ormlite:ormlite-jdbc:6.1")
implementation("com.iridium:IridiumTeams:2.5.7")
implementation("com.iridium:IridiumTeams:2.5.8")

// Other dependencies that are not required or already available at runtime
compileOnly("org.projectlombok:lombok:1.18.34")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public BiomeCommand() {
public boolean execute(User user, Island island, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if (args.length == 0) {
player.openInventory(new BiomeOverviewGUI(player.getOpenInventory().getTopInventory()).getInventory());
player.openInventory(new BiomeOverviewGUI(player).getInventory());
return false;
} else {
Optional<String> categoryName = getCategoryName(String.join(" ", args));
Expand All @@ -38,7 +38,7 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams<Isl
return false;
}

player.openInventory(new BiomeCategoryGUI(categoryName.get(), player.getOpenInventory().getTopInventory()).getInventory());
player.openInventory(new BiomeCategoryGUI(categoryName.get(), player).getInventory());
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams<Isl
}

if (args.length == 0) {
player.openInventory(new BorderGUI(player.getOpenInventory().getTopInventory()).getInventory());
player.openInventory(new BorderGUI(player).getInventory());
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.iridium.iridiumteams.database.TeamBank;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;

import java.math.BigDecimal;
Expand All @@ -38,7 +37,7 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams<Isl
return false;
}

player.openInventory(new RegenGUI(player.getOpenInventory().getTopInventory(), player).getInventory());
player.openInventory(new RegenGUI(player).getInventory());
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public VisitCommand() {
public boolean execute(User user, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if (args.length == 0) {
player.openInventory(new VisitGUI(player.getOpenInventory().getTopInventory(), iridiumTeams).getInventory());
player.openInventory(new VisitGUI(player, iridiumTeams).getInventory());
return false;
}
Optional<Island> island = IridiumSkyblock.getInstance().getTeamManager().getTeamViaNameOrPlayer(args[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.iridium.iridiumcore.utils.StringUtils;
import com.iridium.iridiumskyblock.IridiumSkyblock;
import com.iridium.iridiumskyblock.configs.Biomes;
import com.iridium.iridiumskyblock.configs.Schematics;
import com.iridium.iridiumteams.configs.inventories.NoItemGUI;
import lombok.Getter;
import org.bukkit.Bukkit;
Expand All @@ -24,8 +23,8 @@ public class BiomeCategoryGUI extends BackGUI {
private final String categoryName;
private final Biomes.BiomeCategory biomeCategory;

public BiomeCategoryGUI(String categoryName, Inventory previousInventory) {
super(IridiumSkyblock.getInstance().getInventories().biomeCategoryGUI.background, previousInventory, IridiumSkyblock.getInstance().getInventories().backButton);
public BiomeCategoryGUI(String categoryName, Player player) {
super(IridiumSkyblock.getInstance().getInventories().biomeCategoryGUI.background, player, IridiumSkyblock.getInstance().getInventories().backButton);
this.categoryName = categoryName;
this.biomeCategory = IridiumSkyblock.getInstance().getBiomes().categories.get(categoryName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.iridium.iridiumskyblock.configs.Biomes;
import com.iridium.iridiumteams.configs.inventories.NoItemGUI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
Expand All @@ -15,8 +16,8 @@

public class BiomeOverviewGUI extends BackGUI {

public BiomeOverviewGUI(Inventory previousInventory) {
super(IridiumSkyblock.getInstance().getInventories().biomeOverviewGUI.background, previousInventory, IridiumSkyblock.getInstance().getInventories().backButton);
public BiomeOverviewGUI(Player player) {
super(IridiumSkyblock.getInstance().getInventories().biomeOverviewGUI.background, player, IridiumSkyblock.getInstance().getInventories().backButton);
}

@NotNull
Expand All @@ -41,7 +42,7 @@ public void addContent(Inventory inventory) {
public void onInventoryClick(InventoryClickEvent event) {
for (Map.Entry<String, Biomes.BiomeCategory> category : IridiumSkyblock.getInstance().getBiomes().categories.entrySet()) {
if (event.getSlot() != category.getValue().item.slot) continue;
event.getWhoClicked().openInventory(new BiomeCategoryGUI(category.getKey(), event.getWhoClicked().getOpenInventory().getTopInventory()).getInventory());
event.getWhoClicked().openInventory(new BiomeCategoryGUI(category.getKey(), (Player) event.getWhoClicked()).getInventory());
return;
}
super.onInventoryClick(event);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/iridium/iridiumskyblock/gui/BorderGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import com.iridium.iridiumskyblock.IridiumSkyblock;
import com.iridium.iridiumteams.configs.inventories.NoItemGUI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull;

public class BorderGUI extends BackGUI {

public BorderGUI(Inventory previousInventory) {
public BorderGUI(Player player) {
super(
IridiumSkyblock.getInstance().getInventories().islandBorderGUI.background,
previousInventory,
player,
IridiumSkyblock.getInstance().getInventories().backButton
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/iridium/iridiumskyblock/gui/CreateGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import com.iridium.iridiumcore.gui.ClosableGUI;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;

import java.util.concurrent.CompletableFuture;

@Getter
public class CreateGUI extends SchematicGUI implements ClosableGUI {
private final CompletableFuture<String> completableFuture;

public CreateGUI(Inventory previousInventory, CompletableFuture<String> completableFuture) {
super(previousInventory);
public CreateGUI(Player player, CompletableFuture<String> completableFuture) {
super(player);
this.completableFuture = completableFuture;
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/iridium/iridiumskyblock/gui/RegenGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
import com.iridium.iridiumskyblock.IridiumSkyblock;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;

@Getter
public class RegenGUI extends SchematicGUI {
private final Player player;

public RegenGUI(Inventory previousInventory, Player player) {
super(previousInventory);
public RegenGUI(Player player) {
super(player);
this.player = player;
}

@Override
public void selectSchematic(String schematic) {
IridiumSkyblock.getInstance().getCommandManager().executeCommand(player, IridiumSkyblock.getInstance().getCommands().regenCommand, new String[]{schematic});
}

}
12 changes: 2 additions & 10 deletions src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package com.iridium.iridiumskyblock.gui;

import com.iridium.iridiumcore.gui.BackGUI;
import com.iridium.iridiumcore.utils.InventoryUtils;
import com.iridium.iridiumcore.utils.ItemStackUtils;
import com.iridium.iridiumcore.utils.Placeholder;
import com.iridium.iridiumcore.utils.StringUtils;
import com.iridium.iridiumskyblock.IridiumSkyblock;
import com.iridium.iridiumskyblock.configs.Schematics;
import com.iridium.iridiumskyblock.database.User;
import com.iridium.iridiumteams.bank.BankItem;
import com.iridium.iridiumteams.configs.Shop;
import com.iridium.iridiumteams.configs.inventories.NoItemGUI;
import com.iridium.iridiumteams.database.TeamBank;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
Expand All @@ -21,16 +16,13 @@
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.stream.Collectors;

import static java.util.Collections.addAll;

public abstract class SchematicGUI extends BackGUI {

public SchematicGUI(Inventory previousInventory) {
public SchematicGUI(Player player) {
super(
IridiumSkyblock.getInstance().getInventories().islandSchematicGUI.background,
previousInventory,
player,
IridiumSkyblock.getInstance().getInventories().backButton
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/iridium/iridiumskyblock/gui/VisitGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.iridium.iridiumteams.IridiumTeams;
import com.iridium.iridiumteams.configs.inventories.NoItemGUI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
Expand All @@ -19,14 +20,14 @@
public class VisitGUI extends PagedGUI<Island> {
private final IridiumTeams<Island, User> iridiumTeams;

public VisitGUI(Inventory previousInventory, IridiumTeams<Island, User> iridiumTeams) {
public VisitGUI(Player player, IridiumTeams<Island, User> iridiumTeams) {
super(
1,
IridiumSkyblock.getInstance().getInventories().visitGUI.size,
IridiumSkyblock.getInstance().getInventories().visitGUI.background,
iridiumTeams.getInventories().previousPage,
iridiumTeams.getInventories().nextPage,
previousInventory,
player,
iridiumTeams.getInventories().backButton
);
this.iridiumTeams = iridiumTeams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private CompletableFuture<String> getSchematic(Player player) {
}
}

Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> player.openInventory(new CreateGUI(player.getOpenInventory().getTopInventory(), schematicNameCompletableFuture).getInventory()));
Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> player.openInventory(new CreateGUI(player, schematicNameCompletableFuture).getInventory()));
return schematicNameCompletableFuture;
}

Expand Down

0 comments on commit bc324a2

Please sign in to comment.