Last commit for version 2.1.2.2

This commit is contained in:
Jaime Martínez Rincón 2017-11-29 18:52:21 +01:00
parent aebe9419f0
commit 6cea42767b
5 changed files with 47 additions and 41 deletions

View File

@ -11,7 +11,7 @@
<name>PlayerBalancer Plugin</name>
<artifactId>playerbalancer-plugin</artifactId>
<version>2.1.3</version>
<version>2.1.2.2</version>
<build>
<finalName>PlayerBalancer</finalName>

View File

@ -28,24 +28,25 @@ public class ServerConnectListener implements Listener {
ServerSection section = getSection(player, target);
if (section != null) {
if (target.equals(section.getServer())) {
event.setCancelled(true);
}
if (section == null)
return;
new ConnectionIntent(plugin, player, section) {
@Override
public void connect(ServerInfo server, Callback<Boolean> callback) {
if (plugin.getSectionManager().isReiterative(section)) {
ServerAssignRegistry.assignTarget(player, section, server);
}
event.setCancelled(false);
event.setTarget(server);
callback.done(true, null);
}
};
if (target.equals(section.getServer())) {
event.setCancelled(true);
}
new ConnectionIntent(plugin, player, section) {
@Override
public void connect(ServerInfo server, Callback<Boolean> callback) {
if (plugin.getSectionManager().isReiterative(section)) {
ServerAssignRegistry.assignTarget(player, section, server);
}
event.setCancelled(false);
event.setTarget(server);
callback.done(true, null);
}
};
}
private ServerSection getSection(ProxiedPlayer player, ServerInfo target) {

View File

@ -59,32 +59,34 @@ public class ServerKickListener implements Listener {
));
}
if (matches) {
ServerSection section = getSection(player, from);
if (!matches)
return;
if (section != null) {
List<ServerInfo> servers = new ArrayList<>();
servers.addAll(section.getServers());
servers.remove(from);
ServerSection section = getSection(player, from);
new ConnectionIntent(plugin, player, section, servers) {
@Override
public void connect(ServerInfo server, Callback<Boolean> callback) {
PlayerLocker.lock(player);
event.setCancelled(true);
event.setCancelServer(server);
MessageUtils.send(player, messages.getKickMessage(), (str) -> str
.replace("{reason}", event.getKickReason())
.replace("{from}", from.getName())
.replace("{to}", server.getName()));
plugin.getProxy().getScheduler().schedule(plugin, () -> {
PlayerLocker.unlock(player);
}, 5, TimeUnit.SECONDS);
callback.done(true, null);
}
};
if (section == null)
return;
List<ServerInfo> servers = new ArrayList<>();
servers.addAll(section.getServers());
servers.remove(from);
new ConnectionIntent(plugin, player, section, servers) {
@Override
public void connect(ServerInfo server, Callback<Boolean> callback) {
PlayerLocker.lock(player);
event.setCancelled(true);
event.setCancelServer(server);
MessageUtils.send(player, messages.getKickMessage(), (str) -> str
.replace("{reason}", event.getKickReason())
.replace("{from}", from.getName())
.replace("{to}", server.getName()));
plugin.getProxy().getScheduler().schedule(plugin, () -> {
PlayerLocker.unlock(player);
}, 5, TimeUnit.SECONDS);
callback.done(true, null);
}
}
};
}
private ServerSection getSection(ProxiedPlayer player, ServerInfo from) {

View File

@ -7,7 +7,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
//TODO improve this
public class PlayerLocker {
private static final Set<UUID> storage = Collections.synchronizedSet(new HashSet<UUID>());

View File

@ -90,11 +90,15 @@ public class MainCommand implements CommandExecutor {
sender.sendMessage(ChatColor.GRAY + "Available commands:");
sender.sendMessage(ChatColor.AQUA + "/spb connect <section> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to that section");
sender.sendMessage(ChatColor.AQUA + "/spb fallback [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to the parent of the current section");
/* TODO For version 2.1.3 of the main plugin
sender.sendMessage(ChatColor.AQUA + "/spb bypassconnect <server> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to a specific server without balancing");
sender.sendMessage(ChatColor.AQUA + "/spb setbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Sets a bypass for you or the specified player");
sender.sendMessage(ChatColor.AQUA + "/spb clearbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the bypass for you or the specified player");
sender.sendMessage(ChatColor.AQUA + "/spb overridestatus <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Overrides the accessible status of a specific server, over anything else");
sender.sendMessage(ChatColor.AQUA + "/spb clearoverride <server>" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the overridden status of a specific server");
*/
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
}
}