Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bearofbusiness committed Oct 9, 2024
2 parents 2e2d34e + 3ee5fa7 commit fc58ac2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.vindicterra.vindicterralib.StringUtil;
import org.vindicterra.vindicterralib.utils.StringUtils;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Generic implementation of Java object serialization.
* Objects to be serialized must implement the "java.io.Serializable" interface.
* For a higher-level PDC serializer, check vindicterraLib.serialization.SerializeToPDC
* For a higher-level PDC serializer, check {@link SerializeToPDC}
*/
public class SerializeToBytes {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.vindicterra.vindicterralib;
package org.vindicterra.vindicterralib.utils;


import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.md_5.bungee.api.ChatColor;

import java.math.BigDecimal;
Expand All @@ -12,7 +14,7 @@
* a utility class for string checking and manipulation
*/
@SuppressWarnings("ALL")
public class StringUtil {
public class StringUtils {


public static final Pattern PATTERN = Pattern.compile("\\p{Alnum}+");
Expand Down Expand Up @@ -75,4 +77,31 @@ public static double round(double value) {
decimal = decimal.setScale(1, RoundingMode.HALF_UP);
return decimal.doubleValue();
}

public static double round(double value, int places) {
BigDecimal decimal = BigDecimal.valueOf(value);
decimal = decimal.setScale(places, RoundingMode.HALF_UP);
return decimal.doubleValue();
}

/**
*
* @param name Item name to format
* @return Formatted item name in the style of "Grass Block"
*/
public static String format(final String name) {
StringBuilder output = new StringBuilder();
for (String character : name.split("_")) {
output.append(character.substring(0, 1).toUpperCase()).append(character.substring(1).toLowerCase()).append(" ");
}
return output.substring(0, output.length() - 1);
}

/**
* @param name Name to remove formatting from
* @return Unformatted name in the style of "GRASS_BLOCK"
*/
public static String deformat(final String name) {
return ((TextComponent) Component.text(name.toUpperCase().replace(" ", "_")).compact()).content();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: VindicterraLib
version: '0.0.0-testing'
main: org.vindicterra.vindicterraLib.VindicterraLib
main: org.vindicterra.vindicterralib.VindicterraLib
api-version: '1.20'
load: STARTUP
description: Vindicterra Standard Library

0 comments on commit fc58ac2

Please sign in to comment.