Implement more backend for communities and add a command base

This commit is contained in:
AlexTheCoder 2016-11-20 17:37:34 -05:00 committed by cnr
parent 0007ffc91e
commit a2fb0bb491
9 changed files with 158 additions and 6 deletions

View File

@ -4,7 +4,7 @@ import org.bukkit.ChatColor;
public class Community
{
public Community()
public Community(int id, String name)
{
}

View File

@ -5,7 +5,15 @@ import mineplex.core.common.util.Callback;
public enum CommunitySetting
{
;
CHAT_MESSAGE_COLOR(new Callback<Pair<String, Community>>()
{
public void run(Pair<String, Community> pair)
{
String value = pair.getLeft();
Community community = pair.getRight();
}
});
private Callback<Pair<String, Community>> _parser;

View File

@ -0,0 +1,21 @@
package mineplex.core.communities.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.core.communities.CommunityManager;
public class CommunityCommand extends MultiCommandBase<CommunityManager>
{
public CommunityCommand(CommunityManager plugin)
{
super(plugin, Rank.TITAN, "com");
}
@Override
protected void Help(Player caller, String[] args)
{
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.communities.redis;
import mineplex.serverdata.commands.ServerCommand;
public class CommunityUpdateMemberRole extends ServerCommand
{
private Integer _communityId;
private String _playerUUID;
private String _memberRole;
public CommunityUpdateMemberRole(Integer communityId, String playerUUID, String memberRole)
{
_communityId = communityId;
_playerUUID = playerUUID;
_memberRole = memberRole;
}
public Integer getCommunityId()
{
return _communityId;
}
public String getPlayerUUID()
{
return _playerUUID;
}
public String getMemberRole()
{
return _memberRole;
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.communities.redis;
import java.util.UUID;
import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityRole;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class CommunityUpdateMemberRoleHandler implements CommandCallback
{
private CommunityManager _manager;
public CommunityUpdateMemberRoleHandler(CommunityManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (command instanceof CommunityUpdateMemberRole)
{
CommunityUpdateMemberRole update = ((CommunityUpdateMemberRole) command);
Integer id = update.getCommunityId();
UUID uuid = UUID.fromString(update.getPlayerUUID());
CommunityRole role = CommunityRole.parseRole(update.getMemberRole());
}
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.communities.redis;
import mineplex.serverdata.commands.ServerCommand;
public class CommunityUpdateMembership extends ServerCommand
{
private Integer _communityId;
private String _playerUUID;
private boolean _kick;
public CommunityUpdateMembership(Integer communityId, String playerUUID, boolean kick)
{
_communityId = communityId;
_playerUUID = playerUUID;
_kick = kick;
}
public Integer getCommunityId()
{
return _communityId;
}
public String getPlayerUUID()
{
return _playerUUID;
}
public boolean isKick()
{
return _kick;
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.communities.redis;
import java.util.UUID;
import mineplex.core.communities.CommunityManager;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class CommunityUpdateMembershipHandler implements CommandCallback
{
private CommunityManager _manager;
public CommunityUpdateMembershipHandler(CommunityManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (command instanceof CommunityUpdateMembership)
{
CommunityUpdateMembership update = ((CommunityUpdateMembership) command);
Integer id = update.getCommunityId();
UUID uuid = UUID.fromString(update.getPlayerUUID());
boolean kick = update.isKick();
}
}
}

View File

@ -23,7 +23,6 @@ public class CommunityUpdateSettingHandler implements CommandCallback
Integer id = update.getCommunityId();
CommunitySetting setting = CommunitySetting.valueOf(update.getSetting());
String newValue = update.getNewValue();
_manager.reloadCommunity(update.getCommunityId());
}
}
}

View File

@ -12,9 +12,10 @@ import mineplex.serverdata.database.column.ColumnVarChar;
public class CommunityRepository extends MinecraftRepository
{
private static final String GET_ALL_COMMUNITIES = "";
private static final String GET_COMMUNITY_BY_ID = "";
private static final String GET_COMMUNITY_BY_NAME = "";
private static final String GET_ALL_COMMUNITIES_FOR_BROWSER = "SELECT * FROM communities WHERE memberTotal > 4;";
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_MEMBERS = "SELECT accountId, communityRole FROM communityMembers WHERE communityId=?;";
public CommunityRepository(JavaPlugin plugin)
{