Fix preference ordinal being shifted due to community invite preference being added in the middle, and added region-locking to community names so as to stop EU and US communities from having the same name due to independent redii

This commit is contained in:
AlexTheCoder 2016-12-16 22:47:54 -05:00 committed by cnr
parent eabda7f8c6
commit 07f2679275
4 changed files with 12 additions and 12 deletions

View File

@ -97,7 +97,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
Region region = _us ? Region.US : Region.EU;
_serverRepo = ServerManager.getServerRepository(region);
_repo = new CommunityRepository(plugin, StatusRepository);
_repo = new CommunityRepository(plugin, StatusRepository, _us);
_loadedCommunities = new ConcurrentHashMap<>();
@ -624,9 +624,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
@Override
public String getQuery(int accountId, String uuid, String name)
{
//String query = "SELECT c.*, cm.communityId, cm.communityRole, cs.settingId, cs.settingValue FROM communityMembers cm INNER JOIN communities c ON c.id=cm.communityId INNER JOIN communitySettings cs ON cs.communityId=c.id;";
//return query;
return "SELECT communityId, communityRole FROM communityMembers WHERE accountId=" + accountId + ";";//BEING REPLACED WITH AN INNER JOIN TO LOAD THE COMMUNITY AS WELL
return "SELECT communityId, communityRole FROM communityMembers WHERE accountId=" + accountId + ";";
}
@Override

View File

@ -2,7 +2,6 @@ package mineplex.core.communities.commands;
import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
import mineplex.core.Managers;

View File

@ -28,9 +28,9 @@ import mineplex.serverdata.database.column.ColumnVarChar;
public class CommunityRepository extends MinecraftRepository
{
private static final String GET_ALL_COMMUNITIES = "SELECT * FROM communities;";
private static final String GET_ALL_COMMUNITIES = "SELECT * FROM communities WHERE region=?;";
private static final String GET_COMMUNITY_BY_ID = "SELECT * FROM communities WHERE id=?;";
private static final String GET_COMMUNITY_BY_NAME = "SELECT * FROM communities WHERE name=?;";
private static final String GET_COMMUNITY_BY_NAME = "SELECT * FROM communities WHERE name=? AND region=?;";
private static final String GET_COMMUNITY_MEMBERS = "SELECT cm.accountId, cm.communityRole, ac.name, ac.uuid, ac.lastLogin, now(), cm.readingChat, (SELECT COUNT(id) FROM communityMembers WHERE accountId=cm.accountId AND communityRole='LEADER') FROM communityMembers cm INNER JOIN accounts ac ON ac.id=cm.accountId WHERE communityId=?;";
private static final String GET_COMMUNITY_JOIN_REQUESTS = "SELECT cjr.accountId, ac.name, ac.uuid FROM communityJoinRequests cjr INNER JOIN accounts ac ON ac.id=cjr.accountId WHERE communityId=?;";
private static final String GET_COMMUNITY_SETTINGS = "SELECT settingId, settingValue FROM communitySettings WHERE communityId=?;";
@ -45,17 +45,19 @@ public class CommunityRepository extends MinecraftRepository
private static final String ADD_JOIN_REQUEST = "INSERT INTO communityJoinRequests (accountId, communityId) VALUES (?, ?);";
private static final String REMOVE_JOIN_REQUEST = "DELETE FROM communityJoinRequests WHERE accountId=? AND communityId=?;";
private static final String CREATE_COMMUNITY = "INSERT INTO communities (name) VALUES (?);";
private static final String CREATE_COMMUNITY = "INSERT INTO communities (name, region) VALUES (?, ?);";
private static final String SET_READING_CHAT_IN = "UPDATE communityMembers SET readingChat=? WHERE accountId=? AND communityId=?;";
private DataRepository<PlayerStatus> _repo;
private boolean _us;
public CommunityRepository(JavaPlugin plugin, DataRepository<PlayerStatus> statusRepo)
public CommunityRepository(JavaPlugin plugin, DataRepository<PlayerStatus> statusRepo, boolean us)
{
super(DBPool.getAccount());
_repo = statusRepo;
_us = us;
}
public void loadCommunity(int communityId, final Map<Integer, Community> communityMap)
@ -189,7 +191,7 @@ public class CommunityRepository extends MinecraftRepository
communityMap.clear();
communityMap.putAll(resultant);
});
}, new ColumnVarChar("region", 5, _us ? "US" : "EU"));
}
public void updateMembersAndJoinRequests(LinkedList<Community> communities)
@ -382,7 +384,7 @@ public class CommunityRepository extends MinecraftRepository
{
idCallback.run(-1);
}
}, new ColumnVarChar("name", 15, name));
}, new ColumnVarChar("name", 15, name), new ColumnVarChar("region", 5, _us ? "US" : "EU"));
}
public void deleteCommunity(int communityId)

View File

@ -34,7 +34,6 @@ public enum Preference
PENDING_FRIEND_REQUESTS(true, PreferenceCategory.SOCIAL, Material.RED_ROSE, "Show Pending Friend Requests"),
FRIENDS_DISPLAY_INVENTORY_UI(true, PreferenceCategory.SOCIAL, Material.CHEST, "Display Friend GUI"),
COMMUNITY_INVITES(true, PreferenceCategory.SOCIAL, Material.BOOK, "Show Community Invites"),
CLAN_TIPS(true, PreferenceCategory.MISC, Material.IRON_SWORD, "Show Clan Tips"),
HUB_MUSIC(true, PreferenceCategory.MISC, Material.NOTE_BLOCK, "Hub Music"),
@ -42,6 +41,8 @@ public enum Preference
AUTO_JOIN_NEXT_GAME(true, PreferenceCategory.GAME_PLAY, Material.DIAMOND_SWORD, "Auto Join Next Game", "Feel like playing again?", "Enable this, and when you're out", "a 15 second timer will start", "when it ends, it'll send you", "to another game!"),
DISABLE_WARNING(true, PreferenceCategory.GAME_PLAY, Material.BARRIER, "Disable Automatic Warning", "Know what you're doing?", "Disable this to not receive", "a message warning you about Auto-Join"),
COUNTDOWN_ON_CLICK(false, PreferenceCategory.GAME_PLAY, Material.WATCH, "Countdown to Join", "See that fancy text when you're out?", "If you click it, and this is enabled", "a 15 second time will countdown", "until you are sent to a new game"),
COMMUNITY_INVITES(true, PreferenceCategory.SOCIAL, Material.BOOK, "Show Community Invites"),
;
private static final Map<Integer, Preference> PREFERENCE_MAP = Maps.newHashMap();