Skip to content

Commit 9ff1221

Browse files
committed
1.19 support
1 parent a9c3fd7 commit 9ff1221

5 files changed

Lines changed: 26 additions & 27 deletions

File tree

pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>lol.hyper</groupId>
2525
<artifactId>velocityblockversion</artifactId>
26-
<version>1.0.4</version>
26+
<version>1.0.5</version>
2727
<packaging>jar</packaging>
2828

2929
<name>VelocityBlockVersion</name>
@@ -87,6 +87,11 @@
8787
<!-- Replace this with your package! -->
8888
<shadedPattern>lol.hyper.velocityblockversion.bstats</shadedPattern>
8989
</relocation>
90+
<relocation>
91+
<pattern>lol.hyper.githubreleaseapi</pattern>
92+
<!-- Replace this with your package! -->
93+
<shadedPattern>lol.hyper.velocityblockversion.updater</shadedPattern>
94+
</relocation>
9095
</relocations>
9196
</configuration>
9297
<executions>
@@ -119,6 +124,7 @@
119124
<groupId>net.kyori</groupId>
120125
<artifactId>adventure-text-minimessage</artifactId>
121126
<version>4.11.0</version>
127+
<scope>provided</scope>
122128
</dependency>
123129
<dependency>
124130
<groupId>org.bstats</groupId>
@@ -130,6 +136,13 @@
130136
<groupId>lol.hyper</groupId>
131137
<artifactId>github-release-api</artifactId>
132138
<version>1.0.2</version>
139+
<scope>compile</scope>
140+
<exclusions>
141+
<exclusion>
142+
<groupId>org.json</groupId>
143+
<artifactId>json</artifactId>
144+
</exclusion>
145+
</exclusions>
133146
</dependency>
134147
</dependencies>
135148
</project>

src/main/java/lol/hyper/velocityblockversion/VelocityBlockVersion.java

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,37 @@
3131
import net.kyori.adventure.text.Component;
3232
import net.kyori.adventure.text.minimessage.MiniMessage;
3333
import org.bstats.velocity.Metrics;
34-
import org.json.JSONObject;
3534
import org.slf4j.Logger;
3635

37-
import java.io.BufferedReader;
3836
import java.io.IOException;
39-
import java.io.InputStream;
40-
import java.io.InputStreamReader;
41-
import java.nio.charset.StandardCharsets;
42-
import java.util.stream.Collectors;
4337

4438
@Plugin(
4539
id = "velocityblockversion",
4640
name = "VelocityBlockVersion",
47-
version = "1.0.4",
41+
version = "1.0.5",
4842
authors = {"hyperdefined"},
49-
description = "Block certain Minecraft versions from connecting to your network."
43+
description = "Block certain Minecraft versions from connecting to your network.",
44+
url = "https://github.com/hyperdefined/VelocityBlockVersion"
5045
)
5146
public class VelocityBlockVersion {
5247

5348
public ConfigHandler configHandler;
49+
public final String VERSION = "1.0.5";
5450

5551
public final Logger logger;
5652
private final Metrics.Factory metricsFactory;
57-
ProxyServer server;
58-
String currentVersion;
59-
public MiniMessage miniMessage = MiniMessage.miniMessage();
53+
private final ProxyServer server;
54+
public final MiniMessage miniMessage = MiniMessage.miniMessage();
6055

6156
@Inject
6257
public VelocityBlockVersion(ProxyServer server, Logger logger, Metrics.Factory metricsFactory) {
6358
this.server = server;
6459
this.logger = logger;
6560
this.metricsFactory = metricsFactory;
66-
// this kinda sucks but whatever
67-
InputStream json = VelocityBlockVersion.class.getResourceAsStream("/velocity-plugin.json");
68-
if (json != null) {
69-
String text = new BufferedReader(
70-
new InputStreamReader(json, StandardCharsets.UTF_8))
71-
.lines()
72-
.collect(Collectors.joining("\n"));
73-
JSONObject version = new JSONObject(text);
74-
currentVersion = version.getString("version");
75-
}
7661
}
7762

7863
@Subscribe
7964
public void onProxyInitialization(ProxyInitializeEvent event) {
80-
VersionToStrings.init();
8165
configHandler = new ConfigHandler(this);
8266
configHandler.loadConfig();
8367
metricsFactory.make(this, 13308);
@@ -112,7 +96,7 @@ public void checkForUpdates() {
11296
e.printStackTrace();
11397
return;
11498
}
115-
GitHubRelease current = api.getReleaseByTag(currentVersion);
99+
GitHubRelease current = api.getReleaseByTag(VERSION);
116100
GitHubRelease latest = api.getLatestVersion();
117101
if (current == null) {
118102
logger.warn("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!");

src/main/java/lol/hyper/velocityblockversion/tools/ConfigHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ConfigHandler {
3131
public Toml config;
3232
private final VelocityBlockVersion velocityBlockVersion;
3333
public static final List<Integer> versions = new ArrayList<>();
34-
public static final double CONFIG_VERSION = 2;
34+
public static final double CONFIG_VERSION = 3;
3535

3636
public ConfigHandler(VelocityBlockVersion velocityBlockVersion) {
3737
this.velocityBlockVersion = velocityBlockVersion;

src/main/java/lol/hyper/velocityblockversion/tools/VersionToStrings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class VersionToStrings {
2727
// Set a list of version strings we can grab via the version number.
2828
public static final HashMap<Integer, String> versionStrings = new HashMap<>();
2929

30-
public static void init() {
30+
static {
3131
versionStrings.put(47, "1.8");
3232
versionStrings.put(107, "1.9");
3333
versionStrings.put(108, "1.9.1");
@@ -59,6 +59,7 @@ public static void init() {
5959
versionStrings.put(756, "1.17.1");
6060
versionStrings.put(757, "1.18");
6161
versionStrings.put(758, "1.18.2");
62+
versionStrings.put(759, "1.19");
6263
}
6364

6465
/**

src/main/resources/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ versions = [
3434
756,
3535
757,
3636
758,
37+
759,
3738
]
3839

3940
# Send this message if someone connects with a blocked version.
@@ -42,4 +43,4 @@ versions = [
4243
disconnect_message = "<red>You cannot connect with this version! We only allow version(s) {VERSIONS}.</red>"
4344

4445
# No touch please :)
45-
config_version = 2
46+
config_version = 3

0 commit comments

Comments
 (0)