mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2025-01-22 05:00:05 +00:00
BLEEDING EDGE 1.3_11
- Rename Addon to Module - Adjusted announcer to run every hour - Added Enchanting API, incomplete
This commit is contained in:
parent
71789fa39f
commit
99c19f0ff7
@ -1,5 +1,5 @@
|
||||
pluginMain=SimplexCorePlugin
|
||||
pluginMainPackage=io.github.simplexdev.simplexcore
|
||||
pluginVersion=1.3_10
|
||||
pluginVersion=1.3_11
|
||||
pluginName=SimplexCore
|
||||
pluginJarClassifier=BLEEDING
|
||||
|
13
src/main/java/io/github/simplexdev/api/IEnchant.java
Normal file
13
src/main/java/io/github/simplexdev/api/IEnchant.java
Normal file
@ -0,0 +1,13 @@
|
||||
package io.github.simplexdev.api;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public interface IEnchant {
|
||||
NamespacedKey getNamespacedKey();
|
||||
|
||||
String getName();
|
||||
|
||||
Integer getMaximumLevel();
|
||||
|
||||
Boolean isGlowing();
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package io.github.simplexdev.api.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Enchant {
|
||||
boolean glow() default true;
|
||||
}
|
@ -3,13 +3,13 @@ package io.github.simplexdev.simplexcore;
|
||||
import io.github.simplexdev.simplexcore.command.defaults.Command_info;
|
||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
||||
import io.github.simplexdev.simplexcore.plugin.DependencyManagement;
|
||||
import io.github.simplexdev.simplexcore.module.DependencyManagement;
|
||||
import io.github.simplexdev.simplexcore.task.Announcer;
|
||||
import io.github.simplexdev.simplexcore.listener.DependencyListener;
|
||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
|
||||
public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
||||
public final class SimplexCorePlugin extends SimplexModule<SimplexCorePlugin> {
|
||||
private static boolean debug = false;
|
||||
private static boolean suspended = false;
|
||||
private static SimplexCorePlugin instance;
|
||||
|
@ -2,7 +2,7 @@ package io.github.simplexdev.simplexcore.command;
|
||||
|
||||
import io.github.simplexdev.api.annotations.CommandInfo;
|
||||
import io.github.simplexdev.simplexcore.command.defaults.DefaultCommand;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import io.github.simplexdev.simplexcore.utils.ReflectionTools;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
@ -69,7 +69,7 @@ public final class CommandLoader {
|
||||
*
|
||||
* @param plugin An instance of your plugin to assign as the parent plugin for each command.
|
||||
*/
|
||||
public void load(SimplexAddon<?> plugin) {
|
||||
public void load(SimplexModule<?> plugin) {
|
||||
reflections.getTypesAnnotatedWith(CommandInfo.class).forEach(annotated -> {
|
||||
CommandInfo info = annotated.getDeclaredAnnotation(CommandInfo.class);
|
||||
|
||||
|
@ -3,7 +3,7 @@ package io.github.simplexdev.simplexcore.config;
|
||||
import io.github.simplexdev.api.IConfig;
|
||||
import io.github.simplexdev.api.func.Path;
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -14,7 +14,7 @@ import java.nio.file.NotDirectoryException;
|
||||
import java.util.List;
|
||||
|
||||
public final class Yaml implements IConfig {
|
||||
private final SimplexAddon<?> plugin;
|
||||
private final SimplexModule<?> plugin;
|
||||
private final String fileName;
|
||||
private final File directory;
|
||||
private final String resourcePath;
|
||||
@ -22,7 +22,7 @@ public final class Yaml implements IConfig {
|
||||
private File file;
|
||||
|
||||
// Package private ;)
|
||||
Yaml(SimplexAddon<?> plugin, String fileName, File directory, String resourcePath) {
|
||||
Yaml(SimplexModule<?> plugin, String fileName, File directory, String resourcePath) {
|
||||
if (!fileName.endsWith(".yml")) {
|
||||
fileName += ".yml";
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.github.simplexdev.simplexcore.config;
|
||||
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import io.github.simplexdev.simplexcore.utils.Trio;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -8,12 +8,12 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import java.io.File;
|
||||
|
||||
public final class YamlFactory {
|
||||
private final SimplexAddon<?> plugin;
|
||||
private final SimplexModule<?> plugin;
|
||||
private String resourcePath;
|
||||
private File directory;
|
||||
private String fileName;
|
||||
|
||||
public YamlFactory(SimplexAddon<?> plugin) {
|
||||
public YamlFactory(SimplexModule<?> plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
package io.github.simplexdev.simplexcore.enchanting;
|
||||
|
||||
import io.github.simplexdev.api.annotations.Enchant;
|
||||
import io.github.simplexdev.simplexcore.utils.ReflectionTools;
|
||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class EnchUtils {
|
||||
public SimplexEnch enchantment;
|
||||
|
||||
public <T extends SimplexEnch> void loadFrom(Class<T> clz) {
|
||||
Enchant info = clz.getDeclaredAnnotation(Enchant.class);
|
||||
|
||||
if (info == null) {
|
||||
// TODO
|
||||
return;
|
||||
}
|
||||
|
||||
ReflectionTools.reflect(clz).getTypesAnnotatedWith(info).forEach(cls -> {
|
||||
Constructor<?> c = ReflectionTools.getDeclaredConstructor(cls);
|
||||
if (c == null) return;
|
||||
SimplexEnch ench = (SimplexEnch) ReflectionTools.initConstructor(c);
|
||||
load(ench);
|
||||
});
|
||||
}
|
||||
|
||||
public <T extends SimplexEnch> void load(T enchantment) {
|
||||
EnchantmentWrapper.registerEnchantment(enchantment);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package io.github.simplexdev.simplexcore.enchanting;
|
||||
|
||||
import io.github.simplexdev.api.IEnchant;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class SimplexEnch extends Enchantment implements IEnchant {
|
||||
public SimplexEnch(@NotNull NamespacedKey key) {
|
||||
super(key);
|
||||
}
|
||||
}
|
@ -3,18 +3,17 @@ package io.github.simplexdev.simplexcore.gui;
|
||||
import io.github.simplexdev.api.func.ClickAction;
|
||||
import io.github.simplexdev.api.IGUI;
|
||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class GUIHandler extends SimplexListener {
|
||||
public GUIHandler(SimplexAddon<?> plugin) {
|
||||
public GUIHandler(SimplexModule<?> plugin) {
|
||||
register(this, plugin);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.github.simplexdev.simplexcore.listener;
|
||||
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@ -14,7 +14,7 @@ public abstract class SimplexListener implements Listener {
|
||||
*
|
||||
* @param cls The class to register.
|
||||
*/
|
||||
public static void registerFromClass(Class<? extends SimplexListener> cls, SimplexAddon<?> plugin) {
|
||||
public static void registerFromClass(Class<? extends SimplexListener> cls, SimplexModule<?> plugin) {
|
||||
if (!SimplexListener.class.isAssignableFrom(cls)) {
|
||||
SimplexCorePlugin.getInstance().getLogger().severe("You can only register subclasses of SimplexListener with this method.");
|
||||
return;
|
||||
@ -35,7 +35,7 @@ public abstract class SimplexListener implements Listener {
|
||||
* @param plugin Your plugin instance
|
||||
* @param <T> Type of which extends SimplexListener.
|
||||
*/
|
||||
public static <T extends SimplexListener> void register(T listener, SimplexAddon<?> plugin) {
|
||||
public static <T extends SimplexListener> void register(T listener, SimplexModule<?> plugin) {
|
||||
SimplexCorePlugin.getInstance().getManager().registerEvents(listener, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package io.github.simplexdev.simplexcore.plugin;
|
||||
package io.github.simplexdev.simplexcore.module;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
@ -0,0 +1,21 @@
|
||||
package io.github.simplexdev.simplexcore.module;
|
||||
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
|
||||
public final class ModuleManager {
|
||||
public ModuleManager() {
|
||||
}
|
||||
|
||||
public void disable(SimplexModule<?> simplexModule) {
|
||||
SimplexCorePlugin.getInstance().getManager().disablePlugin(simplexModule);
|
||||
}
|
||||
|
||||
public void enable(SimplexModule<?> simplexModule) {
|
||||
SimplexCorePlugin.getInstance().getManager().enablePlugin(simplexModule);
|
||||
}
|
||||
|
||||
public void reload(SimplexModule<?> simplexModule) {
|
||||
disable(simplexModule);
|
||||
enable(simplexModule);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.github.simplexdev.simplexcore.plugin;
|
||||
package io.github.simplexdev.simplexcore.module;
|
||||
|
||||
import io.github.simplexdev.api.annotations.ReqType;
|
||||
import io.github.simplexdev.api.annotations.Requires;
|
||||
@ -7,18 +7,18 @@ import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class AddonRegistry {
|
||||
private static final AddonRegistry instance = new AddonRegistry();
|
||||
private final Set<SimplexAddon<?>> components = new HashSet<>();
|
||||
public final class ModuleRegistry {
|
||||
private static final ModuleRegistry instance = new ModuleRegistry();
|
||||
private final Set<SimplexModule<?>> modules = new HashSet<>();
|
||||
|
||||
protected AddonRegistry() {
|
||||
protected ModuleRegistry() {
|
||||
}
|
||||
|
||||
public static synchronized AddonRegistry getInstance() {
|
||||
public static synchronized ModuleRegistry getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public <T extends SimplexAddon<T>> boolean isPaper(T addon) {
|
||||
public <T extends SimplexModule<T>> boolean isPaper(T addon) {
|
||||
try {
|
||||
Class.forName(com.destroystokyo.paper.Namespaced.class.getName());
|
||||
return true;
|
||||
@ -29,7 +29,7 @@ public final class AddonRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends SimplexAddon<T>> boolean isBungee(T addon) {
|
||||
private <T extends SimplexModule<T>> boolean isBungee(T addon) {
|
||||
try {
|
||||
Class.forName(net.md_5.bungee.Util.class.getName());
|
||||
return true;
|
||||
@ -40,7 +40,7 @@ public final class AddonRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends SimplexAddon<T>> boolean isWaterfall(T addon) {
|
||||
private <T extends SimplexModule<T>> boolean isWaterfall(T addon) {
|
||||
try {
|
||||
Class.forName(io.github.waterfallmc.waterfall.utils.Hex.class.getName());
|
||||
return true;
|
||||
@ -55,7 +55,7 @@ public final class AddonRegistry {
|
||||
return info.value() == type;
|
||||
}
|
||||
|
||||
public <T extends SimplexAddon<T>> void register(T addon) {
|
||||
public <T extends SimplexModule<T>> void register(T addon) {
|
||||
if (addon.getClass().isAnnotationPresent(Requires.class)) {
|
||||
Requires info = addon.getClass().getDeclaredAnnotation(Requires.class);
|
||||
if (checkAnnotation(info, ReqType.PAPER)
|
||||
@ -71,10 +71,10 @@ public final class AddonRegistry {
|
||||
return;
|
||||
}
|
||||
}
|
||||
getComponents().add(addon);
|
||||
getModules().add(addon);
|
||||
}
|
||||
|
||||
public Set<SimplexAddon<?>> getComponents() {
|
||||
return components;
|
||||
public Set<SimplexModule<?>> getModules() {
|
||||
return modules;
|
||||
}
|
||||
}
|
@ -1,20 +1,18 @@
|
||||
package io.github.simplexdev.simplexcore.plugin;
|
||||
package io.github.simplexdev.simplexcore.module;
|
||||
|
||||
import io.github.simplexdev.simplexcore.command.CommandLoader;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* This class represents a SimplexCore module.
|
||||
* You should extend this instead of JavaPlugin if you are using the core as a dependency.
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class SimplexAddon<T extends SimplexAddon<T>> extends JavaPlugin {
|
||||
public abstract class SimplexModule<T extends SimplexModule<T>> extends JavaPlugin {
|
||||
/**
|
||||
* Gets your plugin as an addon.
|
||||
*
|
||||
@ -65,8 +63,8 @@ public abstract class SimplexAddon<T extends SimplexAddon<T>> extends JavaPlugin
|
||||
return this.getDataFolder();
|
||||
}
|
||||
|
||||
public synchronized AddonRegistry getRegistry() {
|
||||
return AddonRegistry.getInstance();
|
||||
public synchronized ModuleRegistry getRegistry() {
|
||||
return ModuleRegistry.getInstance();
|
||||
}
|
||||
|
||||
public synchronized CommandLoader getCommandLoader() {
|
@ -1,21 +0,0 @@
|
||||
package io.github.simplexdev.simplexcore.plugin;
|
||||
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
|
||||
public final class AddonManager {
|
||||
public AddonManager() {
|
||||
}
|
||||
|
||||
public void disable(SimplexAddon<?> simplexAddon) {
|
||||
SimplexCorePlugin.getInstance().getManager().disablePlugin(simplexAddon);
|
||||
}
|
||||
|
||||
public void enable(SimplexAddon<?> simplexAddon) {
|
||||
SimplexCorePlugin.getInstance().getManager().enablePlugin(simplexAddon);
|
||||
}
|
||||
|
||||
public void reload(SimplexAddon<?> simplexAddon) {
|
||||
disable(simplexAddon);
|
||||
enable(simplexAddon);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import io.github.simplexdev.api.IUsableSign;
|
||||
import io.github.simplexdev.api.func.VoidSupplier;
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -107,7 +107,7 @@ public class SignFactory {
|
||||
}
|
||||
|
||||
private static class SignData extends SimplexListener {
|
||||
public SignData(SimplexAddon<?> plugin) {
|
||||
public SignData(SimplexModule<?> plugin) {
|
||||
register(this, plugin);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package io.github.simplexdev.simplexcore.task;
|
||||
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
import io.github.simplexdev.simplexcore.chat.Messages;
|
||||
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -18,7 +19,7 @@ public class Announcer extends SimplexTask {
|
||||
}};
|
||||
|
||||
public Announcer() {
|
||||
super(20L);
|
||||
super(TickedTime.HOUR);
|
||||
register(this, SimplexCorePlugin.getInstance(), true, false);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package io.github.simplexdev.simplexcore.task;
|
||||
|
||||
import io.github.simplexdev.api.func.VoidSupplier;
|
||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -61,7 +61,7 @@ public abstract class SimplexTask implements Consumer<BukkitTask> {
|
||||
* @param delayed Whether or not to delay the first time the task runs.
|
||||
* @param <T> A subclass of SimplexTask.
|
||||
*/
|
||||
public <T extends SimplexTask> void register(T task, SimplexAddon<?> plugin, boolean repeating, boolean delayed) {
|
||||
public <T extends SimplexTask> void register(T task, SimplexModule<?> plugin, boolean repeating, boolean delayed) {
|
||||
if (delayed && repeating) {
|
||||
SimplexCorePlugin.getInstance().getScheduler().runTaskTimer(plugin, task, DELAY, INTERVAL);
|
||||
} else if (delayed) {
|
||||
@ -84,7 +84,7 @@ public abstract class SimplexTask implements Consumer<BukkitTask> {
|
||||
* @param delayed Whether or not to delay the start of the task.
|
||||
* @param <T> A subclass of SimplexTask.
|
||||
*/
|
||||
public <T extends SimplexTask> void register(T task, SimplexAddon<?> plugin, boolean delayed) {
|
||||
public <T extends SimplexTask> void register(T task, SimplexModule<?> plugin, boolean delayed) {
|
||||
register(task, plugin, false, delayed);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ public abstract class SimplexTask implements Consumer<BukkitTask> {
|
||||
* @param plugin Your plugin instance.
|
||||
* @param <T> A subclass of SimplexTask.
|
||||
*/
|
||||
public <T extends SimplexTask> void register(T task, SimplexAddon<?> plugin) {
|
||||
public <T extends SimplexTask> void register(T task, SimplexModule<?> plugin) {
|
||||
register(task, plugin, false, false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user