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

Commit

Permalink
Check for valid version of Shortify.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed Dec 21, 2014
1 parent e12dbd2 commit 34aed20
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/cnaude/purpleirc/PurpleBot.java
Expand Up @@ -133,7 +133,7 @@ public final class PurpleBot {
public CaseInsensitiveMap<Boolean> enableMessageFiltering;
private final CaseInsensitiveMap<Boolean> shortify;
public CaseInsensitiveMap<String> heroChannel;
public CaseInsensitiveMap<String> townyChannel;
public CaseInsensitiveMap<String> townyChannel;
public CaseInsensitiveMap<Collection<String>> opsList;
public CaseInsensitiveMap<Collection<String>> voicesList;
public CaseInsensitiveMap<Collection<String>> worldList;
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/cnaude/purpleirc/PurpleIRC.java
Expand Up @@ -328,13 +328,13 @@ public void onEnable() {
logInfo("DeathMessages not detected.");
}
if (isPluginEnabled("Shortify")) {
//String shortifyVersion = getServer().getPluginManager().getPlugin("Shortify").getDescription().getVersion();
//if (shortifyVersion.startsWith("1.6")) {
// logError("Shortify v" + shortifyVersion + " not supported. Please install 1.7 or newer.");
//} else {
logInfo("Enabling Shortify support.");
shortifyHook = new ShortifyHook(this);
//}
String shortifyVersion = getServer().getPluginManager().getPlugin("Shortify").getDescription().getVersion();
if (shortifyVersion.startsWith("1.8")) {
logInfo("Enabling Shortify v" + shortifyVersion + " support.");
shortifyHook = new ShortifyHook(this);
} else {
logError("Shortify v" + shortifyVersion + " not supported. Please use the latest version from http://jenkins.cnaude.org/job/Shortify/");
}
} else {
logInfo("Shortify not detected.");
}
Expand All @@ -353,7 +353,7 @@ public void onEnable() {
}
vanishHook = new VanishHook(this);
if (isPluginEnabled("SuperVanish")) {
logInfo("Enabling SuperVanish support.");
logInfo("Enabling SuperVanish support.");
superVanishHook = new SuperVanishHook(this);
} else {
logInfo("SuperVanish not detected.");
Expand Down Expand Up @@ -925,7 +925,7 @@ public String getPlayerGroup(Player player) {
}
return ChatColor.translateAlternateColorCodes('&', groupName);
}

/**
*
* @param player
Expand Down Expand Up @@ -1096,7 +1096,7 @@ public void updateDisplayNameCache(String player, String displayName) {
logDebug("Caching displayName for " + player + " = " + displayName);
displayNameCache.put(player, displayName);
}

/**
*
* @param player
Expand All @@ -1105,7 +1105,7 @@ public void updateUuidCache(Player player) {
logDebug("Caching UUID for " + player.getName() + " = " + player.getUniqueId().toString());
uuidCache.put(player.getName(), player.getUniqueId());
}

/**
*
* @param player
Expand Down Expand Up @@ -1300,7 +1300,7 @@ public void loadDisplayNameCache() {
logError(e.getMessage());
}
}

public void saveUuidCache() {
BufferedWriter writer;
try {
Expand Down
40 changes: 37 additions & 3 deletions src/main/java/com/cnaude/purpleirc/Utilities/NetPackets.java
Expand Up @@ -25,9 +25,14 @@
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.injector.PacketConstructor;
import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.google.common.base.Charsets;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.pircbotx.Channel;
import org.pircbotx.User;
Expand Down Expand Up @@ -108,7 +113,6 @@ private PacketContainer tabPacket(String name, boolean add) {
String displayName = truncateName(plugin.customTabPrefix + name);
PacketContainer packet = null;
String version = plugin.getServer().getVersion();
plugin.logDebug("tabPacket: " + version);
if (version.contains("MC: 1.7.10")) {
try {
packet = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
Expand All @@ -121,14 +125,44 @@ private PacketContainer tabPacket(String name, boolean add) {
plugin.logError("tabPacket: " + ex.getMessage());
}
} else if (version.contains("MC: 1.8")) {
/*
try {
packet = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
//packet.getChatComponents()

UUID uuid = plugin.getPlayerUuid(name);
if (uuid == null) {
uuid = java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8));
}
PlayerInfoData pid = new PlayerInfoData(
packet,
NativeGameMode.CREATIVE,
0,
new WrappedGameProfile(uuid, displayName),
WrappedChatComponent.fromJson("{\"text\": \"" + displayName + "\"}"));
List<PlayerInfoData> pil = packet.getPlayerInfoDataLists().read(0);
int count = packet.getPlayerInfoDataLists().size();
pil.add(pid);
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (plugin.vanishHook != null) {
if (plugin.vanishHook.isVanished(player)) {
continue;
}
}
pil.add(new PlayerInfoData(
packet,
NativeGameMode.valueOf(player.getGameMode().name()),
0,
new WrappedGameProfile(player.getUniqueId(), player.getDisplayName()),
WrappedChatComponent.fromJson("{\"text\": \"" + player.getDisplayName() + "\"}"))
);
}
packet.getPlayerInfoDataLists().write(0, pil);
return packet;
} catch (Exception ex) {
plugin.logError("tabPacket: " + ex.getMessage());
ex.printStackTrace();
}
*/
} else {
plugin.logDebug("tabPacket: deprecated ");
playerListConstructor = protocolManager.createPacketConstructor(Packets.Server.PLAYER_INFO, "", false, (int) 0);
Expand Down

0 comments on commit 34aed20

Please sign in to comment.