mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 05:26:19 +01:00
Fix netPacket errors
This commit is contained in:
parent
dda8c31780
commit
eb3c75b139
8
pom.xml
8
pom.xml
@ -130,6 +130,14 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>spigot-112</artifactId>
|
||||
<version>1.12</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- PircBotX -->
|
||||
<dependency>
|
||||
<groupId>com.cnaude.pircbotx</groupId>
|
||||
|
@ -19,7 +19,6 @@ package com.cnaude.purpleirc.Hooks;
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.kitteh.vanish.staticaccess.VanishNoPacket;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -46,12 +45,10 @@ public class VanishHook {
|
||||
// Try SuperVanish first
|
||||
if (plugin.superVanishHook != null) {
|
||||
return plugin.superVanishHook.isVanished(player);
|
||||
} else if (plugin.vanishNoPacketHook != null) {
|
||||
return plugin.vanishNoPacketHook.isVanished(player);
|
||||
} else {
|
||||
// Fallback to other Vanish
|
||||
if (player.hasMetadata("vanished")) {
|
||||
plugin.logDebug("Player " + player.getName() + " has vanished metadata" + player.getMetadata("vanished").get(0).asString());
|
||||
plugin.logDebug("Player " + player.getName() + " has vanished metadata" + player.getMetadata("vanished").get(0));
|
||||
MetadataValue md = player.getMetadata("vanished").get(0);
|
||||
if (md.asBoolean()) {
|
||||
plugin.logDebug("Player " + player.getName() + " is vanished.");
|
||||
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 cnaude
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.cnaude.purpleirc.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kitteh.vanish.staticaccess.VanishNoPacket;
|
||||
import org.kitteh.vanish.staticaccess.VanishNotLoadedException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class VanishNoPacketHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin the PurpleIRC plugin
|
||||
*/
|
||||
public VanishNoPacketHook(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
public boolean isVanished(Player player) {
|
||||
try {
|
||||
if (VanishNoPacket.isVanished(player.getName())) {
|
||||
plugin.logDebug("Player " + player.getName() + " is vanished.");
|
||||
return true;
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is NOT vanished.");
|
||||
return false;
|
||||
}
|
||||
} catch (VanishNotLoadedException ex) {
|
||||
plugin.logError("VanishNoPacketHook: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -63,7 +63,6 @@ import com.cnaude.purpleirc.Hooks.ShortifyHook;
|
||||
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
|
||||
import com.cnaude.purpleirc.Hooks.TownyChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.VanishHook;
|
||||
import com.cnaude.purpleirc.Hooks.VanishNoPacketHook;
|
||||
import com.cnaude.purpleirc.Hooks.VaultHook;
|
||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||
import com.cnaude.purpleirc.Utilities.ChatTokenizer;
|
||||
@ -225,7 +224,6 @@ public class PurpleIRC extends JavaPlugin {
|
||||
public VaultHook vaultHelpers;
|
||||
public VanishHook vanishHook;
|
||||
public SuperVanishHook superVanishHook;
|
||||
public VanishNoPacketHook vanishNoPacketHook;
|
||||
private YamlConfiguration heroConfig;
|
||||
private final File cacheFile;
|
||||
private final File uuidCacheFile;
|
||||
@ -1728,7 +1726,6 @@ public class PurpleIRC extends JavaPlugin {
|
||||
if (isPluginEnabled(PL_VANISHNOPACKET)) {
|
||||
hookList.add(hookFormat(PL_VANISHNOPACKET, true));
|
||||
getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this);
|
||||
vanishNoPacketHook = new VanishNoPacketHook(this);
|
||||
} else {
|
||||
hookList.add(hookFormat(PL_VANISHNOPACKET, false));
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2015 cnaude
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.cnaude.purpleirc.Utilities;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Chris Naude
|
||||
*/
|
||||
public class NetPacket_112 {
|
||||
|
||||
public static PacketContainer add(String displayName) {
|
||||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8));
|
||||
EntityPlayer pl = new EntityPlayer(
|
||||
MinecraftServer.getServer(),
|
||||
MinecraftServer.getServer().getWorldServer(0),
|
||||
(GameProfile) (new WrappedGameProfile(uuid, displayName)).getHandle(),
|
||||
new PlayerInteractManager(MinecraftServer.getServer().getWorldServer(0))
|
||||
);
|
||||
PacketPlayOutPlayerInfo pi
|
||||
= new PacketPlayOutPlayerInfo(
|
||||
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, pl);
|
||||
return PacketContainer.fromPacket(pi);
|
||||
}
|
||||
|
||||
public static PacketContainer rem(String displayName) {
|
||||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8));
|
||||
EntityPlayer pl = new EntityPlayer(
|
||||
MinecraftServer.getServer(),
|
||||
MinecraftServer.getServer().getWorldServer(0),
|
||||
(GameProfile) (new WrappedGameProfile(uuid, displayName)).getHandle(),
|
||||
new PlayerInteractManager(MinecraftServer.getServer().getWorldServer(0))
|
||||
);
|
||||
PacketPlayOutPlayerInfo pi
|
||||
= new PacketPlayOutPlayerInfo(
|
||||
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, pl);
|
||||
return PacketContainer.fromPacket(pi);
|
||||
}
|
||||
|
||||
}
|
@ -183,7 +183,7 @@ public class NetPackets {
|
||||
} catch (Exception ex) {
|
||||
plugin.logError("tabPacket: " + ex.getMessage());
|
||||
}
|
||||
} else if (version.contains("MC: 1.11")) {
|
||||
} else if (version.contains("MC: 1.11")) {
|
||||
try {
|
||||
if (add) {
|
||||
return NetPacket_111.add(displayName);
|
||||
@ -194,6 +194,17 @@ public class NetPackets {
|
||||
} catch (Exception ex) {
|
||||
plugin.logError("tabPacket: " + ex.getMessage());
|
||||
}
|
||||
} else if (version.contains("MC: 1.12")) {
|
||||
try {
|
||||
if (add) {
|
||||
return NetPacket_112.add(displayName);
|
||||
} else {
|
||||
plugin.logDebug("T112: Removing: " + name);
|
||||
return NetPacket_112.rem(displayName);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plugin.logError("tabPacket: " + ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
plugin.logDebug("tabPacket: deprecated ");
|
||||
playerListConstructor = protocolManager.createPacketConstructor(Packets.Server.PLAYER_INFO, "", false, (int) 0);
|
||||
|
Loading…
Reference in New Issue
Block a user