Memory leak fixes for DisguiseManager and DonationManager.
This commit is contained in:
parent
f4061854cd
commit
10c7d06a88
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.Block;
|
||||
@ -797,53 +798,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
}
|
||||
}
|
||||
|
||||
/*public void reApplyDisguise(final DisguiseBase disguise, final Player player)
|
||||
{
|
||||
PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(disguise.GetEntityId());
|
||||
|
||||
if (disguise.GetEntity() == ((CraftPlayer) player).getHandle())
|
||||
return;
|
||||
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
|
||||
entityPlayer.playerConnection.sendPacket(destroyPacket);
|
||||
|
||||
List<Packet> tempArmor = new ArrayList<Packet>();
|
||||
|
||||
if (disguise instanceof DisguiseInsentient && disguise.GetEntity() instanceof LivingEntity)
|
||||
{
|
||||
if (((DisguiseInsentient) disguise).armorVisible())
|
||||
{
|
||||
for (Packet armorPacket : ((DisguiseInsentient) disguise).getArmorPackets())
|
||||
tempArmor.add(armorPacket);
|
||||
}
|
||||
}
|
||||
|
||||
final List<Packet> armorPackets = tempArmor;
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
entityPlayer.playerConnection.sendPacket(disguise.GetSpawnPacket());
|
||||
|
||||
if (disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null)
|
||||
{
|
||||
for (Packet packet : getBedPackets(player.getLocation(), (DisguisePlayer) disguise))
|
||||
{
|
||||
entityPlayer.playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
for (Packet packet : armorPackets)
|
||||
{
|
||||
entityPlayer.playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
private void prepareChunk(Location loc)
|
||||
{
|
||||
int chunkX = getChunk(loc.getX());
|
||||
@ -1054,4 +1008,28 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
entityPlayer.playerConnection.sendPacket(disguise.GetMetaDataPacket());
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanDisguises(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOWER || _disguisePlayerMap.isEmpty())
|
||||
return;
|
||||
|
||||
for (Iterator<DisguiseBase> disguiseIterator = _disguisePlayerMap.keySet().iterator(); disguiseIterator.hasNext();)
|
||||
{
|
||||
DisguiseBase disguise = disguiseIterator.next();
|
||||
|
||||
if (disguise.GetEntity() instanceof Player && (!((Player)disguise.GetEntity()).isOnline() || !((Player)disguise.GetEntity()).isValid()))
|
||||
disguiseIterator.remove();
|
||||
else
|
||||
{
|
||||
for (Iterator<Player> playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();)
|
||||
{
|
||||
Player player = playerIterator.next();
|
||||
|
||||
if (!player.isOnline() || !player.isValid())
|
||||
playerIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,22 +251,38 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
return;
|
||||
|
||||
for (Player player : _coinQueue.keySet())
|
||||
for (final Player player : _coinQueue.keySet())
|
||||
{
|
||||
String caller = null;
|
||||
int total = 0;
|
||||
String tempCaller = null;
|
||||
int tempTotal = 0;
|
||||
|
||||
for (String curCaller : _coinQueue.get(player).keySet())
|
||||
{
|
||||
caller = curCaller;
|
||||
total += _coinQueue.get(player).get(curCaller);
|
||||
tempCaller = curCaller;
|
||||
tempTotal += _coinQueue.get(player).get(curCaller);
|
||||
}
|
||||
|
||||
final int total = tempTotal;
|
||||
final String caller = tempCaller;
|
||||
|
||||
if (caller == null)
|
||||
continue;
|
||||
|
||||
//Actually Add Gems
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
|
||||
try
|
||||
{
|
||||
//Actually Add Gems
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
System.out.println("Queue Added [" + player + "] with Coins [" + total + "] for [" + caller + "]");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user