Some more compatibility changes

This commit is contained in:
ME1312 2020-06-25 19:47:30 -04:00
parent d8ea0cee66
commit 312d010585
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
7 changed files with 43 additions and 51 deletions

View File

@ -1,6 +1,6 @@
# ![https://s3.postimg.cc/dikyxlz5v/Sub_Banner.png](https://s3.postimg.cc/dikyxlz5v/Sub_Banner.png)
[![Build Status](https://dev.me1312.net/jenkins/job/SubServers%20Platform/badge/icon)](https://dev.me1312.net/jenkins/job/SubServers%20Platform/)
[![Release Verison](https://img.shields.io/github/release/ME1312/SubServers-2/all.svg)](https://github.com/ME1312/SubServers-2/releases) [![Snapshot Verison](https://img.shields.io/badge/dynamic/xml.svg?label=snapshot&url=https%3A%2F%2Fdev.me1312.net%2Fmaven%2Fnet%2FME1312%2FSubServers%2FSubServers.Bungee%2Fmaven-metadata.xml&query=%2F%2Fversioning%2Frelease&colorB=blue)](https://dev.me1312.net/jenkins/job/SubServers%20Platform/) [![Discord](https://img.shields.io/discord/526520424880930867.svg)](https://discord.gg/VZ8YJqz)<br><br>
[![Release Verison](https://img.shields.io/github/release/ME1312/SubServers-2/all.svg)](https://github.com/ME1312/SubServers-2/releases) [![Snapshot Verison](https://img.shields.io/badge/dynamic/xml.svg?label=snapshot&url=https%3A%2F%2Fdev.me1312.net%2Fmaven%2Fnet%2FME1312%2FSubServers%2FSubServers.Bungee%2Fmaven-metadata.xml&query=%2F%2Fversioning%2Frelease&colorB=blue)](https://dev.me1312.net/jenkins/job/SubServers%20Platform/) [![Discord](https://img.shields.io/discord/526520424880930867.svg)](https://discord.gg/zWupnVn)<br><br>
SubServers 2 is a rewrite of SubServers, the Server Management Platform.<br>
> [https://www.spigotmc.org/resources/subservers-bungee.11264/](https://www.spigotmc.org/resources/subservers-bungee.11264/)<br>
> [https://www.spigotmc.org/resources/subservers-host.38833/](https://www.spigotmc.org/resources/subservers-host.38833/)<br>

View File

@ -237,6 +237,10 @@ public final class SubProxy extends BungeeCord implements Listener {
}
}
if (config.get().getMap("Settings").getBoolean("Smart-Fallback", true)) {
setReconnectHandler(new SmartFallback());
}
subprotocol = SubProtocol.get();
subprotocol.registerCipher("DHE", DHE.get(128));
subprotocol.registerCipher("DHE-128", DHE.get(128));
@ -652,9 +656,6 @@ public final class SubProxy extends BungeeCord implements Listener {
getPluginManager().registerCommand(null, SubCommand.BungeeServer.newInstance(this, "server").get());
getPluginManager().registerCommand(null, new SubCommand.BungeeList(this, "glist"));
}
if (config.get().getMap("Settings").getBoolean("Smart-Fallback", true)) {
setReconnectHandler(new SmartFallback());
}
getPluginManager().registerCommand(null, SubCommand.newInstance(this, "subservers").get());
getPluginManager().registerCommand(null, SubCommand.newInstance(this, "subserver").get());
getPluginManager().registerCommand(null, SubCommand.newInstance(this, "sub").get());

View File

@ -26,10 +26,6 @@
<id>puharesource-repo</id>
<url>https://repo.puha.io/repo/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
</repositories>
<dependencies>
@ -62,13 +58,7 @@
<dependency>
<groupId>io.puharesource.mc</groupId>
<artifactId>TitleManager</artifactId>
<version>1.5.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<version>1.5.11</version> <!-- Use this plugin to enable title messages on 1.8, 1.9, and 1.10 servers -->
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -101,7 +101,7 @@ public class DefaultUIRenderer extends UIRenderer {
int min = ((page - 1) * 36);
int max = (min + 35);
int count = (index.size() == 0)?27:((index.size() - min >= max)?36:index.size() - min);
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Host-Menu.Title"));
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
@ -111,7 +111,7 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
ItemStack adiv = block;
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
i = ((count < 9) ? ((9 - count) / 2) : 0);
boolean even = (count & 1) == 0 && count < 9;
NamedContainer<String, Short> enabled, disabled;
@ -149,7 +149,7 @@ public class DefaultUIRenderer extends UIRenderer {
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
i += (int) Math.floor((9 - count) / 2) + 1;
i += ((9 - count) / 2) + 1;
even = (count & 1) == 0;
} else {
i++;
@ -478,7 +478,7 @@ public class DefaultUIRenderer extends UIRenderer {
int min = ((page - 1) * 36);
int max = (min + 35);
int count = (index.size() == 0)?27:((index.size() - min >= max)?36:index.size() - min);
int area = (count % 9 == 0)?count: (int) (Math.floor(count / 9) + 1) * 9;
int area = (count % 9 == 0)?count: ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template.Title").replace("$str$", host.getDisplayName()));
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
@ -488,7 +488,7 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
ItemStack adiv = block;
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
i = ((count < 9) ? ((9 - count) / 2) : 0);
boolean even = (count & 1) == 0 && count < 9;
for (SubCreator.ServerTemplate template : index) {
@ -507,7 +507,7 @@ public class DefaultUIRenderer extends UIRenderer {
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
i += (int) Math.floor((9 - count) / 2) + 1;
i += ((9 - count) / 2) + 1;
even = (count & 1) == 0;
} else {
i++;
@ -591,7 +591,7 @@ public class DefaultUIRenderer extends UIRenderer {
int min = ((page - 1) * 36);
int max = (min + 35);
int count = (renderers.size() == 0)?27:((renderers.size() - min >= max)?36:renderers.size() - min);
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Host-Plugin.Title").replace("$str$", host.getDisplayName()));
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
@ -601,7 +601,7 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
ItemStack adiv = block;
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
i = ((count < 9) ? ((9 - count) / 2) : 0);
boolean even = (count & 1) == 0 && count < 9;
@ -613,7 +613,7 @@ public class DefaultUIRenderer extends UIRenderer {
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
i += (int) Math.floor((9 - count) / 2) + 1;
i += ((9 - count) / 2) + 1;
even = (count & 1) == 0;
} else {
i++;
@ -694,7 +694,7 @@ public class DefaultUIRenderer extends UIRenderer {
int min = ((page - 1) * 36);
int max = (min + 35);
int count = (index.size() == 0)?27:((index.size() - min >= max)?36:index.size() - min);
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Group-Menu.Title"));
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
@ -704,7 +704,7 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
ItemStack adiv = block;
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
i = ((count < 9) ? ((9 - count) / 2) : 0);
boolean even = (count & 1) == 0 && count < 9;
NamedContainer<String, Short> color;
@ -725,7 +725,7 @@ public class DefaultUIRenderer extends UIRenderer {
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
i += (int) Math.floor((9 - count) / 2) + 1;
i += ((9 - count) / 2) + 1;
even = (count & 1) == 0;
} else {
i++;
@ -805,7 +805,7 @@ public class DefaultUIRenderer extends UIRenderer {
int min = ((page - 1) * 36);
int max = (min + 35);
int count = (servers.size() == 0)?27:((servers.size() - min >= max)?36:servers.size() - min);
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, (host == null)?((group == null)?plugin.api.getLang("SubServers", "Interface.Server-Menu.Title"):plugin.api.getLang("SubServers", "Interface.Group-SubServer.Title").replace("$str$", group)):plugin.api.getLang("SubServers", "Interface.Host-SubServer.Title").replace("$str$", hostname.get()));
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
@ -815,7 +815,7 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
ItemStack adiv = block;
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
i = ((count < 9) ? ((9 - count) / 2) : 0);
boolean even = (count & 1) == 0 && count < 9;
NamedContainer<String, Short> external, online, temp, offline, disabled;
@ -889,7 +889,7 @@ public class DefaultUIRenderer extends UIRenderer {
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
i += (int) Math.floor((9 - count) / 2) + 1;
i += ((9 - count) / 2) + 1;
even = (count & 1) == 0;
} else {
i++;
@ -1209,7 +1209,7 @@ public class DefaultUIRenderer extends UIRenderer {
int min = ((page - 1) * 36);
int max = (min + 35);
int count = (renderers.size() == 0)?27:((renderers.size() - min >= max)?36:renderers.size() - min);
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", subserver.getDisplayName()));
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
@ -1219,7 +1219,7 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
ItemStack adiv = block;
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
i = ((count < 9) ? ((9 - count) / 2) : 0);
boolean even = (count & 1) == 0 && count < 9;
@ -1231,7 +1231,7 @@ public class DefaultUIRenderer extends UIRenderer {
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
i += (int) Math.floor((9 - count) / 2) + 1;
i += ((9 - count) / 2) + 1;
even = (count & 1) == 0;
} else {
i++;

View File

@ -10,6 +10,7 @@ import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.*;
@ -108,19 +109,25 @@ public abstract class UIRenderer {
line2 = ChatColor.RESET.toString();
}
try {
Player player = Bukkit.getPlayer(this.player);
if (plugin.api.getGameVersion().compareTo(new Version("1.11")) >= 0) {
if (ChatColor.stripColor(line1).length() == 0 && ChatColor.stripColor(line2).length() == 0) {
Bukkit.getPlayer(player).resetTitle();
player.resetTitle();
} else {
Bukkit.getPlayer(player).sendTitle(line1, line2, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20);
player.sendTitle(line1, line2, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20);
}
return true;
} else if (Bukkit.getPluginManager().getPlugin("TitleManager") != null) {
if (Util.isException(() -> Util.reflect(Class.forName("io.puharesource.mc.titlemanager.api.v2.TitleManagerAPI").getMethod("sendTitles", Player.class, String.class, String.class, int.class, int.class, int.class),
Bukkit.getPluginManager().getPlugin("TitleManager"), player, line1, line2, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20))) { // Attempt TitleAPI v2
// Fallback to TitleAPI v1
io.puharesource.mc.titlemanager.api.TitleObject obj = io.puharesource.mc.titlemanager.api.TitleObject.class.getConstructor(String.class, String.class).newInstance(line1, line2);
if (fadein >= 0) obj.setFadeIn(fadein);
if (stay >= 0) obj.setStay(stay);
if (fadeout >= 0) obj.setFadeOut(fadeout);
obj.send(Bukkit.getPlayer(player));
obj.send(player);
}
return true;
} else return false;
} catch (Throwable e) {
@ -249,16 +256,6 @@ public abstract class UIRenderer {
}
} catch (Exception e) {}
// vault name
if (!Util.isException(() -> Class.forName("net.milkbowl.vault.item.Items"))) {
net.milkbowl.vault.item.ItemInfo info = net.milkbowl.vault.item.Items.itemByString(item.get());
if (info != null) {
ItemStack stack = info.toStack();
stack.setAmount(1);
return stack;
}
}
return def;
}

View File

@ -2,7 +2,7 @@ name: SubServers-Client-Bukkit
main: net.ME1312.SubServers.Client.Bukkit.SubPlugin
version: "2.16a"
authors: ["ME1312"]
softdepend: [Vault, TitleManager]
softdepend: [TitleManager]
website: "https://github.com/ME1312/SubServers-2"
#commands:
# subservers:

View File

@ -92,6 +92,10 @@ public final class ExProxy extends BungeeCord implements Listener {
ConfigUpdater.updateConfig(new UniversalFile(dir, "sync.yml"));
config = new YAMLConfig(new UniversalFile(dir, "sync.yml"));
if (config.get().getMap("Settings").getBoolean("Smart-Fallback", true)) {
setReconnectHandler(new SmartFallback());
}
subprotocol = SubProtocol.get();
subprotocol.registerCipher("DHE", DHE.get(128));
subprotocol.registerCipher("DHE-128", DHE.get(128));