Work towards another memory fix.
This commit is contained in:
parent
5a57c5f372
commit
a7f77c09fe
@ -1,59 +1,102 @@
|
|||||||
package mineplex.core.memory;
|
package mineplex.core.memory;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import net.minecraft.server.v1_7_R4.CraftingManager;
|
import net.minecraft.server.v1_7_R4.CraftingManager;
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityTracker;
|
||||||
import net.minecraft.server.v1_7_R4.IInventory;
|
import net.minecraft.server.v1_7_R4.IInventory;
|
||||||
|
import net.minecraft.server.v1_7_R4.IntHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class MemoryFix
|
public class MemoryFix extends MiniPlugin
|
||||||
{
|
{
|
||||||
private JavaPlugin _plugin;
|
private static Field _intHashMap;
|
||||||
|
|
||||||
public MemoryFix(JavaPlugin plugin)
|
public MemoryFix(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
_plugin = plugin;
|
super("Memory Fix", plugin);
|
||||||
|
|
||||||
_plugin.getServer().getScheduler().scheduleSyncRepeatingTask(_plugin, new Runnable()
|
//_intHashMap = IntHashMap.class.
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void fixInventoryLeaks(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SLOW)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
public void run()
|
for (Object tileEntity : ((CraftWorld)world).getHandle().tileEntityList)
|
||||||
{
|
{
|
||||||
for (World world : Bukkit.getWorlds())
|
if (tileEntity instanceof IInventory)
|
||||||
{
|
{
|
||||||
for (Object tileEntity : ((CraftWorld)world).getHandle().tileEntityList)
|
Iterator<HumanEntity> entityIterator = ((IInventory)tileEntity).getViewers().iterator();
|
||||||
|
|
||||||
|
while (entityIterator.hasNext())
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof IInventory)
|
HumanEntity entity = entityIterator.next();
|
||||||
|
|
||||||
|
if (entity instanceof CraftPlayer && !((CraftPlayer)entity).isOnline())
|
||||||
{
|
{
|
||||||
Iterator<HumanEntity> entityIterator = ((IInventory)tileEntity).getViewers().iterator();
|
entityIterator.remove();
|
||||||
|
|
||||||
while (entityIterator.hasNext())
|
|
||||||
{
|
|
||||||
HumanEntity entity = entityIterator.next();
|
|
||||||
|
|
||||||
if (entity instanceof CraftPlayer && !((CraftPlayer)entity).isOnline())
|
|
||||||
{
|
|
||||||
entityIterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100L, 100L);
|
}
|
||||||
|
|
||||||
_plugin.getServer().getScheduler().scheduleSyncRepeatingTask(_plugin, new Runnable()
|
CraftingManager.getInstance().lastCraftView = null;
|
||||||
|
CraftingManager.getInstance().lastRecipe = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void fixEntityTrackerLeak(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SLOW)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// NEED TO FIX STUCK NETWORKMANAGERS.....
|
||||||
|
/*
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
public void run()
|
EntityTracker tracker = ((CraftWorld)world).getHandle().getTracker();
|
||||||
{
|
|
||||||
CraftingManager.getInstance().lastCraftView = null;
|
EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) tracker.trackedEntities.d(entity.getId());
|
||||||
CraftingManager.getInstance().lastRecipe = null;
|
|
||||||
}
|
if (entitytrackerentry1 != null) {
|
||||||
}, 100L, 100L);
|
this.c.remove(entitytrackerentry1);
|
||||||
|
entitytrackerentry1.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entity instanceof EntityPlayer) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||||
|
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
|
||||||
|
|
||||||
|
entitytrackerentry.a(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) this.trackedEntities.d(entity.getId());
|
||||||
|
|
||||||
|
if (entitytrackerentry1 != null) {
|
||||||
|
this.c.remove(entitytrackerentry1);
|
||||||
|
entitytrackerentry1.a();
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user