PC Party updates.

This commit is contained in:
TadahTech 2016-06-22 00:35:57 -05:00
parent e39326b592
commit 4d31867e98
43 changed files with 1326 additions and 334 deletions

View File

@ -0,0 +1,97 @@
package mineplex.core.party;
import mineplex.core.common.util.C;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import static sun.audio.AudioPlayer.player;
/**
* All chat messages for the party system to align with PE
*/
public enum Lang
{
//Party
SUCCESS_SERVER_CONNECT("Sending you and your party to {0}..."),
INVITE_SUCCESS_PLAYER("Successfully invited {0} to the party."),
SUCCESS_INVITE("{0} has invited {1} to the party."),
INVITE_RECEIVED("You have been invited to {0}'s party!"),
INVITE_ACCEPT("{0} has joined the party."),
INVITE_DENY("{0} declined your invite."),
INVITE_EXPIRED("{0} did not respond in time."),
INVITE_EXPIRED_PLAYER("Your invite to {0}'s party has expired."),
SHOW_MEMBERS("Party members: {0}."),
REMOVE_PLAYER("{0} has left the party."),
REMOVE_PLAYER_KICK("{0} has been removed from the party."),
ADD_MEMBER("{0} has joined the party."),
LEFT("You have left your party."),
PARTY_OWNER_LEAVE("{0} has left the party. {1} is the new party owner."),
TRANSFER_OWNER("{0} has given party leadership to {1}."),
DISBANDED("Your party has been disbanded, due to a lack of players."),
REMOVED("You have been removed from the party."),
NOT_EXIST("Error: {0} is not in a party right now."),
ALREADY_MEMBER("Error: {0} is already in the party!"),
NO_PARTY("Error: You are not in a party!"),
ALREADY_IN("Error: You are already in a party! Type {0} to leave."),
NOT_MEMBER("Error: {0} is not a member of your party."),
NOT_INVITED("Error: You do not have a pending invite to {0}'s party."),
NOT_OWNER("Error: You must be the party owner to do this!"),
NOT_OWNER_SERVER("Error: You must be the owner to move servers!"),
ALREADY_INVITED("Error: {0} has already been invited."),
PARTY_FULL("Error: Your party is full!"),
SERVER_CLOSED("Error: Your server is closed and you cannot invite players to join it right now!"),
SERVER_FULL("Error: Your server is full and you cannot invite more players to join it right now!"),
;
private String _message;
Lang(String message)
{
_message = message;
}
public void send(Player player, String... args)
{
String message = _message;
String colored = "";
if(args.length == 0)
{
player.sendMessage(F.main("Party", _message));
return;
}
for(int i = 0; i < args.length; i++)
{
String s = args[i];
message = message.replace("{" + i + "}", F.elem(s));
colored = C.mBody + message;
}
player.sendMessage(C.mHead + "Party> " + colored);
}
public void send(Party party, String... args)
{
String message = _message;
String colored = "";
if(args.length == 0)
{
party.sendMessage(F.main("Party", _message));
return;
}
for(int i = 0; i < args.length; i++)
{
String s = args[i];
message = message.replace("{" + i + "}", F.elem(s));
colored = C.mBody + message;
}
party.sendMessage(C.mHead + "Party> " + colored);
}
}

View File

@ -2,7 +2,13 @@ package mineplex.core.party;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import mineplex.core.chat.Chat;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.party.event.PartyTransferOwnerEvent;
import mineplex.core.party.event.PartyTransferOwnerEvent.TransferReason;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Map;
@ -13,9 +19,17 @@ import java.util.Map;
public class Party
{
private transient boolean _ownerKickMode = false;
private String _owner;
private List<String> _members;
private Map<String, Long> _invites;
private int size;
public Party()
{
}
public Party(String owner)
{
@ -49,4 +63,71 @@ public class Party
{
getMembers().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message));
}
public int getSize()
{
return size;
}
public void setSize(int size)
{
this.size = size;
}
public void onPlayerAdd(String player)
{
_invites.remove(player);
if(_members.contains(player))
{
return;
}
_members.add(player);
Lang.ADD_MEMBER.send(this, player);
}
public void onPlayerRemove(String player, PartyRemoveReason reason)
{
if(reason == PartyRemoveReason.DISBANDED)
{
Player bukkitPlayer = Bukkit.getPlayerExact(player);
Lang.DISBANDED.send(bukkitPlayer);
return;
}
if(_members.size() <= 0)
{
return;
}
if(reason == PartyRemoveReason.LEFT)
{
Lang.REMOVE_PLAYER.send(this, player);
if(player.equalsIgnoreCase(_owner))
{
_owner = _members.get(0);
Lang.TRANSFER_OWNER.send(this, player, _owner);
PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, _owner, player, TransferReason.LEFT);
UtilServer.getServer().getPluginManager().callEvent(event);
}
return;
}
if(reason == PartyRemoveReason.OTHER)
{
return;
}
Lang.REMOVE_PLAYER_KICK.send(this, player);
}
public boolean isOwnerKickMode()
{
return _ownerKickMode;
}
public void setOwnerKickMode(boolean ownerKickMode)
{
_ownerKickMode = ownerKickMode;
}
public void setOwner(String owner)
{
_owner = owner;
}
}

View File

@ -0,0 +1,99 @@
package mineplex.core.party;
import mineplex.core.common.Rank;
import mineplex.core.party.event.PartyMemberKickGUIEvent;
import mineplex.core.party.event.PartyTransferOwnerEvent;
import mineplex.core.party.manager.PartyRedisManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
/**
*
*/
public class PartyEventListener implements Listener
{
private final PartyManager _plugin;
private final PartyRedisManager _redisManager;
public PartyEventListener(PartyManager plugin, PartyRedisManager redisManager)
{
_plugin = plugin;
_redisManager = redisManager;
_plugin.getPluginManager().registerEvents(this, plugin.getPlugin());
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
String partyName = _plugin.getInviteManager().getPartyWaiting(player.getUniqueId());
if(partyName == null)
{
return;
}
Party party = _plugin.getParty(partyName);
Player bukkitPlayer = Bukkit.getPlayerExact(partyName);
if(party == null)
{
party = new Party(partyName);
int size = 5;
if(bukkitPlayer != null && _plugin.getClientManager().Get(bukkitPlayer).GetRank().isDonor())
{
size = 10;
}
party.setSize(size);
_plugin.addParty(party);
}
_plugin.addToParty(Bukkit.getPlayerExact(partyName), party);
_plugin.addToParty(player, party);
_plugin.getInviteManager().removeFromWaiting(player.getUniqueId());
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
Party party = _plugin.getParty(player);
_plugin.getInviteManager().removeAll(player.getUniqueId());
if (party == null)
{
return;
}
_plugin.removeFromParty(player, PartyRemoveReason.LEFT);
}
@EventHandler
public void onTransferOwner(PartyTransferOwnerEvent event)
{
_plugin.transferOwner(event.getNewOwner(), event.getOldOwner());
}
@EventHandler
public void onKick(PartyMemberKickGUIEvent event)
{
_plugin.removeFromParty(Bukkit.getPlayerExact(event.getPlayerClicked()), PartyRemoveReason.KICKED);
}
}

