Merge branch 'clans-beta' of ssh://184.154.0.242:7999/min/mineplex into clans-beta

This commit is contained in:
libraryaddict 2015-11-25 13:42:31 +13:00
commit ecf42803f9
2 changed files with 23 additions and 18 deletions

View File

@ -64,6 +64,7 @@ import mineplex.game.clans.items.smelting.SmeltingListener;
import mineplex.game.clans.items.ui.GearShop; import mineplex.game.clans.items.ui.GearShop;
import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems;
@ -335,18 +336,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
public static CustomItem parseItem(ItemStack item) public static CustomItem parseItem(ItemStack item)
{ {
String serialization = getItemSerialization(item); String serialization = getItemSerialization(item);
if (serialization!=null)System.out.println("<-GearManager-> serialization string: " + serialization);
if (serialization != null) if (serialization != null)
{ {
CustomItem customItem = null; CustomItem customItem = null;
try try
{ {
customItem = deserialize(serialization); customItem = deserialize(serialization);
System.out.println("<-GearManager-> deserialized item successfully");
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -459,14 +456,17 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
return player.getGameMode() != GameMode.CREATIVE && !_creativePlayers.contains(player.getName()); return player.getGameMode() != GameMode.CREATIVE && !_creativePlayers.contains(player.getName());
} }
@Override
public void handle(PacketInfo packetInfo) public void handle(PacketInfo packetInfo)
{ {
System.out.println("handling packet...");
// Don't mask custom gear lore for creative players, as this will break // Don't mask custom gear lore for creative players, as this will break
// them. // them.
if (!maskGearPacket(packetInfo.getPlayer())) return; if (!maskGearPacket(packetInfo.getPlayer())) return;
Packet packet = packetInfo.getPacket(); Packet<?> packet = packetInfo.getPacket();
System.out.println("<-GearManager-> Packet >> " + packetInfo.getPlayer().getName());
if (packet instanceof PacketPlayOutSetSlot) if (packet instanceof PacketPlayOutSetSlot)
{ {
@ -489,20 +489,21 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
private net.minecraft.server.v1_8_R3.ItemStack maskItem(net.minecraft.server.v1_8_R3.ItemStack item) private net.minecraft.server.v1_8_R3.ItemStack maskItem(net.minecraft.server.v1_8_R3.ItemStack item)
{ {
if (item == null) return null; // Cannot mask a null item System.out.println("<-GearManager-> attempting item mask...");
// Cannot mask a null item
if (item == null)
{
return null;
}
CraftItemStack originalItem = CraftItemStack.asCraftMirror(item); CraftItemStack originalItem = CraftItemStack.asCraftMirror(item);
ItemMeta originalMeta = originalItem.getItemMeta(); ItemMeta originalMeta = originalItem.getItemMeta();
if (originalMeta == null || originalMeta.getLore() == null) return item; // No // No need to modify item packets with no lore
// need if (originalMeta == null || originalMeta.getLore() == null)
// to {
// modify return item;
// item }
// packets
// with
// no
// lore
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
@ -514,6 +515,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
// out-going lore // out-going lore
{ {
lore.add(line); lore.add(line);
System.out.println("<-GearManager-> regular lore allowed");
}else{
System.out.println("<-GearManager-> ser. tag ignored");
} }
} }

View File

@ -720,6 +720,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
player.getInventory().addItem(item); player.getInventory().addItem(item);
} }
}, new String[] { C.cWhite + "Click to get item" }); }, new String[] { C.cWhite + "Click to get item" });
} }