Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added delete all and fixed rounding #50

Merged
merged 3 commits into from
Feb 9, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ public BestiaryAreaInventory(Player player, BestiaryArea area, int offset) {
String secondBars = "|".repeat(20 - bars);
progressBar = progressBar.append(Component.text(secondBars, NamedTextColor.RED).decoration(TextDecoration.ITALIC, false));

//No way for discovered mobs to possibly be a non-integer, but safety first
int discInt = (int)Math.floor(discovered);
int totalInt = (int)Math.floor(total);
progressBar = progressBar.append(Component.text("]", NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, false));
progressBar = progressBar.append(Component.text(" " + discovered + "/" + total, NamedTextColor.BLUE).decoration(TextDecoration.ITALIC, false));
progressBar = progressBar.append(Component.text(" " + discInt + "/" + totalInt, NamedTextColor.BLUE).decoration(TextDecoration.ITALIC, false));
ItemMeta meta = item.getItemMeta();
List<Component> lore = meta.hasLore() ? meta.lore() : new ArrayList<>();
if (!lore.contains(progressBar)) {
Expand Down
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 @@ -9,6 +9,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
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
Loading