Skip to content

Commit b33272c

Browse files
committed
feat: 1.2.4
1 parent f129f42 commit b33272c

12 files changed

Lines changed: 260 additions & 72 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
ignore:
9+
- dependency-name: "*"
10+
update-types: ["version-update:semver-major"]
11+
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"
16+
open-pull-requests-limit: 10
17+
ignore:
18+
- dependency-name: "*"
19+
update-types: ["version-update:semver-major"]

‎.github/workflows/dependabot.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
pull_request:
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.user.login == 'dependabot[bot]'
12+
steps:
13+
- id: metadata
14+
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a
15+
with:
16+
github-token: "${{ secrets.GITHUB_TOKEN }}"
17+
18+
- if: steps.metadata.outputs.update-type != 'version-update:semver-major'
19+
run: gh pr merge --auto --squash "$PR_URL"
20+
env:
21+
PR_URL: ${{ github.event.pull_request.html_url }}
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/publish.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
project: ${{ steps.mrinfo.outputs.PROJECT_ID }}
5151
version: ${{ steps.dist.outputs.REL_NAME }}
5252
loaders: '["bukkit", "spigot", "paper", "purpur", "folia"]'
53-
game-versions: '["1.8.x", "1.9.x", "1.10.x", "1.11.x", "1.12.x", "1.13.x", "1.14.x", "1.15.x", "1.16.x", "1.17.x", "1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x"]'
53+
game-versions: '["1.8.x", "1.9.x", "1.10.x", "1.11.x", "1.12.x", "1.13.x", "1.14.x", "1.15.x", "1.16.x", "1.17.x", "1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x", "26.2"]'
5454
files: dist/${{ steps.dist.outputs.JAR_NAME }}
5555
primary-file: ${{ steps.dist.outputs.JAR_NAME }}
5656
name: ${{ steps.dist.outputs.REL_NAME }}