View File

@ -1,6 +1,8 @@
package mineplex.core.party;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.party.command.PartyCommand;
@ -12,6 +14,7 @@ import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.serverdata.Utility;
import mineplex.serverdata.servers.ServerManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -47,9 +50,9 @@ public class PartyManager extends MiniPlugin
_joinManager = new PartyJoinManager(this);
addCommand(new PartyCommand(this));
getPluginManager().registerEvents(new MenuListener(), getPlugin());
new PartyEventListener(this, _redisManager);
}
public Party getParty(String party)
{
return _parties.get(party);
@ -68,6 +71,13 @@ public class PartyManager extends MiniPlugin
public void addToParty(UUID uuid, Party party)
{
_players.put(uuid, party);
Player player = Bukkit.getPlayer(uuid);
party.onPlayerAdd(player.getName());
}
public void addToParty(Player player, Party party)
{
addToParty(player.getUniqueId(), party);
}
public void removeParty(Party party)
@ -75,10 +85,55 @@ public class PartyManager extends MiniPlugin
_parties.remove(party.getName());
}
public void removeFromParty(UUID uuid)
public void removeFromParty(UUID uuid, PartyRemoveReason reason)
{
_players.remove(uuid);
Party party = _players.remove(uuid);
if(party == null)
{
return;
}
Player player = Bukkit.getPlayer(uuid);
party.getMembers().remove(player.getName());
party.onPlayerRemove(player.getName(), reason);
int size = party.getMembers().size();
if(size <= 1)
{
if(size == 0)
{
removeParty(party);
return;
}
_players.remove(Bukkit.getPlayerExact(party.getMembers().get(0)).getUniqueId());
party.onPlayerRemove(party.getMembers().get(0), PartyRemoveReason.DISBANDED);
removeParty(party);
}
}
public void removeFromParty(Player player, PartyRemoveReason reason)
{
removeFromParty(player.getUniqueId(), reason);
}
public void disbandParty(Party party)
{
party.getMembers().stream().map(Bukkit::getPlayer).forEach(player -> removeFromParty(player.getUniqueId(), PartyRemoveReason.KICKED));
removeParty(party);
}
public void transferOwner(String newOwner, String oldOwner)
{
Party party = _parties.remove(oldOwner.toLowerCase());
_parties.put(newOwner.toLowerCase(), party);
party.getMembers().stream().map(Bukkit::getPlayer).forEach(s ->
{
_players.remove(s.getUniqueId());
_players.put(s.getUniqueId(), party);
});
party.setOwner(newOwner);
party.getMembers().remove(oldOwner);
party.getMembers().add(oldOwner);
}
public Portal getPortal()
{
@ -114,4 +169,6 @@ public class PartyManager extends MiniPlugin
{
return _joinManager;
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.party;
/**
*
*/
public enum PartyRemoveReason
{
KICKED(1, "kicked"),
LEFT(2, "left"),
OTHER(3, "other"),
DISBANDED(4, "disbanded"),
;
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

@ -7,8 +7,10 @@ import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.PartyRemoveReason;
import mineplex.core.party.manager.PartyInviteManager;
import mineplex.core.party.ui.menus.PartyMainMenu;
import mineplex.core.party.ui.menus.PartyOwnerMenu;
@ -35,7 +37,7 @@ public class PartyCommand extends CommandBase<PartyManager>
help("leave", "Leave your current party"),
help("kick <player>", "Kick a player from your party."),
help("disband", "Disband your party."),
C.cBlue + "Party> " + C.cWhite + "#<message> " + C.cGray + "- Send a message tp your party."
C.cBlue + "Party> " + C.cWhite + "#<message> " + C.cGray + "- Send a message to your party."
};
public PartyCommand(PartyManager plugin)
@ -126,12 +128,46 @@ public class PartyCommand extends CommandBase<PartyManager>
private void handleInvite(Player caller, String target)
{
Player possible = Bukkit.getPlayer(target);
Player possible = Bukkit.getPlayerExact(target);
Party party = Plugin.getParty(caller);
//Same Server
if (possible != null)
{
if (party == null)
{
Lang.INVITE_SUCCESS_PLAYER.send(caller, target);
} else
{
if(!party.getOwner().equalsIgnoreCase(caller.getName()))
{
Lang.NOT_OWNER.send(caller);
return;
}
if(Plugin.getInviteManager().isInvitedTo(possible.getUniqueId(), party.getName()))
{
Lang.ALREADY_INVITED.send(caller, target);
return;
}
if(party.getMembers().contains(target))
{
Lang.ALREADY_MEMBER.send(caller, target);
return;
}
if(party.getMembers().size() >= party.getSize())
{
Lang.PARTY_FULL.send(caller);
return;
}
Lang.SUCCESS_INVITE.send(party, caller.getName(), target);
}
UUID uuid = possible.getUniqueId();
caller.sendMessage(F.main("Party", "Sent an invite to " + possible.getName() + "..."));
Lang.INVITE_RECEIVED.send(possible, caller.getName(), caller.getName());
Plugin.getInviteManager().inviteTo(uuid, caller.getName(), caller.getName());
Plugin.getInviteManager().sendAcceptOrDeny(possible, caller.getName());
return;
}
@ -145,7 +181,7 @@ public class PartyCommand extends CommandBase<PartyManager>
if (!inviteManager.isInvitedTo(caller.getUniqueId(), target))
{
//He isn't invited to this party.
caller.sendMessage(F.main("Party", "You do not have an invitation to " + F.elem(target)));
Lang.NOT_INVITED.send(caller, target);
return;
}
@ -158,37 +194,35 @@ public class PartyCommand extends CommandBase<PartyManager>
if (party == null)
{
caller.sendMessage(F.main("Party", "You are not in a party! Do /party help to get started."));
Lang.NO_PARTY.send(caller);
return;
}
if (!party.getOwner().equalsIgnoreCase(caller.getName()))
{
caller.sendMessage(F.main("Party", "You must be the leader of the party to do that!"));
Lang.NOT_OWNER.send(caller);
return;
}
Player playerTarget = Bukkit.getPlayer(target);
Player playerTarget = Bukkit.getPlayerExact(target);
if (playerTarget == null)
{
caller.sendMessage(F.main("Party", target + " is not online, and is not in your party!"));
Lang.NOT_MEMBER.send(caller, target);
return;
}
Party targetParty = Plugin.getParty(playerTarget);
if (targetParty == null || party.getMembers().contains(target))
if (targetParty == null ||!party.getMembers().contains(target))
{
caller.sendMessage(F.main("Party", target + " is not a member of your party."));
Lang.NOT_MEMBER.send(caller, target);
return;
}
Plugin.removeFromParty(playerTarget.getUniqueId());
party.getMembers().remove(target);
Plugin.removeFromParty(playerTarget.getUniqueId(), PartyRemoveReason.KICKED);
targetParty.sendMessage(F.main("Party", "You have been removed from " + party.getName() + "."));
party.sendMessage(F.main("Party", caller.getName() + " has removed " + target + " from the party."));
Lang.REMOVE_PLAYER_KICK.send(targetParty);
}
private void handleLeave(Player caller)
@ -197,14 +231,12 @@ public class PartyCommand extends CommandBase<PartyManager>
if (party == null)
{
caller.sendMessage(F.main("Party", "You are not in a party! Do /party help to get started."));
Lang.NO_PARTY.send(caller);
return;
}
party.getMembers().remove(caller.getName());
Plugin.removeFromParty(caller.getUniqueId());
caller.sendMessage(F.main("Party", "You have left " + party.getOwner() + "'s party"));
party.sendMessage(F.main("Party", caller.getName() + " has left the party."));
Plugin.removeFromParty(caller.getUniqueId(), PartyRemoveReason.LEFT);
Lang.LEFT.send(caller);
}
private void handleDisband(Player caller)
@ -213,23 +245,17 @@ public class PartyCommand extends CommandBase<PartyManager>
if (party == null)
{
caller.sendMessage(F.main("Party", "You are not in a party! Do /party help to get started."));
Lang.NO_PARTY.send(caller);
return;
}
if (!party.getOwner().equalsIgnoreCase(caller.getName()))
{
caller.sendMessage(F.main("Party", "You must be the leader of the party to do that!"));
Lang.NOT_OWNER.send(caller);
return;
}
party.sendMessage(F.main("Party", caller.getName() + " has disbanded the party!"));
party.getMembers().stream().map(Bukkit::getPlayer).forEach(player -> Plugin.removeFromParty(player.getUniqueId()));
party.getMembers().clear();
party.getInvites().clear();
Plugin.removeParty(party);
Plugin.disbandParty(party);
}
private String help(String command, String description)

