forked from SteamWar/SteamWar
Fix PR things
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.configplayer.ConfigConverter;
|
import de.steamwar.bausystem.configplayer.ConfigConverter;
|
||||||
@@ -41,13 +40,15 @@ import de.steamwar.command.AbstractValidator;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.linkage.*;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
|
import de.steamwar.linkage.MaxVersion;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import de.steamwar.linkage.PluginCheck;
|
||||||
import de.steamwar.linkage.api.Disable;
|
import de.steamwar.linkage.api.Disable;
|
||||||
import de.steamwar.linkage.api.Enable;
|
import de.steamwar.linkage.api.Enable;
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
import de.steamwar.network.packets.PacketHandler;
|
import de.steamwar.network.packets.PacketHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.atteo.classindex.ClassIndex;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -115,64 +116,68 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
try {
|
try {
|
||||||
return Class.forName(s);
|
return Class.forName(s);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
return null;
|
Bukkit.shutdown();
|
||||||
|
throw new SecurityException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
classes.forEach(clazz -> {
|
classes.forEach(clazz -> {
|
||||||
|
MinVersion minVersion = clazz.getAnnotation(MinVersion.class);
|
||||||
|
MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class);
|
||||||
|
PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class);
|
||||||
|
if (minVersion != null && Core.getVersion() < minVersion.value()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (maxVersion != null && Core.getVersion() > maxVersion.value()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (PluginCheck pluginCheck : pluginChecks) {
|
||||||
|
if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pluginCheck.has() == PluginCheck.Has.NOT && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object any;
|
||||||
try {
|
try {
|
||||||
Object any = clazz.newInstance();
|
any = clazz.newInstance();
|
||||||
|
|
||||||
MinVersion minVersion = clazz.getAnnotation(MinVersion.class);
|
|
||||||
MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class);
|
|
||||||
PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class);
|
|
||||||
if (minVersion != null && Core.getVersion() < minVersion.value()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (maxVersion != null && Core.getVersion() > maxVersion.value()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (PluginCheck pluginCheck : pluginChecks) {
|
|
||||||
if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (pluginCheck.has() == PluginCheck.Has.NOT && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
instances.put(clazz, any);
|
|
||||||
if (any instanceof Enable) {
|
|
||||||
((Enable) any).enable();
|
|
||||||
}
|
|
||||||
if (any instanceof SWCommand) {
|
|
||||||
((SWCommand) any).setMessage(BauSystem.MESSAGE);
|
|
||||||
}
|
|
||||||
if (any instanceof Listener) {
|
|
||||||
Bukkit.getPluginManager().registerEvents((Listener) any, BauSystem.getInstance());
|
|
||||||
}
|
|
||||||
if (any instanceof PacketHandler) {
|
|
||||||
((PacketHandler) any).register();
|
|
||||||
}
|
|
||||||
if (any instanceof LuaLib) {
|
|
||||||
SteamWarLuaPlugin.add((LuaLib) any);
|
|
||||||
}
|
|
||||||
if (any instanceof ScoreboardElement) {
|
|
||||||
BauScoreboard.addElement((ScoreboardElement) any);
|
|
||||||
}
|
|
||||||
if (any instanceof BauGuiItem) {
|
|
||||||
BauGUI.addItem((BauGuiItem) any);
|
|
||||||
}
|
|
||||||
if (any instanceof PanzernAlgorithm) {
|
|
||||||
Panzern.add((PanzernAlgorithm) any);
|
|
||||||
}
|
|
||||||
if (any instanceof ConfigConverter) {
|
|
||||||
Config.addConfigConverter((ConfigConverter) any);
|
|
||||||
}
|
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||||
|
Bukkit.shutdown();
|
||||||
|
throw new SecurityException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
instances.put(clazz, any);
|
||||||
|
if (any instanceof Enable) {
|
||||||
|
((Enable) any).enable();
|
||||||
|
}
|
||||||
|
if (any instanceof SWCommand) {
|
||||||
|
((SWCommand) any).setMessage(BauSystem.MESSAGE);
|
||||||
|
}
|
||||||
|
if (any instanceof Listener) {
|
||||||
|
Bukkit.getPluginManager().registerEvents((Listener) any, BauSystem.getInstance());
|
||||||
|
}
|
||||||
|
if (any instanceof PacketHandler) {
|
||||||
|
((PacketHandler) any).register();
|
||||||
|
}
|
||||||
|
if (any instanceof LuaLib) {
|
||||||
|
SteamWarLuaPlugin.add((LuaLib) any);
|
||||||
|
}
|
||||||
|
if (any instanceof ScoreboardElement) {
|
||||||
|
BauScoreboard.addElement((ScoreboardElement) any);
|
||||||
|
}
|
||||||
|
if (any instanceof BauGuiItem) {
|
||||||
|
BauGUI.addItem((BauGuiItem) any);
|
||||||
|
}
|
||||||
|
if (any instanceof PanzernAlgorithm) {
|
||||||
|
Panzern.add((PanzernAlgorithm) any);
|
||||||
|
}
|
||||||
|
if (any instanceof ConfigConverter) {
|
||||||
|
Config.addConfigConverter((ConfigConverter) any);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,7 +209,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
WorldData.write();
|
WorldData.write();
|
||||||
Config.getInstance().saveAll();
|
Config.getInstance().saveAll();
|
||||||
TinyProtocol.instance.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends CommandSender> AbstractValidator<T, ?> validator(Permission permission) {
|
private <T extends CommandSender> AbstractValidator<T, ?> validator(Permission permission) {
|
||||||
|
|||||||
Reference in New Issue
Block a user