Skip to content

Commit

Permalink
Added delete all and fixed rounding
Browse files Browse the repository at this point in the history
Added a delete all command to allow for the bestiary data of a player to be reset; and fixed rounding errors in the bestiary entries.
  • Loading branch information
Wembler23 committed Feb 7, 2024
1 parent 45ab26a commit 6d0baaa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ public static void register() {
}
soul.setLore("", sender);
})))
.withSubcommand(new CommandAPICommand("deleteall")
.withPermission(CommandPermission.fromString("los.bestiary.deleteall"))
.withArguments(new EntitySelectorArgument.OnePlayer("player"))
.executes((sender, args) -> {
Player player = (Player)args[0];
BestiaryManager.deleteAll(player);
}))
.register();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.logging.Logger;
import java.util.List;

Check warning on line 17 in src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java#L17 <com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck>

Wrong lexicographical order for 'java.util.List' import. Should be before 'java.util.logging.Logger'.
Raw output
/home/runner/work/library-of-souls/library-of-souls/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java:17:1: warning: Wrong lexicographical order for 'java.util.List' import. Should be before 'java.util.logging.Logger'. (com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck)
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -104,6 +105,13 @@ public static int addKillsToMob(Player player, SoulEntry soul, int amount) {
return INSTANCE.mStorage.addKillsForMob(player, soul, amount);
}

public static void deleteAll(Player player) {
List<SoulEntry> souls = SoulsDatabase.getInstance().getSouls();
for (SoulEntry soul : souls) {
BestiaryManager.setKillsForMob(player, soul, 0);
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void entityDamageByEntityEvent(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public static double getAttributeNumber(ItemStack item, Attribute attribute, Att
}
}
}
return attributeNum;
return Math.round(attributeNum * 1000) / 1000.0;
}

private static ItemStack getHealthItem(double health) {
Expand Down Expand Up @@ -710,6 +710,7 @@ private static ItemStack getSpeedItem(EntityNBT entityNBT, double speed, double
speed *= speedPercent;
}

speed = Math.round(speed * 1000) / 1000.0;
lore.add(Component.text(speed + " Speed", NamedTextColor.GREEN).decoration(TextDecoration.ITALIC, false));
speedMeta.lore(lore);
speedMeta.displayName(Component.text("Speed", NamedTextColor.WHITE).decoration(TextDecoration.ITALIC, false));
Expand Down

0 comments on commit 6d0baaa

Please sign in to comment.