Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
Jonathan Boisclair committed Jul 17, 2024
2 parents 224b79e + 1adcb46 commit d08c2ed
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
4 changes: 2 additions & 2 deletions plugin/src/main/java/io/github/pronze/sba/SBA.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ public void postEnable() {
Bukkit.getServer().getPluginManager().disablePlugin(getPluginInstance());
return;
}
if (!List.of("0.2.20", "0.2.21", "0.2.22", "0.2.23", "0.2.24", "0.2.25", "0.2.26", "0.2.27", "0.2.27.1", "0.2.28", "0.2.29", "0.2.30",
if (!List.of("0.2.29", "0.2.30", "0.2.31",
"0.2.31", "0.2.32", "0.2.32.1").stream()
.anyMatch(BedwarsAPI.getInstance().getPluginVersion()::equals)) {
Logger.warn(
"SBA hasn't been tested on this version of Bedwars. If you encounter bugs, use version 0.2.20 to 0.2.32.1. ");
"SBA hasn't been tested on this version of Bedwars. If you encounter bugs, use version 0.2.29 to 0.2.32.1. ");
}
sbw_0_2_30 = Integer.parseInt(BedwarsAPI.getInstance().getPluginVersion().split("[.-]")[2]) >= 30;
}
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/main/java/io/github/pronze/sba/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public void run() {
} catch (Exception ex) {

}
Bukkit.getServer().shutdown();

} catch (Exception ex) {
Logger.error("Error occurred while updating . {}", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public void onPreGenerateItem(ItemRenderEvent event) {
}

public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference<ItemStack> newItem,
AtomicReference<org.screamingsandals.lib.item.ItemStack> materialItem, PlayerItemInfo itemInfo, ItemSpawnerType type, AtomicReference<String[]> messageOnFail) {
AtomicReference<org.screamingsandals.lib.item.ItemStack> materialItem, PlayerItemInfo itemInfo,
ItemSpawnerType type, AtomicReference<String[]> messageOnFail) {
boolean shouldSellStack = true;
final var game = Main.getInstance().getGameOfPlayer(player);
final var gameStorage = ArenaManager
Expand Down Expand Up @@ -196,7 +197,9 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
// if (upgradeProperties.contains(propertyName)) {
switch (propertyName) {
case "trap":
if (!property.getPropertyData().hasChild("identifier") && property.getPropertyData().hasChild("data")) { // Fix support for SBW Trap special item
if (!property.getPropertyData().hasChild("identifier")
&& property.getPropertyData().hasChild("data")) { // Fix support for SBW Trap special
// item
return Map.entry(true, true);
}

Expand All @@ -219,7 +222,8 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
.forEach(effectItem -> {
try {
String effectType = effectItem.childrenMap().get("type").getString();
var slibEffect = org.screamingsandals.lib.item.meta.PotionEffectType.ofNullable(effectType);
var slibEffect = org.screamingsandals.lib.item.meta.PotionEffectType
.ofNullable(effectType);

PotionEffectType type_;
if (slibEffect != null) {
Expand Down Expand Up @@ -285,7 +289,7 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
teamSharpnessLevel = teamSharpnessLevel + 1;

materialItem.set(ItemStackFactory.build(type.getStack(ePrice)));// . (ItemFactory. (
// type.getStack(ePrice)));
// type.getStack(ePrice)));

if (player.getInventory().containsAtLeast(materialItem.get().as(ItemStack.class),
ePrice)) {
Expand Down Expand Up @@ -338,7 +342,7 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
teamKnockbackLevel = teamKnockbackLevel + 1;

materialItem.set(ItemStackFactory.build(type.getStack(ePrice)));// . (ItemFactory. (
// type.getStack(ePrice)));
// type.getStack(ePrice)));

if (player.getInventory().containsAtLeast(materialItem.get().as(ItemStack.class),
ePrice)) {
Expand Down Expand Up @@ -392,7 +396,7 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
var ePrice = efficiencyPrices.get(efficiencyLevel);
efficiencyLevel = efficiencyLevel + 1;
materialItem.set(ItemStackFactory.build(type.getStack(ePrice)));// . (ItemFactory. (
// type.getStack(ePrice)));
// type.getStack(ePrice)));

if (player.getInventory().containsAtLeast(materialItem.get().as(ItemStack.class),
ePrice)) {
Expand Down Expand Up @@ -515,7 +519,8 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
if (types.contains(material)) {
if (spawner.getTeam() != null
&& spawner.getTeam().getName().equals(team.getName())) {
spawnersToUpgrade.add(spawner);
if (spawner.getCurrentLevel() < maxLevel)
spawnersToUpgrade.add(spawner);
}
}
}
Expand All @@ -533,7 +538,6 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
closestSpawner = spawner;
}


}
}
if (closestSpawner != null) {
Expand All @@ -543,16 +547,15 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
}
});
}

for (var spawner : spawnersToUpgrade) {
double newLevel = spawner.getCurrentLevel() + addLevels;
if (newLevel > maxLevel && maxLevel > 0)
newLevel = maxLevel;
spawner.setCurrentLevel(newLevel);
}

if (spawnersToUpgrade.isEmpty())
{
if (spawnersToUpgrade.isEmpty()) {
messageOnFail.set(MessageKeys.GREATEST_SPAWNER);
shouldSellStack = false;
}
Expand Down Expand Up @@ -592,7 +595,7 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
teamProtectionLevel = teamProtectionLevel + 1;
Logger.trace("teamProtectionLevel:{}", teamProtectionLevel);
materialItem.set(ItemStackFactory.build(type.getStack(ePrice)));// . (ItemFactory. (
// type.getStack(ePrice)));
// type.getStack(ePrice)));

if (player.getInventory().containsAtLeast(materialItem.get().as(ItemStack.class),
ePrice)) {
Expand Down Expand Up @@ -622,8 +625,7 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
default:
if (Arrays.stream(Enchantment.values())
.anyMatch(x -> x.getName().equalsIgnoreCase(propertyName)
||EnchantmentType.of(x).location().path().equalsIgnoreCase(propertyName)
)) {
|| EnchantmentType.of(x).location().path().equalsIgnoreCase(propertyName))) {

if (isAdd) {
team.getConnectedPlayers().forEach(teamPlayer -> {
Expand All @@ -633,7 +635,8 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
.replace("%player%", player.getDisplayName() + ChatColor.RESET)
.send(Players.wrapPlayer(teamPlayer));
Optional<Enchantment> ech = Arrays.stream(Enchantment.values())
.filter(x -> x.getName().equalsIgnoreCase(propertyName)||EnchantmentType.of(x).location().path().equalsIgnoreCase(propertyName))
.filter(x -> x.getName().equalsIgnoreCase(propertyName) || EnchantmentType
.of(x).location().path().equalsIgnoreCase(propertyName))
.findAny();

Arrays.stream(teamPlayer.getInventory().getContents())
Expand All @@ -659,7 +662,7 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
teamOtherLevel = teamOtherLevel + 1;

materialItem.set(ItemStackFactory.build(type.getStack(ePrice)));// . (ItemFactory. (
// type.getStack(ePrice)));
// type.getStack(ePrice)));
if (player.getInventory().containsAtLeast(materialItem.get().as(ItemStack.class),
ePrice)) {
gameStorage.setEnchantLevel(team, propertyName, teamOtherLevel);
Expand Down Expand Up @@ -731,13 +734,14 @@ public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference
.inventoryType(SBAConfig.getInstance().node("shop", "inventory-type")
.getString("CHEST"))
.prefix(LanguageService.getInstance().get(MessageKeys.SHOP_NAME).toComponent()))
.allowAccessToConsole(Main.getConfigurator().config.getBoolean("shop.allow-execution-of-console-commands", true))

// old shop format compatibility (SIv1, SBW 0.2.x)
.variableToProperty("upgrade", "upgrade")
.variableToProperty("generate-lore", "generateLore")
.variableToProperty("generated-lore-text", "generatedLoreText")
.variableToProperty("currency-changer", "currencyChanger");
.allowAccessToConsole(
Main.getConfigurator().config.getBoolean("shop.allow-execution-of-console-commands", true))

// old shop format compatibility (SIv1, SBW 0.2.x)
.variableToProperty("upgrade", "upgrade")
.variableToProperty("generate-lore", "generateLore")
.variableToProperty("generated-lore-text", "generatedLoreText")
.variableToProperty("currency-changer", "currencyChanger");
}

@EventHandler
Expand All @@ -750,7 +754,7 @@ public void onBedWarsOpenShop(BedwarsOpenShopEvent event) {
.send(Players.wrapPlayer(event.getPlayer()));
return;
}
if (Main.getInstance().getGameOfPlayer(event.getPlayer()).getTeamOfPlayer(event.getPlayer())==null) {
if (Main.getInstance().getGameOfPlayer(event.getPlayer()).getTeamOfPlayer(event.getPlayer()) == null) {
LanguageService
.getInstance()
.get(MessageKeys.MESSAGE_NOT_IN_GAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,16 @@ public void onBedwarsPlayerSpectate(PlayerGameModeChangeEvent e) {
.collect(Collectors.toList()).toArray(new ItemStack[0]).clone());
}
if(!collidableValue.containsKey(player.getUniqueId()))
{
try{
collidableValue.put(player.getUniqueId(), player.isCollidable());
}
catch(Throwable t)
{
collidableValue.put(player.getUniqueId(), false);

}
}
Tasker.runDelayed(DefaultThreads.GLOBAL_THREAD, () -> {

player.getInventory().clear();
Expand Down

0 comments on commit d08c2ed

Please sign in to comment.