Skip to content

Commit

Permalink
remove any network names with highlight (recursion)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Jun 17, 2024
1 parent fa71da9 commit 143cd98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public static HighlightingStyle getHighlightType(String highlightedText) {
*/
public static String getNameFromHighlightedText(String highlightedName) {
HighlightingStyle highlight = getHighlightType(highlightedName);
return highlightedName.substring(highlight.prefix.length(),
highlightedName.length() - highlight.suffix.length());
if (highlight == NOTHING) {
return highlightedName;
}
return getNameFromHighlightedText(highlightedName.substring(highlight.prefix.length(),
highlightedName.length() - highlight.suffix.length()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.jetbrains.annotations.Nullable;
import org.sgrewritten.stargate.api.network.portal.flag.PortalFlag;
import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag;

import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;

public class LegacyDataHandler {

private LegacyDataHandler(){
private LegacyDataHandler() {
throw new IllegalStateException("Utility class");
}

Expand Down Expand Up @@ -98,7 +94,7 @@ public static Location loadLocation(World world, String input) {
*/
public static Set<PortalFlag> parseFlags(String[] splitLine) {
Set<PortalFlag> flags = new HashSet<>();
for(Map.Entry<StargateFlag,Integer> entry: LEGACY_FLAG_INDICES.entrySet()) {
for (Map.Entry<StargateFlag, Integer> entry : LEGACY_FLAG_INDICES.entrySet()) {
int position = entry.getValue();
if (splitLine.length > position && splitLine[position].equalsIgnoreCase("true")) {
flags.add(entry.getKey());
Expand Down Expand Up @@ -128,8 +124,9 @@ private static Map<StargateFlag, Integer> loadFlagIndices() {

/**
* Utility method to find any of the given possible keys in the config
*
* @param possibleKeys <p>name variations of possible keys</p>
* @param oldConfig <p>The config to fetch data from</p>
* @param oldConfig <p>The config to fetch data from</p>
* @return <p>The key that had a value in the config, or null if none matched</p>
*/
public static @Nullable String findConfigKey(String[] possibleKeys, Map<String, Object> oldConfig) {
Expand Down

0 comments on commit 143cd98

Please sign in to comment.