Skip to content

Commit

Permalink
Adjust to use "new" potion API and improve custom effects
Browse files Browse the repository at this point in the history
This makes it compile with 1.20.5
  • Loading branch information
Phoenix616 committed Apr 29, 2024
1 parent b548240 commit 60b10a8
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/main/java/com/Acrobot/ChestShop/Listeners/ItemInfoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,22 @@ public static void addPotionInfo(ItemInfoEvent event) {

PotionMeta potionMeta = (PotionMeta) meta;

StringBuilder message = new StringBuilder(50);
CommandSender sender = event.getSender();

message.append(ChatColor.GRAY);
if (potionMeta.getBasePotionType() != null) {
StringBuilder message = new StringBuilder(50);

message.append(capitalizeFirstLetter(item.getType().name(), '_')).append(" of ");
message.append(capitalizeFirstLetter(potionMeta.getBasePotionData().getType().name(), '_')).append(' ');
if (potionMeta.getBasePotionData().isUpgraded()) {
message.append("II");
} else if (potionMeta.getBasePotionData().isExtended()) {
message.append("+");
}
message.append(ChatColor.GRAY);

CommandSender sender = event.getSender();
message.append(capitalizeFirstLetter(item.getType().name(), '_')).append(" of ");
message.append(capitalizeFirstLetter(potionMeta.getBasePotionType().getKey().getKey(), '_')).append(' ');

sender.sendMessage(message.toString());
sender.sendMessage(message.toString());
}

for (PotionEffect effect : potionMeta.getCustomEffects()) {
sender.sendMessage(ChatColor.DARK_GRAY + capitalizeFirstLetter(effect.getType().getName(), '_') + ' ' + toTime(effect.getDuration() / 20));
sender.sendMessage(ChatColor.DARK_GRAY + capitalizeFirstLetter(effect.getType().getKey().getKey(), '_')
+ ' ' + (effect.getAmplifier() + 1) + ' ' + toTime(effect.getDuration() / 20));
}
}

Expand Down

0 comments on commit 60b10a8

Please sign in to comment.