Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
c02adc0232
@ -310,6 +310,8 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
|
||||
|
||||
String senderRank = F.rank(_clientManager.Get(to).GetRank());
|
||||
|
||||
// Inform Admins
|
||||
for (Player staff : UtilServer.getPlayers())
|
||||
{
|
||||
@ -321,7 +323,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
globalMessage.getRank() + " " + globalMessage.getSender() + C.cPurple + " -> "
|
||||
|
||||
+ F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " "
|
||||
+ senderRank + " " + to.getName() + " "
|
||||
|
||||
+ C.cPurple + globalMessage.getMessage());
|
||||
}
|
||||
@ -329,9 +331,8 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
}
|
||||
|
||||
// Message the sender
|
||||
RedisMessageCallback message = new RedisMessageCallback(globalMessage, C.cPurple + "-> "
|
||||
+ F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple
|
||||
+ globalMessage.getMessage(), to.getName());
|
||||
RedisMessageCallback message = new RedisMessageCallback(globalMessage, senderRank, to.getName(), C.cPurple + "-> "
|
||||
+ senderRank + " " + to.getName() + " " + C.cPurple + globalMessage.getMessage());
|
||||
|
||||
message.publish();
|
||||
}
|
||||
@ -342,7 +343,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
if (canMessage != null)
|
||||
{
|
||||
|
||||
RedisMessageCallback message = new RedisMessageCallback(globalMessage, canMessage, null);
|
||||
RedisMessageCallback message = new RedisMessageCallback(globalMessage, null, null, canMessage);
|
||||
|
||||
message.publish();
|
||||
|
||||
@ -356,8 +357,8 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
|
||||
|
||||
// Message the sender
|
||||
RedisMessageCallback message = new RedisMessageCallback(globalMessage, C.cGold + "§l" + globalMessage.getSender()
|
||||
+ " > " + to.getName() + C.cYellow + " §l" + globalMessage.getMessage(), to.getName());
|
||||
RedisMessageCallback message = new RedisMessageCallback(globalMessage, null, to.getName(), C.cGold + "§l"
|
||||
+ globalMessage.getSender() + " > " + to.getName() + C.cYellow + " §l" + globalMessage.getMessage());
|
||||
|
||||
message.publish();
|
||||
}
|
||||
@ -391,6 +392,29 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
Get(target).LastTo = message.getLastReplied();
|
||||
}
|
||||
}
|
||||
|
||||
if (message.isStaffMessage() && message.getLastReplied() != null)
|
||||
{
|
||||
String recevierRank = F.rank(_clientManager.Get(target).GetRank());
|
||||
|
||||
// Inform Admins
|
||||
for (Player staff : UtilServer.getPlayers())
|
||||
{
|
||||
if (!target.equals(staff))
|
||||
{
|
||||
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(staff,
|
||||
|
||||
recevierRank + " " + message.getLastReplied() + C.cPurple + " -> "
|
||||
|
||||
+ message.getRank() + " " + message.getLastReplied() + " "
|
||||
|
||||
+ C.cPurple + message.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,16 +12,16 @@ public class RedisMessageCallback extends ServerCommand
|
||||
private String _message;
|
||||
private String _setLastMessage;
|
||||
private String _target;
|
||||
private String _rank;
|
||||
private UUID _uuid;
|
||||
private boolean _staffMessage;
|
||||
|
||||
public RedisMessageCallback(RedisMessage globalMessage, String message, String setLastReplied)
|
||||
public RedisMessageCallback(RedisMessage globalMessage, String rank, String receivedPlayer, String message)
|
||||
{
|
||||
_target = globalMessage.getSender();
|
||||
_message = message;
|
||||
_setLastMessage = setLastReplied;
|
||||
_setLastMessage = receivedPlayer;
|
||||
_uuid = globalMessage.getUUID();
|
||||
_staffMessage = globalMessage.isStaffMessage();
|
||||
_rank = rank;
|
||||
|
||||
if (globalMessage.getSendingServer() != null)
|
||||
{
|
||||
@ -29,9 +29,14 @@ public class RedisMessageCallback extends ServerCommand
|
||||
}
|
||||
}
|
||||
|
||||
public String getRank()
|
||||
{
|
||||
return _rank;
|
||||
}
|
||||
|
||||
public boolean isStaffMessage()
|
||||
{
|
||||
return _staffMessage;
|
||||
return getRank() != null;
|
||||
}
|
||||
|
||||
public String getLastReplied()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.hub.party;
|
||||
package mineplex.core.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -10,6 +11,10 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.party.redis.RedisPartyData;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,59 +24,81 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
public class Party
|
||||
public class Party
|
||||
{
|
||||
private PartyManager Manager;
|
||||
|
||||
private PartyManager _manager;
|
||||
private boolean _isHub;
|
||||
|
||||
private String _creator = null;
|
||||
|
||||
|
||||
private ArrayList<String> _players = new ArrayList<String>();
|
||||
private NautHashMap<String, Long> _invitee = new NautHashMap<String, Long>();
|
||||
|
||||
private Scoreboard _scoreboard;
|
||||
private Objective _scoreboardObj;
|
||||
private ArrayList<String> _scoreboardLast = new ArrayList<String>();
|
||||
|
||||
|
||||
private long _partyOfflineTimer = -1;
|
||||
|
||||
private long _informNewLeaderTimer = -1;
|
||||
|
||||
public Party(PartyManager manager, RedisPartyData partyData)
|
||||
{
|
||||
this(manager);
|
||||
|
||||
_players = new ArrayList(Arrays.asList(partyData.getPlayers()));
|
||||
_creator = partyData.getLeader();
|
||||
}
|
||||
|
||||
public Party(PartyManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
//Scoreboard
|
||||
_scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||
_scoreboardObj = _scoreboard.registerNewObjective("Party", "dummy");
|
||||
_scoreboardObj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
_scoreboard.registerNewTeam(ChatColor.GREEN + "Members");
|
||||
|
||||
//Scoreboard Ranks
|
||||
for (Rank rank : Rank.values())
|
||||
_manager = manager;
|
||||
Region region = manager.GetPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
String groupName = manager.GetPlugin().getConfig().getString("serverstatus.group");
|
||||
|
||||
ServerGroup serverGroup = ServerManager.getServerRepository(region).getServerGroup(groupName);
|
||||
|
||||
if (serverGroup == null)
|
||||
return;
|
||||
|
||||
_isHub = !serverGroup.getArcadeGroup();
|
||||
|
||||
if (_isHub)
|
||||
{
|
||||
if (rank != Rank.ALL)
|
||||
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " ");
|
||||
else
|
||||
_scoreboard.registerNewTeam(rank.Name).setPrefix("");
|
||||
}
|
||||
|
||||
_scoreboard.registerNewTeam("Party").setPrefix(ChatColor.LIGHT_PURPLE + C.Bold + "Party" + ChatColor.RESET + " ");
|
||||
|
||||
//Add Players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
_scoreboard.getTeam(Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
// Scoreboard
|
||||
_scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||
_scoreboardObj = _scoreboard.registerNewObjective("Party", "dummy");
|
||||
_scoreboardObj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
_scoreboard.registerNewTeam(ChatColor.GREEN + "Members");
|
||||
|
||||
// Scoreboard Ranks
|
||||
for (Rank rank : Rank.values())
|
||||
{
|
||||
if (rank != Rank.ALL)
|
||||
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " ");
|
||||
else
|
||||
_scoreboard.registerNewTeam(rank.Name).setPrefix("");
|
||||
}
|
||||
|
||||
_scoreboard.registerNewTeam("Party").setPrefix(ChatColor.LIGHT_PURPLE + C.Bold + "Party" + ChatColor.RESET + " ");
|
||||
|
||||
// Add Players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
_scoreboard.getTeam(_manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void JoinParty(Player player)
|
||||
{
|
||||
//Add Leader
|
||||
// Add Leader
|
||||
if (_players.isEmpty())
|
||||
{
|
||||
_players.add(player.getName());
|
||||
|
||||
UtilPlayer.message(player, F.main("Party", "You created a new Party."));
|
||||
|
||||
|
||||
_creator = player.getName();
|
||||
}
|
||||
else
|
||||
@ -81,85 +108,94 @@ public class Party
|
||||
|
||||
Announce(F.elem(player.getName()) + " has joined the party!");
|
||||
}
|
||||
|
||||
_scoreboard.getTeam("Party").addPlayer(player);
|
||||
|
||||
if (_isHub)
|
||||
{
|
||||
_scoreboard.getTeam("Party").addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void InviteParty(Player player, boolean inviteeInParty)
|
||||
{
|
||||
_invitee.put(player.getName(), System.currentTimeMillis());
|
||||
|
||||
//Decline
|
||||
// Decline
|
||||
if (_players.contains(player.getName()))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Party", F.name(player.getName()) + " is already in the Party."));
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
|
||||
}
|
||||
|
||||
//Announce
|
||||
// Announce
|
||||
Announce(F.name(player.getName()) + " has been invited to your Party.");
|
||||
|
||||
//Inform
|
||||
// Inform
|
||||
UtilPlayer.message(player, F.main("Party", F.name(GetLeader()) + " invited you to their Party."));
|
||||
|
||||
//Instruct
|
||||
|
||||
// Instruct
|
||||
if (inviteeInParty)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Party", "Type " + F.link("/party leave") + " then " + F.link("/party " + GetLeader()) + " to join."));
|
||||
UtilPlayer.message(player,
|
||||
F.main("Party", "Type " + F.link("/party leave") + " then " + F.link("/party " + GetLeader()) + " to join."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Party", "Type " + F.link("/party " + GetLeader()) + " to join."));
|
||||
}
|
||||
|
||||
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1.5f);
|
||||
}
|
||||
|
||||
public void LeaveParty(Player player)
|
||||
{
|
||||
//Announce
|
||||
// Announce
|
||||
Announce(F.name(player.getName()) + " has left the Party.");
|
||||
|
||||
boolean leader = player.equals(GetLeader());
|
||||
|
||||
_players.remove(player.getName());
|
||||
|
||||
//Set Scoreboard
|
||||
_scoreboard.getTeam(Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
|
||||
|
||||
if (_isHub)
|
||||
{
|
||||
// Set Scoreboard
|
||||
_scoreboard.getTeam(_manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
}
|
||||
|
||||
if (leader && _players.size() > 0)
|
||||
{
|
||||
Announce("Party Leadership passed on to " + F.name(GetLeader()) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void KickParty(String player)
|
||||
{
|
||||
//Announce
|
||||
// Announce
|
||||
Announce(F.name(player) + " was kicked from the Party.");
|
||||
|
||||
|
||||
_players.remove(player);
|
||||
}
|
||||
|
||||
public void PlayerJoin(Player player)
|
||||
{
|
||||
//Scoreboard
|
||||
if (_players.contains(player.getName()))
|
||||
_scoreboard.getTeam("Party").addPlayer(player);
|
||||
else if (Manager.GetClients().Get(player) != null)
|
||||
_scoreboard.getTeam(Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
|
||||
if (_isHub)
|
||||
{
|
||||
// Scoreboard
|
||||
if (_players.contains(player.getName()))
|
||||
_scoreboard.getTeam("Party").addPlayer(player);
|
||||
else if (_manager.GetClients().Get(player) != null)
|
||||
_scoreboard.getTeam(_manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
}
|
||||
|
||||
if (_creator.equals(player.getName()))
|
||||
{
|
||||
_players.remove(player.getName());
|
||||
_players.add(0, player.getName());
|
||||
|
||||
|
||||
Announce("Party Leadership returned to " + F.name(GetLeader()) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
//Shuffle Leader
|
||||
// Shuffle Leader
|
||||
public void PlayerQuit(Player player)
|
||||
{
|
||||
if (player.getName().equals(GetLeader()))
|
||||
@ -167,7 +203,10 @@ public class Party
|
||||
_players.remove(player.getName());
|
||||
_players.add(0, player.getName());
|
||||
|
||||
Announce("Party Leadership passed on to " + F.name(GetLeader()) + ".");
|
||||
if (_informNewLeaderTimer < System.currentTimeMillis())
|
||||
{
|
||||
Announce("Party Leadership passed on to " + F.name(GetLeader()) + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +215,7 @@ public class Party
|
||||
for (String name : _players)
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(name);
|
||||
|
||||
|
||||
if (player != null && player.isOnline())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Party", message));
|
||||
@ -192,7 +231,7 @@ public class Party
|
||||
while (inviteeIterator.hasNext())
|
||||
{
|
||||
String name = inviteeIterator.next();
|
||||
|
||||
|
||||
if (UtilTime.elapsed(_invitee.get(name), 60000))
|
||||
{
|
||||
Announce(F.name(name) + " did not respond to the Party invite.");
|
||||
@ -205,7 +244,7 @@ public class Party
|
||||
{
|
||||
if (_players.isEmpty())
|
||||
return _creator;
|
||||
|
||||
|
||||
return _players.get(0);
|
||||
}
|
||||
|
||||
@ -213,11 +252,11 @@ public class Party
|
||||
{
|
||||
return _players;
|
||||
}
|
||||
|
||||
|
||||
public Collection<Player> GetPlayersOnline()
|
||||
{
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
|
||||
for (String name : _players)
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(name);
|
||||
@ -235,77 +274,80 @@ public class Party
|
||||
|
||||
public void UpdateScoreboard()
|
||||
{
|
||||
_scoreboardObj.setDisplayName(GetLeader() + "'s Party");
|
||||
|
||||
//Clear Past
|
||||
for (String pastLine : _scoreboardLast)
|
||||
_scoreboard.resetScores(pastLine);
|
||||
_scoreboardLast.clear();
|
||||
|
||||
int i=16;
|
||||
|
||||
//Add New
|
||||
for (int j=0 ; j<_players.size() ; j++)
|
||||
if (_isHub)
|
||||
{
|
||||
String name = _players.get(j);
|
||||
Player player = UtilPlayer.searchExact(name);
|
||||
|
||||
ChatColor col = ChatColor.GREEN;
|
||||
if (player == null)
|
||||
col = ChatColor.RED;
|
||||
|
||||
String line = col + name;
|
||||
|
||||
if (line.length() > 16)
|
||||
line = line.substring(0, 16);
|
||||
_scoreboardObj.setDisplayName(GetLeader() + "'s Party");
|
||||
|
||||
_scoreboardObj.getScore(line).setScore(i);
|
||||
// Clear Past
|
||||
for (String pastLine : _scoreboardLast)
|
||||
_scoreboard.resetScores(pastLine);
|
||||
_scoreboardLast.clear();
|
||||
|
||||
_scoreboardLast.add(line);
|
||||
int i = 16;
|
||||
|
||||
i--;
|
||||
}
|
||||
|
||||
//Add New
|
||||
for (String name : _invitee.keySet())
|
||||
{
|
||||
int time = 1 + (int) ((60000 - (System.currentTimeMillis() - _invitee.get(name)))/1000);
|
||||
|
||||
String line = time + " " + ChatColor.GRAY + name;
|
||||
|
||||
if (line.length() > 16)
|
||||
line = line.substring(0, 16);
|
||||
|
||||
_scoreboardObj.getScore(line).setScore(i);
|
||||
|
||||
_scoreboardLast.add(line);
|
||||
|
||||
i--;
|
||||
}
|
||||
|
||||
//Set Scoreboard
|
||||
for (String name : _players)
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(name);
|
||||
|
||||
if (player != null)
|
||||
// Add New
|
||||
for (int j = 0; j < _players.size(); j++)
|
||||
{
|
||||
if (!player.getScoreboard().equals(_scoreboard))
|
||||
String name = _players.get(j);
|
||||
Player player = UtilPlayer.searchExact(name);
|
||||
|
||||
ChatColor col = ChatColor.GREEN;
|
||||
if (player == null)
|
||||
col = ChatColor.RED;
|
||||
|
||||
String line = col + name;
|
||||
|
||||
if (line.length() > 16)
|
||||
line = line.substring(0, 16);
|
||||
|
||||
_scoreboardObj.getScore(line).setScore(i);
|
||||
|
||||
_scoreboardLast.add(line);
|
||||
|
||||
i--;
|
||||
}
|
||||
|
||||
// Add New
|
||||
for (String name : _invitee.keySet())
|
||||
{
|
||||
int time = 1 + (int) ((60000 - (System.currentTimeMillis() - _invitee.get(name))) / 1000);
|
||||
|
||||
String line = time + " " + ChatColor.GRAY + name;
|
||||
|
||||
if (line.length() > 16)
|
||||
line = line.substring(0, 16);
|
||||
|
||||
_scoreboardObj.getScore(line).setScore(i);
|
||||
|
||||
_scoreboardLast.add(line);
|
||||
|
||||
i--;
|
||||
}
|
||||
|
||||
// Set Scoreboard
|
||||
for (String name : _players)
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(name);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
player.setScoreboard(_scoreboard);
|
||||
}
|
||||
if (!player.getScoreboard().equals(_scoreboard))
|
||||
{
|
||||
player.setScoreboard(_scoreboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsDead()
|
||||
public boolean IsDead()
|
||||
{
|
||||
if (_players.size() == 0)
|
||||
return true;
|
||||
|
||||
|
||||
if (_players.size() == 1 && _invitee.size() == 0)
|
||||
return true;
|
||||
|
||||
|
||||
int online = 0;
|
||||
for (String name : _players)
|
||||
{
|
||||
@ -313,9 +355,8 @@ public class Party
|
||||
if (player != null)
|
||||
online++;
|
||||
}
|
||||
|
||||
|
||||
//One or Less Members Online - Expirey Countdown
|
||||
// One or Less Members Online - Expirey Countdown
|
||||
if (online <= 1)
|
||||
{
|
||||
if (_partyOfflineTimer == -1)
|
||||
@ -324,13 +365,24 @@ public class Party
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UtilTime.elapsed(_partyOfflineTimer, 3600000)) // 1 hour
|
||||
if (UtilTime.elapsed(_partyOfflineTimer, online == 0 ? 15000 : 120000)) // 15 seconds for no players, 2 minutes if
|
||||
// one player.
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetWaitingTime()
|
||||
{
|
||||
_partyOfflineTimer = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void switchedServer()
|
||||
{
|
||||
_informNewLeaderTimer = System.currentTimeMillis() + 5000;
|
||||
}
|
||||
}
|
@ -1,8 +1,20 @@
|
||||
package mineplex.hub.party;
|
||||
package mineplex.core.party;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.party.commands.PartyCommand;
|
||||
import mineplex.core.party.redis.RedisPartyData;
|
||||
import mineplex.core.party.redis.RedisPartyHandler;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.portal.ServerTransferEvent;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -10,39 +22,37 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.party.commands.PartyCommand;
|
||||
|
||||
public class PartyManager extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private PreferencesManager _preferenceManager;
|
||||
|
||||
private Portal _portal;
|
||||
|
||||
public HashSet<Party> _parties = new HashSet<Party>();
|
||||
|
||||
public PartyManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferenceManager)
|
||||
|
||||
public PartyManager(JavaPlugin plugin, Portal portal, CoreClientManager clientManager, PreferencesManager preferenceManager)
|
||||
{
|
||||
super("Party Manager", plugin);
|
||||
|
||||
|
||||
_portal = portal;
|
||||
_clientManager = clientManager;
|
||||
_preferenceManager = preferenceManager;
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("RedisPartyData", RedisPartyData.class,
|
||||
new RedisPartyHandler(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void AddCommands()
|
||||
public void AddCommands()
|
||||
{
|
||||
addCommand(new PartyCommand(this));
|
||||
}
|
||||
|
||||
|
||||
public CoreClientManager GetClients()
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
|
||||
public PreferencesManager getPreferenceManager()
|
||||
{
|
||||
return _preferenceManager;
|
||||
@ -53,10 +63,50 @@ public class PartyManager extends MiniPlugin
|
||||
Party party = new Party(this);
|
||||
party.JoinParty(player);
|
||||
_parties.add(party);
|
||||
|
||||
|
||||
return party;
|
||||
}
|
||||
|
||||
|
||||
public void addParty(Party party)
|
||||
{
|
||||
for (Party parties : _parties)
|
||||
{
|
||||
if (parties.GetLeader().equalsIgnoreCase(party.GetLeader()))
|
||||
{
|
||||
parties.resetWaitingTime();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_parties.add(party);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverTransfer(ServerTransferEvent event)
|
||||
{
|
||||
for (Party party : _parties)
|
||||
{
|
||||
if (party.GetLeader().equals(event.getPlayer().getName()))
|
||||
{
|
||||
party.switchedServer();
|
||||
|
||||
RedisPartyData data = new RedisPartyData(party, event.getServer());
|
||||
data.publish();
|
||||
|
||||
for (Player player : party.GetPlayersOnline())
|
||||
{
|
||||
if (player != event.getPlayer())
|
||||
{
|
||||
_portal.sendPlayerToServer(player, event.getServer());
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void PlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
@ -72,7 +122,7 @@ public class PartyManager extends MiniPlugin
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void PlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -81,31 +131,31 @@ public class PartyManager extends MiniPlugin
|
||||
party.PlayerQuit(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void Update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
|
||||
ExpireParties();
|
||||
|
||||
|
||||
for (Party party : _parties)
|
||||
{
|
||||
party.ExpireInvitees();
|
||||
party.UpdateScoreboard();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ExpireParties()
|
||||
{
|
||||
Iterator<Party> partyIterator = _parties.iterator();
|
||||
|
||||
|
||||
while (partyIterator.hasNext())
|
||||
{
|
||||
Party party = partyIterator.next();
|
||||
|
||||
//Empty Party
|
||||
|
||||
// Empty Party
|
||||
if (party.IsDead())
|
||||
{
|
||||
party.Announce("Your Party has been closed.");
|
||||
@ -114,7 +164,7 @@ public class PartyManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public Party GetParty(Player player)
|
||||
public Party GetParty(Player player)
|
||||
{
|
||||
for (Party party : _parties)
|
||||
{
|
||||
@ -123,7 +173,7 @@ public class PartyManager extends MiniPlugin
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
package mineplex.hub.party.commands;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
package mineplex.core.party.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.party.Party;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartyCommand extends CommandBase<PartyManager>
|
||||
{
|
@ -0,0 +1,29 @@
|
||||
package mineplex.core.party.redis;
|
||||
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
|
||||
public class RedisPartyData extends ServerCommand
|
||||
{
|
||||
|
||||
private String[] _players;
|
||||
private String _leader;
|
||||
|
||||
public RedisPartyData(Party party, String newServer)
|
||||
{
|
||||
_players = party.GetPlayers().toArray(new String[0]);
|
||||
_leader = party.GetLeader();
|
||||
|
||||
setTargetServers(newServer);
|
||||
}
|
||||
|
||||
public String[] getPlayers()
|
||||
{
|
||||
return _players;
|
||||
}
|
||||
|
||||
public String getLeader()
|
||||
{
|
||||
return _leader;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.party.redis;
|
||||
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
|
||||
public class RedisPartyHandler implements CommandCallback
|
||||
{
|
||||
private PartyManager _partyManager;
|
||||
|
||||
public RedisPartyHandler(PartyManager partyManager)
|
||||
{
|
||||
_partyManager = partyManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
RedisPartyData data = (RedisPartyData) command;
|
||||
|
||||
_partyManager.addParty(new Party(_partyManager, data));
|
||||
}
|
||||
|
||||
}
|
@ -80,6 +80,9 @@ public class Portal extends MiniPlugin
|
||||
if (_connectingPlayers.contains(player.getName()))
|
||||
return;
|
||||
|
||||
ServerTransferEvent event = new ServerTransferEvent(player, serverName);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
final boolean override = serverName.equalsIgnoreCase("Lobby");
|
||||
final Rank playerRank = _clientManager.Get(player).GetRank();
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
package mineplex.core.portal;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class ServerTransferEvent extends Event
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
private Player _player;
|
||||
private String _server;
|
||||
|
||||
public ServerTransferEvent(Player player, String server)
|
||||
{
|
||||
_player = player;
|
||||
_server = server;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public String getServer()
|
||||
{
|
||||
return _server;
|
||||
}
|
||||
|
||||
}
|
@ -68,12 +68,12 @@ public class Teleport extends MiniPlugin
|
||||
runnable.cancel();
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayerExact(callback.getTarget());
|
||||
Player player = Bukkit.getPlayerExact(callback.getReceivingPlayer());
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Locate" + "> " + C.mBody + "Located [" + C.mElem
|
||||
+ callback.getPlayer() + C.mBody + "] at ");
|
||||
+ callback.getLocatedPlayer() + C.mBody + "] at ");
|
||||
|
||||
message.add(C.cBlue + callback.getServer()).click(ClickEvent.RUN_COMMAND,
|
||||
"/server " + callback.getServer());
|
||||
|
@ -6,24 +6,24 @@ import mineplex.serverdata.ServerCommand;
|
||||
|
||||
public class RedisLocateCallback extends ServerCommand
|
||||
{
|
||||
private String _player;
|
||||
private String _locatedPlayer;
|
||||
private String _server;
|
||||
private String _target;
|
||||
private String _receivingPlayer;
|
||||
private UUID _uuid;
|
||||
|
||||
public RedisLocateCallback(RedisLocate command, String server)
|
||||
public RedisLocateCallback(RedisLocate command, String server, String targetName)
|
||||
{
|
||||
_uuid = command.getUUID();
|
||||
_target = command.getSender();
|
||||
_player = command.getTarget();
|
||||
_receivingPlayer = command.getSender();
|
||||
_locatedPlayer = targetName;
|
||||
_server = server;
|
||||
|
||||
setTargetServers(command.getServer());
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
public String getLocatedPlayer()
|
||||
{
|
||||
return _player;
|
||||
return _locatedPlayer;
|
||||
}
|
||||
|
||||
public String getServer()
|
||||
@ -31,9 +31,9 @@ public class RedisLocateCallback extends ServerCommand
|
||||
return _server;
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
public String getReceivingPlayer()
|
||||
{
|
||||
return _target;
|
||||
return _receivingPlayer;
|
||||
}
|
||||
|
||||
public UUID getUUID()
|
||||
|
@ -28,7 +28,7 @@ public class RedisLocateHandler implements CommandCallback
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
RedisLocateCallback callback = new RedisLocateCallback(locate, _serverName);
|
||||
RedisLocateCallback callback = new RedisLocateCallback(locate, _serverName, target.getName());
|
||||
callback.publish();
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.personalServer.PersonalServerManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
@ -42,7 +43,6 @@ import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
@ -98,9 +98,10 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
//Main Modules
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
|
||||
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
|
||||
|
||||
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());
|
||||
|
||||
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
||||
|
||||
IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal);
|
||||
|
@ -70,6 +70,8 @@ import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
@ -92,8 +94,6 @@ import mineplex.hub.modules.TextManager;
|
||||
import mineplex.hub.modules.UHCManager;
|
||||
import mineplex.hub.modules.VisibilityManager;
|
||||
import mineplex.hub.modules.WorldManager;
|
||||
import mineplex.hub.party.Party;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
import mineplex.hub.poll.PollManager;
|
||||
import mineplex.hub.tutorial.TutorialManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
|
@ -17,9 +17,9 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
|
||||
public class QueueManager extends MiniPlugin
|
||||
{
|
||||
|
@ -6,10 +6,10 @@ import java.util.List;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
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.party.Party;
|
||||
import mineplex.hub.queue.PlayerMatchStatus;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
|
||||
|
@ -5,11 +5,11 @@ import java.util.Iterator;
|
||||
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.party.Party;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -42,6 +42,8 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
@ -50,8 +52,6 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.party.Party;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.queue.ui.QueueShop;
|
||||
import mineplex.hub.server.ui.LobbyShop;
|
||||
@ -505,53 +505,7 @@ public class ServerManager extends MiniPlugin
|
||||
{
|
||||
Party party = _partyManager.GetParty(player);
|
||||
|
||||
if (party != null)
|
||||
{
|
||||
if (player.getName().equals(party.GetLeader()))
|
||||
{
|
||||
for (String name : party.GetPlayers())
|
||||
{
|
||||
Player partyPlayer = UtilPlayer.searchExact(name);
|
||||
|
||||
if (partyPlayer == null)
|
||||
continue;
|
||||
|
||||
if (!_clientManager.Get(partyPlayer).GetRank().Has(Rank.MODERATOR) && serverInfo.CurrentPlayers >= serverInfo.MaxPlayers * 1.5)
|
||||
continue;
|
||||
|
||||
if (_clientManager.Get(partyPlayer).GetRank().Has(Rank.ULTRA) || _donationManager.Get(partyPlayer.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA"))
|
||||
continue;
|
||||
|
||||
if (serverInfo.Name.contains("T_"))
|
||||
continue;
|
||||
|
||||
partyPlayer.leaveVehicle();
|
||||
partyPlayer.eject();
|
||||
|
||||
_portal.sendPlayerToServer(partyPlayer, serverInfo.Name);
|
||||
}
|
||||
|
||||
for (String name : party.GetPlayers())
|
||||
{
|
||||
Player partyPlayer = UtilPlayer.searchExact(name);
|
||||
|
||||
if (partyPlayer == null)
|
||||
continue;
|
||||
|
||||
if (!_clientManager.Get(partyPlayer).GetRank().Has(Rank.MODERATOR) && serverInfo.CurrentPlayers >= serverInfo.MaxPlayers * 1.5)
|
||||
continue;
|
||||
|
||||
if (_clientManager.Get(partyPlayer).GetRank().Has(Rank.ULTRA) || _donationManager.Get(partyPlayer.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA"))
|
||||
{
|
||||
partyPlayer.leaveVehicle();
|
||||
partyPlayer.eject();
|
||||
|
||||
_portal.sendPlayerToServer(partyPlayer, serverInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (party == null || player.getName().equals(party.GetLeader()))
|
||||
{
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
|
@ -7,9 +7,9 @@ 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.party.Party;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
|
||||
public class ServerNpcShop extends ShopBase<ServerManager>
|
||||
|
@ -31,6 +31,7 @@ import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
@ -122,6 +123,8 @@ public class Arcade extends JavaPlugin
|
||||
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
||||
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);
|
||||
cosmeticManager.setInterfaceSlot(7);
|
||||
|
||||
PartyManager partyManager = new PartyManager(this, portal, _clientManager, preferenceManager);
|
||||
|
||||
//Arcade Manager
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress);
|
||||
|
Loading…
Reference in New Issue
Block a user