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

View File

@ -2,13 +2,13 @@ package mineplex.core.communities.storage;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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())
{
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)
{
List<CommunityMemberInfo> members = new ArrayList<>(c.getMembers().values());
List<PlayerStatus> statuses = _repo.getElementsSequential(members.stream().map(info -> info.UUID.toString()).collect(Collectors.toList()));
for (int i = 0; i < members.size(); i++)
// Update member player status
for (Map.Entry<UUID,CommunityMemberInfo> entry : c.getMembers().entrySet())
{
CommunityMemberInfo info = members.get(i);
PlayerStatus status = statuses.get(i);
CommunityMemberInfo info = entry.getValue();
PlayerStatus status = statuses.get(entry.getKey().toString());
boolean online = false;
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())
{
return;
}
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);
CommunityJoinRequestInfo info = entry.getValue();
PlayerStatus status = statuses.get(entry.getKey().toString());
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");
}

View File

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

View File

@ -2,6 +2,7 @@ package mineplex.serverdata.data;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 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 List<T> getElementsSequential(List<String> dataIds);
public Map<String,T> getElementsMap(List<String> dataIds);
public void addElement(T element, int timeout);

View File

@ -2,8 +2,10 @@ package mineplex.serverdata.redis;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import mineplex.serverdata.Region;
@ -104,9 +106,9 @@ public class RedisDataRepository<T extends Data> extends RedisRepository impleme
}
@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))
{
@ -121,12 +123,15 @@ public class RedisDataRepository<T extends Data> extends RedisRepository impleme
// Block until all requests have received pipelined responses
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();
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 boolean PlaySoundGameStart = true;
public double XpMult = 1;
public double XpMult = 2;
public boolean SpeedMeasurement = false;

View File

@ -44,7 +44,7 @@ public class GameRewardManager implements Listener
{
ArcadeManager Manager;
boolean DoubleGem = false;
boolean DoubleGem = true;
boolean TimeReward = true;
public GameRewardManager(ArcadeManager manager)
@ -352,7 +352,7 @@ public class GameRewardManager implements Listener
//Double Gem
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;
}