Winter MOTD, Stat fixes (maybe?!)
This commit is contained in:
parent
5d59b1a015
commit
c3ace42a68
|
@ -56,11 +56,11 @@ public class MotdManager implements Listener, Runnable
|
||||||
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
|
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
|
||||||
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
|
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
|
||||||
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
|
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
|
||||||
String motdLine = " §f§l◄ §b§lNew Game§f§l ▬ §3§lChampions CTF§f§l ►";
|
String motdLine = " §f❄ §2§lWinter Update §f❄ §2§lSnow Fight §f❄";
|
||||||
//String motdLine = " §d§lRank Sale §a§l40% Off");
|
//String motdLine = " §d§lRank Sale §a§l40% Off");
|
||||||
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
|
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
|
||||||
|
|
||||||
updateMainMotd(" §f§l§m §8§l§m[ §r §6§lMineplex§r §f§lGames§r §8§l§m ]§f§l§m §r", motdLine);
|
updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine);
|
||||||
System.out.println("Updated Bungee MOTD");
|
System.out.println("Updated Bungee MOTD");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,42 +91,15 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||||
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue));
|
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue));
|
||||||
|
|
||||||
// Verify stat is in our local cache, if not add it remotely.
|
// Verify stat is in our local cache, if not add it remotely.
|
||||||
if (!_stats.containsKey(statName))
|
registerNewStat(statName, new Runnable()
|
||||||
{
|
|
||||||
runAsync(new Runnable()
|
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
|
||||||
synchronized (_statSync)
|
|
||||||
{
|
|
||||||
// If many players come in for a new stat, when the first add finishes the others are queued to add again
|
|
||||||
// This makes a second check for the stat name (already added before lock was released)
|
|
||||||
// Then it pops into queue and forgets adding the new stat to db.
|
|
||||||
if (_stats.containsKey(statName))
|
|
||||||
{
|
{
|
||||||
addToQueue(statName, player, value);
|
addToQueue(statName, player, value);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_repository.addStat(statName);
|
|
||||||
|
|
||||||
_stats.clear();
|
|
||||||
|
|
||||||
for (Stat stat : _repository.retrieveStats())
|
|
||||||
{
|
|
||||||
_stats.put(stat.Name, stat.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
addToQueue(statName, player, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
addToQueue(statName, player, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addToQueue(String statName, Player player, long value)
|
private void addToQueue(String statName, Player player, long value)
|
||||||
{
|
{
|
||||||
|
@ -192,17 +165,16 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||||
|
|
||||||
public boolean incrementStat(final int accountId, final String statName, final long value)
|
public boolean incrementStat(final int accountId, final String statName, final long value)
|
||||||
{
|
{
|
||||||
if (_stats.containsKey(statName))
|
// This will register a new stat if we don't have one, otherwise it will just run the callback
|
||||||
return false;
|
registerNewStat(statName, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
|
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
|
||||||
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
|
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
|
||||||
uploadQueue.get(accountId).put(_stats.get(statName), value);
|
uploadQueue.get(accountId).put(_stats.get(statName), value);
|
||||||
|
|
||||||
runAsync(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_repository.saveStats(uploadQueue);
|
_repository.saveStats(uploadQueue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -210,6 +182,35 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerNewStat(final String statName, final Runnable callback)
|
||||||
|
{
|
||||||
|
runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
synchronized (_statSync)
|
||||||
|
{
|
||||||
|
if (_stats.containsKey(statName))
|
||||||
|
{
|
||||||
|
if (callback != null) callback.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_repository.addStat(statName);
|
||||||
|
|
||||||
|
_stats.clear();
|
||||||
|
|
||||||
|
for (Stat stat : _repository.retrieveStats())
|
||||||
|
{
|
||||||
|
_stats.put(stat.Name, stat.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback != null) callback.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public int getStatId(String statName)
|
public int getStatId(String statName)
|
||||||
{
|
{
|
||||||
return _stats.get(statName);
|
return _stats.get(statName);
|
||||||
|
|
Loading…
Reference in New Issue