Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/gem-hunters

This commit is contained in:
Sam 2016-12-27 18:59:03 +00:00
commit 4c7f5c5716
7 changed files with 56 additions and 48 deletions

View File

@ -85,8 +85,6 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
private volatile boolean _cycling = false; private volatile boolean _cycling = false;
private volatile boolean _updateJoinRequests = false;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public CommunityManager(JavaPlugin plugin, CoreClientManager clientManager) public CommunityManager(JavaPlugin plugin, CoreClientManager clientManager)
{ {
@ -141,13 +139,8 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
LinkedList<Community> communities = new LinkedList<>(); LinkedList<Community> communities = new LinkedList<>();
_loadedCommunities.values().forEach(community -> communities.add(community)); _loadedCommunities.values().forEach(community -> communities.add(community));
_repo.updateMembers(communities); _repo.updateMembersAndJoinRequests(communities);
if (_updateJoinRequests) }, 0L, 20 * 10);
{
_repo.updateJoinRequests(communities);
}
_updateJoinRequests = !_updateJoinRequests;
}, 0L, 20 * 7);
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
{ {

View File

@ -2,13 +2,13 @@ package mineplex.core.communities.storage;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -144,21 +144,31 @@ public class CommunityRepository extends MinecraftRepository
} }
} }
public void updateMembers(LinkedList<Community> communities) public void updateMembersAndJoinRequests(List<Community> communities)
{ {
if (communities.isEmpty()) if (communities.isEmpty())
{ {
return; return;
} }
TimingManager.start("member elements");
TimingManager.start("members + join requests");
Map<String, PlayerStatus> statuses = _repo.getElementsMap(
Stream.concat(
communities.stream().flatMap(community -> community.getMembers().keySet().stream()),
communities.stream().flatMap(community -> community.getJoinRequests().keySet().stream())
)
.distinct()
.map(UUID::toString)
.collect(Collectors.toList())
);
for (Community c : communities) for (Community c : communities)
{ {
List<CommunityMemberInfo> members = new ArrayList<>(c.getMembers().values()); // Update member player status
List<PlayerStatus> statuses = _repo.getElementsSequential(members.stream().map(info -> info.UUID.toString()).collect(Collectors.toList())); for (Map.Entry<UUID,CommunityMemberInfo> entry : c.getMembers().entrySet())
for (int i = 0; i < members.size(); i++)
{ {
CommunityMemberInfo info = members.get(i); CommunityMemberInfo info = entry.getValue();
PlayerStatus status = statuses.get(i); PlayerStatus status = statuses.get(entry.getKey().toString());
boolean online = false; boolean online = false;
String server = ""; String server = "";
@ -180,25 +190,13 @@ public class CommunityRepository extends MinecraftRepository
} }
} }
} }
}
TimingManager.stop("member elements");
}
public void updateJoinRequests(LinkedList<Community> communities) // Update join request names
for (Map.Entry<UUID,CommunityJoinRequestInfo> entry : c.getJoinRequests().entrySet())
{ {
if (communities.isEmpty())
{ CommunityJoinRequestInfo info = entry.getValue();
return; PlayerStatus status = statuses.get(entry.getKey().toString());
}
TimingManager.start("request elements");
for (Community c : communities)
{
List<CommunityJoinRequestInfo> requests = new ArrayList<>(c.getJoinRequests().values());
List<PlayerStatus> statuses = _repo.getElementsSequential(requests.stream().map(info -> info.UUID.toString()).collect(Collectors.toList()));
for (int i = 0; i < requests.size(); i++)
{
CommunityJoinRequestInfo info = requests.get(i);
PlayerStatus status = statuses.get(i);
if (status != null) if (status != null)
{ {
@ -209,6 +207,15 @@ public class CommunityRepository extends MinecraftRepository
} }
} }
} }
TimingManager.stop("members + join requests");
}
public void updateJoinRequests(LinkedList<Community> communities)
{
if (communities.isEmpty())
{
return;
}
TimingManager.stop("request elements"); TimingManager.stop("request elements");
} }