View File

@ -0,0 +1,37 @@
package mineplex.core.party.event;
import mineplex.core.party.Party;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* An event called when a server receives a PartyPacket containing the information about a party
*/
public class PartyDataReceivedEvent extends Event
{
private static final HandlerList HANDLER_LIST = new HandlerList();
private final Party _party;
public PartyDataReceivedEvent(Party party)
{
_party = party;
}
public Party getParty()
{
return _party;
}
@Override
public HandlerList getHandlers()
{
return HANDLER_LIST;
}
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
}

View File

@ -0,0 +1,51 @@
package mineplex.core.party.event;
import mineplex.core.party.Party;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* This event is called when an owner clicks a PartyMemberIcon while having Kick mode activated.
*/
public class PartyMemberKickGUIEvent extends Event
{
private static final HandlerList HANDLER_LIST = new HandlerList();
private final Party _party;
private final String _playerClicked;
private final Player _owner;
public PartyMemberKickGUIEvent(Party party, String playerClicked, Player owner)
{
_party = party;
_playerClicked = playerClicked;
_owner = owner;
}
public String getPlayerClicked()
{
return _playerClicked;
}
public Player getOwner()
{
return _owner;
}
public Party getParty()
{
return _party;
}
@Override
public HandlerList getHandlers()
{
return HANDLER_LIST;
}
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
}

View File

@ -0,0 +1,36 @@
package mineplex.core.party.event;
import mineplex.core.party.Party;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* This event is called when a party owner selects the compass icon.
*/
public class PartySelectServerEvent extends Event
{
private static final HandlerList HANDLER_LIST = new HandlerList();
private final Party _party;
public PartySelectServerEvent(Party party)
{
_party = party;
}
public Party getParty()
{
return _party;
}
@Override
public HandlerList getHandlers()
{
return HANDLER_LIST;
}
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
}

View File

@ -0,0 +1,65 @@
package mineplex.core.party.event;
import mineplex.core.party.Party;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* An event called when an owner leaves a party
*/
public class PartyTransferOwnerEvent extends Event
{
public enum TransferReason
{
LEFT,
TRANSFER;
}
private static final HandlerList HANDLER_LIST = new HandlerList();
private final Party _party;
private final String _newOwner;
private final String _oldOwner;
private final TransferReason _reason;
public PartyTransferOwnerEvent(Party party, String newOwner, String oldOwner, TransferReason reason)
{
_party = party;
_newOwner = newOwner;
_oldOwner = oldOwner;
_reason = reason;
}
public String getNewOwner()
{
return _newOwner;
}
public String getOldOwner()
{
return _oldOwner;
}
public TransferReason getReason()
{
return _reason;
}
public Party getParty()
{
return _party;
}
@Override
public HandlerList getHandlers()
{
return HANDLER_LIST;
}
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
}

View File

