Advertisement
GamesofFreak

Second Java Code

Jul 15th, 2024
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | Gaming | 0 0
  1. package me.sparklearts.astralinfusion.procedures;
  2.  
  3. import net.minecraft.world.entity.player.Player;
  4. import net.minecraft.world.entity.Entity;
  5. import net.minecraft.network.chat.Component;
  6. import net.minecraft.ChatFormatting;
  7.  
  8. import api.sparklearts.astralinfusion.soul.SoulType;
  9.  
  10. public class SoulCMDProcedure {
  11.     public static void execute(Entity entity) {
  12.         if (entity == null)
  13.             return;
  14.         if (entity instanceof Player player && !player.level().isClientSide()) {
  15.             player.displayClientMessage(Component.literal("Registered Soul Types:"), false);
  16.             for (SoulType soulType : SoulType.getSoulTypes()) {
  17.                 ChatFormatting rarityColor = switch (soulType.getRarity()) {
  18.                     case COMMON -> ChatFormatting.WHITE;
  19.                     case UNCOMMON -> ChatFormatting.GREEN;
  20.                     case RARE -> ChatFormatting.BLUE;
  21.                     case EPIC -> ChatFormatting.DARK_PURPLE;
  22.                     case LEGENDARY -> ChatFormatting.GOLD;
  23.                 };
  24.                 ChatFormatting resetColor = ChatFormatting.RESET;
  25.                 String message = String.format("- %s (ID: %s, Rarity: %s, Corruption: %.2f, Strength: %.2f)", soulType.getDisplayName(), soulType.getId(), rarityColor + soulType.getRarity().toString() + resetColor, soulType.getCorruption(),
  26.                         soulType.getStrength());
  27.                 player.displayClientMessage(Component.literal(message), false);
  28.             }
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement