Implementing suggested code style/locking changes and recommitting (JIRA-76)
This commit is contained in:
parent
661a869116
commit
63f082b424
@ -23,8 +23,12 @@ public class SimpleStats extends MiniPlugin
|
|||||||
_repository.initialize();
|
_repository.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NautHashMap<String, String> get_entries() {
|
public NautHashMap<String, String> getEntries()
|
||||||
return _entries;
|
{
|
||||||
|
synchronized (_transferLock)
|
||||||
|
{
|
||||||
|
return _entries;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -33,16 +37,16 @@ public class SimpleStats extends MiniPlugin
|
|||||||
if (updateEvent.getType() != UpdateType.SLOW)
|
if (updateEvent.getType() != UpdateType.SLOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
synchronized (_transferLock)
|
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
public void run()
|
||||||
{
|
{
|
||||||
public void run()
|
synchronized (_transferLock)
|
||||||
{
|
{
|
||||||
_entries = (_repository.retrieveStatRecords());
|
_entries = (_repository.retrieveStatRecords());
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void store(String statName, String statValue)
|
public void store(String statName, String statValue)
|
||||||
@ -50,15 +54,15 @@ public class SimpleStats extends MiniPlugin
|
|||||||
final String statNameFinal = statName;
|
final String statNameFinal = statName;
|
||||||
final String statValueFinal = statValue;
|
final String statValueFinal = statValue;
|
||||||
|
|
||||||
synchronized (_transferLock)
|
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
public void run()
|
||||||
{
|
{
|
||||||
public void run()
|
synchronized (_transferLock)
|
||||||
{
|
{
|
||||||
_repository.storeStatValue(statNameFinal, statValueFinal);
|
_repository.storeStatValue(statNameFinal, statValueFinal);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,6 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class SimpleStatsRepository
|
public class SimpleStatsRepository
|
||||||
{
|
{
|
||||||
private static Object _connectionLock = new Object();
|
private static Object _connectionLock = new Object();
|
||||||
|
Loading…
Reference in New Issue
Block a user