Prepare UI Elements for 1.13 // Add SubData Whitelist Wildcards

This commit is contained in:
ME1312 2017-12-07 12:22:36 -05:00
parent a8bbd09e9d
commit ce895cdecd
21 changed files with 292 additions and 168 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -149,7 +149,7 @@
<div class="block">Thrown if 192- or 256-bit AES encryption or decryption is attempted,
but not available on the particular Java platform.</div>
</dd>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html#allowConnection-java.net.InetAddress-">allowConnection(InetAddress)</a></span> - Static method in class net.ME1312.SubServers.Bungee.Network.<a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html" title="class in net.ME1312.SubServers.Bungee.Network">SubDataServer</a></dt>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html#allowConnection-java.lang.String-">allowConnection(String)</a></span> - Static method in class net.ME1312.SubServers.Bungee.Network.<a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html" title="class in net.ME1312.SubServers.Bungee.Network">SubDataServer</a></dt>
<dd>
<div class="block">Allow Connections from an Address</div>
</dd>
@ -388,7 +388,7 @@
</dd>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Bungee/Host/Internal/InternalHost.html#deleteSubServer-java.util.UUID-java.lang.String-">deleteSubServer(UUID, String)</a></span> - Method in class net.ME1312.SubServers.Bungee.Host.Internal.<a href="net/ME1312/SubServers/Bungee/Host/Internal/InternalHost.html" title="class in net.ME1312.SubServers.Bungee.Host.Internal">InternalHost</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html#denyConnection-java.net.InetAddress-">denyConnection(InetAddress)</a></span> - Static method in class net.ME1312.SubServers.Bungee.Network.<a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html" title="class in net.ME1312.SubServers.Bungee.Network">SubDataServer</a></dt>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html#denyConnection-java.lang.String-">denyConnection(String)</a></span> - Static method in class net.ME1312.SubServers.Bungee.Network.<a href="net/ME1312/SubServers/Bungee/Network/SubDataServer.html" title="class in net.ME1312.SubServers.Bungee.Network">SubDataServer</a></dt>
<dd>
<div class="block">Deny Connections from an Address</div>
</dd>

View File

@ -177,7 +177,7 @@ extends java.lang.Object</pre>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../net/ME1312/SubServers/Bungee/Network/SubDataServer.html#allowConnection-java.net.InetAddress-">allowConnection</a></span>(java.net.InetAddress&nbsp;address)</code>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../net/ME1312/SubServers/Bungee/Network/SubDataServer.html#allowConnection-java.lang.String-">allowConnection</a></span>(java.lang.String&nbsp;address)</code>
<div class="block">Allow Connections from an Address</div>
</td>
</tr>
@ -190,7 +190,7 @@ extends java.lang.Object</pre>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../net/ME1312/SubServers/Bungee/Network/SubDataServer.html#denyConnection-java.net.InetAddress-">denyConnection</a></span>(java.net.InetAddress&nbsp;address)</code>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../net/ME1312/SubServers/Bungee/Network/SubDataServer.html#denyConnection-java.lang.String-">denyConnection</a></span>(java.lang.String&nbsp;address)</code>
<div class="block">Deny Connections from an Address</div>
</td>
</tr>
@ -588,13 +588,13 @@ extends java.lang.Object</pre>
</dl>
</li>
</ul>
<a name="allowConnection-java.net.InetAddress-">
<a name="allowConnection-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>allowConnection</h4>
<pre>public static&nbsp;void&nbsp;allowConnection(java.net.InetAddress&nbsp;address)</pre>
<pre>public static&nbsp;void&nbsp;allowConnection(java.lang.String&nbsp;address)</pre>
<div class="block">Allow Connections from an Address</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
@ -602,13 +602,13 @@ extends java.lang.Object</pre>
</dl>
</li>
</ul>
<a name="denyConnection-java.net.InetAddress-">
<a name="denyConnection-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>denyConnection</h4>
<pre>public static&nbsp;void&nbsp;denyConnection(java.net.InetAddress&nbsp;address)</pre>
<pre>public static&nbsp;void&nbsp;denyConnection(java.lang.String&nbsp;address)</pre>
<div class="block">Deny Connections from an Address</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>

Binary file not shown.

View File

@ -1419,6 +1419,14 @@
<dd>
<div class="block">New PacketTeleportPlayer (Out)</div>
</dd>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#parseItem-java.lang.String-">parseItem(String)</a></span> - Method in class net.ME1312.SubServers.Client.Bukkit.Graphic.<a href="net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html" title="class in net.ME1312.SubServers.Client.Bukkit.Graphic">UIRenderer</a></dt>
<dd>
<div class="block">Parse an ItemStack from a String</div>
</dd>
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#parseItem-java.lang.String-org.bukkit.inventory.ItemStack-">parseItem(String, ItemStack)</a></span> - Method in class net.ME1312.SubServers.Client.Bukkit.Graphic.<a href="net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html" title="class in net.ME1312.SubServers.Client.Bukkit.Graphic">UIRenderer</a></dt>
<dd>
<div class="block">Parse an ItemStack from a String</div>
</dd>
</dl>
<a name="I:R">
<!-- -->

