mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 00:06:10 +00:00
Cleanup
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.plugin;
|
||||
|
||||
public interface IActivator {
|
||||
|
||||
}
|
||||
@@ -156,7 +156,8 @@ public class Metrics {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException e) {Iris.reportError(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
// Register our service
|
||||
@@ -255,7 +256,8 @@ public class Metrics {
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {Iris.reportError(e);
|
||||
} catch (Exception e) {
|
||||
Iris.reportError(e);
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
@@ -314,7 +316,8 @@ public class Metrics {
|
||||
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||
pluginData.add(object);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {Iris.reportError(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Iris.reportError(e);
|
||||
// minecraft version 1.14+
|
||||
|
||||
if (logFailedRequests) {
|
||||
@@ -326,7 +329,8 @@ public class Metrics {
|
||||
Iris.reportError(ignored);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException e) {Iris.reportError(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +341,8 @@ public class Metrics {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {Iris.reportError(e);
|
||||
} catch (Exception e) {
|
||||
Iris.reportError(e);
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
@@ -444,7 +449,8 @@ public class Metrics {
|
||||
return null;
|
||||
}
|
||||
chart.add("data", data);
|
||||
} catch (Throwable t) {Iris.reportError(t);
|
||||
} catch (Throwable t) {
|
||||
Iris.reportError(t);
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,8 @@ public class MetricsLite {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException e) {Iris.reportError(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
// Register our service
|
||||
@@ -232,7 +233,8 @@ public class MetricsLite {
|
||||
// org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {Iris.reportError(e);
|
||||
} catch (Exception e) {
|
||||
Iris.reportError(e);
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
@@ -291,7 +293,8 @@ public class MetricsLite {
|
||||
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||
pluginData.add(object);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {Iris.reportError(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Iris.reportError(e);
|
||||
// minecraft version 1.14+
|
||||
if (logFailedRequests) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception ", e);
|
||||
@@ -302,7 +305,8 @@ public class MetricsLite {
|
||||
Iris.reportError(ignored);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException e) {Iris.reportError(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +318,8 @@ public class MetricsLite {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {Iris.reportError(e);
|
||||
} catch (Exception e) {
|
||||
Iris.reportError(e);
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
|
||||
@@ -20,8 +20,8 @@ package com.volmit.iris.util.plugin;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@@ -20,9 +20,9 @@ package com.volmit.iris.util.plugin;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.reflect.V;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
@@ -58,7 +58,8 @@ public class VirtualCommand {
|
||||
ICommand cmd = (ICommand) i.getType().getConstructor().newInstance();
|
||||
new V(command, true, true).set(i.getName(), cmd);
|
||||
children.put(cmd.getAllNodes(), new VirtualCommand(cmd, cc.value().trim().isEmpty() ? tag : cc.value().trim()));
|
||||
} catch (Exception e) {Iris.reportError(e);
|
||||
} catch (Exception e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
listenersField.setAccessible(true);
|
||||
//noinspection unchecked
|
||||
listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField.get(getServer().getPluginManager());
|
||||
} catch (Throwable e) {Iris.reportError(e);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
@@ -101,7 +102,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
//noinspection unchecked
|
||||
commands = (Map<String, Command>) knownCommandsField.get(commandMap);
|
||||
|
||||
} catch (Throwable e) {Iris.reportError(e);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +136,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
if (cl instanceof URLClassLoader) {
|
||||
try {
|
||||
((URLClassLoader) cl).close();
|
||||
} catch (IOException e) {Iris.reportError(e);
|
||||
} catch (IOException e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -193,7 +196,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
outputPluginInfo();
|
||||
outputCommandInfo();
|
||||
outputPermissionInfo();
|
||||
} catch (Throwable e) {Iris.reportError(e);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -275,7 +279,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
for (org.bukkit.permissions.Permission i : computePermissions()) {
|
||||
try {
|
||||
Bukkit.getPluginManager().addPermission(i);
|
||||
} catch (Throwable e) {Iris.reportError(e);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -290,7 +295,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
g.add(toPermission(x));
|
||||
g.addAll(computePermissions(x));
|
||||
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
|
||||
Iris.reportError(e);e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,7 +376,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
i.tick();
|
||||
} catch (Throwable e) {
|
||||
w("Failed to tick controller " + i.getName());
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +407,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
v("Registered " + pc.getName() + " (" + i.getName() + ")");
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
w("Failed to register controller (field " + i.getName() + ")");
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,7 +433,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
v("Started " + pc.getName());
|
||||
} catch (Throwable e) {
|
||||
w("Failed to start controller " + pc.getName());
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +450,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
v("Registered Instance " + i.getName());
|
||||
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
|
||||
w("Failed to register instance (field " + i.getName() + ")");
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,7 +469,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
v("Unregistered Instance " + i.getName());
|
||||
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
|
||||
w("Failed to unregister instance (field " + i.getName() + ")");
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,7 +494,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
v("Registered Commands /" + pc.getNode() + " (" + i.getName() + ")");
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
w("Failed to register command (field " + i.getName() + ")");
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -591,7 +603,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,7 +643,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
for (VirtualCommand i : commands.v()) {
|
||||
try {
|
||||
unregisterCommand(i.getCommand());
|
||||
} catch (Throwable e) {Iris.reportError(e);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -655,7 +669,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
unregisterListener(i);
|
||||
i.stop();
|
||||
v("Stopped " + i.getName());
|
||||
} catch (Throwable e) {Iris.reportError(e);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
w("Failed to stop controller " + i.getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user