Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9d58e08c9 | ||
|
|
24eda2b3a5 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>io.github.retrooper</groupId>
|
||||
<artifactId>packetevents</artifactId>
|
||||
<version>1.7.7</version>
|
||||
<version>1.7.8</version>
|
||||
|
||||
<!-- You can build the project with this: "mvn clean compile assembly:single" -->
|
||||
<build>
|
||||
@@ -122,6 +122,20 @@
|
||||
<version>4.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.ProtocolSupport</groupId>
|
||||
<artifactId>ProtocolSupport</artifactId>
|
||||
<version>3d24efeda6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
|
||||
@@ -37,7 +37,8 @@ import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||
import io.github.retrooper.packetevents.utils.player.ClientVersion;
|
||||
import io.github.retrooper.packetevents.utils.server.PEVersion;
|
||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||
import io.github.retrooper.packetevents.utils.v_1_7_10.ProtocolVersionAccessor_v_1_7;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.VersionLookupUtils;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.v_1_7_10.ProtocolVersionAccessor_v_1_7;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -49,7 +50,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
@@ -58,8 +58,8 @@ public final class PacketEvents implements Listener {
|
||||
private static final PacketEventsAPI packetEventsAPI = new PacketEventsAPI();
|
||||
private static final PacketEvents instance = new PacketEvents();
|
||||
private static final ArrayList<Plugin> plugins = new ArrayList<>(1);
|
||||
private static boolean loading, loaded, initialized, initializing;
|
||||
private static final PEVersion version = new PEVersion(1, 7, 7);
|
||||
private static boolean loading, loaded, initialized, initializing, uninitializing;
|
||||
private static final PEVersion version = new PEVersion(1, 7, 8);
|
||||
private static PacketEventsSettings settings = new PacketEventsSettings();
|
||||
/**
|
||||
* General executor service, basically for anything that the packet executor service doesn't do.
|
||||
@@ -182,7 +182,8 @@ public final class PacketEvents implements Listener {
|
||||
*
|
||||
*/
|
||||
public static void stop() {
|
||||
if (initialized) {
|
||||
if (initialized && !uninitializing) {
|
||||
uninitializing = true;
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
PacketEvents.getAPI().packetManager.ejectPlayer(player);
|
||||
}
|
||||
@@ -194,6 +195,7 @@ public final class PacketEvents implements Listener {
|
||||
PacketEvents.generalExecutorService.shutdownNow();
|
||||
PacketEvents.packetHandlingExecutorService.shutdownNow();
|
||||
initialized = false;
|
||||
uninitializing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,10 +242,14 @@ public final class PacketEvents implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
Object channel = NMSUtils.getChannel(e.getPlayer());
|
||||
if (PacketEvents.getAPI().getServerUtils().getVersion() == ServerVersion.v_1_7_10) {
|
||||
Object channel = NMSUtils.getChannel(e.getPlayer());
|
||||
ClientVersion version = ClientVersion.getClientVersion(ProtocolVersionAccessor_v_1_7.getProtocolVersion(e.getPlayer()));
|
||||
PacketEvents.getAPI().getPlayerUtils().clientVersionsMap.put(channel, version);
|
||||
} else if (VersionLookupUtils.isDependencyAvailable()) {
|
||||
int protocolVersion = VersionLookupUtils.getProtocolVersion(e.getPlayer());
|
||||
ClientVersion version = ClientVersion.getClientVersion(protocolVersion);
|
||||
PacketEvents.getAPI().getPlayerUtils().clientVersionsMap.put(channel, version);
|
||||
}
|
||||
//Waiting for the BungeeCord server to send their plugin message with your version,
|
||||
if (!PacketEvents.getSettings().shouldInjectEarly()) {
|
||||
@@ -258,6 +264,7 @@ public final class PacketEvents implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onQuit(final PlayerQuitEvent e) {
|
||||
PacketEvents.getAPI().getPlayerUtils().clientVersionsMap.remove(e.getPlayer().getUniqueId());
|
||||
Object channel = NMSUtils.getChannelNoCache(e.getPlayer());
|
||||
PacketEvents.getAPI().getPlayerUtils().clientVersionsMap.remove(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,12 @@
|
||||
package io.github.retrooper.packetevents.example;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.event.PacketListenerDynamic;
|
||||
import io.github.retrooper.packetevents.event.impl.PacketReceiveEvent;
|
||||
import io.github.retrooper.packetevents.event.priority.PacketEventPriority;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.chat.WrappedPacketInChat;
|
||||
import io.github.retrooper.packetevents.utils.player.ClientVersion;
|
||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
||||
@@ -41,9 +41,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class PacketManager {
|
||||
|
||||
private static final AtomicInteger handlerID = new AtomicInteger();
|
||||
private final int handlerNumber = handlerID.getAndIncrement();
|
||||
private final Plugin plugin;
|
||||
private final boolean tinyProtocolMode;
|
||||
public final TinyProtocol tinyProtocol;
|
||||
@@ -57,8 +54,8 @@ public class PacketManager {
|
||||
tinyProtocol = new TinyProtocol(plugin);
|
||||
nettyProtocol = null;
|
||||
} else {
|
||||
tinyProtocol = null;
|
||||
nettyProtocol = new NettyPacketManager(plugin);
|
||||
tinyProtocol = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +160,7 @@ public class PacketManager {
|
||||
}
|
||||
|
||||
public String getNettyHandlerName() {
|
||||
return "pe-" + plugin.getName() + "-" + handlerNumber;
|
||||
return "pe-" + plugin.getName();
|
||||
}
|
||||
|
||||
public Object read(Player player, Object channel, Object packet) {
|
||||
@@ -278,12 +275,13 @@ public class PacketManager {
|
||||
}
|
||||
|
||||
private void interceptLogin(PacketLoginEvent event) {
|
||||
if (event.getPacketId() == PacketType.Login.HANDSHAKE &&
|
||||
PacketEvents.getAPI().getServerUtils().getVersion() != ServerVersion.v_1_7_10) {
|
||||
WrappedPacketLoginHandshake handshake = new WrappedPacketLoginHandshake(event.getNMSPacket());
|
||||
int protocolVersion = handshake.getProtocolVersion();
|
||||
ClientVersion version = ClientVersion.getClientVersion(protocolVersion);
|
||||
PacketEvents.getAPI().getPlayerUtils().clientVersionsMap.put(event.getChannel(), version);
|
||||
if (event.getPacketId() == PacketType.Login.HANDSHAKE
|
||||
&& PacketEvents.getAPI().getServerUtils().getVersion() != ServerVersion.v_1_7_10
|
||||
&& !PacketEvents.getAPI().getServerUtils().isBungeeCordEnabled()) {
|
||||
WrappedPacketLoginHandshake handshake = new WrappedPacketLoginHandshake(event.getNMSPacket());
|
||||
int protocolVersion = handshake.getProtocolVersion();
|
||||
ClientVersion version = ClientVersion.getClientVersion(protocolVersion);
|
||||
PacketEvents.getAPI().getPlayerUtils().clientVersionsMap.put(event.getChannel(), version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-4
@@ -38,11 +38,7 @@ public final class WrappedPacketInUseEntity extends WrappedPacket {
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
//System.out.println("USE ENTITY HAS BEEN LOADED BROOOIOII");
|
||||
Class<?> useEntityClass = NMSUtils.getNMSClassWithoutException("PacketPlayInUseEntity");
|
||||
/*if(useEntityClass == null) {
|
||||
System.out.println("failed to init use entity wtfffff");
|
||||
}*/
|
||||
try {
|
||||
enumEntityUseActionClass = NMSUtils.getNMSClass("EnumEntityUseAction");
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
package io.github.retrooper.packetevents.settings;
|
||||
|
||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
|
||||
public class PacketEventsSettings {
|
||||
private ServerVersion backupServerVersion = ServerVersion.v_1_7_10;
|
||||
|
||||
@@ -53,7 +53,8 @@ public enum ClientVersion {
|
||||
v_1_16_1(736),
|
||||
v_1_16_2(751),
|
||||
v_1_16_3(753),
|
||||
HIGHER_THAN_SUPPORTED_VERSIONS(754),
|
||||
v_1_16_4(754),
|
||||
HIGHER_THAN_SUPPORTED_VERSIONS(755),
|
||||
/**
|
||||
* Pre releases just aren't supported, we would end up with so many enum constants.
|
||||
*/
|
||||
@@ -65,6 +66,7 @@ public enum ClientVersion {
|
||||
|
||||
private static final int lowestSupportedProtocolVersion = 5;
|
||||
private static final int highestSupportedProtocolVersion = 753;
|
||||
|
||||
ClientVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
@@ -94,24 +96,21 @@ public enum ClientVersion {
|
||||
}
|
||||
|
||||
public static ClientVersion getClientVersion(int protocolVersion) {
|
||||
if(protocolVersion == -1) {
|
||||
return ClientVersion.UNRESOLVED;
|
||||
if (protocolVersion == -1) {
|
||||
return ClientVersion.UNRESOLVED;
|
||||
}
|
||||
for(ClientVersion version : ClientVersion.values()) {
|
||||
if(version.protocolVersion > protocolVersion) {
|
||||
for (ClientVersion version : ClientVersion.values()) {
|
||||
if (version.protocolVersion > protocolVersion) {
|
||||
break;
|
||||
}
|
||||
else if(version.protocolVersion == protocolVersion) {
|
||||
} else if (version.protocolVersion == protocolVersion) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
if(protocolVersion < lowestSupportedProtocolVersion) {
|
||||
if (protocolVersion < lowestSupportedProtocolVersion) {
|
||||
return LOWER_THAN_SUPPORTED_VERSIONS;
|
||||
}
|
||||
else if(protocolVersion > highestSupportedProtocolVersion) {
|
||||
} else if (protocolVersion > highestSupportedProtocolVersion) {
|
||||
return HIGHER_THAN_SUPPORTED_VERSIONS;
|
||||
}
|
||||
else if(protocolVersion > lowestSupportedProtocolVersion
|
||||
} else if (protocolVersion > lowestSupportedProtocolVersion
|
||||
&& protocolVersion < highestSupportedProtocolVersion) {
|
||||
return ANY_PRE_RELEASE_VERSION;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public enum ServerVersion {
|
||||
v_1_11_2((short) 316), v_1_12((short) 335), v_1_12_1((short) 338), v_1_12_2((short) 340), v_1_13((short) 393),
|
||||
v_1_13_1((short) 401), v_1_13_2((short) 404), v_1_14((short) 477), v_1_14_1((short) 480), v_1_14_2((short) 485),
|
||||
v_1_14_3((short) 490), v_1_14_4((short) 498), v_1_15((short) 573), v_1_15_1((short) 575), v_1_15_2((short) 578),
|
||||
v_1_16((short) 735), v_1_16_1((short) 736), v_1_16_2((short) 751), v_1_16_3((short) 753), ERROR((short) -1), EMPTY((short) -1);
|
||||
v_1_16((short) 735), v_1_16_1((short) 736), v_1_16_2((short) 751), v_1_16_3((short) 753), v_1_16_4((short)754),ERROR((short) -1);
|
||||
|
||||
private static final String nmsVersionSuffix = Bukkit.getServer().getClass().getPackage().getName()
|
||||
.replace(".", ",").split(",")[3];
|
||||
@@ -58,6 +58,9 @@ public enum ServerVersion {
|
||||
if (reversedValues[0] == null) {
|
||||
reversedValues = ServerVersion.reverse(values());
|
||||
}
|
||||
if(reversedValues == null) {
|
||||
throw new IllegalStateException("Failed to reverse the ServerVersion enum constant values.");
|
||||
}
|
||||
for (final ServerVersion val : reversedValues) {
|
||||
String valName = val.name().substring(2).replace("_", ".");
|
||||
if (Bukkit.getBukkitVersion().contains(valName)) {
|
||||
@@ -125,7 +128,7 @@ public enum ServerVersion {
|
||||
* @return True if the supplied version is lower or equal, false if it is higher
|
||||
* than the server's version.
|
||||
*/
|
||||
public boolean isAtLeast(final ServerVersion version) {
|
||||
public boolean isHigherThanOrEquals(final ServerVersion version) {
|
||||
return protocolId >= version.protocolId;
|
||||
}
|
||||
|
||||
@@ -149,7 +152,7 @@ public enum ServerVersion {
|
||||
* @return True if the supplied version is higher or equal, false if it is lower
|
||||
* than the server's version.
|
||||
*/
|
||||
public boolean isAtMost(final ServerVersion version) {
|
||||
public boolean isLowerThanOrEquals(final ServerVersion version) {
|
||||
return version.protocolId >= protocolId;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020 retrooper
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.protocollib.ProtocolLibVersionLookupUtils;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.protocolsupport.ProtocolSupportVersionLookupUtils;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.viaversion.ViaVersionLookupUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VersionLookupUtils {
|
||||
public static boolean isDependencyAvailable() {
|
||||
return ViaVersionLookupUtils.isAvailable() || ProtocolSupportVersionLookupUtils.isAvailable()
|
||||
|| ProtocolLibVersionLookupUtils.isAvailable();
|
||||
}
|
||||
|
||||
public static int getProtocolVersion(Player player) {
|
||||
if (ViaVersionLookupUtils.isAvailable()) {
|
||||
return ViaVersionLookupUtils.getProtocolVersion(player);
|
||||
} else if (ProtocolSupportVersionLookupUtils.isAvailable()) {
|
||||
return ProtocolSupportVersionLookupUtils.getProtocolVersion(player);
|
||||
} else if (ProtocolLibVersionLookupUtils.isAvailable()) {
|
||||
return ProtocolLibVersionLookupUtils.getProtocolVersion(player);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020 retrooper
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.utils.versionlookup.protocollib;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ProtocolLibVersionLookupUtils {
|
||||
public static boolean isAvailable() {
|
||||
return Bukkit.getPluginManager().isPluginEnabled("ProtocolLib");
|
||||
}
|
||||
|
||||
public static int getProtocolVersion(Player player) {
|
||||
return ProtocolLibrary.getProtocolManager().getProtocolVersion(player);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020 retrooper
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.utils.versionlookup.protocolsupport;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import protocolsupport.api.ProtocolSupportAPI;
|
||||
|
||||
public class ProtocolSupportVersionLookupUtils {
|
||||
public static boolean isAvailable() {
|
||||
return Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
|
||||
}
|
||||
|
||||
public static int getProtocolVersion(Player player) {
|
||||
return ProtocolSupportAPI.getProtocolVersion(player).getId();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.utils.v_1_7_10;
|
||||
package io.github.retrooper.packetevents.utils.versionlookup.v_1_7_10;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020 retrooper
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.utils.versionlookup.viaversion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
public class ViaVersionLookupUtils {
|
||||
public static boolean isAvailable() {
|
||||
return Bukkit.getPluginManager().isPluginEnabled("ViaVersion");
|
||||
}
|
||||
|
||||
public static int getProtocolVersion(Player player) {
|
||||
return Via.getAPI().getPlayerVersion(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user