Completely prevent players in parties from joining Clans servers

This commit is contained in:
AlexTheCoder 2016-07-27 05:51:49 -04:00
parent d162750aec
commit 157c969e8d
2 changed files with 21 additions and 7 deletions

View File

@ -98,12 +98,18 @@ 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.getParty() != null && override) if (event.getParty() != null && override)
{ {
Party party = event.getParty(); Party party = event.getParty();
sendParty(party); sendParty(party);
return; return;
} }
if (event.getParty() != null && serverName.toUpperCase().startsWith("CLANS-"))
{
event.getParty().sendMessage(F.main(getName(), "You cannot join Clans while in a party!"));
return;
}
if (override) if (override)
{ {
@ -111,7 +117,7 @@ public class Portal extends MiniPlugin
return; return;
} }
if(event.isCancel()) if (event.isCancel())
{ {
return; return;
} }
@ -139,23 +145,23 @@ public class Portal extends MiniPlugin
MinecraftServer best = null; MinecraftServer best = null;
List<MinecraftServer> serverList = Lists.newArrayList(repository.getServersByGroup("Lobby")); List<MinecraftServer> serverList = Lists.newArrayList(repository.getServersByGroup("Lobby"));
int lowest = Integer.MAX_VALUE; int lowest = Integer.MAX_VALUE;
for(MinecraftServer server : serverList) for (MinecraftServer server : serverList)
{ {
int playercount = server.getPlayerCount(); int playercount = server.getPlayerCount();
if(playercount < 20) if (playercount < 20)
{ {
continue; continue;
} }
if(playercount < lowest) if (playercount < lowest)
{ {
lowest = playercount; lowest = playercount;
if(best == null) if (best == null)
{ {
best = server; best = server;
} }
} }
} }
if(best == null) if (best == null)
{ {
//Well, fuck. //Well, fuck.
best = serverList.get(new Random().nextInt(serverList.size())); best = serverList.get(new Random().nextInt(serverList.size()));

View File

@ -28,6 +28,7 @@ import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ServerManager;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEnterEvent;
@ -193,6 +194,13 @@ public class ClansTransferManager extends MiniDbClientPlugin<SimpleClanToken>
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true);
return; return;
} }
if (_party.getParty(player) != null)
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
player.sendMessage(F.main("Party", "You cannot join Clans while in a party."));
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true);
return;
}
if (!Recharge.Instance.use(player, "Transfer Portal", 5000, false, false)) if (!Recharge.Instance.use(player, "Transfer Portal", 5000, false, false))
{ {