‎pom.xml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>xyz.webmc</groupId>
55
<artifactId>wlib</artifactId>
6-
<version>1.2.3-SNAPSHOT</version>
6+
<version>1.2.4-SNAPSHOT</version>
77
<distributionManagement>
88
<repository>
99
<id>github</id>
@@ -167,14 +167,14 @@
167167
</relocation>
168168
</relocations>
169169
<filters>
170-
<filter>
171-
<artifact>*:*</artifact>
172-
<excludes>
173-
<exclude>org/checkerframework/**</exclude>
174-
<exclude>org/slf4j/**</exclude>
175-
</excludes>
176-
</filter>
177-
</filters>
170+
<filter>
171+
<artifact>*:*</artifact>
172+
<excludes>
173+
<exclude>org/checkerframework/**</exclude>
174+
<exclude>org/slf4j/**</exclude>
175+
</excludes>
176+
</filter>
177+
</filters>
178178
</configuration>
179179
</execution>
180180
</executions>
@@ -197,7 +197,7 @@
197197
<plugin>
198198
<groupId>com.diffplug.spotless</groupId>
199199
<artifactId>spotless-maven-plugin</artifactId>
200-
<version>3.4.0</version>
200+
<version>3.5.1</version>
201201
<configuration>
202202
<java>
203203
<cleanthat>

‎src/main/java/xyz/webmc/wlib/api/WLIB.java‎

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package xyz.webmc.wlib.api;
22

3+
import xyz.webmc.wlib.api.util.RNGUtil;
4+
5+
import java.lang.StackWalker.Option;
6+
import java.lang.StackWalker.StackFrame;
37
import java.util.ArrayList;
48
import java.util.List;
59
import java.util.logging.Logger;
610

711
import dev.colbster937.reflect.MirrorSafe;
12+
import org.bukkit.Bukkit;
13+
import org.bukkit.ChatColor;
14+
import org.bukkit.entity.Player;
815
import org.bukkit.plugin.Plugin;
916

1017
@SuppressWarnings({ "NonConstantLogger" })
1118
public final class WLIB {
19+
private static final StackWalker stackWalker = StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);
1220
private static final List<Plugin> plugins = new ArrayList<>();
1321
private static Logger logger;
1422

@@ -34,11 +42,60 @@ public static final List<String> getWLIBPluginNames() {
3442
return ret;
3543
}
3644

37-
public static final Logger getLogger() {
38-
return logger;
45+
public static final void devAlert(final String... txt) {
46+
final Class<?> clazz = stackWalker.getCallerClass();
47+
final String ctx = clazz.getSimpleName();
48+
final String str = ChatColor.DARK_GREEN + "[" + ChatColor.GREEN + "DEV" + ChatColor.RESET + " - " + ChatColor.GREEN
49+
+ ChatColor.DARK_GREEN + ctx + "] " + ChatColor.RESET + String.join(" ", txt);
50+
51+
for (final Player p : Bukkit.getOnlinePlayers()) {
52+
if (p.hasPermission("wlib.alerts.dev") && !p.hasPermission("wlib.alerts.dev.muted." + ctx)) {
53+
p.sendMessage(str);
54+
}
55+
}
56+
}
57+
58+
public static final void warnDeprecatedUsage() {
59+
final StackFrame[] frames = stackWalker.walk(s -> s.skip(1).toArray(StackFrame[]::new));
60+
if (frames.length > 1) {
61+
final StackFrame called = frames[0];
62+
final StackFrame caller = frames[1];
63+
64+
final StringBuilder sb = new StringBuilder();
65+
66+
sb.append(caller.getClassName())
67+
.append('.')
68+
.append(caller.getMethodName())
69+
.append(':')
70+
.append(caller.getLineNumber())
71+
.append(" called deprecated method ")
72+
.append(called.getClassName())
73+
.append('.')
74+
.append(called.getMethodName());
75+
76+
for (int i = 2; i < frames.length; i++) {
77+
final StackFrame frame = frames[i];
78+
79+
sb.append("\n at ")
80+
.append(frame.getClassName())
81+
.append('.')
82+
.append(frame.getMethodName())
83+
.append('(')
84+
.append(frame.getFileName())
85+
.append(':')
86+
.append(frame.getLineNumber())
87+
.append(")");
88+
}
89+
90+
logger.warning(sb.toString());
91+
}
3992
}
4093

4194
public static final boolean getIsModernServer() {
4295
return MirrorSafe.getClassExists("org.bukkit.block.data.BlockData");
4396
}
97+
98+
public static final Logger getLogger() {
99+
return logger;
100+
}
44101
}

‎src/main/java/xyz/webmc/wlib/api/structure/AbstractBaseStructure.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.webmc.wlib.api.structure;
22

3+
import xyz.webmc.wlib.api.util.SchemUtil;
4+
35
import java.io.File;
46
import java.io.FileInputStream;
57
import java.io.IOException;
@@ -9,16 +11,13 @@
911
import java.util.List;
1012
import java.util.Map;
1113

12-
import org.bukkit.Location;
13-
1414
import com.cryptomorin.xseries.XMaterial;
15-
1615
import dev.colbster937.reflect.MirrorSafe;
1716
import net.sandrohc.schematic4j.exception.ParsingException;
1817
import net.sandrohc.schematic4j.schematic.Schematic;
1918
import net.sandrohc.schematic4j.schematic.types.SchematicBlock;
2019
import net.sandrohc.schematic4j.schematic.types.SchematicBlockPos;
21-
import xyz.webmc.wlib.api.util.SchemUtil;
20+
import org.bukkit.Location;
2221

2322

2423
@SuppressWarnings({ "unchecked" })
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
package xyz.webmc.wlib.api.util;
22

3-
import java.lang.StackWalker.Option;
4-
5-
import org.bukkit.Bukkit;
6-
import org.bukkit.ChatColor;
7-
import org.bukkit.entity.Player;
3+
import xyz.webmc.wlib.api.WLIB;
84

5+
@Deprecated(forRemoval = true)
96
public final class AlertUtil {
10-
private static final StackWalker sw = StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);
11-
7+
@Deprecated(forRemoval = true)
128
public static final void devAlert(final String... txt) {
13-
final Class<?> clazz = sw.getCallerClass();
14-
final String ctx = clazz.getSimpleName();
15-
final String str = ChatColor.DARK_GREEN + "[" + ChatColor.GREEN + "DEV" + ChatColor.RESET + " - " + ChatColor.GREEN + ChatColor.DARK_GREEN + ctx + "] " + ChatColor.RESET + String.join(" ", txt);
16-
17-
for (final Player p : Bukkit.getOnlinePlayers()) {
18-
if (p.hasPermission("wlib.alerts.dev") && !p.hasPermission("wlib.alerts.dev.muted." + ctx)) {
19-
p.sendMessage(str);
20-
}
21-
}
9+
WLIB.warnDeprecatedUsage();
10+
WLIB.devAlert(txt);
2211
}
2312
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package xyz.webmc.wlib.api.util;
2+
3+
public final class HashUtil {
4+
public static int mix32(final int z) {
5+
int ret = z;
6+
ret = (ret ^ (ret >>> 16)) * 0x85EBCA6B;
7+
ret = (ret ^ (ret >>> 13)) * 0xC2B2AE35;
8+
return ret ^ (ret >>> 16);
9+
}
10+
11+
public static final long mix64(final long z) {
12+
long ret = z;
13+
ret = (ret ^ (ret >>> 33)) * 0xFF51AFD7ED558CCDL;
14+
ret = (ret ^ (ret >>> 33)) * 0xC4CEB9FE1A85EC53L;
15+
return ret ^ (ret >>> 33);
16+
}
17+
18+
public static int hash32(final byte[] data) {
19+
int hash = 0x811C9DC5;
20+
21+
for (final byte b : data) {
22+
hash ^= b & 0xFF;
23+
hash *= 0x01000193;
24+
}
25+
26+
return mix32(hash);
27+
}
28+
29+
public static String hash32H(final byte[] data) {
30+
return String.format("%08x", hash32(data));
31+
}
32+
33+
public static String hash32S(final String str) {
34+
return hash32H(str.getBytes());
35+
}
36+
37+
public static long hash64(final byte[] data) {
38+
long hash = 0xCBF29CE484222325L;
39+
40+
for (final byte b : data) {
41+
hash ^= b & 0xFFL;
42+
hash *= 0x100000001B3L;
43+
}
44+
45+
return mix64(hash);
46+
}
47+
48+
public static String hash64H(final byte[] data) {
49+
return String.format("%016x", hash64(data));
50+
}
51+
52+
public static String hash64S(final String str) {
53+
return hash64H(str.getBytes());
54+
}
55+
}

‎src/main/java/xyz/webmc/wlib/api/util/MagicUtil.java‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

‎src/main/java/xyz/webmc/wlib/api/util/RNGUtil.java‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.webmc.wlib.api.util;
22

3+
import xyz.webmc.wlib.api.WLIB;
4+
35
import java.util.SplittableRandom;
46

57
public final class RNGUtil {
@@ -40,10 +42,15 @@ public static final String getRandomStringLowercaseAZ(final int len) {
4042
return getRandomStringLowercaseAZ(len, getRandomSeed());
4143
}
4244

45+
@Deprecated(forRemoval = true)
46+
public static int mix32(final int z) {
47+
WLIB.warnDeprecatedUsage();
48+
return HashUtil.mix32(z);
49+
}
50+
51+
@Deprecated(forRemoval = true)
4352
public static final long mix64(final long z) {
44-
long ret = z;
45-
ret = (ret ^ (ret >>> 33)) * 0xFF51AFD7ED558CCDL;
46-
ret = (ret ^ (ret >>> 33)) * 0xC4CEB9FE1A85EC53L;
47-
return ret ^ (ret >>> 33);
53+
WLIB.warnDeprecatedUsage();
54+
return HashUtil.mix64(z);
4855
}
4956
}

0 commit comments

Comments
 (0)