mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-02 08:50:17 +01:00
title detection
This commit is contained in:
parent
688544da28
commit
d9aa12b984
@ -8,11 +8,11 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>2.8.10.0</version>
|
||||
<version>2.8.11</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<finalName>PlotSquared-${project.version}</finalName>
|
||||
<finalName>PlotSquared</finalName>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -273,9 +273,10 @@ public class DefaultTitleManager {
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public void clearTitle(final Player player) {
|
||||
try {
|
||||
public void clearTitle(final Player player) throws Exception {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
@ -283,9 +284,6 @@ public class DefaultTitleManager {
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,18 +292,14 @@ public class DefaultTitleManager {
|
||||
* @param player
|
||||
* Player
|
||||
*/
|
||||
public void resetTitle(final Player player) {
|
||||
try {
|
||||
public void resetTitle(final Player player) throws Exception {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(final Class<?> clazz) {
|
||||
|
@ -274,9 +274,10 @@ public class DefaultTitleManager_183 {
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public void clearTitle(final Player player) {
|
||||
try {
|
||||
public void clearTitle(final Player player) throws Exception {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
@ -284,9 +285,6 @@ public class DefaultTitleManager_183 {
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,19 +292,21 @@ public class DefaultTitleManager_183 {
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
* @throws SecurityException
|
||||
* @throws NoSuchMethodException
|
||||
* @throws InvocationTargetException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IllegalAccessException
|
||||
* @throws InstantiationException
|
||||
*/
|
||||
public void resetTitle(final Player player) {
|
||||
try {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void resetTitle(final Player player) throws Exception {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(final Class<?> clazz) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.titles;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -265,20 +266,17 @@ public class HackTitleManager {
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public void clearTitle(final Player player) {
|
||||
public void clearTitle(final Player player) throws Exception {
|
||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
||||
try {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,20 +285,17 @@ public class HackTitleManager {
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public void resetTitle(final Player player) {
|
||||
public void resetTitle(final Player player) throws Exception {
|
||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
||||
try {
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Send timings first
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = this.packetActions.getEnumConstants();
|
||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,18 +305,13 @@ public class HackTitleManager {
|
||||
* @param player
|
||||
* Player
|
||||
* @return Protocol version
|
||||
* @throws Exception
|
||||
*/
|
||||
private int getProtocolVersion(final Player player) {
|
||||
int version = 0;
|
||||
try {
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object networkManager = getValue("networkManager", connection);
|
||||
version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
||||
return version;
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
private int getProtocolVersion(final Player player) throws Exception {
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object networkManager = getValue("networkManager", connection);
|
||||
Integer version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
||||
return version;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user