Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 2.1.8 Release (13.05.2026)
* Fixed block replacement (on bridge) and in inventory for legacy versions
* Fixed InventoryView Error
* Added a Base Validation check on Arena Border if already present
* Updated to MinigamesBox 1.4.6

### 2.1.7 Release (17.01.2026)
* Updated to MinigamesBox 1.4.5

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>plugily.projects</groupId>
<artifactId>thebridge</artifactId>
<version>2.1.7</version>
<version>2.1.7-SNAPSHOT2</version>
<name>TheBridge</name>

<properties>
Expand Down Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>plugily.projects</groupId>
<artifactId>MiniGamesBox-Classic</artifactId>
<version>1.4.5</version>
<version>1.4.6</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/plugily/projects/thebridge/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.Nullable;
import plugily.projects.minigamesbox.api.arena.IArenaState;
import plugily.projects.minigamesbox.classic.arena.PluginArena;
Expand Down Expand Up @@ -63,7 +62,7 @@ public class Arena extends PluginArena {
private final ArrayList<Block> placedBlocks = new ArrayList<>();

private List<Cuboid> bridgeCuboid;
private final HashMap<Location, Material> brokenBlocks = new HashMap<>();
private final HashMap<Location, XMaterial> brokenBlocks = new HashMap<>();

private final HashMap<Player, Player> hits = new HashMap<>();
private int resetRound = 0;
Expand Down Expand Up @@ -350,10 +349,10 @@ public void addBridgeCuboid(Cuboid cuboid) {
this.bridgeCuboid.add(cuboid);
}

public HashMap<Location, Material> getBrokenBlocks() {
public HashMap<Location, XMaterial> getBrokenBlocks() {
return brokenBlocks;
}
public void addBrokenBlock(Location location, Material material) {
public void addBrokenBlock(Location location, XMaterial material) {
this.brokenBlocks.put(location, material);
}

Expand All @@ -365,7 +364,7 @@ public void resetPlacedBlocks() {
}

public void resetBrokenBlocks() {
brokenBlocks.forEach((location, material) -> XBlock.setType(location.getBlock(), XMaterial.matchXMaterial(material)));
brokenBlocks.forEach((location, material) -> XBlock.setType(location.getBlock(), material));
brokenBlocks.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
import plugily.projects.minigamesbox.classic.utils.version.events.api.PlugilyEntityPickupItemEvent;
import plugily.projects.minigamesbox.classic.utils.version.events.api.PlugilyPlayerPickupArrow;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XBlock;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XSound;
import plugily.projects.minigamesbox.classic.utils.version.xseries.inventory.XInventoryView;
import plugily.projects.thebridge.Main;
import plugily.projects.thebridge.arena.base.Base;
import plugily.projects.thebridge.arena.managers.ScoreboardManager;
Expand Down Expand Up @@ -114,7 +116,7 @@
// Only add blocks to the list if the block is not found to be in the broken blocks list
// Making it so that resetting placed blocks and resetting broken blocks will not tamper with each other
if(!arena.getBrokenBlocks().containsKey(event.getBlock().getLocation())) {
arena.addBrokenBlock(event.getBlock().getLocation(), event.getBlock().getType());
arena.addBrokenBlock(event.getBlock().getLocation(), XBlock.getType(event.getBlock()));
}
} else {
new MessageBuilder("IN_GAME_MESSAGES_ARENA_BUILD_BREAK")
Expand Down Expand Up @@ -613,8 +615,8 @@
if(plugin.getArenaRegistry().getArena(((Player) event.getWhoClicked())).getArenaState()
!= IArenaState.IN_GAME) {
if(event.getClickedInventory() == event.getWhoClicked().getInventory()) {
if(event.getView().getType() == InventoryType.CRAFTING
|| event.getView().getType() == InventoryType.PLAYER) {
if(XInventoryView.of(event.getView()).getType() == InventoryType.CRAFTING

Check warning on line 618 in src/main/java/plugily/projects/thebridge/arena/ArenaEvents.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this if statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=Plugily-Projects_TheBridge&issues=AZ4ltTmqWFA0G-Ytz5Vg&open=AZ4ltTmqWFA0G-Ytz5Vg&pullRequest=83
|| XInventoryView.of(event.getView()).getType() == InventoryType.PLAYER) {
event.setResult(Event.Result.DENY);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@

package plugily.projects.thebridge.handlers.setup;

import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
import plugily.projects.minigamesbox.classic.handlers.setup.categories.PluginLocationCategory;
import plugily.projects.minigamesbox.classic.handlers.setup.items.category.LocationItem;
import plugily.projects.minigamesbox.classic.handlers.setup.items.category.LocationSelectorItem;
import plugily.projects.minigamesbox.classic.utils.dimensional.Cuboid;
import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder;
import plugily.projects.minigamesbox.classic.utils.serialization.LocationSerializer;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
import plugily.projects.minigamesbox.inventory.normal.NormalFastInv;

Expand All @@ -35,14 +38,26 @@
*/
public class LocationCategory extends PluginLocationCategory {
@Override
public void addItems(NormalFastInv gui) {

Check failure on line 41 in src/main/java/plugily/projects/thebridge/handlers/setup/LocationCategory.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=Plugily-Projects_TheBridge&issues=AZ4ltTqvWFA0G-Ytz5Vi&open=AZ4ltTqvWFA0G-Ytz5Vi&pullRequest=83
super.addItems(gui);

LocationItem midLocation = new LocationItem(getSetupInventory(), new ItemBuilder(XMaterial.BEACON.parseMaterial()), "Mid", "Set the location where all \n lines will be crossed from each base", "midlocation");
gui.setItem((getInventoryLine() * 9) + 4, midLocation);
getItemList().add(midLocation);

LocationSelectorItem arenaBorder = new LocationSelectorItem(getSetupInventory(), new ItemBuilder(XMaterial.BEDROCK.parseMaterial()), "Arena", "Location where all bases and lines are in \n (players will be able to build inside) \n MAKE SURE TO SET IT OUTSIDE \n OF THE BASES WHICH YOU SET BEFORE!", "arenalocation");
LocationSelectorItem arenaBorder = new LocationSelectorItem(getSetupInventory(), new ItemBuilder(XMaterial.BEDROCK.parseMaterial()), "Arena Cuboid/Border", "Location where all bases and lines are in \n (players will be able to build inside) \n MAKE SURE TO SET IT OUTSIDE \n OF THE BASES (Baselocations) WHICH YOU SET BEFORE!", "arenalocation", inventoryClickEvent -> {
String path = "instances." + getSetupInventory().getArenaKey();
if(getSetupInventory().getConfig().getString(path + ".arenalocation.1") != null && getSetupInventory().getConfig().getString(path + ".arenalocation.2") != null) {
Cuboid arenaCuboid = new Cuboid(LocationSerializer.getLocation(getSetupInventory().getConfig().getString(path + ".arenalocation.1", "world,364.0,63.0,-72.0,0.0,0.0")), LocationSerializer.getLocation(getSetupInventory().getConfig().getString(path + ".arenalocation.2", "world,364.0,63.0,-72.0,0.0,0.0")));
for(String bases : getSetupInventory().getConfig().getConfigurationSection("instances." + getSetupInventory().getArenaKey() + ".bases").getKeys(false)) {
if(getSetupInventory().getConfig().getString(path + "." + bases + ".baselocation.1") != null && getSetupInventory().getConfig().getString(path + "." + bases + ".baselocation.2") != null) {
if(!(arenaCuboid.isIn(LocationSerializer.getLocation(getSetupInventory().getConfig().getString(path + "." + bases + ".baselocation.1"))) && arenaCuboid.isIn(LocationSerializer.getLocation(getSetupInventory().getConfig().getString(path + "." + bases + ".baselocation.2"))))) {

Check warning on line 54 in src/main/java/plugily/projects/thebridge/handlers/setup/LocationCategory.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this if statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=Plugily-Projects_TheBridge&issues=AZ4ltTqvWFA0G-Ytz5Vh&open=AZ4ltTqvWFA0G-Ytz5Vh&pullRequest=83
new MessageBuilder("&c&l✘ &cArena validation failed! Please set your arena cuboids outside your base cuboids! The arena needs to be bigger than your bases locations! The following base is not inside the arena cuboid: " + bases).prefix().player(getSetupInventory().getPlayer()).sendPlayer();
}
}
}
}
});
gui.setItem((getInventoryLine() * 9) + 5, arenaBorder);
getItemList().add(arenaBorder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
NormalFastInv pagedGui = new BasePage(9, setupInventory.getPlugin().getPluginMessagePrefix() + "Base Editor Menu", setupInventory);
pagedGui.open(setupInventory.getPlayer());
return Prompt.END_OF_CONVERSATION;
} catch (IllegalArgumentException ignored) {
} catch(IllegalArgumentException ignored) {
context.getForWhom().sendRawMessage(new MessageBuilder("&cTry again. This is not an color!").prefix().build());
return Prompt.END_OF_CONVERSATION;
}
}
}).buildFor((Player) event.getWhoClicked());
}));

LocationSelectorItem baseCorners = new LocationSelectorItem(setupInventory, new ItemBuilder(XMaterial.BEDROCK.parseMaterial()), "Base", "Set the corners of one base", "bases." + getId(setupInventory.getPlayer()) + ".baselocation");
LocationSelectorItem baseCorners = new LocationSelectorItem(setupInventory, new ItemBuilder(XMaterial.BEDROCK.parseMaterial()), "Base", "Set the corners of one base", "bases." + getId(setupInventory.getPlayer()) + ".baselocation");
setItem(1, baseCorners);

//portal in mid function? LocationSerializer.saveLoc(setupInventory.getPlugin(), setupInventory.getConfig(), "arenas", "instances." + setupInventory.getArenaKey() + ".bases." + getId(setupInventory.getPlayer()) + ".portalhologram", new Cuboid(selection.getFirstPos(), selection.getSecondPos()).getCenter().add(0, 2, 0));
Expand All @@ -103,30 +103,41 @@
.lore(ChatColor.GREEN + "Click to finish & save the setup of this base")
.build(), event -> {
String path = "instances." + setupInventory.getArenaKey() + ".bases." + getId(setupInventory.getPlayer());
if (setupInventory.getConfig().get(path + ".baselocation.1") == null) {
if(setupInventory.getConfig().get(path + ".baselocation.1") == null) {

Check failure on line 106 in src/main/java/plugily/projects/thebridge/handlers/setup/components/BasePage.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal ".baselocation.1" 3 times.

See more on https://sonarcloud.io/project/issues?id=Plugily-Projects_TheBridge&issues=AZ4ltTrJWFA0G-Ytz5Vj&open=AZ4ltTrJWFA0G-Ytz5Vj&pullRequest=83
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure base location properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if (setupInventory.getConfig().get(path + ".portallocation.1") == null) {
if(setupInventory.getConfig().get(path + ".portallocation.1") == null) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure portal location properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if (setupInventory.getConfig().get(path + ".spawnpoint") == null) {
if(setupInventory.getConfig().get(path + ".spawnpoint") == null) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure spawnpoint properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if (setupInventory.getConfig().get(path + ".respawnpoint") == null) {
if(setupInventory.getConfig().get(path + ".respawnpoint") == null) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure respawnpoint properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if (setupInventory.getConfig().get(path + ".color") == null) {
if(setupInventory.getConfig().get(path + ".color") == null) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure color properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if (setupInventory.getConfig().get(path + ".portalhologram") == null) {
if(setupInventory.getConfig().get(path + ".portalhologram") == null) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure portalhologram properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if(setupInventory.getConfig().get(path + ".portalhologram") == null) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please configure portalhologram properly!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
if(setupInventory.getConfig().getString("instances." + setupInventory.getArenaKey() + ".arenalocation.1") != null && setupInventory.getConfig().getString("instances." + setupInventory.getArenaKey() + ".arenalocation.2") != null) {
Cuboid arenaBorder = new Cuboid(LocationSerializer.getLocation(setupInventory.getConfig().getString("instances." + setupInventory.getArenaKey() + ".arenalocation.1", "world,364.0,63.0,-72.0,0.0,0.0")), LocationSerializer.getLocation(setupInventory.getConfig().getString("instances." + setupInventory.getArenaKey() + ".arenalocation.2", "world,364.0,63.0,-72.0,0.0,0.0")));
if(!(arenaBorder.isIn(LocationSerializer.getLocation(setupInventory.getConfig().getString(path + ".baselocation.1"))) && arenaBorder.isIn(LocationSerializer.getLocation(setupInventory.getConfig().getString(path + ".baselocation.2"))))) {
new MessageBuilder("&c&l✘ &cBase validation failed! Please set your base cuboids (baselocation.1 and baselocation.2) inside your arena cuboid (Main Setup Menu of Arena -> Arena)!").prefix().player(setupInventory.getPlayer()).sendPlayer();
return;
}
}
new MessageBuilder("&a&l✔ &aValidation succeeded! Registering new base: " + getId(setupInventory.getPlayer())).prefix().player(setupInventory.getPlayer()).sendPlayer();
setupInventory.setConfig("bases." + getId(setupInventory.getPlayer()) + ".isdone", true);
Base base = new Base(
Expand All @@ -139,13 +150,13 @@
LocationSerializer.getLocation(setupInventory.getConfig().getString(path + ".portallocation.2")),
setupInventory.getConfig().getInt(path + ".maximumsize")
);
if (setupInventory.getConfig().get(path + ".cagelocation.1") != null && setupInventory.getConfig().get(path + ".cagelocation.2") != null) {
if(setupInventory.getConfig().get(path + ".cagelocation.1") != null && setupInventory.getConfig().get(path + ".cagelocation.2") != null) {
base.setCageCuboid(new Cuboid(LocationSerializer.getLocation(setupInventory.getConfig().getString(path + ".cagelocation.1")), LocationSerializer.getLocation(setupInventory.getConfig().getString(path + ".cagelocation.2"))));
}
Arena arena = (Arena) setupInventory.getPlugin().getArenaRegistry().getArena(setupInventory.getArenaKey());
arena.addBase(base);
ArmorStandHologram portal = new ArmorStandHologram(setupInventory.getPlugin().getBukkitHelper().getBlockCenter(LocationSerializer.getLocation(setupInventory.getConfig().getString(path + ".portalhologram"))));
for (String str : setupInventory.getPlugin().getLanguageManager().getLanguageMessage(setupInventory.getPlugin().getMessageManager().getPath("IN_GAME_MESSAGES_ARENA_PORTAL_HOLOGRAM")).split(";")) {
for(String str : setupInventory.getPlugin().getLanguageManager().getLanguageMessage(setupInventory.getPlugin().getMessageManager().getPath("IN_GAME_MESSAGES_ARENA_PORTAL_HOLOGRAM")).split(";")) {
portal.appendLine(str.replace("%arena_base_color_formatted%", base.getFormattedColor()));
}
base.setArmorStandHologram(portal);
Expand All @@ -167,14 +178,14 @@

@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (!NumberUtils.isInteger(input)) {
if(!NumberUtils.isInteger(input)) {
context.getForWhom().sendRawMessage(new MessageBuilder("&cTry again. Its not a number!").prefix().build());
return Prompt.END_OF_CONVERSATION;
}
int number = Integer.parseInt(input);

if (setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases") != null) {
if (number >= setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases").getKeys(false).size()) {
if(setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases") != null) {
if(number >= setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases").getKeys(false).size()) {
context.getForWhom().sendRawMessage(new MessageBuilder("&cTry again. The number is higher than bases that you have!").prefix().build());
return Prompt.END_OF_CONVERSATION;
}
Expand All @@ -195,9 +206,9 @@


public int getId(Player player) {
if (!BaseUtilities.check(player)) {
if(!BaseUtilities.check(player)) {
int id = 0;
if (setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases") != null) {
if(setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases") != null) {
id = setupInventory.getConfig().getConfigurationSection("instances." + setupInventory.getArenaKey() + ".bases").getKeys(false).size();
}
BaseUtilities.getBaseId().put(player, id);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/plugily/projects/thebridge/kits/KitUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ public static ItemStack handleItem(PluginMain plugin, Player player, ItemStack i
plugin.getDebugger().performance("Kit", "Arena {0} Handle item method called for player {1} item stack {2}.", arena.getId(), player, itemStack);

// Replaces white terracotta with coloured terracotta if the player is in a team
if(itemStack.getType().equals(XMaterial.matchXMaterial(plugin.getConfig().getString("Kit.Colored-Block-Replace-Material", "WHITE_WOOL")).orElse(XMaterial.WHITE_WOOL).parseMaterial())) {
if(XMaterial.matchXMaterial(plugin.getConfig().getString("Kit.Colored-Block-Replace-Material", "WHITE_WOOL")).orElse(XMaterial.WHITE_WOOL).isSimilar(itemStack)) {
Optional<XMaterial> material = XMaterial.matchXMaterial(arena.getBase(player).getMaterialColor().toUpperCase() + "_" + plugin.getConfig().getString("Kit.Colored-Block-Material", "WOOL"));
material.ifPresent(xMaterial -> itemStack.setType(Objects.requireNonNull(xMaterial.parseMaterial())));
material.ifPresent(xMaterial -> {
xMaterial.setType(itemStack);
});
plugin.getDebugger().performance("Kit", "Arena {0} Changing coloured block to {1}.", arena.getId(), arena.getBase(player).getMaterialColor().toUpperCase() + "_" + plugin.getConfig().getString("Kit.Colored-Block-Material", "WOOL"));
return itemStack;
}

// Replaces leather armour with the coloured leather armour if the player is in a team
if(itemStack.getType().equals(XMaterial.LEATHER_HELMET.parseMaterial()) || itemStack.getType().equals(XMaterial.LEATHER_CHESTPLATE.parseMaterial()) || itemStack.getType().equals(XMaterial.LEATHER_LEGGINGS.parseMaterial()) || itemStack.getType().equals(XMaterial.LEATHER_BOOTS.parseMaterial())) {
if(XMaterial.LEATHER_HELMET.isSimilar(itemStack) || XMaterial.LEATHER_CHESTPLATE.isSimilar(itemStack) || XMaterial.LEATHER_LEGGINGS.isSimilar(itemStack) || XMaterial.LEATHER_BOOTS.isSimilar(itemStack)) {
LeatherArmorMeta itemMeta = (LeatherArmorMeta) itemStack.getItemMeta();
assert itemMeta != null;
itemMeta.setColor(ColorUtil.fromChatColor(ChatColor.valueOf(arena.getBase(player).getColor().toUpperCase())));
Expand Down
Loading