Improve party system
This commit is contained in:
parent
53bb67ec4f
commit
56e03221ad
@ -6,6 +6,9 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||
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.common.util.NautHashMap;
|
||||
@ -15,6 +18,8 @@ import mineplex.core.party.redis.RedisPartyData;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.transfers.ServerTransfer;
|
||||
import mineplex.serverdata.transfers.TransferCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -29,7 +34,8 @@ public class Party
|
||||
private PartyManager _manager;
|
||||
private boolean _isHub;
|
||||
|
||||
private String _creator = null;
|
||||
private String _creator;
|
||||
private String _previousServer;
|
||||
|
||||
private ArrayList<String> _players = new ArrayList<String>();
|
||||
private NautHashMap<String, Long> _invitee = new NautHashMap<String, Long>();
|
||||
@ -47,6 +53,7 @@ public class Party
|
||||
|
||||
_players = new ArrayList(Arrays.asList(partyData.getPlayers()));
|
||||
_creator = partyData.getLeader();
|
||||
_previousServer = partyData.getPreviousServer();
|
||||
}
|
||||
|
||||
public Party(PartyManager manager)
|
||||
@ -135,12 +142,27 @@ public class Party
|
||||
// Instruct
|
||||
if (inviteeInParty)
|
||||
{
|
||||
UtilPlayer.message(player,
|
||||
F.main("Party", "Type " + F.link("/party leave") + " then " + F.link("/party " + GetLeader()) + " to join."));
|
||||
ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Party> " + C.mBody + "Type ");
|
||||
|
||||
message.add(F.link("/party leave")).click(ClickEvent.RUN_COMMAND, "/party leave");
|
||||
|
||||
message.add(C.mBody + " then ");
|
||||
|
||||
message.add(F.link("/party " + GetLeader())).click(ClickEvent.RUN_COMMAND, "/party " + GetLeader());
|
||||
|
||||
message.add(C.mBody + " to join.");
|
||||
|
||||
message.sendToPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Party", "Type " + F.link("/party " + GetLeader()) + " to join."));
|
||||
ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Party> " + C.mBody + "Type ");
|
||||
|
||||
message.add(F.link("/party " + GetLeader())).click(ClickEvent.RUN_COMMAND, "/party " + GetLeader());
|
||||
|
||||
message.add(C.mBody + " to join.");
|
||||
|
||||
message.sendToPlayer(player);
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1.5f);
|
||||
@ -191,7 +213,32 @@ public class Party
|
||||
_players.remove(player.getName());
|
||||
_players.add(0, player.getName());
|
||||
|
||||
Announce("Party Leadership returned to " + F.name(GetLeader()) + ".");
|
||||
if (_informNewLeaderTimer < System.currentTimeMillis())
|
||||
{
|
||||
Announce("Party Leadership returned to " + F.name(GetLeader()) + ".");
|
||||
}
|
||||
|
||||
if (_previousServer != null)
|
||||
{
|
||||
for (String playerName : _players)
|
||||
{
|
||||
Player p = Bukkit.getPlayerExact(playerName);
|
||||
|
||||
if (p != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TransferCommand transferCommand = new TransferCommand(
|
||||
new ServerTransfer(playerName, _manager.getServerName()));
|
||||
|
||||
transferCommand.setTargetServers(_previousServer);
|
||||
|
||||
transferCommand.publish();
|
||||
}
|
||||
|
||||
_previousServer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +248,7 @@ public class Party
|
||||
if (player.getName().equals(GetLeader()))
|
||||
{
|
||||
_players.remove(player.getName());
|
||||
_players.add(0, player.getName());
|
||||
_players.add(player.getName());
|
||||
|
||||
if (_informNewLeaderTimer < System.currentTimeMillis())
|
||||
{
|
||||
@ -365,20 +412,24 @@ public class Party
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UtilTime.elapsed(_partyOfflineTimer, online == 0 ? 15000 : 120000)) // 15 seconds for no players, 2 minutes if
|
||||
if (UtilTime.elapsed(_partyOfflineTimer, online == 0 ? 5000 : 120000)) // 5 seconds for no players, 2 minutes if
|
||||
// one player.
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_partyOfflineTimer > 0)
|
||||
{
|
||||
_partyOfflineTimer = -1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetWaitingTime()
|
||||
{
|
||||
_partyOfflineTimer = System.currentTimeMillis();
|
||||
_partyOfflineTimer = -1;
|
||||
}
|
||||
|
||||
public void switchedServer()
|
||||
|
@ -27,6 +27,7 @@ public class PartyManager extends MiniPlugin
|
||||
private CoreClientManager _clientManager;
|
||||
private PreferencesManager _preferenceManager;
|
||||
private Portal _portal;
|
||||
private String _serverName;
|
||||
|
||||
public HashSet<Party> _parties = new HashSet<Party>();
|
||||
|
||||
@ -37,6 +38,7 @@ public class PartyManager extends MiniPlugin
|
||||
_portal = portal;
|
||||
_clientManager = clientManager;
|
||||
_preferenceManager = preferenceManager;
|
||||
_serverName = GetPlugin().getConfig().getString("serverstatus.name");
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("RedisPartyData", RedisPartyData.class,
|
||||
new RedisPartyHandler(this));
|
||||
@ -67,6 +69,11 @@ public class PartyManager extends MiniPlugin
|
||||
return party;
|
||||
}
|
||||
|
||||
public String getServerName()
|
||||
{
|
||||
return _serverName;
|
||||
}
|
||||
|
||||
public void addParty(Party party)
|
||||
{
|
||||
for (Party parties : _parties)
|
||||
@ -91,14 +98,25 @@ public class PartyManager extends MiniPlugin
|
||||
{
|
||||
party.switchedServer();
|
||||
|
||||
RedisPartyData data = new RedisPartyData(party, event.getServer());
|
||||
boolean destLobby = event.getServer().equalsIgnoreCase("lobby");
|
||||
|
||||
RedisPartyData data = new RedisPartyData(party, destLobby ? _serverName : null);
|
||||
|
||||
if (!destLobby)
|
||||
{
|
||||
data.setTargetServers(event.getServer());
|
||||
}
|
||||
|
||||
data.publish();
|
||||
|
||||
for (Player player : party.GetPlayersOnline())
|
||||
if (!destLobby)
|
||||
{
|
||||
if (player != event.getPlayer())
|
||||
for (Player player : party.GetPlayersOnline())
|
||||
{
|
||||
_portal.sendPlayerToServer(player, event.getServer());
|
||||
if (player != event.getPlayer())
|
||||
{
|
||||
_portal.sendPlayerToServer(player, event.getServer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,17 @@ package mineplex.core.party.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||
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.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -15,7 +20,10 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
{
|
||||
public PartyCommand(PartyManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, new String[] {"party","z"});
|
||||
super(plugin, Rank.ALL, new String[]
|
||||
{
|
||||
"party", "z"
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -25,16 +33,16 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Party", "Listing Party Commands;"));
|
||||
UtilPlayer.message(caller, F.value(0, "/party <Player>", "Join/Create/Invite Player"));
|
||||
UtilPlayer.message(caller, F.value(0, "/party leave", "Leave your current Party"));
|
||||
UtilPlayer.message(caller, F.value(0, "/party kick <Player>", "Kick player from your Party"));
|
||||
UtilPlayer.message(caller, F.value(0, "/party leave", "Leave your current Party"));
|
||||
UtilPlayer.message(caller, F.value(0, "/party kick <Player>", "Kick player from your Party"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Callers Party
|
||||
// Callers Party
|
||||
Party party = Plugin.GetParty(caller);
|
||||
|
||||
//Leave
|
||||
// Leave
|
||||
if (args[0].equalsIgnoreCase("leave"))
|
||||
{
|
||||
if (party == null)
|
||||
@ -49,7 +57,7 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
return;
|
||||
}
|
||||
|
||||
//Leave
|
||||
// Leave
|
||||
if (args[0].equalsIgnoreCase("kick"))
|
||||
{
|
||||
if (party == null)
|
||||
@ -61,14 +69,15 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
if (party.GetLeader().equals(caller.getName()))
|
||||
{
|
||||
String target = UtilPlayer.searchCollection(caller, args[1], party.GetPlayers(), "Party ", true);
|
||||
if (target == null) return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if (target.equals(caller.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Party", "You cannot kick yourself from the Party."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
party.KickParty(target);
|
||||
}
|
||||
else
|
||||
@ -80,24 +89,28 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
return;
|
||||
}
|
||||
|
||||
//Main
|
||||
// Main
|
||||
Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
if (target == null) return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if (target.equals(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Party", "You cannot Party with yourself."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Preference check
|
||||
if (!Plugin.getPreferenceManager().Get(target).PartyRequests)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Party", "You may not party with " + F.name(UtilEnt.getName(target)) + "! They are not accepting party requests!"));
|
||||
UtilPlayer.message(
|
||||
caller,
|
||||
F.main("Party", "You may not party with " + F.name(UtilEnt.getName(target))
|
||||
+ "! They are not accepting party requests!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Invite or Suggest
|
||||
// Invite or Suggest
|
||||
if (party != null)
|
||||
{
|
||||
if (party.GetPlayers().size() + party.GetInvitees().size() >= 16)
|
||||
@ -105,36 +118,48 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
UtilPlayer.message(caller, "Your party cannot be larger than 16 players.");
|
||||
caller.playSound(caller.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
|
||||
}
|
||||
//Decline
|
||||
// Decline
|
||||
else if (party.GetPlayers().contains(target.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Party", F.name(target.getName()) + " is already in the Party."));
|
||||
caller.playSound(caller.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
|
||||
}
|
||||
//Decline
|
||||
// Decline
|
||||
else if (party.GetInvitees().contains(target.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Party", F.name(target.getName()) + " is already invited to the Party."));
|
||||
caller.playSound(caller.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
|
||||
}
|
||||
//Invite
|
||||
// Invite
|
||||
else if (party.GetLeader().equals(caller.getName()))
|
||||
{
|
||||
party.InviteParty(target, Plugin.GetParty(target) != null);
|
||||
}
|
||||
//Suggest
|
||||
// Suggest
|
||||
else
|
||||
{
|
||||
party.Announce(F.name(caller.getName()) + " suggested " + F.name(target.getName()) + " be invited to the Party.");
|
||||
UtilPlayer.message(UtilPlayer.searchExact(party.GetLeader()), F.main("Party", "Type " + F.link("/party " + target.getName()) + " to invite them."));
|
||||
|
||||
Player leader = Bukkit.getPlayerExact(party.GetLeader());
|
||||
|
||||
if (leader != null)
|
||||
{
|
||||
ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Party> " + C.mBody + "Type ");
|
||||
|
||||
message.add(F.link("/party " + target.getName())).click(ClickEvent.RUN_COMMAND, "/party " + target.getName());
|
||||
|
||||
message.add(C.mBody + " to invite them.");
|
||||
|
||||
message.sendToPlayer(leader);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Create or Join
|
||||
// Create or Join
|
||||
else
|
||||
{
|
||||
Party targetParty = Plugin.GetParty(target);
|
||||
|
||||
//Try to Join
|
||||
// Try to Join
|
||||
if (targetParty != null)
|
||||
{
|
||||
if (targetParty.GetInvitees().contains(caller.getName()))
|
||||
@ -144,7 +169,7 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
}
|
||||
}
|
||||
|
||||
//Create
|
||||
// Create
|
||||
party = Plugin.CreateParty(caller);
|
||||
party.InviteParty(target, Plugin.GetParty(target) != null);
|
||||
}
|
||||
|
@ -8,13 +8,18 @@ public class RedisPartyData extends ServerCommand
|
||||
|
||||
private String[] _players;
|
||||
private String _leader;
|
||||
private String _previousServer;
|
||||
|
||||
public RedisPartyData(Party party, String newServer)
|
||||
public RedisPartyData(Party party, String previousServer)
|
||||
{
|
||||
_players = party.GetPlayers().toArray(new String[0]);
|
||||
_leader = party.GetLeader();
|
||||
|
||||
setTargetServers(newServer);
|
||||
_previousServer = previousServer;
|
||||
}
|
||||
|
||||
public String getPreviousServer()
|
||||
{
|
||||
return _previousServer;
|
||||
}
|
||||
|
||||
public String[] getPlayers()
|
||||
|
@ -101,7 +101,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
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);
|
||||
@ -111,6 +110,9 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
StatsManager statsManager = new StatsManager(this, clientManager);
|
||||
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager);
|
||||
|
||||
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
|
||||
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this));
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
|
||||
|
@ -31,7 +31,6 @@ 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;
|
||||
@ -124,8 +123,6 @@ public class Arcade extends JavaPlugin
|
||||
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);
|
||||
|
||||
|
@ -58,6 +58,7 @@ import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.movement.Movement;
|
||||
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;
|
||||
@ -162,6 +163,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private HologramManager _hologramManager;
|
||||
private AchievementManager _achievementManager;
|
||||
private StatsManager _statsManager;
|
||||
private PartyManager _partyManager;
|
||||
|
||||
private TaskManager _taskManager;
|
||||
private ArcadeRepository _arcadeRepository;
|
||||
@ -229,7 +231,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_projectileManager = projectileManager;
|
||||
|
||||
_packetHandler = packetHandler;
|
||||
|
||||
|
||||
_partyManager = new PartyManager(plugin, portal, _clientManager, preferences);
|
||||
_statsManager = new StatsManager(plugin, clientManager);
|
||||
_taskManager = new TaskManager(plugin, webAddress);
|
||||
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
||||
@ -1172,4 +1175,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
HandlerList.unregisterAll(_classShop);
|
||||
}
|
||||
}
|
||||
|
||||
public PartyManager getPartyManager()
|
||||
{
|
||||
return _partyManager;
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,11 @@ package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.achievement.Achievement;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.party.Party;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
@ -84,6 +83,24 @@ public class GameChatManager implements Listener
|
||||
rankStr = Rank.ULTRA.GetTag(true, true) + " ";
|
||||
}
|
||||
|
||||
if (event.getMessage().charAt(0) == '@')
|
||||
{
|
||||
//Party Chat
|
||||
Party party = Manager.getPartyManager().GetParty(sender);
|
||||
|
||||
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 + "%1$s " + C.cPurple + "%2$s");
|
||||
|
||||
event.getRecipients().addAll(party.GetPlayersOnline());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Base Format
|
||||
event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + "%1$s " + ChatColor.WHITE + "%2$s");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user