Party PR Updates.

This commit is contained in:
TadahTech 2016-07-20 16:18:49 -05:00
parent 67a185acc9
commit 96261c1a6d
9 changed files with 85 additions and 156 deletions

View File

@ -7,50 +7,19 @@ public class InviteData
{
private String _invitedTo;
private String _invitedBy;
private long _timeStamp;
private long _expires;
private String _serverFrom;
public InviteData(String invitedBy, String invitedTo, long timeStamp, String serverFrom)
public InviteData(String invitedTo, String serverFrom)
{
_invitedBy = invitedBy;
_invitedTo = invitedTo;
_timeStamp = timeStamp;
_expires = timeStamp + 60000;
_serverFrom = serverFrom;
}
public long getTimeRemaining()
{
return _expires - System.currentTimeMillis();
}
public boolean hasExpired()
{
return System.currentTimeMillis() >= _expires;
}
public String getInvitedTo()
{
return _invitedTo;
}
public String getInvitedBy()
{
return _invitedBy;
}
public long getTimeStamp()
{
return _timeStamp;
}
public long getExpires()
{
return _expires;
}
public String getServerFrom()
{
return _serverFrom;

View File

@ -1,7 +1,6 @@
package mineplex.core.party;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import org.bukkit.entity.Player;
import java.text.MessageFormat;
@ -58,45 +57,21 @@ public enum Lang
public void send(Player player, String... args)
{
String color = C.mBody;
if(args.length == 0)
{
player.sendMessage(F.main("Party", _message));
return;
}
if(_message.startsWith("Error:"))
{
color = C.cRed;
}
int firstIndex = _message.indexOf("{");
String[] coloredArgs = new String[args.length];
for(int i = 0; i < args.length; i++)
{
coloredArgs[i] = C.cYellow + args[i] + color;
}
String message = MessageFormat.format(_message, coloredArgs);
String coloredRest = message.substring(firstIndex);
message = color + message.substring(0, firstIndex) + coloredRest;
player.sendMessage(C.mHead + "Party> " + message);
player.sendMessage(C.mHead + "Party> " + getFormatted(args));
}
public void send(Party party, String... args)
{
party.sendMessage(C.mHead + "Party> " + getFormatted(args));
}
private String getFormatted(String[] args)
{
String color = C.mBody;
if(args.length == 0)
{
party.sendMessage(F.main("Party", _message));
return;
return _message;
}
if(_message.startsWith("Error:"))
@ -118,9 +93,7 @@ public enum Lang
String coloredRest = message.substring(firstIndex);
message = color + message.substring(0, firstIndex) + coloredRest;
party.sendMessage(C.mHead + "Party> " + message);
return message;
}
}

View File

@ -31,14 +31,14 @@ public class Party
private transient boolean _alreadyTeamed = false;
/**
* The standard _size for parties, for ALL {@code {@link mineplex.core.common.Rank}}
* The standard size for parties, for ALL {@code {@link mineplex.core.common.Rank}}
*/
private transient final int PARTY_MIN_SIZE = 5;
private static final int PARTY_MIN_SIZE = 5;
/**
* An upgrade _size for the party, given to donators and staff.
* An upgraded size for the party, given to donators and staff.
*/
private transient final int PARTY_MAX_SIZE = 10;
private static final int PARTY_MAX_SIZE = 10;
/**
* The current leader of this party
@ -158,7 +158,8 @@ public class Party
}
_members.add(player);
Lang.ADD_MEMBER.send(this, player);
getMembers().stream().forEach(s -> {
getMembers().forEach(s ->
{
Player player1 = Bukkit.getPlayer(s);
player1.playSound(player1.getLocation(), Sound.NOTE_PLING, 1.0F, 10.0F);
});

View File

@ -22,7 +22,7 @@ public class PartyCommand extends CommandBase<PartyManager>
F.main("Party", "Party Commands (Click the command!)"),
help("", "Brings up the Party GUI"),
help("<player>", "Send an invitation to a player."),
help("leave", "Send an invitation to a player."),
help("leave", "Leave your current party."),
C.cBlue + "Party> " + C.cWhite + "#<message> " + C.cGray + "- Send a message to your party.",
C.cGreenB + "All party functions have been moved to the GUI!",
C.cGreenB + "Click the NameTag in your hotbar to get started!"

View File

@ -8,14 +8,16 @@ import mineplex.core.common.util.F;
public enum JoinResponseReason
{
CANNOT_JOIN_FULL(F.main("Party", "Your party cannot join full servers!")),
SUCCESS("");
CANNOT_JOIN_FULL(F.main("Party", "Your party cannot join full servers!"), "no"),
SUCCESS("", "yes");
private String _message;
private String _code;
JoinResponseReason(String message)
JoinResponseReason(String message, String code)
{
_message = message;
_code = code;
}
public String getMessage()
@ -23,4 +25,8 @@ public enum JoinResponseReason
return _message;
}
public String getCode()
{
return _code;
}
}

View File

@ -5,30 +5,11 @@ package mineplex.core.party.constants;
*/
public enum PartyRemoveReason
{
KICKED(1, "kicked"),
LEFT(2, "left"),
OTHER(3, "other"),
DISBANDED(4, "disbanded"),
DISBANDED_BY_OWNER(5, "disbandedByOwner"),
;
KICKED,
LEFT,
OTHER,
DISBANDED,
DISBANDED_BY_OWNER,;
private int _id;
private String _name;
PartyRemoveReason(int id, String name)
{
_id = id;
_name = name;
}
public int getId()
{
return _id;
}
public String getName()
{
return _name;
}
}

View File

@ -209,7 +209,7 @@ public class PartyInviteManager
*/
public void inviteTo(UUID player, String invitedBy, String party, String server)
{
addToInvite(player, invitedBy, party, System.currentTimeMillis(), server);
addToInvite(player, invitedBy, party, server);
_tasks.put(player, new BukkitRunnable()
{
@Override
@ -338,17 +338,16 @@ public class PartyInviteManager
* @param invited The invited players UUUD
* @param invitedBy The person who invited him
* @param party The name of the party invited to
* @param currentTime The time which this invite was initiated
* @param server The server the request is from
*/
private void addToInvite(UUID invited, String invitedBy, String party, long currentTime, String server)
private void addToInvite(UUID invited, String invitedBy, String party, String server)
{
List<InviteData> inviteDatas = _activeInvites.get(invited);
if (inviteDatas == null)
{
inviteDatas = Lists.newArrayList();
}
InviteData inviteData = new InviteData(invitedBy, party, currentTime, server);
InviteData inviteData = new InviteData(party, server);
inviteDatas.add(inviteData);
_invitedBy.put(invited, invitedBy);
_activeInvites.put(invited, inviteDatas);

View File

@ -21,9 +21,6 @@ import java.util.stream.Collectors;
public class PartyJoinManager
{
private final String CANNOT_JOIN = "no";
private final String CAN_JOIN = "yes";
private final PartyManager _plugin;
private final int _maxPLayers;
private final List<UUID> _transferring;
@ -74,12 +71,12 @@ public class PartyJoinManager
//Max number of people on.
if (!canJoinFull)
{
_plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.CANNOT_JOIN_FULL.name(), CANNOT_JOIN, _plugin.getServerName());
_plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.CANNOT_JOIN_FULL.name(), JoinResponseReason.CANNOT_JOIN_FULL.getCode(), _plugin.getServerName());
return;
}
}
_plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.SUCCESS.name(), CAN_JOIN, _plugin.getServerName());
_plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.SUCCESS.name(), JoinResponseReason.SUCCESS.getCode(), _plugin.getServerName());
}
@ -103,7 +100,7 @@ public class PartyJoinManager
{
return;
}
if (response.equalsIgnoreCase(CANNOT_JOIN))
if (response.equalsIgnoreCase(JoinResponseReason.CANNOT_JOIN_FULL.getCode()))
{
party.sendMessage(reason.getMessage());
return;

View File

@ -95,6 +95,7 @@ public class PartyRedisManager
String first = contents[0];
String second = contents[1];
String third = contents[2];
Bukkit.getScheduler().runTask(_plugin.getPlugin(), () -> {
switch (messageType)
{
case INVITE_PLAYER_REQUEST:
@ -150,6 +151,8 @@ public class PartyRedisManager
_plugin.getJoinManager().handleJoinResponse(first, third, contents[3], JoinResponseReason.valueOf(second.toUpperCase()));
break;
}
});
}
/**