Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into update/clans
This commit is contained in:
commit
a1fd021f8d
@ -31,14 +31,9 @@ public class Party
|
|||||||
private transient boolean _alreadyTeamed = false;
|
private transient boolean _alreadyTeamed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The standard size for parties, for ALL {@code {@link mineplex.core.common.Rank}}
|
* The maximum amount of players a party can have.
|
||||||
*/
|
*/
|
||||||
private static final int PARTY_MIN_SIZE = 5;
|
private static final int PARTY_MAX_SIZE = 16;
|
||||||
|
|
||||||
/**
|
|
||||||
* An upgraded size for the party, given to donators and staff.
|
|
||||||
*/
|
|
||||||
private static final int PARTY_MAX_SIZE = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current leader of this party
|
* The current leader of this party
|
||||||
|
@ -3,9 +3,11 @@ package mineplex.core.party;
|
|||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.party.constants.PartyRemoveReason;
|
import mineplex.core.party.constants.PartyRemoveReason;
|
||||||
import mineplex.core.party.event.PartyMemberKickGUIEvent;
|
import mineplex.core.party.event.PartyMemberKickGUIEvent;
|
||||||
|
import mineplex.core.party.event.PartySendToServerEvent;
|
||||||
import mineplex.core.party.event.PartyTransferOwnerEvent;
|
import mineplex.core.party.event.PartyTransferOwnerEvent;
|
||||||
import mineplex.core.party.ui.Menu;
|
import mineplex.core.party.ui.Menu;
|
||||||
import mineplex.core.portal.ServerTransferEvent;
|
import mineplex.core.portal.ServerTransferEvent;
|
||||||
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -128,6 +130,7 @@ public class PartyEventListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.setParty(party);
|
||||||
event.setCancel(true);
|
event.setCancel(true);
|
||||||
|
|
||||||
if (!party.getOwner().equalsIgnoreCase(player.getName()))
|
if (!party.getOwner().equalsIgnoreCase(player.getName()))
|
||||||
@ -136,8 +139,21 @@ public class PartyEventListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_plugin.getJoinManager().requestServerJoin(event.getServer(), party);
|
String server = event.getServer();
|
||||||
|
if(server.equalsIgnoreCase("Lobby"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_plugin.getJoinManager().requestServerJoin(event.getServer(), party);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onSend(PartySendToServerEvent event)
|
||||||
|
{
|
||||||
|
Party party = event.getParty();
|
||||||
|
MinecraftServer server = event.getMinecraftServer();
|
||||||
|
_plugin.getRedisManager().sendPartyInfo(server.getName(), party);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package mineplex.core.party.event;
|
||||||
|
|
||||||
|
import mineplex.core.party.Party;
|
||||||
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PartySendToServerEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
|
||||||
|
private final Party _party;
|
||||||
|
private final MinecraftServer _minecraftServer;
|
||||||
|
|
||||||
|
public PartySendToServerEvent(Party party, MinecraftServer minecraftServer)
|
||||||
|
{
|
||||||
|
_party = party;
|
||||||
|
_minecraftServer = minecraftServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Party getParty()
|
||||||
|
{
|
||||||
|
return _party;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinecraftServer getMinecraftServer()
|
||||||
|
{
|
||||||
|
return _minecraftServer;
|
||||||
|
}
|
||||||
|
}
|
@ -114,7 +114,7 @@ public class PartyInviteManager
|
|||||||
*/
|
*/
|
||||||
public void handleInviteRequest(String sender, String target, String serverFrom)
|
public void handleInviteRequest(String sender, String target, String serverFrom)
|
||||||
{
|
{
|
||||||
Player player = Bukkit.getPlayer(target);
|
Player player = Bukkit.getPlayerExact(target);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
//Shouldn't happen, as a "findPLayer" packet will be sent out first.
|
//Shouldn't happen, as a "findPLayer" packet will be sent out first.
|
||||||
|
@ -50,10 +50,38 @@ public class PartyMethodManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(party != null)
|
||||||
|
{
|
||||||
|
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(_plugin.getParty(target) != null)
|
||||||
|
{
|
||||||
|
Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(party.getMembers().size() >= party.getSize())
|
||||||
|
{
|
||||||
|
Lang.PARTY_FULL.send(caller);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Same Server
|
//Same Server
|
||||||
if (possible != null)
|
if (possible != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!_plugin.getPreferencesManager().Get(possible).PartyRequests)
|
if(!_plugin.getPreferencesManager().Get(possible).PartyRequests)
|
||||||
{
|
{
|
||||||
caller.sendMessage(F.main("Party> ", F.name(target) + " is not accepting invites at this time."));
|
caller.sendMessage(F.main("Party> ", F.name(target) + " is not accepting invites at this time."));
|
||||||
@ -75,32 +103,6 @@ public class PartyMethodManager
|
|||||||
Lang.INVITE_SUCCESS_PLAYER.send(caller, possible.getName());
|
Lang.INVITE_SUCCESS_PLAYER.send(caller, possible.getName());
|
||||||
} else
|
} 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(_plugin.getParty(target) != null)
|
|
||||||
{
|
|
||||||
Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(party.getMembers().size() >= party.getSize())
|
|
||||||
{
|
|
||||||
Lang.PARTY_FULL.send(caller);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Lang.SUCCESS_INVITE.send(party, caller.getName(), target);
|
Lang.SUCCESS_INVITE.send(party, caller.getName(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +318,7 @@ public class PartyMethodManager
|
|||||||
{
|
{
|
||||||
List<UUID> members = Lists.newArrayList(party.getMembersByUUID());
|
List<UUID> members = Lists.newArrayList(party.getMembersByUUID());
|
||||||
Lang.DISBANDED_BY_OWNER.send(party);
|
Lang.DISBANDED_BY_OWNER.send(party);
|
||||||
members.stream().forEach(player -> removeFromParty(player, PartyRemoveReason.DISBANDED_BY_OWNER));
|
members.forEach(player -> removeFromParty(player, PartyRemoveReason.DISBANDED_BY_OWNER));
|
||||||
party.getMembers().clear();
|
party.getMembers().clear();
|
||||||
party.getMembersByUUID().clear();
|
party.getMembersByUUID().clear();
|
||||||
_plugin.removeParty(party);
|
_plugin.removeParty(party);
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.party.ui.button.tools.invite;
|
|||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.party.PartyManager;
|
import mineplex.core.party.PartyManager;
|
||||||
import mineplex.core.party.ui.Button;
|
import mineplex.core.party.ui.Button;
|
||||||
import mineplex.core.party.ui.menus.PartyMainMenu;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,6 +28,6 @@ public class BackButton extends Button
|
|||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
new PartyMainMenu(getPlugin()).open(player);
|
player.chat("/party");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public class PartyInvitesMenu extends Menu
|
|||||||
.setTitle(C.cRedB + "No Invites")
|
.setTitle(C.cRedB + "No Invites")
|
||||||
.build(), null);
|
.build(), null);
|
||||||
|
|
||||||
|
private final int INV_SIZE = 54;
|
||||||
private final int SLOTS_PER_PAGE = 27;
|
private final int SLOTS_PER_PAGE = 27;
|
||||||
private final int STARTING_SLOT = 18;
|
private final int STARTING_SLOT = 18;
|
||||||
private final int BACK_BUTTON_SLOT = 0;
|
private final int BACK_BUTTON_SLOT = 0;
|
||||||
@ -59,7 +60,7 @@ public class PartyInvitesMenu extends Menu
|
|||||||
@Override
|
@Override
|
||||||
protected Button[] setUp(Player player)
|
protected Button[] setUp(Player player)
|
||||||
{
|
{
|
||||||
Button[] buttons = new Button[54];
|
Button[] buttons = new Button[INV_SIZE];
|
||||||
boolean showFiltered = false;
|
boolean showFiltered = false;
|
||||||
|
|
||||||
buttons[BACK_BUTTON_SLOT] = new BackButton(_plugin);
|
buttons[BACK_BUTTON_SLOT] = new BackButton(_plugin);
|
||||||
|
@ -13,15 +13,21 @@ import mineplex.core.party.ui.button.tools.owner.SelectServerButton;
|
|||||||
import mineplex.core.party.ui.button.tools.owner.TransferOwnerButton;
|
import mineplex.core.party.ui.button.tools.owner.TransferOwnerButton;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The display menu for managing parties by the owner
|
* The display menu for managing parties by the owner
|
||||||
*/
|
*/
|
||||||
public class PartyOwnerMenu extends Menu
|
public class PartyOwnerMenu extends Menu
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final int INV_SIZE = 54;
|
||||||
|
private final int OWNER_HEAD_SLOT = 13;
|
||||||
private final int STARTING_SLOT = 20;
|
private final int STARTING_SLOT = 20;
|
||||||
private final int CUT_OFF_SLOT = 25;
|
private final int CUT_OFF_SLOT = 25;
|
||||||
|
private final int CUT_OFF_SLOT_2 = 34;
|
||||||
private final int SKIP_TO_SLOT = 29;
|
private final int SKIP_TO_SLOT = 29;
|
||||||
|
private final int SKIP_TO_SLOT_2 = 38;
|
||||||
private final int ADD_PLAYER_BUTTON_SLOT = 1;
|
private final int ADD_PLAYER_BUTTON_SLOT = 1;
|
||||||
private final int KICK_PLAYER_BUTTON_SLOT = 4;
|
private final int KICK_PLAYER_BUTTON_SLOT = 4;
|
||||||
private final int TRANSFER_OWNER_BUTTON_SLOT = 7;
|
private final int TRANSFER_OWNER_BUTTON_SLOT = 7;
|
||||||
@ -45,7 +51,7 @@ public class PartyOwnerMenu extends Menu
|
|||||||
@Override
|
@Override
|
||||||
protected Button[] setUp(Player player)
|
protected Button[] setUp(Player player)
|
||||||
{
|
{
|
||||||
Button[] buttons = new Button[54];
|
Button[] buttons = new Button[INV_SIZE];
|
||||||
//Tools
|
//Tools
|
||||||
buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(_plugin, _party);
|
buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(_plugin, _party);
|
||||||
//Kick player
|
//Kick player
|
||||||
@ -59,16 +65,23 @@ public class PartyOwnerMenu extends Menu
|
|||||||
//Disband
|
//Disband
|
||||||
buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(_plugin);
|
buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(_plugin);
|
||||||
|
|
||||||
|
List<String> members = _party.getMembers();
|
||||||
|
members.remove(_party.getOwner());
|
||||||
|
buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true);
|
||||||
|
|
||||||
int slot = STARTING_SLOT;
|
int slot = STARTING_SLOT;
|
||||||
//Players
|
//Players
|
||||||
for (int i = 0; i < _party.getMembers().size(); i++)
|
for (String member : members)
|
||||||
{
|
{
|
||||||
if (slot == CUT_OFF_SLOT)
|
if (slot == CUT_OFF_SLOT)
|
||||||
{
|
{
|
||||||
slot = SKIP_TO_SLOT;
|
slot = SKIP_TO_SLOT;
|
||||||
|
} else if (slot == CUT_OFF_SLOT_2)
|
||||||
|
{
|
||||||
|
slot = SKIP_TO_SLOT_2;
|
||||||
}
|
}
|
||||||
String member = _party.getMembers().get(i);
|
|
||||||
buttons[slot++] = new PartyMemberIcon(member, _party, member.equalsIgnoreCase(_party.getOwner()));
|
buttons[slot++] = new PartyMemberIcon(member, _party, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_party.getSize() == 5)
|
if(_party.getSize() == 5)
|
||||||
|
@ -9,15 +9,21 @@ import mineplex.core.party.ui.button.tools.LeavePartyButton;
|
|||||||
import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton;
|
import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu a player see's when he is a member, and not an owner, of a party.
|
* The menu a player see's when he is a member, and not an owner, of a party.
|
||||||
*/
|
*/
|
||||||
public class PartyViewMenu extends Menu
|
public class PartyViewMenu extends Menu
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final int INV_SIZE = 54;
|
||||||
|
private final int OWNER_HEAD_SLOT = 13;
|
||||||
private final int STARTING_SLOT = 20;
|
private final int STARTING_SLOT = 20;
|
||||||
private final int CUT_OFF_SLOT = 25;
|
private final int CUT_OFF_SLOT = 25;
|
||||||
|
private final int CUT_OFF_SLOT_2 = 34;
|
||||||
private final int SKIP_TO_SLOT = 29;
|
private final int SKIP_TO_SLOT = 29;
|
||||||
|
private final int SKIP_TO_SLOT_2 = 38;
|
||||||
private final int LEAVE_PARTY_BUTTON_SLOT = 3;
|
private final int LEAVE_PARTY_BUTTON_SLOT = 3;
|
||||||
private final int SUGGEST_PLAYER_BUTTON_SLOT = 5;
|
private final int SUGGEST_PLAYER_BUTTON_SLOT = 5;
|
||||||
|
|
||||||
@ -32,22 +38,29 @@ public class PartyViewMenu extends Menu
|
|||||||
@Override
|
@Override
|
||||||
protected Button[] setUp(Player player)
|
protected Button[] setUp(Player player)
|
||||||
{
|
{
|
||||||
Button[] buttons = new Button[54];
|
Button[] buttons = new Button[INV_SIZE];
|
||||||
//Tools
|
//Tools
|
||||||
buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin);
|
buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin);
|
||||||
//Suggest Player
|
//Suggest Player
|
||||||
buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, _plugin);
|
buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, _plugin);
|
||||||
|
|
||||||
|
List<String> members = _party.getMembers();
|
||||||
|
members.remove(_party.getOwner());
|
||||||
|
buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true);
|
||||||
|
|
||||||
int slot = STARTING_SLOT;
|
int slot = STARTING_SLOT;
|
||||||
//Players
|
//Players
|
||||||
for (int i = 0; i < _party.getMembers().size(); i++)
|
for (String member : members)
|
||||||
{
|
{
|
||||||
if (slot == CUT_OFF_SLOT)
|
if (slot == CUT_OFF_SLOT)
|
||||||
{
|
{
|
||||||
slot = SKIP_TO_SLOT;
|
slot = SKIP_TO_SLOT;
|
||||||
|
} else if (slot == CUT_OFF_SLOT_2)
|
||||||
|
{
|
||||||
|
slot = SKIP_TO_SLOT_2;
|
||||||
}
|
}
|
||||||
String member = _party.getMembers().get(i);
|
|
||||||
buttons[slot++] = new PartyMemberIcon(member, _party, member.equalsIgnoreCase(_party.getOwner()));
|
buttons[slot++] = new PartyMemberIcon(member, _party, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return addPanes(buttons);
|
return addPanes(buttons);
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
package mineplex.core.portal;
|
package mineplex.core.portal;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import com.google.common.collect.Lists;
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
@ -21,6 +9,8 @@ import mineplex.core.common.util.Callback;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTabTitle;
|
import mineplex.core.common.util.UtilTabTitle;
|
||||||
|
import mineplex.core.party.Party;
|
||||||
|
import mineplex.core.party.event.PartySendToServerEvent;
|
||||||
import mineplex.core.portal.Commands.SendCommand;
|
import mineplex.core.portal.Commands.SendCommand;
|
||||||
import mineplex.core.portal.Commands.ServerCommand;
|
import mineplex.core.portal.Commands.ServerCommand;
|
||||||
import mineplex.serverdata.Region;
|
import mineplex.serverdata.Region;
|
||||||
@ -30,6 +20,20 @@ import mineplex.serverdata.commands.TransferCommand;
|
|||||||
import mineplex.serverdata.data.MinecraftServer;
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
import mineplex.serverdata.servers.ServerManager;
|
||||||
import mineplex.serverdata.servers.ServerRepository;
|
import mineplex.serverdata.servers.ServerRepository;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Portal extends MiniPlugin
|
public class Portal extends MiniPlugin
|
||||||
{
|
{
|
||||||
@ -47,10 +51,10 @@ public class Portal extends MiniPlugin
|
|||||||
public Portal(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
|
public Portal(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
|
||||||
{
|
{
|
||||||
super("Portal", plugin);
|
super("Portal", plugin);
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
|
|
||||||
_region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
_region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||||
_serverName = serverName;
|
_serverName = serverName;
|
||||||
_repository = ServerManager.getServerRepository(_region);
|
_repository = ServerManager.getServerRepository(_region);
|
||||||
@ -94,34 +98,71 @@ public class Portal extends MiniPlugin
|
|||||||
final boolean override = serverName.equalsIgnoreCase("Lobby") || serverName.equalsIgnoreCase("ClansHub");
|
final boolean override = serverName.equalsIgnoreCase("Lobby") || serverName.equalsIgnoreCase("ClansHub");
|
||||||
final Rank playerRank = _clientManager.Get(player).GetRank();
|
final Rank playerRank = _clientManager.Get(player).GetRank();
|
||||||
|
|
||||||
if(event.isCancel() && !event.isDraggedByParty())
|
if(event.getParty() != null && override)
|
||||||
{
|
{
|
||||||
|
Party party = event.getParty();
|
||||||
|
sendParty(party);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (override)
|
if (override)
|
||||||
{
|
{
|
||||||
sendPlayer(player, serverName);
|
sendPlayer(player, serverName);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
if(event.isCancel())
|
||||||
{
|
{
|
||||||
runAsync(() -> {
|
return;
|
||||||
final MinecraftServer server = _repository.getServerStatus(serverName);
|
}
|
||||||
|
|
||||||
if (server == null)
|
runAsync(() -> {
|
||||||
return;
|
final MinecraftServer server = _repository.getServerStatus(serverName);
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(_plugin, () -> {
|
if (server == null)
|
||||||
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA))
|
return;
|
||||||
{
|
|
||||||
sendPlayer(player, serverName);
|
Bukkit.getServer().getScheduler().runTask(_plugin, () -> {
|
||||||
}
|
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA))
|
||||||
|
{
|
||||||
|
sendPlayer(player, serverName);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is full!"));
|
UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is full!"));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendParty(Party party)
|
||||||
|
{
|
||||||
|
ServerRepository repository = ServerManager.getServerRepository(_region);
|
||||||
|
MinecraftServer best = null;
|
||||||
|
List<MinecraftServer> serverList = Lists.newArrayList(repository.getServersByGroup("Lobby"));
|
||||||
|
int lowest = Integer.MAX_VALUE;
|
||||||
|
for(MinecraftServer server : serverList)
|
||||||
|
{
|
||||||
|
int playercount = server.getPlayerCount();
|
||||||
|
if(playercount < 20)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(playercount < lowest)
|
||||||
|
{
|
||||||
|
lowest = playercount;
|
||||||
|
if(best == null)
|
||||||
|
{
|
||||||
|
best = server;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(best == null)
|
||||||
|
{
|
||||||
|
//Well, fuck.
|
||||||
|
best = serverList.get(new Random().nextInt(serverList.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PartySendToServerEvent serverEvent = new PartySendToServerEvent(party, best);
|
||||||
|
getPluginManager().callEvent(serverEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transferPlayer(String playerName, String serverName)
|
public static void transferPlayer(String playerName, String serverName)
|
||||||
@ -195,4 +236,6 @@ public class Portal extends MiniPlugin
|
|||||||
|
|
||||||
UtilPlayer.message(player, F.main(getName(), "You have been sent from " + C.cGold + _serverName + C.cGray + " to " + C.cGold + serverName));
|
UtilPlayer.message(player, F.main(getName(), "You have been sent from " + C.cGold + _serverName + C.cGray + " to " + C.cGold + serverName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.core.portal;
|
package mineplex.core.portal;
|
||||||
|
|
||||||
|
import mineplex.core.party.Party;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@ -10,6 +11,7 @@ public class ServerTransferEvent extends Event
|
|||||||
private static final HandlerList _handlers = new HandlerList();
|
private static final HandlerList _handlers = new HandlerList();
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private String _server;
|
private String _server;
|
||||||
|
private Party _party;
|
||||||
private boolean _draggedByParty;
|
private boolean _draggedByParty;
|
||||||
private boolean _cancel;
|
private boolean _cancel;
|
||||||
|
|
||||||
@ -59,4 +61,14 @@ public class ServerTransferEvent extends Event
|
|||||||
{
|
{
|
||||||
_cancel = cancel;
|
_cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Party getParty()
|
||||||
|
{
|
||||||
|
return _party;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParty(Party party)
|
||||||
|
{
|
||||||
|
_party = party;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ import mineplex.core.achievement.AchievementManager;
|
|||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.chatsnap.SnapshotManager;
|
|
||||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
|
||||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
import mineplex.core.common.MinecraftVersion;
|
import mineplex.core.common.MinecraftVersion;
|
||||||
import mineplex.core.common.Pair;
|
import mineplex.core.common.Pair;
|
||||||
@ -39,8 +36,6 @@ import mineplex.core.portal.Portal;
|
|||||||
import mineplex.core.preferences.PreferencesManager;
|
import mineplex.core.preferences.PreferencesManager;
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.report.ReportManager;
|
|
||||||
import mineplex.core.report.ReportPlugin;
|
|
||||||
import mineplex.core.resourcepack.ResourcePackManager;
|
import mineplex.core.resourcepack.ResourcePackManager;
|
||||||
import mineplex.core.serverConfig.ServerConfiguration;
|
import mineplex.core.serverConfig.ServerConfiguration;
|
||||||
import mineplex.core.spawn.Spawn;
|
import mineplex.core.spawn.Spawn;
|
||||||
@ -205,4 +200,4 @@ public class Clans extends JavaPlugin
|
|||||||
{
|
{
|
||||||
return MAP;
|
return MAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package mineplex.hub;
|
package mineplex.hub;
|
||||||
|
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
import mineplex.core.brawl.fountain.FountainManager;
|
||||||
import com.avaje.ebean.config.ServerConfig;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -74,10 +73,6 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
|||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
import mineplex.minecraft.game.core.fire.Fire;
|
import mineplex.minecraft.game.core.fire.Fire;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public class Hub extends JavaPlugin implements IRelation
|
public class Hub extends JavaPlugin implements IRelation
|
||||||
{
|
{
|
||||||
private String WEB_CONFIG = "webServer";
|
private String WEB_CONFIG = "webServer";
|
||||||
|
Loading…
Reference in New Issue
Block a user