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.serverdata.serialization.RuntimeTypeAdapterFactory;
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.PacketPlayOutWindowItems;
@ -91,7 +92,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
// selecting item type
// (legendary/weapon/armor/bow)
private Set<String> _creativePlayers; // Set of names for all players
// currently in Creative gamemode
// currently in Creative gamemode
// Legendary generation
private WeightSet<Class<? extends LegendaryItem>> _legendaryWeights;
@ -335,18 +336,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
public static CustomItem parseItem(ItemStack item)
{
String serialization = getItemSerialization(item);
if (serialization!=null)System.out.println("<-GearManager-> serialization string: " + serialization);
if (serialization != null)
{
CustomItem customItem = null;
try
{
customItem = deserialize(serialization);
System.out.println("<-GearManager-> deserialized item successfully");
}
catch (Exception exception)
{
@ -459,14 +456,17 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
return player.getGameMode() != GameMode.CREATIVE && !_creativePlayers.contains(player.getName());
}
@Override
public void handle(PacketInfo packetInfo)
{
System.out.println("handling packet...");
// Don't mask custom gear lore for creative players, as this will break
// them.
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)
{
@ -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)
{
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);
ItemMeta originalMeta = originalItem.getItemMeta();
if (originalMeta == null || originalMeta.getLore() == null) return item; // No
// need
// to
// modify
// item
// packets
// with
// no
// lore
// No need to modify item packets with no lore
if (originalMeta == null || originalMeta.getLore() == null)
{
return item;
}
List<String> lore = new ArrayList<String>();
@ -514,6 +515,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
// out-going lore
{
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)
{
player.getInventory().addItem(item);
}
}, new String[] { C.cWhite + "Click to get item" });
}