@ -2,8 +2,10 @@ package mineplex.core.party.manager;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.party.InviteData;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.redis.RedisMessageType;
@ -42,7 +44,7 @@ public class PartyInviteManager
public String format(String target)
{
return String.format(_message, target);
return C.mHead + "Party> " + F.name(target) + " " + _message.substring(_message.indexOf("}" + 1));
}
}
@ -78,7 +80,7 @@ public class PartyInviteManager
String message = InviteResponse.DENIED.format(player.getName());
if (newParty == null)
{
player.sendMessage(message);
possible.sendMessage(message);
return;
}
newParty.sendMessage(message);
@ -89,10 +91,7 @@ public class PartyInviteManager
newParty = new Party(possible.getName());
_plugin.addParty(newParty);
_plugin.addToParty(possible.getUniqueId(), newParty);
possible.sendMessage(F.main("Party", "Created a new party!"));
}
newParty.getMembers().add(player.getName());
newParty.sendMessage(F.main("Party", player.getName() + " has joined the party"));
_plugin.addToParty(player.getUniqueId(), newParty);
return;
}
@ -114,6 +113,7 @@ public class PartyInviteManager
_players.put(player.getUniqueId(), player.getName());
INVITE_FROM_SERVERS.put(target, serverFrom);
inviteTo(player.getUniqueId(), sender, sender);
Lang.INVITE_RECEIVED.send(player, sender);
sendAcceptOrDeny(player, sender);
}
@ -137,7 +137,6 @@ public class PartyInviteManager
party = new Party(sender);
_plugin.addParty(party);
_plugin.addToParty(player.getUniqueId(), party);
player.sendMessage(F.main("Party", "Created a new party!"));
}
party.sendMessage(message);
addToPendingJoin(targetUUID, party.getName());
@ -147,7 +146,6 @@ public class PartyInviteManager
if (party == null)
{
player.sendMessage(message);
player.sendMessage(F.main("Party", "Party not created."));
return;
}
party.sendMessage(message);
@ -155,6 +153,18 @@ public class PartyInviteManager
}
}
/**
* Remove all references tied with this player
*
* @param player The player's UUID
*/
public void removeAll(UUID player)
{
_players.remove(player);
_invitedBy.remove(player);
_activeInvites.remove(player);
}
/**
* Get the name of the server that this request was initiated from.
*
@ -177,6 +187,16 @@ public class PartyInviteManager
return _awaitingJoin.get(player);
}
/**
* Remove the party reference that invited this player
*
* @param player The player's UUID
*/
public void removeFromWaiting(UUID player)
{
_awaitingJoin.remove(player);
}
/**
* Get the name of the person who has invited the target player
* Used mainly for player locating
@ -296,7 +316,6 @@ public class PartyInviteManager
public void sendAcceptOrDeny(Player player, String arg)
{
player.sendMessage(F.main("Party", "You have received an invite from " + arg));
TextComponent textComponent = new TextComponent(F.main("Party", "Click one: "));
TextComponent accept = new TextComponent("ACCEPT");

View File

@ -64,7 +64,7 @@ public class PartyJoinManager
public void handleJoinRequest(String serverFrom, int partySize, String initiator, boolean canJoinFull)
{
int currentPlayers = UtilServer.getPlayers().length;
if (currentPlayers >= _maxPLayers)
if (currentPlayers >= _maxPLayers || (currentPlayers + partySize) >= _maxPLayers)
{
//Max number of people on.
if (!canJoinFull)
@ -74,6 +74,7 @@ public class PartyJoinManager
return;
}
}
_plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, "yes", "none");
}
@ -95,6 +96,7 @@ public class PartyJoinManager
return;
}
party.sendMessage(F.main("Party", "Transferring servers..."));
_plugin.getRedisManager().sendPartyInfo(server, party);
party.getMembers().stream().map(Bukkit::getPlayer).forEach(player1 -> _plugin.getPortal().sendPlayerToServer(player1, server));
}

View File

@ -1,8 +1,14 @@
package mineplex.core.party.manager;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import mineplex.core.common.util.F;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.PartyRemoveReason;
import mineplex.core.party.event.PartyDataReceivedEvent;
import mineplex.core.party.manager.PartyInviteManager.InviteResponse;
import mineplex.core.party.manager.PartyJoinManager.JoinResponseReason;
import mineplex.core.party.redis.PartyRedisListener;
@ -22,6 +28,8 @@ import java.util.UUID;
*/
public class PartyRedisManager
{
protected final Gson GSON = new GsonBuilder().create();
protected static final String CHANNEL_BASE = "party-pubsub";
protected static final String FIND_PLAYERS_CHANNEL = "party-player-finder";
private final Map<String, BukkitTask> TASKS = Maps.newHashMap();
@ -62,7 +70,7 @@ public class PartyRedisManager
public void handle(RedisMessageType messageType, String message)
{
String[] contents = message.split("-");
if(contents.length < 3)
if (contents.length < 3)
{
return;
}
@ -71,6 +79,10 @@ public class PartyRedisManager
String third = contents[2];
switch (messageType)
{
case PARTY_INFO:
handlePartyInfo(first);
break;
case INVITE_PLAYER_REQUEST:
_inviteManager.handleInviteRequest(second, third, first);
break;
@ -82,26 +94,37 @@ public class PartyRedisManager
case PLAYER_FIND_REQUEST:
Player player = Bukkit.getPlayer(second);
if(player == null)
if (player == null)
{
return;
}
publish(first, RedisMessageType.PLAYER_FIND_RESPONSE,
_serverName, player.getName(), player.getUniqueId().toString(), second);
publish(first, RedisMessageType.PLAYER_FIND_RESPONSE, _serverName, player.getName(), player.getUniqueId().toString(), second);
break;
case PLAYER_FIND_RESPONSE:
UUID uuid = UUID.fromString(third);
BukkitTask task = TASKS.remove(second);
if(task != null)
if (task != null)
{
task.cancel();
}
_inviteManager.inviteTo(uuid, contents[3], contents[3]);
publish(first, RedisMessageType.INVITE_PLAYER_REQUEST, _serverName, contents[3], second);
Player inviter = Bukkit.getPlayerExact(contents[3]);
if (_inviteManager.isInvitedTo(uuid, inviter.getName()))
{
Lang.ALREADY_INVITED.send(inviter, second);
return;
}
if (_plugin.getParty(inviter) == null)
{
Lang.INVITE_SUCCESS_PLAYER.send(inviter, second);
} else
{
Lang.SUCCESS_INVITE.send(_plugin.getParty(inviter), inviter.getName(), second);
}
_inviteManager.inviteTo(uuid, inviter.getName(), inviter.getName());
publish(first, RedisMessageType.INVITE_PLAYER_REQUEST, _serverName, inviter.getName(), second);
break;
case PREJOIN_SERVER_REQUEST:
@ -123,7 +146,7 @@ public class PartyRedisManager
{
TASKS.remove(player);
Player senderPlayer = Bukkit.getPlayerExact(sender);
if(senderPlayer == null)
if (senderPlayer == null)
{
return;
}
@ -139,5 +162,32 @@ public class PartyRedisManager
});
}
public void sendPartyInfo(String server, Party party)
{
publish(server, RedisMessageType.PARTY_INFO, GSON.toJson(party));
_plugin.removeParty(party);
party.getMembers().stream().map(Bukkit::getPlayer).forEach(player -> _plugin.removeFromParty(player.getUniqueId(), PartyRemoveReason.OTHER));
}
public void handlePartyInfo(String json)
{
new BukkitRunnable()
{
@Override
public void run()
{
Party party = GSON.fromJson(json, Party.class);
_plugin.addParty(party);
party.getMembers().forEach(s ->
{
Player player = Bukkit.getPlayerExact(s);
if (player != null)
{
_plugin.addToParty(player, party);
}
});
Bukkit.getServer().getPluginManager().callEvent(new PartyDataReceivedEvent(party));
}
}.runTaskLater(_plugin.getPlugin(), 10L);
}
}

