mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2025-02-11 09:01:33 +01:00
Add support for Minecraft 1.8.4.
This commit is contained in:
parent
5654897419
commit
0a3a8c3a53
@ -133,13 +133,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.8.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>spigot-183</artifactId>
|
||||||
<version>1.8.3</version>
|
<version>1.8.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot-184</artifactId>
|
||||||
<version>1.8.3</version>
|
<version>1.8.4</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -356,7 +362,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<build.number>SNAPSHOT</build.number>
|
<build.number>SNAPSHOT</build.number>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<bukkit.version>1.8.3</bukkit.version>
|
<bukkit.version>1.8.4</bukkit.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
14
pom.xml
14
pom.xml
@ -6,7 +6,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!-- Bukkit API Version, change if out dated -->
|
<!-- Bukkit API Version, change if out dated -->
|
||||||
<bukkit.version>1.8.3</bukkit.version>
|
<bukkit.version>1.8.4</bukkit.version>
|
||||||
<build.number>SNAPSHOT</build.number>
|
<build.number>SNAPSHOT</build.number>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -79,8 +79,16 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot-183</artifactId>
|
||||||
<version>${bukkit.version}</version>
|
<version>1.8.3</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>spigot-184</artifactId>
|
||||||
|
<version>1.8.4</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -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_8_R2.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R2.MinecraftServer;
|
||||||
|
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo;
|
||||||
|
import net.minecraft.server.v1_8_R2.PlayerInteractManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author cnaude
|
||||||
|
*/
|
||||||
|
public class NetPacket_183 {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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_8_R2.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R2.MinecraftServer;
|
||||||
|
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo;
|
||||||
|
import net.minecraft.server.v1_8_R2.PlayerInteractManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author cnaude
|
||||||
|
*/
|
||||||
|
public class NetPacket_184 {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,19 +18,16 @@ package com.cnaude.purpleirc.Utilities;
|
|||||||
|
|
||||||
import com.cnaude.purpleirc.PurpleBot;
|
import com.cnaude.purpleirc.PurpleBot;
|
||||||
import com.cnaude.purpleirc.PurpleIRC;
|
import com.cnaude.purpleirc.PurpleIRC;
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.Packets;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.injector.PacketConstructor;
|
||||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.UUID;
|
|
||||||
import net.minecraft.server.v1_8_R2.EntityPlayer;
|
|
||||||
import net.minecraft.server.v1_8_R2.MinecraftServer;
|
|
||||||
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo;
|
|
||||||
import net.minecraft.server.v1_8_R2.PlayerInteractManager;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.pircbotx.Channel;
|
import org.pircbotx.Channel;
|
||||||
import org.pircbotx.User;
|
import org.pircbotx.User;
|
||||||
@ -43,6 +40,7 @@ public class NetPackets {
|
|||||||
|
|
||||||
PurpleIRC plugin;
|
PurpleIRC plugin;
|
||||||
private final ProtocolManager protocolManager;
|
private final ProtocolManager protocolManager;
|
||||||
|
private PacketConstructor playerListConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -63,6 +61,9 @@ public class NetPackets {
|
|||||||
if (!plugin.customTabList) {
|
if (!plugin.customTabList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isPlayerOnline(name, ircBot, channel.getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String channelName = channel.getName();
|
String channelName = channel.getName();
|
||||||
if (ircBot.tabIgnoreNicks.containsKey(channelName)) {
|
if (ircBot.tabIgnoreNicks.containsKey(channelName)) {
|
||||||
for (String s : ircBot.tabIgnoreNicks.get(channelName)) {
|
for (String s : ircBot.tabIgnoreNicks.get(channelName)) {
|
||||||
@ -112,39 +113,43 @@ public class NetPackets {
|
|||||||
String displayName = truncateName(plugin.customTabPrefix + name);
|
String displayName = truncateName(plugin.customTabPrefix + name);
|
||||||
PacketContainer packet = null;
|
PacketContainer packet = null;
|
||||||
String version = plugin.getServer().getVersion();
|
String version = plugin.getServer().getVersion();
|
||||||
if (version.contains("MC: 1.8.3")) {
|
if (version.contains("MC: 1.7.10")) {
|
||||||
|
try {
|
||||||
|
packet = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
|
||||||
|
packet.getIntegers().write(0, (add ? 0 : 4));
|
||||||
|
packet.getGameProfiles().write(0, new WrappedGameProfile(java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), displayName));
|
||||||
|
packet.getIntegers().write(1, 0);
|
||||||
|
packet.getIntegers().write(2, 0);
|
||||||
|
packet.getStrings().write(0, displayName);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
plugin.logError("tabPacket: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
} else if (version.contains("MC: 1.8.3")) {
|
||||||
try {
|
try {
|
||||||
UUID uuid = null; // = plugin.getPlayerUuid(name);
|
|
||||||
if (uuid == null) {
|
|
||||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8));
|
|
||||||
}
|
|
||||||
if (add) {
|
if (add) {
|
||||||
EntityPlayer pl = new EntityPlayer(
|
return NetPacket_183.add(displayName);
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
plugin.logDebug("T: Removing: " + name);
|
plugin.logDebug("T: Removing: " + name);
|
||||||
EntityPlayer pl = new EntityPlayer(
|
return NetPacket_183.rem(displayName);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.logError("tabPacket: " + ex.getMessage());
|
plugin.logError("tabPacket: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
} else if (version.contains("MC: 1.8.4")) {
|
||||||
|
try {
|
||||||
|
if (add) {
|
||||||
|
return NetPacket_184.add(displayName);
|
||||||
|
} else {
|
||||||
|
plugin.logDebug("T: Removing: " + name);
|
||||||
|
return NetPacket_184.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);
|
||||||
|
packet = playerListConstructor.createPacket(displayName, add, 0);
|
||||||
}
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
@ -193,4 +198,18 @@ public class NetPackets {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPlayerOnline(String name, PurpleBot ircBot, String channel) {
|
||||||
|
if (ircBot.tabIgnoreDuplicates.containsKey(channel)) {
|
||||||
|
if (ircBot.tabIgnoreDuplicates.get(channel)) {
|
||||||
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
if (name.equalsIgnoreCase(player.getName())) {
|
||||||
|
plugin.logDebug("Not adidng to tab list due to player with same name.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user