View File

@ -2,12 +2,14 @@ package mineplex.mapparser;
public enum GameType public enum GameType
{ {
//Mini // Stand Alone
Other("Other"), Other("Other"),
Unknown("Unknown"), Unknown("Unknown"),
Lobby("Lobby"), Lobby("Lobby"),
Event("Mineplex Event"), Event("Mineplex Event"),
GemHunters("Gem Hunters"),
// Games
BaconBrawl("Bacon Brawl"), BaconBrawl("Bacon Brawl"),
Barbarians("A Barbarians Life"), Barbarians("A Barbarians Life"),
Bridge("The Bridges"), Bridge("The Bridges"),
@ -69,11 +71,11 @@ public enum GameType
Wizards("Wizards"), Wizards("Wizards"),
ZombieSurvival("Zombie Survival"), ZombieSurvival("Zombie Survival"),
// Build States
Upload("Upload"), Upload("Upload"),
Submissions("Submissions"), Submissions("Submissions"),
InProgress("In Progress"), InProgress("In Progress"),
None("None"); None("None");
String _name; String _name;

View File

@ -2,6 +2,7 @@ package mineplex.serverdata.data;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* DataRepository is used to store {@link Data} objects in a central database * DataRepository is used to store {@link Data} objects in a central database
@ -19,7 +20,7 @@ public interface DataRepository<T extends Data>
public Collection<T> getElements(Collection<String> dataIds); public Collection<T> getElements(Collection<String> dataIds);
public List<T> getElementsSequential(List<String> dataIds); public Map<String,T> getElementsMap(List<String> dataIds);
public void addElement(T element, int timeout); public void addElement(T element, int timeout);

View File

@ -2,8 +2,10 @@ package mineplex.serverdata.redis;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import mineplex.serverdata.Region; import mineplex.serverdata.Region;
@ -104,9 +106,9 @@ public class RedisDataRepository<T extends Data> extends RedisRepository impleme
} }
@Override @Override
public List<T> getElementsSequential(List<String> dataIds) public Map<String,T> getElementsMap(List<String> dataIds)
{ {
List<T> elements = new ArrayList<>(); Map<String,T> elements = new HashMap<>();
try(Jedis jedis = getResource(false)) try(Jedis jedis = getResource(false))
{ {
@ -121,12 +123,15 @@ public class RedisDataRepository<T extends Data> extends RedisRepository impleme
// Block until all requests have received pipelined responses // Block until all requests have received pipelined responses
pipeline.sync(); pipeline.sync();
for (Response<String> response : responses) for (int i = 0; i < responses.size(); i++)
{ {
String key = dataIds.get(i);
Response<String> response = responses.get(i);
String serializedData = response.get(); String serializedData = response.get();
T element = deserialize(serializedData); T element = deserialize(serializedData);
elements.add(element); elements.put(key, element);
} }
} }

View File

@ -292,7 +292,7 @@ public abstract class Game implements Listener
public long PrepareTime = 9000; public long PrepareTime = 9000;
public boolean PlaySoundGameStart = true; public boolean PlaySoundGameStart = true;
public double XpMult = 1; public double XpMult = 2;
public boolean SpeedMeasurement = false; public boolean SpeedMeasurement = false;

View File

@ -44,7 +44,7 @@ public class GameRewardManager implements Listener
{ {
ArcadeManager Manager; ArcadeManager Manager;
boolean DoubleGem = false; boolean DoubleGem = true;
boolean TimeReward = true; boolean TimeReward = true;
public GameRewardManager(ArcadeManager manager) public GameRewardManager(ArcadeManager manager)
@ -352,7 +352,7 @@ public class GameRewardManager implements Listener
//Double Gem //Double Gem
if (DoubleGem && game.GemDoubleEnabled) if (DoubleGem && game.GemDoubleEnabled)
{ {
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend")); UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Holiday Double Gems"));
totalGems += earnedGems; totalGems += earnedGems;
} }