mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-20 07:47:38 +01:00
Remove unsupported versions and display error messages
This commit is contained in:
parent
e1009b8cd8
commit
14541eb25d
@ -14,14 +14,11 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>v1_8_r2</module>
|
||||
<module>v1_8_r3</module>
|
||||
<module>v1_9_r1</module>
|
||||
<module>v1_9_r2</module>
|
||||
<module>v1_10_r1</module>
|
||||
<module>v1_11_r1</module>
|
||||
<module>v1_12_r1</module>
|
||||
<module>v1_13_r1</module>
|
||||
<module>v1_13_r2</module>
|
||||
<module>v1_14_r1</module>
|
||||
<module>v1_15_r1</module>
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_13_R1</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||
import me.filoghost.holographicdisplays.common.nms.PacketListener;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
@Override
|
||||
public EntityID newEntityID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSPacketList createPacketList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectPacketListener(Player player, PacketListener packetListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninjectPacketListener(Player player) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_8_r2</artifactId>
|
||||
<name>HolographicDisplays NMS v1_8_R2</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_8_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||
import me.filoghost.holographicdisplays.common.nms.PacketListener;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
@Override
|
||||
public EntityID newEntityID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSPacketList createPacketList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectPacketListener(Player player, PacketListener packetListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninjectPacketListener(Player player) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_9_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_9_R1</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||
import me.filoghost.holographicdisplays.common.nms.PacketListener;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
@Override
|
||||
public EntityID newEntityID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSPacketList createPacketList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectPacketListener(Player player, PacketListener packetListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninjectPacketListener(Player player) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -34,21 +34,11 @@
|
||||
<artifactId>holographicdisplays-legacy-api-v2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_8_r2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_8_r3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_9_r1</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_9_r2</artifactId>
|
||||
@ -69,11 +59,6 @@
|
||||
<artifactId>holographicdisplays-nms-v1_12_r1</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_13_r2</artifactId>
|
||||
|
@ -37,6 +37,7 @@ import me.filoghost.holographicdisplays.plugin.placeholder.internal.DefaultPlace
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.util.NMSVersion;
|
||||
import me.filoghost.holographicdisplays.plugin.util.NMSVersion.OutdatedVersionException;
|
||||
import me.filoghost.holographicdisplays.plugin.util.NMSVersion.UnknownVersionException;
|
||||
import org.bstats.bukkit.MetricsLite;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -87,9 +88,9 @@ public class HolographicDisplays extends FCommonsPlugin {
|
||||
try {
|
||||
nmsManager = NMSVersion.getCurrent().createNMSManager(errorCollector);
|
||||
} catch (UnknownVersionException e) {
|
||||
throw new PluginEnableException(
|
||||
"Holographic Displays does not support this server version.",
|
||||
"Supported Spigot versions: from 1.8.3 to 1.17.");
|
||||
throw new PluginEnableException("Holographic Displays only supports Spigot from 1.8 to 1.17.");
|
||||
} catch (OutdatedVersionException e) {
|
||||
throw new PluginEnableException("Holographic Displays only supports " + e.getMinimumSupportedVersion() + " and above.");
|
||||
} catch (Throwable t) {
|
||||
throw new PluginEnableException(t, "Couldn't initialize the NMS manager.");
|
||||
}
|
||||
|
@ -19,23 +19,26 @@ import java.util.regex.Pattern;
|
||||
public enum NMSVersion {
|
||||
|
||||
// Not using shorter method reference syntax here because it initializes the class, causing a ClassNotFoundException
|
||||
v1_8_R2((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_8_R2.VersionNMSManager()),
|
||||
v1_8_R3((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_8_R3.VersionNMSManager(errorCollector)),
|
||||
v1_9_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_9_R1.VersionNMSManager()),
|
||||
v1_9_R2((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_9_R2.VersionNMSManager(errorCollector)),
|
||||
v1_10_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_10_R1.VersionNMSManager(errorCollector)),
|
||||
v1_11_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_11_R1.VersionNMSManager(errorCollector)),
|
||||
v1_12_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_12_R1.VersionNMSManager(errorCollector)),
|
||||
v1_13_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_13_R1.VersionNMSManager()),
|
||||
v1_13_R2((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_13_R2.VersionNMSManager(errorCollector)),
|
||||
v1_14_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_14_R1.VersionNMSManager(errorCollector)),
|
||||
v1_15_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_15_R1.VersionNMSManager(errorCollector)),
|
||||
v1_16_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_16_R1.VersionNMSManager(errorCollector)),
|
||||
v1_16_R2((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_16_R2.VersionNMSManager(errorCollector)),
|
||||
v1_16_R3((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_16_R3.VersionNMSManager(errorCollector)),
|
||||
v1_17_R1((errorCollector) -> new me.filoghost.holographicdisplays.nms.v1_17_R1.VersionNMSManager(errorCollector));
|
||||
|
||||
private static final NMSVersion CURRENT_VERSION = extractCurrentVersion();
|
||||
/* 1.8 - 1.8.2 */ v1_8_R1(NMSManagerFactory.outdatedVersion("1.8.4")),
|
||||
/* 1.8.3 */ v1_8_R2(NMSManagerFactory.outdatedVersion("1.8.4")),
|
||||
/* 1.8.4 - 1.8.9 */ v1_8_R3(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_8_R3.VersionNMSManager(errorCollector)),
|
||||
/* 1.9 - 1.9.3 */ v1_9_R1(NMSManagerFactory.outdatedVersion("1.9.4")),
|
||||
/* 1.9.4 */ v1_9_R2(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_9_R2.VersionNMSManager(errorCollector)),
|
||||
/* 1.10 - 1.10.2 */ v1_10_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_10_R1.VersionNMSManager(errorCollector)),
|
||||
/* 1.11 - 1.11.2 */ v1_11_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_11_R1.VersionNMSManager(errorCollector)),
|
||||
/* 1.12 - 1.12.2 */ v1_12_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_12_R1.VersionNMSManager(errorCollector)),
|
||||
/* 1.13 */ v1_13_R1(NMSManagerFactory.outdatedVersion("1.13.1")),
|
||||
/* 1.13.1 - 1.13.2 */ v1_13_R2(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_13_R2.VersionNMSManager(errorCollector)),
|
||||
/* 1.14 - 1.14.4 */ v1_14_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_14_R1.VersionNMSManager(errorCollector)),
|
||||
/* 1.15 - 1.15.2 */ v1_15_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_15_R1.VersionNMSManager(errorCollector)),
|
||||
/* 1.16 - 1.16.1 */ v1_16_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_16_R1.VersionNMSManager(errorCollector)),
|
||||
/* 1.16.2 - 1.16.3 */ v1_16_R2(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_16_R2.VersionNMSManager(errorCollector)),
|
||||
/* 1.16.4 - 1.16.5 */ v1_16_R3(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_16_R3.VersionNMSManager(errorCollector)),
|
||||
/* 1.17 - ? */ v1_17_R1(errorCollector -> new me.filoghost.holographicdisplays.nms.v1_17_R1.VersionNMSManager(errorCollector)),
|
||||
/* Other versions */ UNKNOWN(NMSManagerFactory.unknownVersion());
|
||||
|
||||
private static final NMSVersion CURRENT_VERSION = detectCurrentVersion();
|
||||
|
||||
private final NMSManagerFactory nmsManagerFactory;
|
||||
|
||||
@ -43,38 +46,62 @@ public enum NMSVersion {
|
||||
this.nmsManagerFactory = nmsManagerFactory;
|
||||
}
|
||||
|
||||
public NMSManager createNMSManager(ErrorCollector errorCollector) {
|
||||
public NMSManager createNMSManager(ErrorCollector errorCollector) throws OutdatedVersionException, UnknownVersionException {
|
||||
return nmsManagerFactory.create(errorCollector);
|
||||
}
|
||||
|
||||
public static NMSVersion getCurrent() throws UnknownVersionException {
|
||||
if (CURRENT_VERSION == null) {
|
||||
throw new UnknownVersionException();
|
||||
}
|
||||
public static NMSVersion getCurrent() {
|
||||
return CURRENT_VERSION;
|
||||
}
|
||||
|
||||
private static NMSVersion extractCurrentVersion() {
|
||||
private static NMSVersion detectCurrentVersion() {
|
||||
Matcher matcher = Pattern.compile("v\\d+_\\d+_R\\d+").matcher(Bukkit.getServer().getClass().getPackage().getName());
|
||||
if (!matcher.find()) {
|
||||
return null;
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
String nmsVersionName = matcher.group();
|
||||
try {
|
||||
return valueOf(nmsVersionName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null; // Unknown version
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
private interface NMSManagerFactory {
|
||||
|
||||
NMSManager create(ErrorCollector errorCollector);
|
||||
NMSManager create(ErrorCollector errorCollector) throws UnknownVersionException, OutdatedVersionException;
|
||||
|
||||
static NMSManagerFactory unknownVersion() {
|
||||
return errorCollector -> {
|
||||
throw new UnknownVersionException();
|
||||
};
|
||||
}
|
||||
|
||||
static NMSManagerFactory outdatedVersion(String minimumSupportedVersion) {
|
||||
return errorCollector -> {
|
||||
throw new OutdatedVersionException(minimumSupportedVersion);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class UnknownVersionException extends Exception {}
|
||||
|
||||
public static class OutdatedVersionException extends Exception {
|
||||
|
||||
private final String minimumSupportedVersion;
|
||||
|
||||
public OutdatedVersionException(String minimumSupportedVersion) {
|
||||
this.minimumSupportedVersion = minimumSupportedVersion;
|
||||
}
|
||||
|
||||
public String getMinimumSupportedVersion() {
|
||||
return minimumSupportedVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
18
pom.xml
18
pom.xml
@ -96,24 +96,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_8_r2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_8_r3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_9_r1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_9_r2</artifactId>
|
||||
@ -138,12 +126,6 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-v1_13_r2</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user