Skip to content

Commit 377ee8c

Browse files
authored
Merge pull request #679 from ArikSquad/feat/spark
Fix Spark
2 parents 320c34d + 6596a89 commit 377ee8c

File tree

13 files changed

+623
-8
lines changed

13 files changed

+623
-8
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ subprojects {
1717
mavenLocal()
1818
maven("https://repo.viaversion.com")
1919
maven("https://jitpack.io")
20+
maven("https://repo.lucko.me/")
2021
}
2122

2223
java {

loader/src/main/java/net/swofty/loader/Hypixel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import net.swofty.proxyapi.redis.ProxyToClient;
2424
import net.swofty.proxyapi.redis.ServerOutboundMessage;
2525
import net.swofty.proxyapi.redis.ServiceToClient;
26+
import net.swofty.spark.Spark;
2627
import net.swofty.type.generic.HypixelConst;
2728
import net.swofty.type.generic.HypixelGenericLoader;
2829
import net.swofty.type.generic.HypixelTypeLoader;
@@ -33,7 +34,7 @@
3334
import org.reflections.Reflections;
3435
import org.tinylog.Logger;
3536

36-
import java.lang.reflect.InvocationTargetException;
37+
import java.nio.file.Files;
3738
import java.util.*;
3839
import java.util.concurrent.CompletableFuture;
3940
import java.util.concurrent.TimeUnit;
@@ -157,7 +158,7 @@ public static void main(String[] args) {
157158
* Start spark if enabled
158159
*/
159160
if (ENABLE_SPARK) {
160-
// Spark.enable(Files.createTempDirectory("spark"));
161+
Spark.enable(Files.createTempDirectory("spark"));
161162
}
162163

163164
/**

spark/build.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ java {
1717
}
1818
}
1919

20-
repositories {
21-
maven("https://jitpack.io")
22-
}
23-
2420
dependencies {
2521
implementation("net.minestom:minestom:2025.12.20c-1.21.11") {
2622
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
2723
}
28-
implementation(files("dependencies/spark-1.10.1.10-minestom.jar"))
2924
implementation(project(":type.generic"))
25+
implementation("com.google.guava:guava:33.5.0-jre")
26+
api("me.lucko:spark-common:1.10.158-20260110.094844-1")
3027
}
3128

3229
application {
-4.67 MB
Binary file not shown.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* This file is part of spark.
3+
*
4+
* Copyright (c) lucko (Luck) <luck@lucko.me>
5+
* Copyright (c) contributors
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package me.lucko.spark.minestom;
22+
23+
import java.util.function.BiPredicate;
24+
import me.lucko.spark.common.command.sender.AbstractCommandSender;
25+
import net.kyori.adventure.text.Component;
26+
import net.minestom.server.command.CommandSender;
27+
import net.minestom.server.command.ConsoleSender;
28+
import net.minestom.server.entity.Player;
29+
30+
import java.util.UUID;
31+
import org.jetbrains.annotations.NotNull;
32+
33+
final class MinestomCommandSender extends AbstractCommandSender<CommandSender> {
34+
35+
private final @NotNull BiPredicate<CommandSender, String> permissionHandler;
36+
37+
public MinestomCommandSender(CommandSender delegate, @NotNull BiPredicate<CommandSender, String> permissionHandler) {
38+
super(delegate);
39+
this.permissionHandler = permissionHandler;
40+
}
41+
42+
@Override
43+
public String getName() {
44+
if (this.delegate instanceof Player player) return player.getUsername();
45+
else if (this.delegate instanceof ConsoleSender) return "Console";
46+
return "unknown:" + this.delegate.getClass().getSimpleName();
47+
}
48+
49+
@Override
50+
public UUID getUniqueId() {
51+
if (super.delegate instanceof Player player) return player.getUuid();
52+
return null;
53+
}
54+
55+
@Override
56+
public void sendMessage(Component message) {
57+
this.delegate.sendMessage(message);
58+
}
59+
60+
@Override
61+
public boolean hasPermission(String permission) {
62+
return this.permissionHandler.test(this.delegate, permission);
63+
}
64+
65+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* This file is part of spark.
3+
*
4+
* Copyright (c) lucko (Luck) <luck@lucko.me>
5+
* Copyright (c) contributors
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package me.lucko.spark.minestom;
22+
23+
import me.lucko.spark.common.platform.PlatformInfo;
24+
import net.minestom.server.MinecraftServer;
25+
26+
final class MinestomPlatformInfo implements PlatformInfo {
27+
@Override
28+
public Type getType() {
29+
return Type.SERVER;
30+
}
31+
32+
@Override
33+
public String getName() {
34+
return "Minestom";
35+
}
36+
37+
@Override
38+
public String getBrand() {
39+
return "Minestom";
40+
}
41+
42+
@Override
43+
public String getVersion() {
44+
return MinecraftServer.VERSION_NAME + "-" + MinecraftServer.getBrandName();
45+
}
46+
47+
@Override
48+
public String getMinecraftVersion() {
49+
return MinecraftServer.VERSION_NAME;
50+
}
51+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* This file is part of spark.
3+
*
4+
* Copyright (c) lucko (Luck) <luck@lucko.me>
5+
* Copyright (c) contributors
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package me.lucko.spark.minestom;
22+
23+
import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
24+
import net.minestom.server.MinecraftServer;
25+
import net.minestom.server.entity.Player;
26+
27+
import java.util.Map;
28+
import java.util.stream.Collectors;
29+
30+
public final class MinestomPlayerPingProvider implements PlayerPingProvider {
31+
@Override
32+
public Map<String, Integer> poll() {
33+
return MinecraftServer.getConnectionManager().getOnlinePlayers().stream()
34+
.collect(Collectors.toMap(
35+
Player::getUsername,
36+
Player::getLatency
37+
));
38+
}
39+
}

0 commit comments

Comments
 (0)