mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 00:37:36 +00:00
BLEEDING EDGE 1.3_13
This commit is contained in:
parent
4039e9b86b
commit
96b25fe139
@ -1,5 +1,5 @@
|
|||||||
pluginMain=SimplexCorePlugin
|
pluginMain=SimplexCorePlugin
|
||||||
pluginMainPackage=io.github.simplexdev.simplexcore
|
pluginMainPackage=io.github.simplexdev.simplexcore
|
||||||
pluginVersion=1.3_11
|
pluginVersion=1.3_13
|
||||||
pluginName=SimplexCore
|
pluginName=SimplexCore
|
||||||
pluginJarClassifier=BLEEDING
|
pluginJarClassifier=BLEEDING
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package io.github.simplexdev.api.annotations;
|
package io.github.simplexdev.api.annotations;
|
||||||
|
|
||||||
public enum ReqType {
|
public enum ReqType {
|
||||||
PAPER,
|
SPIGOT,
|
||||||
WATERFALL,
|
|
||||||
BUNGEECORD
|
BUNGEECORD
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package io.github.simplexdev.simplexcore;
|
package io.github.simplexdev.simplexcore;
|
||||||
|
|
||||||
|
import io.github.simplexdev.api.annotations.ReqType;
|
||||||
|
import io.github.simplexdev.api.annotations.Requires;
|
||||||
import io.github.simplexdev.simplexcore.command.defaults.Command_info;
|
import io.github.simplexdev.simplexcore.command.defaults.Command_info;
|
||||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||||
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
||||||
|
import io.github.simplexdev.simplexcore.crafting.RecipeBuilder;
|
||||||
import io.github.simplexdev.simplexcore.module.DependencyManagement;
|
import io.github.simplexdev.simplexcore.module.DependencyManagement;
|
||||||
import io.github.simplexdev.simplexcore.task.Announcer;
|
import io.github.simplexdev.simplexcore.task.Announcer;
|
||||||
import io.github.simplexdev.simplexcore.listener.DependencyListener;
|
import io.github.simplexdev.simplexcore.listener.DependencyListener;
|
||||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
|
|
||||||
|
@Requires(ReqType.SPIGOT)
|
||||||
public final class SimplexCorePlugin extends SimplexModule<SimplexCorePlugin> {
|
public final class SimplexCorePlugin extends SimplexModule<SimplexCorePlugin> {
|
||||||
private static boolean debug = false;
|
private static boolean debug = false;
|
||||||
private static boolean suspended = false;
|
private static boolean suspended = false;
|
||||||
|
@ -5,9 +5,10 @@ import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
|||||||
import io.github.simplexdev.simplexcore.chat.Messages;
|
import io.github.simplexdev.simplexcore.chat.Messages;
|
||||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||||
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
||||||
|
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||||
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||||
import io.github.simplexdev.simplexcore.utils.Utilities;
|
import io.github.simplexdev.simplexcore.utils.Utilities;
|
||||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,23 +30,25 @@ public abstract class Ban implements IBan {
|
|||||||
private final BanType type;
|
private final BanType type;
|
||||||
private final Date banDate;
|
private final Date banDate;
|
||||||
private final long banDuration;
|
private final long banDuration;
|
||||||
|
private final SimplexModule<?> plugin;
|
||||||
|
|
||||||
private final String banId;
|
private final String banId;
|
||||||
private final String banReason;
|
private final String banReason;
|
||||||
|
|
||||||
public Ban(Player player, CommandSender sender) {
|
public Ban(SimplexModule<?> plugin, Player player, CommandSender sender) {
|
||||||
this(player, sender, BanType.TEMPORARY);
|
this(plugin, player, sender, BanType.TEMPORARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(Player player, CommandSender sender, BanType type) {
|
public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType type) {
|
||||||
this(player, sender, type, TickedTime.DAY);
|
this(plugin, player, sender, type, TickedTime.DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(Player player, CommandSender sender, BanType type, long banDuration) {
|
public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType type, long banDuration) {
|
||||||
this(player, sender, type, Utilities.generateBanId(type), Messages.BAN.getMessage(), new Date(), banDuration);
|
this(plugin, player, sender, type, Utilities.generateBanId(type), Messages.BAN.getMessage(), new Date(), banDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(Player player, CommandSender sender, BanType type, String banId, String banReason, Date banDate, long banDuration) {
|
public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType type, String banId, String banReason, Date banDate, long banDuration) {
|
||||||
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -2,23 +2,22 @@ package io.github.simplexdev.simplexcore.ban;
|
|||||||
|
|
||||||
import io.github.simplexdev.api.IBan;
|
import io.github.simplexdev.api.IBan;
|
||||||
import io.github.simplexdev.api.func.VoidSupplier;
|
import io.github.simplexdev.api.func.VoidSupplier;
|
||||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
|
||||||
import io.github.simplexdev.simplexcore.chat.Messages;
|
import io.github.simplexdev.simplexcore.chat.Messages;
|
||||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||||
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||||
import io.github.simplexdev.simplexcore.utils.Utilities;
|
import io.github.simplexdev.simplexcore.utils.Utilities;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import static io.github.simplexdev.simplexcore.utils.Utilities.pathway;
|
import static io.github.simplexdev.simplexcore.utils.Utilities.pathway;
|
||||||
|
|
||||||
public final class BanFactory {
|
public final class BanFactory {
|
||||||
|
private final SimplexModule<?> plugin;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final Date banDate;
|
private final Date banDate;
|
||||||
@ -27,7 +26,8 @@ public final class BanFactory {
|
|||||||
private String banReason;
|
private String banReason;
|
||||||
private long banDuration;
|
private long banDuration;
|
||||||
|
|
||||||
public BanFactory(Player player, CommandSender sender, Date banDate, BanType type) {
|
public BanFactory(SimplexModule<?> plugin, Player player, CommandSender sender, Date banDate, BanType type) {
|
||||||
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.banDate = banDate;
|
this.banDate = banDate;
|
||||||
@ -72,7 +72,7 @@ public final class BanFactory {
|
|||||||
* @return A new ban instance.
|
* @return A new ban instance.
|
||||||
*/
|
*/
|
||||||
public Ban create() {
|
public Ban create() {
|
||||||
return new Ban(player, sender, type, banDuration) {
|
return new Ban(plugin, player, sender, type, banDuration) {
|
||||||
@Override
|
@Override
|
||||||
public UUID getOffender() {
|
public UUID getOffender() {
|
||||||
return player.getUniqueId();
|
return player.getUniqueId();
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package io.github.simplexdev.simplexcore.ban;
|
||||||
|
|
||||||
|
import io.github.simplexdev.simplexcore.chat.Messages;
|
||||||
|
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||||
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
|
||||||
|
|
||||||
|
public class BanManager extends SimplexListener {
|
||||||
|
private final Map<Ban, BanType> banMap = new HashMap<>();
|
||||||
|
private final SimplexModule<?> plugin;
|
||||||
|
|
||||||
|
public BanManager(SimplexModule<?> plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBan(Ban ban) {
|
||||||
|
banMap.put(ban, ban.getBanType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Ban getBan(OfflinePlayer player) {
|
||||||
|
if (banMap.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AtomicReference<Ban> temp = new AtomicReference<>();
|
||||||
|
banMap.forEach((ban, type) -> {
|
||||||
|
if (ban.getOffender().equals(player.getUniqueId())) {
|
||||||
|
temp.set(ban);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return temp.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void banHandler(AsyncPlayerPreLoginEvent event) {
|
||||||
|
UUID player = event.getUniqueId();
|
||||||
|
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||||
|
Ban ban = getBan(op);
|
||||||
|
if (ban != null) {
|
||||||
|
if (ban.getBanType().equals(BanType.PERMANENT)) {
|
||||||
|
event.disallow(Result.KICK_BANNED, Messages.PERMBAN.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban.getBanType().equals(BanType.TEMPORARY)
|
||||||
|
|| ban.getBanType().equals(BanType.CUSTOM)) {
|
||||||
|
if ((ban.getDate().getTime()
|
||||||
|
+ ban.getBanDuration()) > (new Date()).getTime()) {
|
||||||
|
event.disallow(Result.KICK_BANNED, Messages.PERMBAN.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,8 @@ package io.github.simplexdev.simplexcore.ban;
|
|||||||
public enum BanType {
|
public enum BanType {
|
||||||
PERMANENT("P-"),
|
PERMANENT("P-"),
|
||||||
TEMPORARY("T-"),
|
TEMPORARY("T-"),
|
||||||
CUSTOM("C-");
|
CUSTOM("C-"),
|
||||||
|
UNKNOWN("");
|
||||||
|
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
|
|
||||||
@ -21,6 +22,18 @@ public enum BanType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BanType getFromId(String banId) {
|
||||||
|
if (banId.startsWith("P")) {
|
||||||
|
return PERMANENT;
|
||||||
|
} else if (banId.startsWith("T")) {
|
||||||
|
return TEMPORARY;
|
||||||
|
} else if (banId.startsWith("C")){
|
||||||
|
return CUSTOM;
|
||||||
|
} else {
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getPrefix() {
|
public String getPrefix() {
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public final class ChatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void msg(TextComponent component) {
|
public void msg(TextComponent component) {
|
||||||
target.sendMessage(component);
|
target.spigot().sendMessage(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void err(Messages message) {
|
public void err(Messages message) {
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package io.github.simplexdev.simplexcore.chat;
|
package io.github.simplexdev.simplexcore.chat;
|
||||||
|
|
||||||
|
import io.github.simplexdev.simplexcore.CoreState;
|
||||||
|
|
||||||
public enum Messages {
|
public enum Messages {
|
||||||
NO_PERMS("You do not have permission to use this command!"),
|
NO_PERMS("You do not have permission to use this command!"),
|
||||||
DISCORD("https://discord.gg/Rumx5dTJuf"),
|
DISCORD("https://discord.gg/Rumx5dTJuf"),
|
||||||
BAN("You have been banned from this server."),
|
BAN("You have been banned from this server."),
|
||||||
KICK("You have been kicked by a moderator."),
|
KICK("You have been kicked by a moderator."),
|
||||||
AFK_KICK("You were kicked to ensure space for active players.");
|
AFK_KICK("You were kicked to ensure space for active players."),
|
||||||
|
PERMBAN("You are permanently banned from this server.");
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
|
@ -0,0 +1,105 @@
|
|||||||
|
package io.github.simplexdev.simplexcore.crafting;
|
||||||
|
|
||||||
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
|
import io.github.simplexdev.simplexcore.utils.Utilities;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public final class RecipeBuilder {
|
||||||
|
private final SimplexModule<?> plugin;
|
||||||
|
|
||||||
|
public RecipeBuilder(SimplexModule<?> plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Worker of(ItemStack result, String recipeName, boolean isShaped) {
|
||||||
|
return new Worker(result, recipeName, isShaped);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class Worker {
|
||||||
|
private final Map<Character, Material> ingredients = new HashMap<>();
|
||||||
|
private final ItemStack stack;
|
||||||
|
private final NamespacedKey key;
|
||||||
|
private final boolean shaped;
|
||||||
|
private final List<Material> materials = new ArrayList<>();
|
||||||
|
private String[] shape = {"", "", ""};
|
||||||
|
|
||||||
|
public Worker(ItemStack stack, String name, boolean isShaped) {
|
||||||
|
this.stack = stack;
|
||||||
|
this.key = new NamespacedKey(plugin, name);
|
||||||
|
this.shaped = isShaped;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShapelessRecipe nosha() {
|
||||||
|
ShapelessRecipe recipe = new ShapelessRecipe(key, stack);
|
||||||
|
if (materials.size() > 9 || materials.isEmpty()) return recipe;
|
||||||
|
materials.forEach(recipe::addIngredient);
|
||||||
|
materials.clear();
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShapedRecipe sha() {
|
||||||
|
ShapedRecipe recipe = new ShapedRecipe(key, stack);
|
||||||
|
if (ingredients.isEmpty()) return recipe;
|
||||||
|
recipe.shape(shape);
|
||||||
|
ingredients.forEach(recipe::setIngredient);
|
||||||
|
ingredients.clear();
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void make() {
|
||||||
|
plugin.getServer().addRecipe(shaped ? sha() : nosha());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is for shaped crafting.
|
||||||
|
*
|
||||||
|
* @param identifier The specific identifier
|
||||||
|
* @param ingredient The ingredient represented by the identifier.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Worker addIngredient(@NotNull Character identifier, @NotNull Material ingredient) {
|
||||||
|
ingredients.put(identifier, ingredient);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Worker setShape(@Nullable String top, @Nullable String middle, @Nullable String bottom) {
|
||||||
|
String a = "";
|
||||||
|
String b = "";
|
||||||
|
String c = "";
|
||||||
|
if (top != null) {
|
||||||
|
a = top;
|
||||||
|
}
|
||||||
|
if (middle != null) {
|
||||||
|
b = middle;
|
||||||
|
}
|
||||||
|
if (bottom != null) {
|
||||||
|
c = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
shape = new String[]{a, b, c};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is for shapeless crafting.
|
||||||
|
*
|
||||||
|
* @param ingredients any number (up to nine) of ingredients required to craft this recipe.
|
||||||
|
* @return An appendable instance of this class.
|
||||||
|
*/
|
||||||
|
public Worker addIngredients(Material... ingredients) {
|
||||||
|
Utilities.forEach(ingredients, materials::add);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package io.github.simplexdev.simplexcore.listener;
|
|||||||
|
|
||||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
|
import io.github.simplexdev.simplexcore.utils.ReflectionTools;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@ -20,12 +21,8 @@ public abstract class SimplexListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
Constructor<? extends SimplexListener> constr = ReflectionTools.getDeclaredConstructor(cls);
|
||||||
Constructor<? extends SimplexListener> constr = cls.getDeclaredConstructor();
|
register(ReflectionTools.initConstructor(constr), plugin);
|
||||||
register(constr.newInstance(), plugin);
|
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
|
||||||
SimplexCorePlugin.getInstance().getLogger().severe("Could not register this listener!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,17 @@ public final class ModuleRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends SimplexModule<T>> boolean isSpigot(T addon) {
|
||||||
|
try {
|
||||||
|
Class.forName(org.spigotmc.WatchdogThread.class.getName());
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
addon.stop();
|
||||||
|
SimplexCorePlugin.getInstance().getLogger().severe(addon.getName() + " has been disabled: This module requires Paper!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private <T extends SimplexModule<T>> boolean isBungee(T addon) {
|
private <T extends SimplexModule<T>> boolean isBungee(T addon) {
|
||||||
try {
|
try {
|
||||||
Class.forName(net.md_5.bungee.Util.class.getName());
|
Class.forName(net.md_5.bungee.Util.class.getName());
|
||||||
@ -40,17 +51,6 @@ public final class ModuleRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends SimplexModule<T>> boolean isWaterfall(T addon) {
|
|
||||||
try {
|
|
||||||
Class.forName(io.github.waterfallmc.waterfall.utils.Hex.class.getName());
|
|
||||||
return true;
|
|
||||||
} catch (ClassNotFoundException ignored) {
|
|
||||||
addon.stop();
|
|
||||||
SimplexCorePlugin.getInstance().getLogger().severe(addon.getName() + " has been disabled: This module requires Waterfall!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkAnnotation(Requires info, ReqType type) {
|
private boolean checkAnnotation(Requires info, ReqType type) {
|
||||||
return info.value() == type;
|
return info.value() == type;
|
||||||
}
|
}
|
||||||
@ -58,18 +58,14 @@ public final class ModuleRegistry {
|
|||||||
public <T extends SimplexModule<T>> void register(T addon) {
|
public <T extends SimplexModule<T>> void register(T addon) {
|
||||||
if (addon.getClass().isAnnotationPresent(Requires.class)) {
|
if (addon.getClass().isAnnotationPresent(Requires.class)) {
|
||||||
Requires info = addon.getClass().getDeclaredAnnotation(Requires.class);
|
Requires info = addon.getClass().getDeclaredAnnotation(Requires.class);
|
||||||
if (checkAnnotation(info, ReqType.PAPER)
|
if (checkAnnotation(info, ReqType.SPIGOT)
|
||||||
&& !isPaper(addon)) {
|
&& (!isSpigot(addon) || !isPaper(addon))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (checkAnnotation(info, ReqType.BUNGEECORD)
|
if (checkAnnotation(info, ReqType.BUNGEECORD)
|
||||||
&& !isBungee(addon)) {
|
&& !isBungee(addon)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (checkAnnotation(info, ReqType.WATERFALL)
|
|
||||||
&& !isWaterfall(addon)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getModules().add(addon);
|
getModules().add(addon);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user