View File

@ -19,7 +19,6 @@ public class PartyRedisListener extends JedisPubSub
@Override
public void onMessage(String channel, String message)
{
System.out.println(channel + " - " + message);
RedisMessageType type = RedisMessageType.valueOf(message.split(":")[0].toUpperCase());
_redisManager.handle(type, message.split(":")[1]);
}

View File

@ -20,7 +20,10 @@ public enum RedisMessageType
//Message: SERVER_FROM-PLAYER_INITIATING-PARTY_SIZE-_CAN_JOIN_FULL
PREJOIN_SERVER_REQUEST(5, "{0}-{1}-{2}-{3}"),
//Message: PLAYER_INITIATING-RESPONSE-REASON-SERVER
PREJOIN_SERVER_RESPONSE(6, "{0}-{1}-{2}-[3}")
PREJOIN_SERVER_RESPONSE(6, "{0}-{1}-{2}-[3}"),
//Message: JSON Party
PARTY_INFO(7, "{0}")
;
private int _id;

View File

@ -1,9 +1,12 @@
package mineplex.core.party.ui;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.button.IconButton;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
@ -19,6 +22,11 @@ import java.util.UUID;
public abstract class Menu
{
protected static final Button PANE = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE)
.setTitle(" ")
.setData(DyeColor.LIGHT_BLUE.getWoolData())
.build(), null);
protected static final Button[] EMPTY = new Button[45];
protected static Map<UUID, Menu> MENUS = new HashMap<>();
private String _name;
@ -37,7 +45,6 @@ public abstract class Menu
return MENUS.get(name);
}
/**
* Create an icon (no click action)
*
@ -54,6 +61,36 @@ public abstract class Menu
return ChatColor.translateAlternateColorCodes('&', _name);
}
public Button[] addPanes(Button[] buttons)
{
for (int i = 0; i < 9; i++)
{
if (buttons[i] == null)
{
buttons[i] = PANE;
}
if(buttons.length == 9)
{
continue;
}
if (buttons[i + buttons.length - 9] == null)
{
buttons[i + buttons.length - 9] = PANE;
}
if (i == 0 || i == 8)
{
for (int a = 9; a < buttons.length; a += 9)
{
buttons[i + a] = PANE;
}
}
}
return buttons;
}
/**
* Open and setup the inventory for the player to view
* Store a reference to it inside a map for retrieving later

View File

@ -1,5 +1,7 @@
package mineplex.core.party.ui;
import mineplex.core.party.ui.button.PartyMemberIcon;
import mineplex.core.party.ui.menus.PartyOwnerMenu;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@ -39,6 +41,16 @@ public class MenuListener implements Listener
return;
}
if(button instanceof PartyMemberIcon)
{
if(!(gui instanceof PartyOwnerMenu))
{
return;
}
((PartyMemberIcon) button).onClick(player, event.getCurrentItem());
return;
}
button.onClick(player, event.getClick());
}

View File

@ -1,10 +1,15 @@
package mineplex.core.party.ui.button;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.event.PartyMemberKickGUIEvent;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.button.tools.PartyButton;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -14,21 +19,31 @@ import org.bukkit.inventory.ItemStack;
/**
* The button representing a Party member.
*/
public class PartyMemberIcon extends IconButton
public class PartyMemberIcon extends PartyButton
{
public PartyMemberIcon(String player, boolean owner)
public PartyMemberIcon(String player, Party party, boolean owner)
{
super(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3)
.setTitle(C.cYellow + player)
.setGlow(owner)
.setPlayerHead(player).build(), null);
.setPlayerHead(player).build(), party, null);
}
public PartyMemberIcon(String player)
public PartyMemberIcon(String player, Party party)
{
this(player, false);
this(player, party, false);
}
public void onClick(Player clicker, ItemStack clicked)
{
String name = ChatColor.stripColor(clicked.getItemMeta().getDisplayName());
UtilServer.getPluginManager().callEvent(new PartyMemberKickGUIEvent(getParty(), name, clicker));
}
@Override
public void onClick(Player player, ClickType clickType)
{
}
}

View File

@ -27,7 +27,8 @@ public class LeavePartyButton extends Button
@Override
public void onClick(Player player, ClickType clickType)
{
player.performCommand("party leave");
player.chat("/party leave");
player.closeInventory();
}
}

View File

@ -1,8 +1,34 @@
package mineplex.core.party.ui.button.tools.main;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.menus.input.PartyInvitePlayerMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class InvitePlayerButton
public class InvitePlayerButton extends Button
{
private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG)
.setTitle(C.cYellow + "Invite a Player")
.setLore(" ", C.cGray + "Invites a player to join", C.cGray + "you in a new party.")
.build();
public InvitePlayerButton(PartyManager plugin)
{
super(ITEM, plugin);
}
@Override
public void onClick(Player player, ClickType clickType)
{
new PartyInvitePlayerMenu(getPlugin(), player).openInventory();
}
}

View File

@ -1,8 +1,35 @@
package mineplex.core.party.ui.button.tools.main;
import mineplex.core.common.util.C;
import mineplex.core.inventory.data.Item;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.menus.PartyInvitesMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class ViewInvitesButton
public class ViewInvitesButton extends Button
{
private static final ItemStack ITEM = new ItemBuilder(Material.BOOK)
.setTitle(C.cYellow + "View Invites")
.setLore(" ", C.cGray + "Manage invites to parties.")
.build();
public ViewInvitesButton(PartyManager plugin)
{
super(ITEM, plugin);
}
@Override
public void onClick(Player player, ClickType clickType)
{
new PartyInvitesMenu(getPlugin()).open(player);
}
}

