Skip to content
Open
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
26 changes: 26 additions & 0 deletions src/main/java/me/unariginal/novaraids/config/BossesConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ public void loadSettings(String categoryId, File file) throws IOException, NullP
if (root.has("item_settings"))
itemSettings = root.getAsJsonObject("item_settings");

Boolean raidBallsEnabledOverride = null;
if (itemSettings.has("raid_balls_enabled")) {
JsonElement categoryRaidBallsOverrideElement = itemSettings.get("raid_balls_enabled");
if (!categoryRaidBallsOverrideElement.isJsonNull()) {
raidBallsEnabledOverride = categoryRaidBallsOverrideElement.getAsBoolean();
}
}
itemSettings.remove("raid_balls_enabled");
if (raidBallsEnabledOverride != null) {
itemSettings.addProperty("raid_balls_enabled", raidBallsEnabledOverride);
}

JsonObject categoryChoiceVoucherObject = new JsonObject();
if (itemSettings.has("category_choice_voucher"))
categoryChoiceVoucherObject = itemSettings.getAsJsonObject("category_choice_voucher");
Expand Down Expand Up @@ -268,6 +280,7 @@ public void loadSettings(String categoryId, File file) throws IOException, NullP
fightBossbar,
preCatchBossbar,
catchBossbar,
raidBallsEnabledOverride,
categoryChoiceVoucher,
categoryRandomVoucher,
categoryPass,
Expand Down Expand Up @@ -775,6 +788,7 @@ else if (pokemonDetails.has("gender"))
// Item Settings
boolean allowGlobalPokeballs = true;
boolean allowCategoryPokeballs = true;
Boolean raidBallsEnabledOverride = null;

JsonObject itemSettingsObject = new JsonObject();
if (root.has("item_settings"))
Expand All @@ -790,6 +804,17 @@ else if (pokemonDetails.has("gender"))
itemSettingsObject.remove("allow_category_pokeballs");
itemSettingsObject.addProperty("allow_category_pokeballs", allowCategoryPokeballs);

if (itemSettingsObject.has("raid_balls_enabled")) {
JsonElement bossRaidBallsOverrideElement = itemSettingsObject.get("raid_balls_enabled");
if (!bossRaidBallsOverrideElement.isJsonNull()) {
raidBallsEnabledOverride = bossRaidBallsOverrideElement.getAsBoolean();
}
}
itemSettingsObject.remove("raid_balls_enabled");
if (raidBallsEnabledOverride != null) {
itemSettingsObject.addProperty("raid_balls_enabled", raidBallsEnabledOverride);
}

JsonObject bossVoucherObject = new JsonObject();
if (itemSettingsObject.has("boss_voucher"))
bossVoucherObject = itemSettingsObject.get("boss_voucher").getAsJsonObject();
Expand Down Expand Up @@ -828,6 +853,7 @@ else if (pokemonDetails.has("gender"))
ItemSettings itemSettings = new ItemSettings(
allowGlobalPokeballs,
allowCategoryPokeballs,
raidBallsEnabledOverride,
bossVoucher,
bossPass,
bossBalls
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/unariginal/novaraids/data/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public record Category(String id,
String fightBossbar,
String preCatchBossbar,
String catchBossbar,
Boolean raidBallsEnabledOverride,
Voucher categoryChoiceVoucher,
Voucher categoryRandomVoucher,
Pass categoryPass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public record ItemSettings(boolean allowGlobalPokeballs,
boolean allowCategoryPokeballs,
Boolean raidBallsEnabledOverride,
Voucher voucher,
Pass pass,
List<RaidBall> raidBalls) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/me/unariginal/novaraids/managers/EventManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public static void rightClickEvents() {
player.sendMessage(TextUtils.deserialize(TextUtils.parse(messages.getMessage("used_voucher"), boss)));
}
}
} else if (customData.copyNbt().getString("raid_item").equals("raid_ball") && nr.config().raidBallsEnabled) {
} else if (customData.copyNbt().getString("raid_item").equals("raid_ball")) {
boolean canThrow = false;

if (nr.config().playerLinkedRaidBalls && customData.contains("owner_uuid")) {
Expand All @@ -627,10 +627,12 @@ public static void rightClickEvents() {
canThrow = PlayerRaidCache.isInRaid(player.getUuid());

if (canThrow) {
canThrow = false;

Raid raid = PlayerRaidCache.currentRaid(player);
if (raid != null && raid.stage() == 4) {
if (!raid.isRaidBallsEnabled()) {
player.sendMessage(TextUtils.deserialize(TextUtils.parse(messages.getMessage("warning_not_catch_phase"))));
return TypedActionResult.fail(itemStack);
}

if (customData.contains("raid_categories") || customData.contains("raid_bosses")) {
// do nothing - same as previous logic
Expand Down Expand Up @@ -676,7 +678,7 @@ public static void rightClickEvents() {
Raid raid = PlayerRaidCache.currentRaid(player);
if (raid == null) return TypedActionResult.pass(itemStack);

if (isPokeball(itemStack) && nr.config().raidBallsEnabled) {
if (isPokeball(itemStack) && raid.isRaidBallsEnabled()) {
player.sendMessage(TextUtils.deserialize(TextUtils.parse(messages.getMessage("warning_deny_normal_pokeball"))));
return TypedActionResult.fail(itemStack);
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/me/unariginal/novaraids/managers/Raid.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,20 @@ public Location raidBossLocation() {
return raidBossLocation;
}

public boolean isRaidBallsEnabled() {
Boolean bossOverride = bossInfo.itemSettings().raidBallsEnabledOverride();
if (bossOverride != null) {
return bossOverride;
}

Boolean categoryOverride = raidBossCategory.raidBallsEnabledOverride();
if (categoryOverride != null) {
return categoryOverride;
}

return nr.config().raidBallsEnabled;
}

public int currentHealth() {
return currentHealth;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"item_settings": {
"allow_global_pokeballs": true,
"allow_category_pokeballs": true,
"raid_balls_enabled": true,
"boss_voucher": {
"voucher_item": "minecraft:feather",
"voucher_name": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}
},
"item_settings": {
"raid_balls_enabled": true,
"category_choice_voucher": {
"voucher_item": "minecraft:feather",
"voucher_name": "",
Expand Down