View File

@ -241,7 +241,7 @@ extends <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/U
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;net.ME1312.SubServers.Client.Bukkit.Graphic.<a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html" title="class in net.ME1312.SubServers.Client.Bukkit.Graphic">UIRenderer</a></h3>
<code><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#addHostPlugin-java.lang.String-net.ME1312.SubServers.Client.Bukkit.Graphic.Renderer-">addHostPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#addSubServerPlugin-java.lang.String-net.ME1312.SubServers.Client.Bukkit.Graphic.Renderer-">addSubServerPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#getHostPlugins--">getHostPlugins</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#getSubServerPlugins--">getSubServerPlugins</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#removeHostPlugin-java.lang.String-">removeHostPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#removeSubServerPlugin-java.lang.String-">removeSubServerPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-">sendTitle</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-int-">sendTitle</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-int-int-int-">sendTitle</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#setDownloading-java.lang.String-">setDownloading</a></code></li>
<code><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#addHostPlugin-java.lang.String-net.ME1312.SubServers.Client.Bukkit.Graphic.Renderer-">addHostPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#addSubServerPlugin-java.lang.String-net.ME1312.SubServers.Client.Bukkit.Graphic.Renderer-">addSubServerPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#getHostPlugins--">getHostPlugins</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#getSubServerPlugins--">getSubServerPlugins</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#parseItem-java.lang.String-">parseItem</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#parseItem-java.lang.String-org.bukkit.inventory.ItemStack-">parseItem</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#removeHostPlugin-java.lang.String-">removeHostPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#removeSubServerPlugin-java.lang.String-">removeSubServerPlugin</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-">sendTitle</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-int-">sendTitle</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-int-int-int-">sendTitle</a>, <a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#setDownloading-java.lang.String-">setDownloading</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">

View File

@ -17,7 +17,7 @@
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":6,"i3":6,"i4":9,"i5":9,"i6":6,"i7":6,"i8":6,"i9":6,"i10":6,"i11":6,"i12":6,"i13":9,"i14":9,"i15":6,"i16":10,"i17":10,"i18":10,"i19":6,"i20":10,"i21":6,"i22":6};
var methods = {"i0":9,"i1":9,"i2":6,"i3":6,"i4":9,"i5":9,"i6":6,"i7":6,"i8":6,"i9":6,"i10":6,"i11":6,"i12":6,"i13":10,"i14":10,"i15":9,"i16":9,"i17":6,"i18":10,"i19":10,"i20":10,"i21":6,"i22":10,"i23":6,"i24":6};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
@ -261,37 +261,50 @@ extends java.lang.Object</pre>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>org.bukkit.inventory.ItemStack</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#parseItem-java.lang.String-">parseItem</a></span>(java.lang.String&nbsp;str)</code>
<div class="block">Parse an ItemStack from a String</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>org.bukkit.inventory.ItemStack</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#parseItem-java.lang.String-org.bukkit.inventory.ItemStack-">parseItem</a></span>(java.lang.String&nbsp;str,
org.bukkit.inventory.ItemStack&nbsp;def)</code>
<div class="block">Parse an ItemStack from a String</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#removeHostPlugin-java.lang.String-">removeHostPlugin</a></span>(java.lang.String&nbsp;handle)</code>
<div class="block">Remove Host Plugin</div>
</td>
</tr>
<tr id="i14" class="altColor">
<tr id="i16" class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#removeSubServerPlugin-java.lang.String-">removeSubServerPlugin</a></span>(java.lang.String&nbsp;handle)</code>
<div class="block">Remove SubServer Plugin</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<tr id="i17" class="rowColor">
<td class="colFirst"><code>abstract void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#reopen--">reopen</a></span>()</code>
<div class="block">Reopens the current window</div>
</td>
</tr>
<tr id="i16" class="altColor">
<tr id="i18" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-">sendTitle</a></span>(java.lang.String&nbsp;str)</code>
<div class="block">Attempt to send a Title Message</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<tr id="i19" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-int-">sendTitle</a></span>(java.lang.String&nbsp;str,
int&nbsp;stay)</code>
<div class="block">Attempt to send a Title Message</div>
</td>
</tr>
<tr id="i18" class="altColor">
<tr id="i20" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#sendTitle-java.lang.String-int-int-int-">sendTitle</a></span>(java.lang.String&nbsp;str,
int&nbsp;fadein,
@ -300,7 +313,7 @@ extends java.lang.Object</pre>
<div class="block">Attempt to send a Title Message</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<tr id="i21" class="rowColor">
<td class="colFirst"><code>abstract void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#serverMenu-int-java.lang.String-java.lang.String-">serverMenu</a></span>(int&nbsp;page,
java.lang.String&nbsp;host,
@ -308,19 +321,19 @@ extends java.lang.Object</pre>
<div class="block">Opens the SubServer Menu</div>
</td>
</tr>
<tr id="i20" class="altColor">
<tr id="i22" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#setDownloading-java.lang.String-">setDownloading</a></span>(java.lang.String&nbsp;subtitle)</code>
<div class="block">Shows/Hides the Downloading Title Message</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<tr id="i23" class="rowColor">
<td class="colFirst"><code>abstract void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#subserverAdmin-java.lang.String-">subserverAdmin</a></span>(java.lang.String&nbsp;server)</code>
<div class="block">Opens SubServer/&lt;name&gt;</div>
</td>
</tr>
<tr id="i22" class="altColor">
<tr id="i24" class="altColor">
<td class="colFirst"><code>abstract void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Client/Bukkit/Graphic/UIRenderer.html#subserverPlugin-int-java.lang.String-">subserverPlugin</a></span>(int&nbsp;page,
java.lang.String&nbsp;server)</code>
@ -475,9 +488,9 @@ extends java.lang.Object</pre>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>str</code> - Message</dd>
<dd><code>fadein</code> - FadeIn Transition length</dd>
<dd><code>stay</code> - How long the message should stay</dd>
<dd><code>fadeout</code> - FadeOut Transition length</dd>
<dd><code>fadein</code> - FadeIn Transition length (in ticks)</dd>
<dd><code>stay</code> - How long the message should stay (in ticks)</dd>
<dd><code>fadeout</code> - FadeOut Transition length (in ticks)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Success Status</dd>
</dl>
@ -497,6 +510,40 @@ extends java.lang.Object</pre>
</dl>
</li>
</ul>
<a name="parseItem-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>parseItem</h4>
<pre>public&nbsp;org.bukkit.inventory.ItemStack&nbsp;parseItem(java.lang.String&nbsp;str)</pre>
<div class="block">Parse an ItemStack from a String</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>str</code> - String to parse</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>ItemStack</dd>
</dl>
</li>
</ul>
<a name="parseItem-java.lang.String-org.bukkit.inventory.ItemStack-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>parseItem</h4>
<pre>public&nbsp;org.bukkit.inventory.ItemStack&nbsp;parseItem(java.lang.String&nbsp;str,
org.bukkit.inventory.ItemStack&nbsp;def)</pre>
<div class="block">Parse an ItemStack from a String</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>str</code> - String to parse</dd>
<dd><code>def</code> - Default to return if unable to parse</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>ItemStack</dd>
</dl>
</li>
</ul>
<a name="addHostPlugin-java.lang.String-net.ME1312.SubServers.Client.Bukkit.Graphic.Renderer-">
<!-- -->
</a>