View File

@ -30,7 +30,7 @@ public class AddPlayerButton extends PartyButton
@Override
public void onClick(Player player, ClickType clickType)
{
new PartyInvitePlayerMenu(getPlugin(), player, getParty()).openInventory();
new PartyInvitePlayerMenu(getPlugin(), player).openInventory();
}
}

View File

@ -1,8 +1,38 @@
package mineplex.core.party.ui.button.tools.owner;
import mineplex.core.common.util.C;
import mineplex.core.inventory.data.Item;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class DisbandPartyButton
public class DisbandPartyButton extends Button
{
private static final ItemStack ITEM = new ItemBuilder(Material.BARRIER)
.setTitle(C.cRedB + "Disband your party")
.setLore(" ", C.cGray + "This will erase your party!", C.cRed + "Shift-Right-Click " + C.cGray + " to disband.")
.build();
public DisbandPartyButton(PartyManager plugin)
{
super(ITEM, plugin);
}
@Override
public void onClick(Player player, ClickType clickType)
{
if(clickType != ClickType.SHIFT_RIGHT)
{
return;
}
player.chat("/party disband");
}
}

View File

@ -1,8 +1,51 @@
package mineplex.core.party.ui.button.tools.owner;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.Party;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.button.tools.PartyButton;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class KickPlayerButton
public class KickPlayerButton extends PartyButton
{
private static final ItemStack ITEM_OFF = new ItemBuilder(Material.IRON_AXE)
.setTitle(C.cYellow + "Kick Player's")
.setLore(" ", C.cRed + "Right Click to enter " + C.cGreen + "Kick Mode",
C.cGray + "While activated, click on a player's head", C.cGray + "to remove them fro the party")
.build();
private static final ItemStack ITEM_ON = new ItemBuilder(Material.IRON_AXE)
.setTitle(C.cYellow + "Kick Player's")
.setLore(" ", C.cGreen + "Right Click to leave " + C.cRed + "Kick Mode",
C.cGray + "While activated, click on a player's head", C.cGray + "to remove them fro the party")
.setGlow(true)
.build();
public KickPlayerButton(Party party)
{
super(ITEM_OFF, party, null);
}
@Override
public void onClick(Player player, ClickType clickType)
{
getParty().setOwnerKickMode(!getParty().isOwnerKickMode());
if (getParty().isOwnerKickMode())
{
setItemStack(ITEM_ON);
} else
{
setItemStack(ITEM_OFF);
}
Menu.get(player.getUniqueId()).update(player);
}
}

View File

@ -1,8 +1,37 @@
package mineplex.core.party.ui.button.tools.owner;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.event.PartySelectServerEvent;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.button.tools.PartyButton;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class SelectServerButton
public class SelectServerButton extends PartyButton
{
private static final ItemStack ITEM = new ItemBuilder(Material.COMPASS)
.setTitle(C.cYellow + "Select Server")
.setLore(" ", C.cGray + "Brings up the Server Selection GUI")
.build();
public SelectServerButton(Party party)
{
super(ITEM, party, null);
}
@Override
public void onClick(Player player, ClickType clickType)
{
UtilServer.getPluginManager().callEvent(new PartySelectServerEvent(getParty()));
}
}

View File

@ -1,8 +1,36 @@
package mineplex.core.party.ui.button.tools.owner;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.button.tools.PartyButton;
import mineplex.core.party.ui.menus.input.PartyTransferOwnerMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class TransferOwnerButton
public class TransferOwnerButton extends PartyButton
{
private static final ItemStack ITEM = new ItemBuilder(Material.BOOK_AND_QUILL)
.setTitle(C.cYellow + "Transfer Ownership")
.setLore(" ", C.cGray + "Transfers ownership of the party", C.cGray + "to another player",
" ", C.cDRed + "This cannot be undone!")
.build();
public TransferOwnerButton(Party party, PartyManager plugin)
{
super(ITEM, party, plugin);
}
@Override
public void onClick(Player player, ClickType clickType)
{
new PartyTransferOwnerMenu(getPlugin(), player, getParty());
}
}

View File

@ -19,6 +19,7 @@ public class PartyInvitesMenu extends Menu
@Override
protected Button[] setUp(Player player)
{
return new Button[0];
Button[] buttons = new Button[54];
return addPanes(buttons);
}
}

View File

