Skip to content

Commit a847a22

Browse files
committed
v1.4.0
1 parent 2257950 commit a847a22

File tree

3 files changed

+27
-69
lines changed

3 files changed

+27
-69
lines changed

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ plugins {
66
}
77

88
repositories {
9-
mavenLocal()
109
mavenCentral()
1110
maven {
1211
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
1312
}
13+
maven {
14+
url = uri('https://repo.papermc.io/repository/maven-public/')
15+
}
1416
maven {
1517
url = uri('https://oss.sonatype.org/content/groups/public/')
1618
}
@@ -20,17 +22,14 @@ repositories {
2022
maven {
2123
url = uri('https://repo.maven.apache.org/maven2/')
2224
}
23-
maven {
24-
url = uri('https://jitpack.io')
25-
}
2625
maven {
2726
url = uri('https://redempt.dev')
2827
}
2928
maven {
30-
url = uri('https://repo.extendedclip.com/content/repositories/placeholderapi/')
29+
url = uri('https://jitpack.io')
3130
}
3231
maven {
33-
url = uri('https://repo.papermc.io/repository/maven-public/')
32+
url = uri('https://repo.extendedclip.com/content/repositories/placeholderapi/')
3433
}
3534
maven {
3635
url = uri('https://hub.jeff-media.com/nexus/repository/jeff-media-public/')
@@ -48,7 +47,8 @@ dependencies {
4847
implementation 'org.bstats:bstats-bukkit:3.0.2'
4948
implementation 'com.jeff_media:MorePersistentDataTypes:2.4.0'
5049

51-
compileOnly 'dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT'
50+
compileOnly files('libs/folia-api-1.20.4-R0.1-SNAPSHOT.jar') // Modified API jar with Java 8 support
51+
compileOnly 'net.kyori:adventure-api:4.17.0' // Not used but needed for Folia compilation
5252
compileOnly 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
5353
compileOnly 'org.jetbrains:annotations:24.1.0'
5454
compileOnly 'me.clip:placeholderapi:2.11.6'
1.97 MB
Binary file not shown.
Lines changed: 20 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,44 @@
11
package me.byteful.plugin.leveltools.util;
22

3-
import org.apache.commons.lang3.ArrayUtils;
3+
import java.util.*;
44
import org.bukkit.ChatColor;
55
import org.jetbrains.annotations.NotNull;
6+
import redempt.redlib.misc.FormatUtils;
67

7-
import java.util.*;
8-
import java.util.stream.Collectors;
9-
10-
// Borrowed from RedLib (https://github.com/boxbeam/RedCommands/blob/master/src/redempt/redlib/misc/FormatUtils.java)
118
public final class Text {
129
@NotNull
1310
public static String decolorize(@NotNull String string) {
1411
return colorize(string).replace("" + ChatColor.COLOR_CHAR, "&");
1512
}
1613

17-
private static Set<Character> colorChars = "4c6e2ab319d5f780rlonmk".chars().mapToObj(i -> (char) i).collect(Collectors.toSet());
18-
1914
@NotNull
20-
// Author: boxbeam
2115
public static String colorize(String input) {
22-
StringBuilder builder = new StringBuilder();
23-
for (int i = 0; i < input.length(); i++) {
24-
char c = input.charAt(i);
25-
if (i + 1 >= input.length()) {
26-
builder.append(c);
27-
continue;
28-
}
29-
char n = input.charAt(i + 1);
30-
if (c == '\\' && (n == '&' || n == '\\')) {
31-
i++;
32-
builder.append(n);
33-
continue;
34-
}
35-
if (c != '&') {
36-
builder.append(c);
37-
continue;
38-
}
39-
if (colorChars.contains(n)) {
40-
builder.append(ChatColor.COLOR_CHAR);
41-
continue;
42-
}
43-
if (n == '#' && i + 7 <= input.length()) {
44-
String hexCode = input.substring(i + 2, i + 8).toUpperCase(Locale.ROOT);
45-
if (hexCode.chars().allMatch(ch -> (ch <= '9' && ch >= '0') || (ch <= 'F' && ch >= 'A'))) {
46-
hexCode = Arrays.stream(hexCode.split("")).map(s -> ChatColor.COLOR_CHAR + s).collect(Collectors.joining());
47-
builder.append(ChatColor.COLOR_CHAR).append("x").append(hexCode);
48-
i += 7;
49-
continue;
50-
}
51-
}
52-
builder.append(c);
53-
}
54-
return builder.toString();
16+
return FormatUtils.color(input);
5517
}
5618

5719
// From Apache lang library
5820
public static String[] substringsBetween(String str, String open, String close) {
5921
int strLen = str.length();
60-
if (strLen == 0) {
61-
return ArrayUtils.EMPTY_STRING_ARRAY;
62-
} else {
63-
int closeLen = close.length();
64-
int openLen = open.length();
65-
List<String> list = new ArrayList();
66-
67-
int end;
68-
for(int pos = 0; pos < strLen - closeLen; pos = end + closeLen) {
69-
int start = str.indexOf(open, pos);
70-
if (start < 0) {
71-
break;
72-
}
73-
74-
start += openLen;
75-
end = str.indexOf(close, start);
76-
if (end < 0) {
77-
break;
78-
}
22+
int closeLen = close.length();
23+
int openLen = open.length();
24+
List<String> list = new ArrayList();
25+
26+
int end;
27+
for (int pos = 0; pos < strLen - closeLen; pos = end + closeLen) {
28+
int start = str.indexOf(open, pos);
29+
if (start < 0) {
30+
break;
31+
}
7932

80-
list.add(str.substring(start, end));
33+
start += openLen;
34+
end = str.indexOf(close, start);
35+
if (end < 0) {
36+
break;
8137
}
8238

83-
return list.isEmpty() ? null : (String[])list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
39+
list.add(str.substring(start, end));
8440
}
41+
42+
return list.isEmpty() ? null : list.toArray(new String[0]);
8543
}
8644
}

0 commit comments

Comments
 (0)