Binary file not shown.

Binary file not shown.

View File

@ -35,7 +35,7 @@ public abstract class Host implements ExtraDataHandler {
*/
public Host(SubPlugin plugin, String name, Boolean enabled, InetAddress address, String directory, String gitBash) {
if (name.contains(" ")) throw new InvalidHostException("Host names cannot have spaces: " + name);
SubDataServer.allowConnection(address);
SubDataServer.allowConnection(address.getHostAddress());
}
/**

View File

@ -37,7 +37,7 @@ public class ServerContainer extends BungeeServerInfo implements Server {
super(name, address, ChatColor.translateAlternateColorCodes('&', motd), restricted);
if (Util.isNull(name, address, motd, hidden, restricted)) throw new NullPointerException();
if (name.contains(" ")) throw new InvalidServerException("Server names cannot have spaces: " + name);
SubDataServer.allowConnection(getAddress().getAddress());
SubDataServer.allowConnection(getAddress().getAddress().getHostAddress());
this.motd = motd;
this.restricted = restricted;
this.hidden = hidden;

View File

@ -14,6 +14,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* SubDataServer Class
@ -22,7 +24,7 @@ public final class SubDataServer {
private static int MAX_QUEUE = 64;
private static HashMap<Class<? extends PacketOut>, String> pOut = new HashMap<Class<? extends PacketOut>, String>();
private static HashMap<String, List<PacketIn>> pIn = new HashMap<String, List<PacketIn>>();
private static List<InetAddress> allowedAddresses = new ArrayList<InetAddress>();
private static List<String> allowedAddresses = new ArrayList<String>();
private static boolean defaults = false;
private HashMap<String, Client> clients = new HashMap<String, Client>();
private ServerSocket server;
@ -50,10 +52,10 @@ public final class SubDataServer {
if (Util.isNull(plugin, port, encryption, MAX_QUEUE)) throw new NullPointerException();
if (address == null) {
server = new ServerSocket(port, MAX_QUEUE);
allowConnection(InetAddress.getByName("127.0.0.1"));
allowConnection("127.0.0.1");
} else {
server = new ServerSocket(port, MAX_QUEUE, address);
allowConnection(address);
allowConnection(address.getHostAddress());
}
this.plugin = plugin;
this.encryption = encryption;
@ -65,7 +67,7 @@ public final class SubDataServer {
defaults = true;
for (String s : plugin.config.get().getSection("Settings").getSection("SubData").getStringList("Allowed-Connections", new ArrayList<String>())) {
try {
allowedAddresses.add(InetAddress.getByName(s));
allowedAddresses.add(s);
} catch (Exception e) {
e.printStackTrace();
}
@ -152,7 +154,7 @@ public final class SubDataServer {
*/
public Client addClient(Socket socket) throws IOException {
if (Util.isNull(socket)) throw new NullPointerException();
if (allowedAddresses.contains(socket.getInetAddress())) {
if (checkConnection(socket.getInetAddress())) {
Client client = new Client(this, socket);
System.out.println("SubData > " + client.getAddress().toString() + " has connected");
clients.put(client.getAddress().toString(), client);
@ -341,17 +343,34 @@ public final class SubDataServer {
*
* @param address Address to allow
*/
public static void allowConnection(InetAddress address) {
public static void allowConnection(String address) {
if (Util.isNull(address)) throw new NullPointerException();
if (!allowedAddresses.contains(address)) allowedAddresses.add(address);
}
private boolean checkConnection(InetAddress address) {
boolean whitelisted = false;
Matcher regaddress = Pattern.compile("^(\\d{1,3}).(\\d{1,3}).(\\d{1,3}).(\\d{1,3})$").matcher(address.getHostAddress());
if (regaddress.find()) {
for (String allowed : allowedAddresses) if (!whitelisted) {
Matcher regallowed = Pattern.compile("^(\\d{1,3}|%).(\\d{1,3}|%).(\\d{1,3}|%).(\\d{1,3}|%)$").matcher(allowed);
if (regallowed.find() && (
(regaddress.group(1).equals(regallowed.group(1)) || regallowed.group(1).equals("%")) &&
(regaddress.group(2).equals(regallowed.group(2)) || regallowed.group(2).equals("%")) &&
(regaddress.group(3).equals(regallowed.group(3)) || regallowed.group(3).equals("%")) &&
(regaddress.group(4).equals(regallowed.group(4)) || regallowed.group(4).equals("%"))
)) whitelisted = true;
}
}
return whitelisted;
}
/**
* Deny Connections from an Address
*
* @param address Address to deny
*/
public static void denyConnection(InetAddress address) {
public static void denyConnection(String address) {
if (Util.isNull(address)) throw new NullPointerException();
allowedAddresses.remove(address);
}

Binary file not shown.

View File

@ -51,7 +51,6 @@ public class InternalUIHandler implements UIHandler, Listener {
enabled = false;
}
@SuppressWarnings("ConstantConditions")
@EventHandler(priority = EventPriority.HIGHEST)
public void click(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();

View File

@ -1,7 +1,9 @@
package net.ME1312.SubServers.Client.Bukkit.Graphic;
import net.ME1312.SubServers.Client.Bukkit.Library.Container;
import net.ME1312.SubServers.Client.Bukkit.Library.NamedContainer;
import net.ME1312.SubServers.Client.Bukkit.Library.Util;
import net.ME1312.SubServers.Client.Bukkit.Library.Version.Version;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadHostInfo;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadServerInfo;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadServerList;
@ -65,37 +67,16 @@ public class InternalUIRenderer extends UIRenderer {
reopen();
}
@SuppressWarnings("deprecation")
private ItemStack parseItem(String str) {
final Container<String> item = new Container<String>(str);
// int
Matcher matcher = Pattern.compile("(?i)^(\\d+)$").matcher(item.get());
if (matcher.find()) {
return new ItemStack(Integer.parseInt(matcher.group(1)));
}
// int:int
matcher.reset();
matcher = Pattern.compile("(?i)^(\\d+):(\\d+)$").matcher(item.get());
if (matcher.find()) {
return new ItemStack(Integer.parseInt(matcher.group(1)), 1, Short.parseShort(matcher.group(2)));
}
// minecraft:name
if (item.get().startsWith("minecraft:")) {
item.set(item.get().substring(10));
}
// bukkit name
if (!Util.isException(() -> Material.valueOf(item.get().toUpperCase()))) {
return new ItemStack(Material.valueOf(item.get().toUpperCase()));
}
// 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) {
return new ItemStack(info.getType(), 1, info.getSubTypeId());
ItemStack createItem(String material, String newdata, short olddata) {
try {
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
return ItemStack.class.getConstructor(Material.class, int.class, short.class).newInstance(Material.valueOf(material), 1, olddata);
} else {
return new ItemStack(Material.valueOf(newdata), 1);
}
} catch (Exception e) {
return new ItemStack(Material.AIR);
}
return new ItemStack(Material.ENDER_CHEST);
}
public void hostMenu(final int page) {
@ -111,7 +92,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -123,7 +104,7 @@ public class InternalUIRenderer extends UIRenderer {
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.Host-Menu.Title", '&'));
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
block.setItemMeta(divMeta);
while (i < area) {
inv.setItem(i, block);
@ -142,7 +123,7 @@ public class InternalUIRenderer extends UIRenderer {
disabled = (short) (((i & 1) == 0) ? 2 : 14);
if (json.getJSONObject("hosts").getJSONObject(host).getBoolean("enabled")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, enabled);
block = createItem("STAINED_GLASS_PANE", "AIR", enabled);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.AQUA + json.getJSONObject("hosts").getJSONObject(host).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -152,7 +133,7 @@ public class InternalUIRenderer extends UIRenderer {
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) lore.add(ChatColor.WHITE + json.getJSONObject("hosts").getJSONObject(host).getString("address"));
blockMeta.setLore(lore);
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, disabled);
block = createItem("STAINED_GLASS_PANE", "AIR", disabled);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + json.getJSONObject("hosts").getJSONObject(host).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -176,7 +157,7 @@ public class InternalUIRenderer extends UIRenderer {
}
if (hosts.size() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Menu.No-Hosts", '&'));
block.setItemMeta(blockMeta);
@ -193,7 +174,7 @@ public class InternalUIRenderer extends UIRenderer {
i = inv.getSize() - 9;
if (min != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -201,7 +182,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(i++, block);
} else i += 2;
i++;
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 1);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 1);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Menu.Group-Menu", '&'));
block.setItemMeta(blockMeta);
@ -210,7 +191,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(i++, block);
i++;
if (hosts.size() - 1 > max) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -235,7 +216,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -249,16 +230,16 @@ public class InternalUIRenderer extends UIRenderer {
}
if (!(Bukkit.getPlayer(player).hasPermission("subservers.host.create.*") || Bukkit.getPlayer(player).hasPermission("subservers.host.create." + host.toLowerCase()))) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Creator", '&')));
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.host.create." + host.toLowerCase())));
} else if (!json.getJSONObject("host").getBoolean("enabled")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Creator", '&')));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Creator", '&'));
}
@ -270,7 +251,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(11, block);
inv.setItem(12, block);
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.SubServers", '&'));
block.setItemMeta(blockMeta);
@ -282,11 +263,11 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(16, block);
if (!json.getJSONObject("host").getBoolean("enabled")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Plugins", '&')));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 11);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Plugins", '&'));
}
@ -295,7 +276,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(28, block);
if (json.getJSONObject("host").getBoolean("enabled")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 11);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.AQUA + json.getJSONObject("host").getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -305,7 +286,7 @@ public class InternalUIRenderer extends UIRenderer {
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) lore.add(ChatColor.WHITE + json.getJSONObject("host").getString("address"));
blockMeta.setLore(lore);
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + json.getJSONObject("host").getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -322,7 +303,7 @@ public class InternalUIRenderer extends UIRenderer {
if (hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -350,7 +331,7 @@ public class InternalUIRenderer extends UIRenderer {
setDownloading(null);
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -364,11 +345,11 @@ public class InternalUIRenderer extends UIRenderer {
}
if (options.getName() == null) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Name", '&'));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GREEN + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Name", '&'));
blockMeta.setLore(Arrays.asList(ChatColor.GRAY + options.getName()));
@ -379,11 +360,11 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(12, block);
if (options.getPort() <= 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Port", '&'));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GREEN + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Port", '&'));
blockMeta.setLore(Arrays.asList(ChatColor.GRAY.toString() + options.getPort()));
@ -394,11 +375,11 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(16, block);
if (options.getTemplate() == null) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Template", '&'));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GREEN + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Template", '&'));
blockMeta.setLore(Arrays.asList(ChatColor.GRAY + options.getTemplate()));
@ -409,11 +390,11 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(30, block);
if (options.getVersion() == null) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Version", '&'));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GREEN + plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Version", '&'));
blockMeta.setLore(Arrays.asList(ChatColor.GRAY + "v" + options.getVersion().toString()));
@ -424,12 +405,12 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(34, block);
if (!options.hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY + ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Undo", '&')));
block.setItemMeta(blockMeta);
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 1);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 1);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Undo", '&'));
block.setItemMeta(blockMeta);
@ -439,13 +420,13 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(46, block);
if (options.getName() == null || options.getTemplate() == null || options.getVersion() == null || options.getPort() <= 0 && options.getMemory() < 256) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY + ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Submit", '&')));
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Form-Incomplete", '&')));
block.setItemMeta(blockMeta);
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Submit", '&'));
block.setItemMeta(blockMeta);
@ -456,7 +437,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(50, block);
if (hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -489,7 +470,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -501,7 +482,7 @@ public class InternalUIRenderer extends UIRenderer {
int area = (count % 9 == 0)?count: (int) (Math.floor(count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Template.Title", '&').replace("$str$", json.getJSONObject("host").getString("display")));
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
block.setItemMeta(divMeta);
while (i < area) {
inv.setItem(i, block);
@ -515,7 +496,7 @@ public class InternalUIRenderer extends UIRenderer {
if (templates.indexOf(template) >= min && templates.indexOf(template) <= max) {
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
block = parseItem(json.getJSONObject("host").getJSONObject("creator").getJSONObject("templates").getJSONObject(template).getString("icon"));
block = parseItem(json.getJSONObject("host").getJSONObject("creator").getJSONObject("templates").getJSONObject(template).getString("icon"), new ItemStack(Material.ENDER_CHEST));
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.YELLOW + json.getJSONObject("host").getJSONObject("creator").getJSONObject("templates").getJSONObject(template).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -536,7 +517,7 @@ public class InternalUIRenderer extends UIRenderer {
}
if (templates.size() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Creator.Edit-Template.No-Templates", '&'));
block.setItemMeta(blockMeta);
@ -553,7 +534,7 @@ public class InternalUIRenderer extends UIRenderer {
i = inv.getSize() - 9;
if (min != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -561,7 +542,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(i++, block);
} else i += 2;
i++;
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -570,7 +551,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(i++, block);
i++;
if (templates.size() - 1 > max) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -602,7 +583,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -614,7 +595,7 @@ public class InternalUIRenderer extends UIRenderer {
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.Title", '&').replace("$str$", json.getJSONObject("host").getString("display")));
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
block.setItemMeta(divMeta);
while (i < area) {
inv.setItem(i, block);
@ -642,7 +623,7 @@ public class InternalUIRenderer extends UIRenderer {
}
if (renderers.size() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.No-Plugins", '&'));
block.setItemMeta(blockMeta);
@ -659,7 +640,7 @@ public class InternalUIRenderer extends UIRenderer {
i = inv.getSize() - 9;
if (min != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -668,7 +649,7 @@ public class InternalUIRenderer extends UIRenderer {
} else i += 2;
i++;
if (hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -678,7 +659,7 @@ public class InternalUIRenderer extends UIRenderer {
i++;
}
if (renderers.size() - 1 > max) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -705,7 +686,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -717,7 +698,7 @@ public class InternalUIRenderer extends UIRenderer {
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.Group-Menu.Title", '&'));
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
block.setItemMeta(divMeta);
while (i < area) {
inv.setItem(i, block);
@ -734,7 +715,7 @@ public class InternalUIRenderer extends UIRenderer {
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
color = (short) (((i & 1) == 0) ? 1 : 4);
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, color);
block = createItem("STAINED_GLASS_PANE", "AIR", color);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GOLD + group);
LinkedList<String> lore = new LinkedList<String>();
@ -754,7 +735,7 @@ public class InternalUIRenderer extends UIRenderer {
}
if (groups.size() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Group-Menu.No-Groups", '&'));
block.setItemMeta(blockMeta);
@ -771,7 +752,7 @@ public class InternalUIRenderer extends UIRenderer {
i = inv.getSize() - 9;
if (min != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -779,7 +760,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(i++, block);
} else i += 2;
i++;
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Group-Menu.Server-Menu", '&'));
block.setItemMeta(blockMeta);
@ -788,7 +769,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(i++, block);
i++;
if (groups.size() - 1 > max) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -839,7 +820,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -851,7 +832,7 @@ public class InternalUIRenderer extends UIRenderer {
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, (host == null)?((group == null)?plugin.lang.getSection("Lang").getColoredString("Interface.Server-Menu.Title", '&'):plugin.lang.getSection("Lang").getColoredString("Interface.Group-SubServer.Title", '&').replace("$str$", group)):plugin.lang.getSection("Lang").getColoredString("Interface.Host-SubServer.Title", '&').replace("$str$", json.getJSONObject("hosts").getJSONObject(host).getString("display")));
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
block.setItemMeta(divMeta);
while (i < area) {
inv.setItem(i, block);
@ -873,7 +854,7 @@ public class InternalUIRenderer extends UIRenderer {
disabled = (short) (((i & 1) == 0) ? 2 : 14);
if (hosts.get(server) == null) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, external);
block = createItem("STAINED_GLASS_PANE", "AIR", external);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.AQUA + json.getJSONObject("servers").getJSONObject(server).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -885,7 +866,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?json.getJSONObject("servers").getJSONObject(server).getString("address"):json.getJSONObject("servers").getJSONObject(server).getString("address").split(":")[json.getJSONObject("servers").getJSONObject(server).getString("address").split(":").length - 1]));
blockMeta.setLore(lore);
} else if (json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getBoolean("temp")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, temp);
block = createItem("STAINED_GLASS_PANE", "AIR", temp);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.AQUA + json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -896,7 +877,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address"):json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address").split(":")[json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address").split(":").length - 1]));
blockMeta.setLore(lore);
} else if (json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getBoolean("running")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, online);
block = createItem("STAINED_GLASS_PANE", "AIR", online);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GREEN + json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -906,7 +887,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address"):json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address").split(":")[json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address").split(":").length - 1]));
blockMeta.setLore(lore);
} else if (json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getBoolean("enabled") && json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getJSONArray("incompatible").length() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, offline);
block = createItem("STAINED_GLASS_PANE", "AIR", offline);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.YELLOW + json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -916,7 +897,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address"):json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address").split(":")[json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("address").split(":").length - 1]));
blockMeta.setLore(lore);
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, disabled);
block = createItem("STAINED_GLASS_PANE", "AIR", disabled);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + json.getJSONObject("hosts").getJSONObject(hosts.get(server)).getJSONObject("servers").getJSONObject(server).getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -948,7 +929,7 @@ public class InternalUIRenderer extends UIRenderer {
}
if (servers.size() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Server-Menu.No-Servers", '&'));
block.setItemMeta(blockMeta);
@ -965,7 +946,7 @@ public class InternalUIRenderer extends UIRenderer {
i = inv.getSize() - 9;
if (min != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -974,7 +955,7 @@ public class InternalUIRenderer extends UIRenderer {
} else i += 2;
i++;
if (host == null || group == null || hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) ((host == null && group == null)?11:14));
block = createItem("STAINED_GLASS_PANE", "AIR", (short) ((host == null && group == null)?11:14));
blockMeta = block.getItemMeta();
blockMeta.setDisplayName((host == null && group == null)?plugin.lang.getSection("Lang").getColoredString("Interface.Server-Menu.Host-Menu", '&'):plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -984,7 +965,7 @@ public class InternalUIRenderer extends UIRenderer {
i++;
}
if (servers.size() - 1 > max) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -1008,7 +989,7 @@ public class InternalUIRenderer extends UIRenderer {
lastVisitedObjects[0] = subserver;
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -1024,12 +1005,12 @@ public class InternalUIRenderer extends UIRenderer {
if (json.getJSONObject("server").getBoolean("running")) {
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate." + subserver.toLowerCase()))) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Terminate", '&')));
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.subserver.terminate." + subserver.toLowerCase())));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Terminate", '&'));
}
@ -1039,12 +1020,12 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(10, block);
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.stop.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.stop." + subserver.toLowerCase()))) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Stop", '&')));
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.subserver.stop." + subserver.toLowerCase())));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 2);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 2);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Stop", '&'));
}
@ -1055,12 +1036,12 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(12, block);
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.command.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.command." + subserver.toLowerCase()))) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Command", '&')));
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.subserver.command." + subserver.toLowerCase())));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Command", '&'));
}
@ -1073,16 +1054,16 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(16, block);
} else {
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.start.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.start." + subserver.toLowerCase()))) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&')));
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.subserver.start." + subserver.toLowerCase())));
} else if (!json.getJSONObject("server").getBoolean("enabled") || json.getJSONObject("server").getJSONArray("incompatible").length() != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&')));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&'));
}
@ -1096,11 +1077,11 @@ public class InternalUIRenderer extends UIRenderer {
}
if (!json.getJSONObject("server").getBoolean("enabled")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Plugins", '&')));
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 11);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Plugins", '&'));
}
@ -1109,7 +1090,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(28, block);
if (json.getJSONObject("server").getBoolean("temp")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 11);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.AQUA + json.getJSONObject("server").getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -1120,7 +1101,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + json.getJSONObject("server").getString("address"));
blockMeta.setLore(lore);
} else if (json.getJSONObject("server").getBoolean("running")) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GREEN + json.getJSONObject("server").getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -1130,7 +1111,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + json.getJSONObject("server").getString("address"));
blockMeta.setLore(lore);
} else if (json.getJSONObject("server").getBoolean("enabled") && json.getJSONObject("server").getJSONArray("incompatible").length() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.YELLOW + json.getJSONObject("server").getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -1140,7 +1121,7 @@ public class InternalUIRenderer extends UIRenderer {
lore.add(ChatColor.WHITE + json.getJSONObject("server").getString("address"));
blockMeta.setLore(lore);
} else {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + json.getJSONObject("server").getString("display"));
LinkedList<String> lore = new LinkedList<String>();
@ -1164,7 +1145,7 @@ public class InternalUIRenderer extends UIRenderer {
inv.setItem(32, block);
if (hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -1197,7 +1178,7 @@ public class InternalUIRenderer extends UIRenderer {
ItemStack block;
ItemMeta blockMeta;
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack div = createItem("STAINED_GLASS_PANE", "AIR", (short) 15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
@ -1209,7 +1190,7 @@ public class InternalUIRenderer extends UIRenderer {
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.Title", '&').replace("$str$", json.getJSONObject("server").getString("display")));
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 7);
block.setItemMeta(divMeta);
while (i < area) {
inv.setItem(i, block);
@ -1237,7 +1218,7 @@ public class InternalUIRenderer extends UIRenderer {
}
if (renderers.size() == 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.No-Plugins", '&'));
block.setItemMeta(blockMeta);
@ -1254,7 +1235,7 @@ public class InternalUIRenderer extends UIRenderer {
i = inv.getSize() - 9;
if (min != 0) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
block.setItemMeta(blockMeta);
@ -1263,7 +1244,7 @@ public class InternalUIRenderer extends UIRenderer {
} else i += 2;
i++;
if (hasHistory()) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
block.setItemMeta(blockMeta);
@ -1273,7 +1254,7 @@ public class InternalUIRenderer extends UIRenderer {
i++;
}
if (renderers.size() - 1 > max) {
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
block = createItem("STAINED_GLASS_PANE", "AIR", (short) 4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
block.setItemMeta(blockMeta);

View File

@ -8,9 +8,14 @@ import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketCreateServer;
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 org.bukkit.scheduler.BukkitTask;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* GUI Renderer Layout Class
@ -19,7 +24,7 @@ public abstract class UIRenderer {
protected static HashMap<String, Renderer> hostPlugins = new HashMap<String, Renderer>();
protected static HashMap<String, Renderer> subserverPlugins = new HashMap<String, Renderer>();
private NamedContainer<String, Integer> tdownload = null;
private BukkitTask download = null;
private int download = -1;
private final UUID player;
private SubPlugin plugin;
@ -87,14 +92,14 @@ public abstract class UIRenderer {
* Attempt to send a Title Message
*
* @param str Message
* @param fadein FadeIn Transition length
* @param stay How long the message should stay
* @param fadeout FadeOut Transition length
* @param fadein FadeIn Transition length (in ticks)
* @param stay How long the message should stay (in ticks)
* @param fadeout FadeOut Transition length (in ticks)
* @return Success Status
*/
public boolean sendTitle(String str, int fadein, int stay, int fadeout) {
if (Util.isNull(str, fadein, stay, fadeout)) throw new NullPointerException();
if (Bukkit.getPluginManager().getPlugin("TitleManager") != null && plugin.config.get().getSection("Settings").getBoolean("Use-Title-Messages", true)) {
if (plugin.config.get().getSection("Settings").getBoolean("Use-Title-Messages", true)) {
String line1, line2;
if (!str.startsWith("\n") && str.contains("\n")) {
line1 = str.split("\\n")[0];
@ -104,18 +109,25 @@ public abstract class UIRenderer {
line2 = ChatColor.RESET.toString();
}
try {
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));
return true;
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();
} else {
Bukkit.getPlayer(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) {
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));
return true;
} else return false;
} catch (Throwable e) {
return false;
}
} else {
return false;
}
} else return false;
}
/**
@ -124,10 +136,11 @@ public abstract class UIRenderer {
* @param subtitle Subtitle to display (or null to hide)
*/
public void setDownloading(String subtitle) {
if (subtitle != null && !(Bukkit.getPluginManager().getPlugin("TitleManager") != null && plugin.config.get().getSection("Settings").getBoolean("Use-Title-Messages", true))) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (subtitle != null && !(plugin.config.get().getSection("Settings").getBoolean("Use-Title-Messages", true) && (plugin.api.getGameVersion().compareTo(new Version("1.11")) >= 0 || Bukkit.getPluginManager().getPlugin("TitleManager") != null))) {
if (download != -1) Bukkit.getScheduler().cancelTask(download);
download = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (tdownload != null) Bukkit.getPlayer(player).sendMessage(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Downloading", '&').replace("$str$", subtitle));
download = null;
download = -1;
}, 50L);
} if (subtitle != null && tdownload == null) {
tdownload = new NamedContainer<String, Integer>(subtitle, 0);
@ -169,13 +182,70 @@ public abstract class UIRenderer {
if (tdownload != null) {
tdownload = null;
}
if (download != null) {
download.cancel();
download = null;
if (download != -1) {
Bukkit.getScheduler().cancelTask(download);
download = -1;
}
}
}
/**
* Parse an ItemStack from a String
*
* @param str String to parse
* @return ItemStack
*/
public ItemStack parseItem(String str) {
return parseItem(str, new ItemStack(Material.AIR));
}
/**
* Parse an ItemStack from a String
*
* @param str String to parse
* @param def Default to return if unable to parse
* @return ItemStack
*/
public ItemStack parseItem(String str, ItemStack def) {
final Container<String> item = new Container<String>(str);
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
try {
// int
Matcher matcher = Pattern.compile("(?i)^(\\d+)$").matcher(item.get());
if (matcher.find()) {
return ItemStack.class.getConstructor(int.class, int.class).newInstance(Integer.parseInt(matcher.group(1)), 1);
}
// int:int
matcher.reset();
matcher = Pattern.compile("(?i)^(\\d+):(\\d+)$").matcher(item.get());
if (matcher.find()) {
return ItemStack.class.getConstructor(int.class, int.class, short.class).newInstance(Integer.parseInt(matcher.group(1)), 1, Short.parseShort(matcher.group(2)));
}
} catch (Exception e) {
return def;
}
}
// minecraft:name
if (item.get().toLowerCase().startsWith("minecraft:")) {
item.set(item.get().substring(10));
}
// bukkit name
if (!Util.isException(() -> Material.valueOf(item.get().toUpperCase()))) {
return new ItemStack(Material.valueOf(item.get().toUpperCase()), 1);
}
// 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;
}
/**
* Add Host Plugin
*

View File

@ -128,7 +128,7 @@ public final class SubAPI {
*/
public Version getGameVersion() {
try {
return new Version(Bukkit.getServer().getVersion().split("\\(MC\\: ")[1].split("\\)")[0]);
return new Version(Bukkit.getBukkitVersion().split("-")[0]);
} catch (ArrayIndexOutOfBoundsException e) {
return new Version(plugin.version.toString().substring(0, plugin.version.toString().length() - 1));
}

Binary file not shown.