@ -3,6 +3,8 @@ package mineplex.core.party.ui.menus;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.button.tools.main.InvitePlayerButton;
import mineplex.core.party.ui.button.tools.main.ViewInvitesButton;
import org.bukkit.entity.Player;
/**
@ -21,6 +23,9 @@ public class PartyMainMenu extends Menu
{
Button[] buttons = new Button[9];
buttons[3] = new InvitePlayerButton(_plugin);
buttons[5] = new ViewInvitesButton(_plugin);
return buttons;
}
}

View File

@ -5,7 +5,7 @@ import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.button.PartyMemberIcon;
import mineplex.core.party.ui.button.tools.owner.AddPlayerButton;
import mineplex.core.party.ui.button.tools.owner.*;
import mineplex.core.party.ui.button.tools.LeavePartyButton;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -33,15 +33,15 @@ public class PartyOwnerMenu extends Menu
//Tools
buttons[1] = new AddPlayerButton(_plugin, _party);
//Kick player
buttons[4] = create(new ItemStack(Material.IRON_AXE));
buttons[4] = new KickPlayerButton(_party);
//Transfer ownership
buttons[7] = create(new ItemStack(Material.BOOK_AND_QUILL));
buttons[7] = new TransferOwnerButton(_party, _plugin);
//Go to server
buttons[46] = create(new ItemStack(Material.COMPASS));
buttons[46] = new SelectServerButton(_party);
//Leave party
buttons[49] = new LeavePartyButton();
//Disband
buttons[52] = create(new ItemStack(Material.BARRIER));
buttons[52] = new DisbandPartyButton(_plugin);
int slot = 20;
//Players
@ -51,9 +51,9 @@ public class PartyOwnerMenu extends Menu
{
slot = 29;
}
buttons[slot++] = new PartyMemberIcon(_party.getMembers().get(i));
buttons[slot++] = new PartyMemberIcon(_party.getMembers().get(i), _party);
}
return buttons;
return addPanes(buttons);
}
}

View File

@ -26,23 +26,23 @@ public class PartyViewMenu extends Menu
@Override
protected Button[] setUp(Player player)
{
Button[] buttons = new Button[36];
Button[] buttons = new Button[54];
//Tools
buttons[1] = new LeavePartyButton();
buttons[3] = new LeavePartyButton();
//Suggest Player
buttons[4] = new SuggestPlayerButton(_party, _plugin);
buttons[5] = new SuggestPlayerButton(_party, _plugin);
int slot = 20;
//Players
for(int i = 0; i < _party.getMembers().size(); i++)
for (int i = 0; i < _party.getMembers().size(); i++)
{
if(slot == 25)
if (slot == 25)
{
slot = 29;
}
buttons[slot++] = new PartyMemberIcon(_party.getMembers().get(i));
buttons[slot++] = new PartyMemberIcon(_party.getMembers().get(i), _party);
}
return buttons;
return addPanes(buttons);
}
}

View File

@ -37,8 +37,7 @@ public abstract class PlayerNameActionMenu implements Listener
_player = player;
_partyManager = partyManager;
_party = party;
openInventory();
player.closeInventory();
_partyManager.registerEvents(this);
}
@ -81,6 +80,7 @@ public abstract class PlayerNameActionMenu implements Listener
{
if (_itemName.length() > 1 && !_searching)
{
_searching = true;
final String name = _itemName;
_partyManager.getClientManager().checkPlayerName(_player, _itemName, result -> {
@ -88,8 +88,7 @@ public abstract class PlayerNameActionMenu implements Listener
if (result != null)
{
onSuccess(name);
unregisterListener();
onSuccess(result);
} else
{
onFail(name);
@ -112,7 +111,6 @@ public abstract class PlayerNameActionMenu implements Listener
public void openInventory()
{
_player.closeInventory();
EntityPlayer p = ((CraftPlayer) _player).getHandle();

View File

@ -1,6 +1,5 @@
package mineplex.core.party.ui.menus.input;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.menus.PartyOwnerMenu;
import mineplex.core.party.ui.menus.PlayerNameActionMenu;
@ -13,17 +12,21 @@ import org.bukkit.entity.Player;
public class PartyInvitePlayerMenu extends PlayerNameActionMenu
{
public PartyInvitePlayerMenu(PartyManager partyManager, Player player, Party party)
public PartyInvitePlayerMenu(PartyManager partyManager, Player player)
{
super(partyManager, player, party);
super(partyManager, player, null);
}
@Override
public void onSuccess(String name)
{
_partyManager.getRedisManager().findAndInvite(name, _player.getName());
_player.chat("/party invite " + name);
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
_player.closeInventory();
if (_partyManager.getParty(_player) == null)
{
return;
}
new PartyOwnerMenu(_party, _partyManager).open(_player);
}

View File

@ -0,0 +1,34 @@
package mineplex.core.party.ui.menus.input;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.menus.PlayerNameActionMenu;
import org.bukkit.entity.Player;
/**
*
*/
public class PartyTransferOwnerMenu extends PlayerNameActionMenu
{
public PartyTransferOwnerMenu(PartyManager partyManager, Player player, Party party)
{
super(partyManager, player, party);
}
@Override
public void onSuccess(String name)
{
_partyManager.transferOwner(name, _player.getName());
Lang.TRANSFER_OWNER.send(_party, _player.getName(), name);
_player.closeInventory();
_player.chat("/party");
}
@Override
public void onFail(String name)
{
}
}

View File

@ -26,13 +26,18 @@ public class PlayerSuggestPlayerMenu extends PlayerNameActionMenu
public void onSuccess(String name)
{
Player player = Bukkit.getPlayerExact(_party.getOwner());
_party.sendMessage(C.mHead + "Party> " + F.name(player.getName()) + " has suggested " + F.name(name) + " be invited.");
_party.sendMessage(C.mHead + "Party> " + F.name(_player.getName()) + " has suggested " + F.name(name) + " be invited.");
ChildJsonMessage message = new ChildJsonMessage("").extra(F.main("Party", "Type or click "));
message.add(F.link("/party invite " + name))
.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Clicking this will invite " + C.cYellow + name + C.cGreen + " to the party")
.click(ClickEvent.RUN_COMMAND, "/party invite " + name);
message.add(C.mBody + " to invite them");
message.sendToPlayer(player);
_player.closeInventory();
_player.chat("/party");
}
@Override

View File

@ -54,7 +54,15 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
@ -97,8 +105,21 @@ import mineplex.core.treasure.TreasureManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.hub.commands.*;
import mineplex.hub.modules.*;
import mineplex.hub.commands.DisguiseCommand;
import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.HubVisibilityManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.KothManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager;
import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.ValentinesManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.profile.gui.GUIProfile;
import mineplex.hub.tutorial.TutorialManager;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
@ -112,36 +133,6 @@ import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
public class HubManager extends MiniClientPlugin<HubClient>
{
@ -197,10 +188,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
// Christmas Songs
private Random _random = new Random();
private int _lastSong = 0;
// private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"};
// private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"};
private final ArrayList<NoteSong> _songs;
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager)
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, BoosterManager boosterManager)
{
super("Hub Manager", plugin);
@ -613,7 +604,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
Rank rank = GetClients().Get(player).GetRank();
if(GetClients().Get(player).isDisguised())
if (GetClients().Get(player).isDisguised())
rank = GetClients().Get(player).getDisguisedRank();
//Level Prefix
@ -622,10 +613,35 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Rank Prefix
String rankStr = "";
if (rank != Rank.ALL)
{
rankStr = rank.getTag(true, true) + " ";
//Party Chat
if (event.getMessage().charAt(0) == '#')
{
Party party = _partyManager.getParty(player);
if (party != null)
{
event.getRecipients().clear();
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s");
for (String name : party.getMembers())
{
Player other = UtilPlayer.searchExact(name);
if (other != null)
{
event.getRecipients().add(other);
}
}
} else
{
UtilPlayer.message(player, F.main("Party", "You are not in a Party."));
event.setCancelled(true);
}
} else
{
TextComponent rankComponent = new TextComponent(rankStr);
TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName);
TextComponent component = new TextComponent();
@ -636,6 +652,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
component.addExtra(rankComponent);
component.addExtra(playerNameText);
component.addExtra(" " + ChatColor.WHITE + event.getMessage());
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.InTutorial(other))
@ -644,10 +661,12 @@ public class HubManager extends MiniClientPlugin<HubClient>
continue;
}
if(!event.isCancelled())
if (!event.isCancelled())
other.spigot().sendMessage(component);
}
event.setCancelled(true);
// }
}
}
@EventHandler

