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