Skip to content

Commit bfbbaff

Browse files
Fixed issue with destroy/success dust not working
1 parent 2706589 commit bfbbaff

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

changelog.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
## Fixes
2-
- Fixed an issue on startup where config#getString("Player") was null
3-
- getStringList() returns an empty list, but getString() throws an NPE, rather than an empty String.
4-
- The solution was `config#getString("Player", "")` which is so very amusing.
2+
- Fixed an issue where Success/Destroy dust was not working.

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[versions]
2-
crazyenchantments = "2.6.1"
2+
crazyenchantments = "2.6.2"
33

44
# Minecraft
5-
minecraft = "1.21.7"
5+
minecraft = "1.21.10"
66

77
## JetBrains
88
annotations = "24.1.0" # https://github.com/JetBrains/java-annotations
@@ -23,16 +23,16 @@ kingdoms = "1.16.20.5" # https://www.spigotmc.org/resources/kingdomsx.
2323
bStats = "3.1.0" # https://github.com/Bastian/bStats
2424

2525
## Paper
26-
paperweight = "2.0.0-beta.17" # https://github.com/PaperMC/paperweight
27-
paper = "1.21.7-R0.1-SNAPSHOT" # https://github.com/PaperMC/Paper
26+
paperweight = "2.0.0-beta.19" # https://github.com/PaperMC/paperweight
27+
paper = "1.21.10-R0.1-SNAPSHOT" # https://github.com/PaperMC/Paper
2828

2929
## Gradle Plugins
3030
fix-javadoc = "1.19" # https://github.com/mfnalex/gradle-fix-javadoc-plugin
3131
run-paper = "2.3.1" # https://github.com/jpenilla/run-task
3232
minotaur = "2.8.7" # https://github.com/modrinth/minotaur
3333
feather = "0.4.0" # https://github.com/ryderbelserion/Feather
3434
hangar = "0.1.3" # https://github.com/HangarMC/hangar-publish-plugin
35-
shadow = "9.0.0-beta17" # https://github.com/GradleUp/shadow
35+
shadow = "9.2.2" # https://github.com/GradleUp/shadow
3636

3737
fusion = "2.4.3" # https://github.com/ryderbelserion/Fusion
3838

paper/src/main/java/com/badbones69/crazyenchantments/paper/listeners/DustControlListener.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
import com.badbones69.crazyenchantments.paper.api.enums.pdc.EnchantedBook;
1313
import com.badbones69.crazyenchantments.paper.api.objects.CEnchantment;
1414
import com.badbones69.crazyenchantments.paper.api.utils.ColorUtils;
15+
import com.google.gson.Gson;
1516
import io.papermc.paper.datacomponent.DataComponentTypes;
1617
import io.papermc.paper.datacomponent.item.ItemLore;
1718
import io.papermc.paper.persistence.PersistentDataContainerView;
1819
import net.kyori.adventure.text.Component;
1920
import net.kyori.adventure.text.TextComponent;
21+
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
2022
import org.bukkit.Color;
2123
import org.bukkit.GameMode;
2224
import org.bukkit.Sound;
@@ -41,6 +43,8 @@ public class DustControlListener implements Listener {
4143
@NotNull
4244
private final CrazyEnchantments plugin = JavaPlugin.getPlugin(CrazyEnchantments.class);
4345

46+
private final ComponentLogger logger = this.plugin.getComponentLogger();
47+
4448
@NotNull
4549
private final Starter starter = this.plugin.getStarter();
4650

@@ -90,9 +94,12 @@ public void onInventoryClick(InventoryClickEvent event) { // dust use
9094
if (book.getAmount() > 1) return;
9195

9296
final PersistentDataContainerView container = dust.getPersistentDataContainer();
97+
final PersistentDataContainerView bookContainer = book.getPersistentDataContainer();
98+
99+
final Gson gson = Methods.getGson();
93100

94-
final DustData dustData = Methods.getGson().fromJson(container.get(DataKeys.dust.getNamespacedKey(), PersistentDataType.STRING), DustData.class);
95-
final EnchantedBook bookData = Methods.getGson().fromJson(container.get(DataKeys.stored_enchantments.getNamespacedKey(), PersistentDataType.STRING), EnchantedBook.class); //Once Books have PDC
101+
final DustData dustData = gson.fromJson(container.get(DataKeys.dust.getNamespacedKey(), PersistentDataType.STRING), DustData.class);
102+
final EnchantedBook bookData = gson.fromJson(bookContainer.get(DataKeys.stored_enchantments.getNamespacedKey(), PersistentDataType.STRING), EnchantedBook.class); //Once Books have PDC
96103

97104
if (bookData == null || dustData == null) return;
98105

@@ -110,7 +117,9 @@ public void onInventoryClick(InventoryClickEvent event) { // dust use
110117

111118
if (!toggle) return;
112119

113-
if (dustData.getConfigName().equalsIgnoreCase(Dust.SUCCESS_DUST.getConfigName())) {
120+
final String configName = dustData.getConfigName();
121+
122+
if (configName.equalsIgnoreCase(Dust.SUCCESS_DUST.getConfigName())) {
114123
int per = dustData.getChance();
115124

116125
if (this.methods.hasArgument("%success_rate%", config.getStringList("Settings.EnchantmentBookLore"))) {
@@ -138,7 +147,7 @@ public void onInventoryClick(InventoryClickEvent event) { // dust use
138147
return;
139148
}
140149

141-
if (dustData.getConfigName().equalsIgnoreCase(Dust.DESTROY_DUST.getConfigName())) {
150+
if (configName.equalsIgnoreCase(Dust.DESTROY_DUST.getConfigName())) {
142151
int per = dustData.getChance();
143152

144153
if (this.methods.hasArgument("%destroy_rate%", config.getStringList("Settings.EnchantmentBookLore"))) {

0 commit comments

Comments
 (0)