View File

@ -249,7 +249,7 @@ public class NewsManager extends MiniPlugin
}
}
@EventHandler
/* @EventHandler
public void DragonBarUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
@ -296,10 +296,10 @@ public class NewsManager extends MiniPlugin
}
else if (Manager.Type == HubType.Halloween)
{
/**
*//**
* @author Mysticate
* Myst's sexy ass animation :>
*/
*//*
_animationIndex = (_animationIndex + 1) % 147;
@ -457,5 +457,5 @@ public class NewsManager extends MiniPlugin
((MorphWither)gadget).setWitherData(text, healthPercent);
}
}
}
}*/
}

View File

@ -2,16 +2,21 @@ package mineplex.hub.queue.ui;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.party.Party;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.queue.PlayerMatchStatus;
import mineplex.hub.queue.QueueManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.List;
import java.util.stream.Collectors;
public class QueuePage extends ShopPageBase<QueueManager, QueueShop>
{
private boolean _closeOnNextUpdate;
@ -124,9 +129,18 @@ public class QueuePage extends ShopPageBase<QueueManager, QueueShop>
}
private void queuePlayer(int gameType, Player player)
{
Party party = getPlugin().getPartyManager().getParty(player);
if(party == null)
{
getPlugin().queuePlayer(gameType, player);
return;
}
if(party.getOwner().equalsIgnoreCase(player.getName()))
{
List<Player> players = party.getMembers().stream().map(Bukkit::getPlayerExact).collect(Collectors.toList());
getPlugin().queuePlayer(gameType, players.toArray(new Player[players.size()]));
}
buildPage();
}

View File

@ -1,12 +1,16 @@
package mineplex.hub.queue.ui;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.queue.QueueManager;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,15 +32,15 @@ public class QueueShop extends ShopBase<QueueManager>
@Override
protected boolean canOpenShop(Player player)
{
/* Party party = getPlugin().getPartyManager().GetParty(player);
Party party = getPlugin().getPartyManager().getParty(player);
if (party != null && !player.getName().equalsIgnoreCase(party.GetLeader()))
if (party != null && !player.getName().equalsIgnoreCase(party.getOwner()))
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
player.sendMessage(F.main("Party", "Only Party Leaders can join games."));
player.sendMessage(F.main("Party", "Type " + C.cGreen + "/party leave" + C.cGray + " if you wish to leave your party."));
return false;
}*/
}
return true;
}

View File

@ -1,11 +1,15 @@
package mineplex.hub.server.ui;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerManager;
import mineplex.serverdata.data.ServerGroup;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class ServerNpcShop extends ShopBase<ServerManager>
@ -36,15 +40,15 @@ public class ServerNpcShop extends ShopBase<ServerManager>
@Override
protected boolean canOpenShop(Player player)
{
/* Party party = getPlugin().getPartyManager().GetParty(player);
Party party = getPlugin().getPartyManager().getParty(player);
if (party != null && !player.getName().equalsIgnoreCase(party.GetLeader()))
if (party != null && !player.getName().equalsIgnoreCase(party.getOwner()))
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
player.sendMessage(F.main("Party", "Only Party Leaders can join games."));
player.sendMessage(F.main("Party", "Type " + C.cGreen + "/party leave" + C.cGray + " if you wish to leave your party."));
return false;
}*/
}
return true;
}

View File

@ -1,12 +1,15 @@
package mineplex.hub.server.ui.clans;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
import mineplex.hub.server.ServerManager;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class ClanMoveServerShop extends ShopBase<ServerManager>
@ -33,14 +36,14 @@ public class ClanMoveServerShop extends ShopBase<ServerManager>
@Override
protected boolean canOpenShop(Player player)
{
/* Party party = getPlugin().getPartyManager().GetParty(player);
Party party = getPlugin().getPartyManager().getParty(player);
if (party != null)
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
player.sendMessage(F.main("Party", "You cannot join Clans while in a party."));
return false;
}*/
}
return true;
}

View File

@ -1,11 +1,14 @@
package mineplex.hub.server.ui.clans;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.hub.server.ServerManager;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class ClansServerShop extends ShopBase<ServerManager>
@ -28,14 +31,14 @@ public class ClansServerShop extends ShopBase<ServerManager>
@Override
protected boolean canOpenShop(Player player)
{
/* Party party = getPlugin().getPartyManager().GetParty(player);
Party party = getPlugin().getPartyManager().getParty(player);
if (party != null)
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
player.sendMessage(F.main("Party", "You cannot join Clans while in a party."));
return false;
}*/
}
return true;
}

View File

@ -1,7 +1,7 @@
package nautilus.game.arcade.game.games.speedbuilders.data;
import java.util.ArrayList;
import mineplex.core.common.util.*;
import mineplex.core.hologram.Hologram;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -13,14 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Bed;
import org.bukkit.material.Door;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
import java.util.ArrayList;
public class DemolitionData
{

View File

@ -6,10 +6,12 @@ import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.party.Party;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -20,6 +22,7 @@ import org.jooq.tools.json.JSONObject;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
public class GameChatManager implements Listener
{
@ -116,10 +119,10 @@ public class GameChatManager implements Listener
rankStr = rank.getTag(true, true) + " " + C.Reset;
}
/* if (event.getMessage().charAt(0) == '@')
if (event.getMessage().charAt(0) == '#')
{
//Party Chat
Party party = _manager.getPartyManager().GetParty(sender);
Party party = _manager.getPartyManager().getParty(sender);
if (party != null)
{
@ -134,14 +137,14 @@ public class GameChatManager implements Listener
name = C.cWhiteB + sender.getName() + C.Reset;
message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage());
if(safeSend(sender, format, rankStr, rank, name, message, party.GetPlayersOnline()))
if(safeSend(sender, format, rankStr, rank, name, message, party.getMembers().stream().map(Bukkit::getPlayerExact).collect(Collectors.toList())))
{
event.setCancelled(true);
}
return;
}
}*/
}
event.setFormat(levelStr + rankStr + senderName + " " + C.cWhite + "%2$s");