Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Update for MC 194.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed May 14, 2016
1 parent 9270733 commit 7910820
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Expand Up @@ -103,6 +103,14 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.bukkit</groupId>
<artifactId>spigot-194</artifactId>
<version>1.9.4</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.bukkit</groupId>
<artifactId>spigot-184</artifactId>
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/com/cnaude/purpleirc/Utilities/NetPacket_194.java
@@ -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_9_R2.EntityPlayer;
import net.minecraft.server.v1_9_R2.MinecraftServer;
import net.minecraft.server.v1_9_R2.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_9_R2.PlayerInteractManager;

/**
*
* @author Chris Naude
*/
public class NetPacket_194 {

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);
}

}
11 changes: 11 additions & 0 deletions src/main/java/com/cnaude/purpleirc/Utilities/NetPackets.java
Expand Up @@ -150,6 +150,17 @@ private PacketContainer tabPacket(String name, boolean add) {
} catch (Exception ex) {
plugin.logError("tabPacket: " + ex.getMessage());
}
} else if (version.contains("MC: 1.9.4")) {
try {
if (add) {
return NetPacket_194.add(displayName);
} else {
plugin.logDebug("T194: Removing: " + name);
return NetPacket_194.rem(displayName);
}
} catch (Exception ex) {
plugin.logError("tabPacket: " + ex.getMessage());
}
} else if (version.contains("MC: 1.9")) {
try {
if (add) {
Expand Down

0 comments on commit 7910820

Please sign in to comment.