mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-28 21:26:01 +01:00
Remove package.xml requirement for SubServers.Host
This commit is contained in:
parent
92c649eabe
commit
56f8d3dfba
@ -289,7 +289,7 @@
|
||||
<br>
|
||||
<div class="footer">
|
||||
<hr>
|
||||
<a href="javascript:void(0)" draggable="false"><img src="https://src.ME1312.net/img/me1312.net.inverted.png" draggable="false" /></a>
|
||||
<a href="https://www.ME1312.net" draggable="false"><img src="https://src.ME1312.net/img/me1312.net.inverted.png" draggable="false" /></a>
|
||||
<div><a href="https://github.com/ME1312/SubServers-2/tree/master/Artifacts" target="_blank" draggable="false">Download not working?</a></div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -703,6 +703,8 @@
|
||||
<dd>
|
||||
<div class="block">Gets this Plugin's data folder</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Host/Library/PluginClassLoader.html#getDefaultClass--">getDefaultClass()</a></span> - Method in class net.ME1312.SubServers.Host.Library.<a href="net/ME1312/SubServers/Host/Library/PluginClassLoader.html" title="class in net.ME1312.SubServers.Host.Library">PluginClassLoader</a></dt>
|
||||
<dd> </dd>
|
||||
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Host/Library/Config/YAMLValue.html#getDefiningSection--">getDefiningSection()</a></span> - Method in class net.ME1312.SubServers.Host.Library.Config.<a href="net/ME1312/SubServers/Host/Library/Config/YAMLValue.html" title="class in net.ME1312.SubServers.Host.Library.Config">YAMLValue</a></dt>
|
||||
<dd>
|
||||
<div class="block">Get the YAML Section this Object was defined in</div>
|
||||
@ -1997,6 +1999,8 @@
|
||||
<dd>
|
||||
<div class="block">Sets the Command to be Sent</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Host/Library/PluginClassLoader.html#setDefaultClass-java.lang.Class-">setDefaultClass(Class<?>)</a></span> - Method in class net.ME1312.SubServers.Host.Library.<a href="net/ME1312/SubServers/Host/Library/PluginClassLoader.html" title="class in net.ME1312.SubServers.Host.Library">PluginClassLoader</a></dt>
|
||||
<dd> </dd>
|
||||
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Host/Executable/SubCreator.ServerTemplate.html#setDisplayName-java.lang.String-">setDisplayName(String)</a></span> - Method in class net.ME1312.SubServers.Host.Executable.<a href="net/ME1312/SubServers/Host/Executable/SubCreator.ServerTemplate.html" title="class in net.ME1312.SubServers.Host.Executable">SubCreator.ServerTemplate</a></dt>
|
||||
<dd>
|
||||
<div class="block">Sets the Display Name for this Template</div>
|
||||
|
@ -17,6 +17,12 @@
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
var methods = {"i0":10,"i1":10};
|
||||
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
|
||||
var altColor = "altColor";
|
||||
var rowColor = "rowColor";
|
||||
var tableTab = "tableTab";
|
||||
var activeTableTab = "activeTableTab";
|
||||
</script>
|
||||
<noscript>
|
||||
<div>JavaScript is disabled on your browser.</div>
|
||||
@ -69,13 +75,13 @@
|
||||
<li>Nested | </li>
|
||||
<li>Field | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#methods.inherited.from.class.java.net.URLClassLoader">Method</a></li>
|
||||
<li><a href="#method.summary">Method</a></li>
|
||||
</ul>
|
||||
<ul class="subNavList">
|
||||
<li>Detail: </li>
|
||||
<li>Field | </li>
|
||||
<li><a href="#constructor.detail">Constr</a> | </li>
|
||||
<li>Method</li>
|
||||
<li><a href="#method.detail">Method</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<a name="skip.navbar.top">
|
||||
@ -160,6 +166,21 @@ extends java.net.URLClassLoader</pre>
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Method Summary</h3>
|
||||
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
|
||||
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption>
|
||||
<tr>
|
||||
<th class="colFirst" scope="col">Modifier and Type</th>
|
||||
<th class="colLast" scope="col">Method and Description</th>
|
||||
</tr>
|
||||
<tr id="i0" class="altColor">
|
||||
<td class="colFirst"><code>java.lang.Class<?></code></td>
|
||||
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../net/ME1312/SubServers/Host/Library/PluginClassLoader.html#getDefaultClass--">getDefaultClass</a></span>()</code> </td>
|
||||
</tr>
|
||||
<tr id="i1" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../net/ME1312/SubServers/Host/Library/PluginClassLoader.html#setDefaultClass-java.lang.Class-">setDefaultClass</a></span>(java.lang.Class<?> clazz)</code> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.java.net.URLClassLoader">
|
||||
<!-- -->
|
||||
@ -227,6 +248,37 @@ extends java.net.URLClassLoader</pre>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- ============ METHOD DETAIL ========== -->
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="method.detail">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Method Detail</h3>
|
||||
<a name="setDefaultClass-java.lang.Class-">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>setDefaultClass</h4>
|
||||
<pre>public void setDefaultClass(java.lang.Class<?> clazz)</pre>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getDefaultClass--">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockListLast">
|
||||
<li class="blockList">
|
||||
<h4>getDefaultClass</h4>
|
||||
<pre>public java.lang.Class<?> getDefaultClass()
|
||||
throws java.lang.ClassNotFoundException</pre>
|
||||
<dl>
|
||||
<dt><span class="throwsLabel">Throws:</span></dt>
|
||||
<dd><code>java.lang.ClassNotFoundException</code></dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -280,13 +332,13 @@ extends java.net.URLClassLoader</pre>
|
||||
<li>Nested | </li>
|
||||
<li>Field | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#methods.inherited.from.class.java.net.URLClassLoader">Method</a></li>
|
||||
<li><a href="#method.summary">Method</a></li>
|
||||
</ul>
|
||||
<ul class="subNavList">
|
||||
<li>Detail: </li>
|
||||
<li>Field | </li>
|
||||
<li><a href="#constructor.detail">Constr</a> | </li>
|
||||
<li>Method</li>
|
||||
<li><a href="#method.detail">Method</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<a name="skip.navbar.bottom">
|
||||
|
Binary file not shown.
Binary file not shown.
@ -205,8 +205,10 @@ public class Client {
|
||||
*/
|
||||
public void disconnect() throws IOException {
|
||||
if (!socket.isClosed()) getConnection().close();
|
||||
if (handler != null && handler.getSubData() != null && equals(handler.getSubData())) setHandler(null);
|
||||
if (handler != null) {
|
||||
setHandler(null);
|
||||
handler = null;
|
||||
}
|
||||
closed = true;
|
||||
if (subdata.getClients().contains(this)) subdata.removeClient(this);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class PacketLinkExHost implements PacketIn, PacketOut {
|
||||
client.sendPacket(new PacketLinkExHost(4, "That host does not support a network interface"));
|
||||
}
|
||||
} else {
|
||||
client.sendPacket(new PacketLinkExHost(2, "There is no host with that name"));
|
||||
client.sendPacket(new PacketLinkExHost(2, "There is no host with name: " + data.getString("name")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
client.sendPacket(new PacketLinkExHost(1, e.getClass().getCanonicalName() + ": " + e.getMessage()));
|
||||
|
@ -2,7 +2,6 @@ package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.SubServers.Bungee.Host.Server;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
||||
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
|
||||
import net.ME1312.SubServers.Bungee.Library.Util;
|
||||
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Bungee.Network.Client;
|
||||
@ -12,7 +11,6 @@ import net.ME1312.SubServers.Bungee.SubPlugin;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -67,9 +65,9 @@ public class PacketLinkServer implements PacketIn, PacketOut {
|
||||
} else if ((server = searchIP(new InetSocketAddress(client.getAddress().getAddress(), data.getInt("port")))) != null) {
|
||||
link(client, server);
|
||||
} else if (data.keySet().contains("name")) {
|
||||
client.sendPacket(new PacketLinkServer(null, 2, "There is no server with that name"));
|
||||
client.sendPacket(new PacketLinkServer(null, 2, "There is no server with name: " + data.getString("name")));
|
||||
} else {
|
||||
client.sendPacket(new PacketLinkServer(null, 2, "Could not find server with address: " + client.getAddress().getAddress().getHostAddress() + ':' + data.getInt("port")));
|
||||
client.sendPacket(new PacketLinkServer(null, 2, "There is no server with address: " + client.getAddress().getAddress().getHostAddress() + ':' + data.getInt("port")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
client.sendPacket(new PacketLinkServer(null, 1, e.getClass().getCanonicalName() + ": " + e.getMessage()));
|
||||
@ -92,7 +90,7 @@ public class PacketLinkServer implements PacketIn, PacketOut {
|
||||
Server server = null;
|
||||
for (Server s : plugin.api.getServers().values()) {
|
||||
if (s.getAddress().equals(address)) {
|
||||
if (server != null) throw new InvalidServerException("Multiple servers match address: " + address.getAddress().getHostAddress() + ':' + address.getPort());
|
||||
if (server != null) throw new IllegalStateException("Multiple servers match address: " + address.getAddress().getHostAddress() + ':' + address.getPort());
|
||||
server = s;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public final class SubCommand extends CommandX {
|
||||
if (plugin.bversion == null) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Bungee/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Bungee/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
|
||||
NodeList updnodeList = updxml.getElementsByTagName("version");
|
||||
Version updversion = plugin.version;
|
||||
|
Binary file not shown.
@ -54,9 +54,11 @@ public class PacketLinkServer implements PacketIn, PacketOut {
|
||||
} else {
|
||||
try {
|
||||
if (data.getInt("r") == 2) {
|
||||
if (!plugin.config.get().getSection("Settings").getSection("SubData").contains("Name")) {
|
||||
plugin.config.get().getSection("Settings").getSection("SubData").set("Name", "undefined");
|
||||
plugin.config.save();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
Bukkit.getLogger().info("SubData > Could not link name with server: " + data.getString("m"));
|
||||
plugin.onDisable();
|
||||
|
@ -52,7 +52,7 @@ public final class SubCommand implements CommandExecutor {
|
||||
if (plugin.bversion == null) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
try {
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Client.Bukkit/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Client.Bukkit/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
|
||||
NodeList updnodeList = updxml.getElementsByTagName("version");
|
||||
Version updversion = plugin.version;
|
||||
|
Binary file not shown.
@ -182,13 +182,11 @@ public final class ExHost {
|
||||
* Find Jars
|
||||
*/
|
||||
UniversalFile pldir = new UniversalFile(dir, "Plugins");
|
||||
LinkedList<URL> jars = new LinkedList<URL>();
|
||||
LinkedList<File> pljars = new LinkedList<File>();
|
||||
if (pldir.exists() && pldir.isDirectory()) for (File file : pldir.listFiles()) {
|
||||
if (file.getName().endsWith(".jar")) {
|
||||
jars.add(file.toURI().toURL());
|
||||
if (file.getName().endsWith(".jar")) pljars.add(file);
|
||||
}
|
||||
}
|
||||
if (jars.size() > 0) {
|
||||
if (pljars.size() > 0) {
|
||||
long begin = Calendar.getInstance().getTime().getTime();
|
||||
log.info.println("Loading SubAPI Plugins...");
|
||||
|
||||
@ -196,59 +194,37 @@ public final class ExHost {
|
||||
* Load Jars & Find Main Classes
|
||||
* (Unordered)
|
||||
*/
|
||||
URLClassLoader superloader = new URLClassLoader(jars.toArray(new URL[jars.size()]), this.getClass().getClassLoader());
|
||||
LinkedHashMap<String, NamedContainer<LinkedList<String>, LinkedHashMap<String, String>>> classes = new LinkedHashMap<String, NamedContainer<LinkedList<String>, LinkedHashMap<String, String>>>();
|
||||
for (File file : pldir.listFiles()) {
|
||||
if (file.getName().endsWith(".jar")) {
|
||||
LinkedHashMap<PluginClassLoader, NamedContainer<LinkedList<String>, LinkedHashMap<String, String>>> classes = new LinkedHashMap<PluginClassLoader, NamedContainer<LinkedList<String>, LinkedHashMap<String, String>>>();
|
||||
for (File file : pljars) {
|
||||
try {
|
||||
JarFile jar = new JarFile(file);
|
||||
Enumeration<JarEntry> entries = jar.entries();
|
||||
LinkedList<String> mains = new LinkedList<String>();
|
||||
PluginClassLoader loader = new PluginClassLoader(this.getClass().getClassLoader(), file.toURI().toURL());
|
||||
List<String> contents = new ArrayList<String>();
|
||||
|
||||
if (jar.getJarEntry("package.xml") != null) {
|
||||
try {
|
||||
NodeList xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(jar.getInputStream(jar.getJarEntry("package.xml"))).getElementsByTagName("class");
|
||||
if (xml.getLength() > 0) {
|
||||
for (int i = 0; i < xml.getLength(); i++) {
|
||||
mains.add(xml.item(i).getTextContent());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error.println(new IllegalPluginException(e, "Couldn't load package.xml for " + file.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
boolean isplugin = false;
|
||||
loader.setDefaultClass(ClassNotFoundException.class);
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
|
||||
String cname = entry.getName().substring(0, entry.getName().length() - 6).replace('/', '.');
|
||||
contents.add(cname);
|
||||
if (mains.contains(cname)) {
|
||||
mains.remove(cname);
|
||||
try {
|
||||
Class<?> clazz = superloader.loadClass(cname);
|
||||
if (!clazz.isAnnotationPresent(SubPlugin.class))
|
||||
throw new ClassCastException("Cannot find plugin descriptor");
|
||||
|
||||
NamedContainer<LinkedList<String>, LinkedHashMap<String, String>> jarmap = (classes.keySet().contains(file.getName()))?classes.get(file.getName()):new NamedContainer<LinkedList<String>, LinkedHashMap<String, String>>(new LinkedList<String>(), new LinkedHashMap<>());
|
||||
Class<?> clazz = loader.loadClass(cname);
|
||||
if (clazz.isAnnotationPresent(SubPlugin.class)) {
|
||||
NamedContainer<LinkedList<String>, LinkedHashMap<String, String>> jarmap = (classes.keySet().contains(loader))?classes.get(loader):new NamedContainer<LinkedList<String>, LinkedHashMap<String, String>>(new LinkedList<String>(), new LinkedHashMap<>());
|
||||
for (String dependancy : clazz.getAnnotation(SubPlugin.class).dependencies()) jarmap.name().add(dependancy);
|
||||
for (String dependancy : clazz.getAnnotation(SubPlugin.class).softDependencies()) jarmap.name().add(dependancy);
|
||||
jarmap.get().put(clazz.getAnnotation(SubPlugin.class).name(), cname);
|
||||
classes.put(file.getName(), jarmap);
|
||||
classes.put(loader, jarmap);
|
||||
isplugin = true;
|
||||
} catch (ClassCastException e) {
|
||||
log.error.println(new IllegalPluginException(e, "Main class isn't annotated as a SubPlugin: " + cname));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error.println(new IllegalPluginException(e, "Couldn't load main class: " + cname));
|
||||
log.error.println(new IllegalPluginException(e, "Couldn't load class: " + cname));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String main : mains) {
|
||||
log.error.println(new IllegalPluginException(new ClassNotFoundException(), "Couldn't find main class: " + main));
|
||||
}
|
||||
loader.setDefaultClass(null);
|
||||
|
||||
if (!isplugin) {
|
||||
new PluginClassLoader(this.getClass().getClassLoader(), file.toURI().toURL());
|
||||
@ -260,33 +236,29 @@ public final class ExHost {
|
||||
log.error.println(new InvocationTargetException(e, "Problem searching plugin jar: " + file.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
superloader.close();
|
||||
|
||||
/*
|
||||
* Load Main Classes & Plugin Descriptions
|
||||
* (Ordered by Known Dependencies)
|
||||
*/
|
||||
int progress = 1;
|
||||
HashMap<String, PluginClassLoader> loaders = new HashMap<String, PluginClassLoader>();
|
||||
HashMap<String, SubPluginInfo> plugins = new LinkedHashMap<String, SubPluginInfo>();
|
||||
while (classes.size() > 0) {
|
||||
LinkedHashMap<String, LinkedList<String>> loaded = new LinkedHashMap<String, LinkedList<String>>();
|
||||
for (String jar : classes.keySet()) {
|
||||
LinkedHashMap<PluginClassLoader, LinkedList<String>> loaded = new LinkedHashMap<PluginClassLoader, LinkedList<String>>();
|
||||
for (PluginClassLoader loader : classes.keySet()) {
|
||||
LinkedList<String> loadedlist = new LinkedList<String>();
|
||||
if (!loaders.keySet().contains(jar)) loaders.put(jar, new PluginClassLoader(this.getClass().getClassLoader(), new File(pldir, jar).toURI().toURL()));
|
||||
for (String name : classes.get(jar).get().keySet()) {
|
||||
for (String name : classes.get(loader).get().keySet()) {
|
||||
boolean load = true;
|
||||
for (String depend : classes.get(jar).name()) {
|
||||
for (String depend : classes.get(loader).name()) {
|
||||
if (!plugins.keySet().contains(depend.toLowerCase())) {
|
||||
load = progress <= 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (load) {
|
||||
String main = classes.get(jar).get().get(name);
|
||||
String main = classes.get(loader).get().get(name);
|
||||
try {
|
||||
Class<?> clazz = loaders.get(jar).loadClass(main);
|
||||
Class<?> clazz = loader.loadClass(main);
|
||||
if (!clazz.isAnnotationPresent(SubPlugin.class))
|
||||
throw new ClassCastException("Cannot find plugin descriptor");
|
||||
|
||||
@ -313,17 +285,17 @@ public final class ExHost {
|
||||
loadedlist.add(name);
|
||||
}
|
||||
}
|
||||
if (loadedlist.size() > 0) loaded.put(jar, loadedlist);
|
||||
if (loadedlist.size() > 0) loaded.put(loader, loadedlist);
|
||||
}
|
||||
progress = 0;
|
||||
for (String jar : loaded.keySet()) {
|
||||
NamedContainer<LinkedList<String>, LinkedHashMap<String, String>> jarmap = classes.get(jar);
|
||||
for (PluginClassLoader loader : loaded.keySet()) {
|
||||
NamedContainer<LinkedList<String>, LinkedHashMap<String, String>> jarmap = classes.get(loader);
|
||||
progress++;
|
||||
for (String main : loaded.get(jar)) jarmap.get().remove(main);
|
||||
for (String main : loaded.get(loader)) jarmap.get().remove(main);
|
||||
if (jarmap.get().size() > 0) {
|
||||
classes.put(jar, jarmap);
|
||||
classes.put(loader, jarmap);
|
||||
} else {
|
||||
classes.remove(jar);
|
||||
classes.remove(loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
* Plugin ClassLoader Class
|
||||
*/
|
||||
public class PluginClassLoader extends URLClassLoader {
|
||||
private static final Set<PluginClassLoader> loaders = new CopyOnWriteArraySet<PluginClassLoader>();
|
||||
private static Set<PluginClassLoader> loaders = new CopyOnWriteArraySet<PluginClassLoader>();
|
||||
private Class<?> defaultClass = null;
|
||||
|
||||
/**
|
||||
* Load Classes from URLs
|
||||
@ -33,6 +34,26 @@ public class PluginClassLoader extends URLClassLoader {
|
||||
loaders.add(this);
|
||||
}
|
||||
|
||||
public void setDefaultClass(Class<?> clazz) {
|
||||
this.defaultClass = clazz;
|
||||
}
|
||||
|
||||
public Class<?> getDefaultClass() throws ClassNotFoundException {
|
||||
if (defaultClass == null) {
|
||||
throw new ClassNotFoundException();
|
||||
} else {
|
||||
return defaultClass;
|
||||
}
|
||||
}
|
||||
|
||||
private Class<?> getDefaultClass(String name) throws ClassNotFoundException {
|
||||
try {
|
||||
return getDefaultClass();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
}
|
||||
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
return this.loadClass(name, resolve, true);
|
||||
}
|
||||
@ -40,7 +61,7 @@ public class PluginClassLoader extends URLClassLoader {
|
||||
private Class<?> loadClass(String name, boolean resolve, boolean check) throws ClassNotFoundException {
|
||||
try {
|
||||
return super.loadClass(name, resolve);
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (NoClassDefFoundError | ClassNotFoundException e) {
|
||||
if (check) {
|
||||
Iterator i = loaders.iterator();
|
||||
|
||||
@ -48,17 +69,17 @@ public class PluginClassLoader extends URLClassLoader {
|
||||
PluginClassLoader loader;
|
||||
do {
|
||||
if (!i.hasNext()) {
|
||||
throw new ClassNotFoundException(name);
|
||||
return getDefaultClass(name);
|
||||
}
|
||||
loader = (PluginClassLoader) i.next();
|
||||
} while (loader == this);
|
||||
|
||||
try {
|
||||
return loader.loadClass(name, resolve, false);
|
||||
} catch (ClassNotFoundException ex) {}
|
||||
} catch (NoClassDefFoundError | ClassNotFoundException ex) {}
|
||||
}
|
||||
} else {
|
||||
throw new ClassNotFoundException(name);
|
||||
return getDefaultClass(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class SubCommand {
|
||||
if (host.bversion == null) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Host/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Host/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
|
||||
NodeList updnodeList = updxml.getElementsByTagName("version");
|
||||
Version updversion = host.version;
|
||||
|
Binary file not shown.
@ -45,9 +45,11 @@ public class PacketLinkProxy implements PacketIn, PacketOut {
|
||||
} else {
|
||||
try {
|
||||
if (data.getInt("r") == 2) {
|
||||
if (!plugin.config.get().getSection("Settings").getSection("SubData").contains("Name")) {
|
||||
plugin.config.get().getSection("Settings").getSection("SubData").set("Name", "undefined");
|
||||
plugin.config.save();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
System.out.println("SubData > Could not link name with server: " + data.getString("m"));
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public final class SubCommand extends CommandX {
|
||||
if (plugin.bversion == null) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Sync/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
Document updxml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://src.me1312.net/maven/net/ME1312/SubServers/SubServers.Sync/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
|
||||
NodeList updnodeList = updxml.getElementsByTagName("version");
|
||||
Version updversion = plugin.version;
|
||||
|
Loading…
Reference in New Issue
Block a user