Remove unnecessary database calls that checked for siege weapons remaining in the database, which is not possible, as siege weapons clean themselves up.

This commit is contained in:
Ben 2016-04-07 08:06:16 +01:00
parent eed3df720a
commit 9ccec50fd0
1 changed files with 1 additions and 23 deletions

View File

@ -1,7 +1,5 @@
package mineplex.game.clans.clans.siege; package mineplex.game.clans.clans.siege;
import java.util.Stack;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -188,8 +186,6 @@ public class SiegeManager extends MiniPlugin
private void saveSiegeWeapons() private void saveSiegeWeapons()
{ {
final Stack<Runnable> queue = new Stack<>();
for (final SiegeWeapon weapon : LiveSiegeWeapons.values()) for (final SiegeWeapon weapon : LiveSiegeWeapons.values())
{ {
final SiegeWeaponToken token = weapon.toToken(); final SiegeWeaponToken token = weapon.toToken();
@ -197,28 +193,10 @@ public class SiegeManager extends MiniPlugin
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId))) if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
continue; continue;
queue.push(() -> { runAsync(() -> {
_repository.updateWeapon(token); _repository.updateWeapon(token);
}); });
} }
runAsync(() -> {
while (!queue.isEmpty())
{
queue.pop().run();
}
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> {
tokens.forEach(token -> {
if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)) && !UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
{
System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting.");
_repository.deleteWeapon(token.UniqueId);
}
});
});
});
} }
@EventHandler @EventHandler