mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-21 14:55:17 +01:00
Began documenting
This commit is contained in:
parent
d15fa74629
commit
eb032f2483
@ -68,7 +68,7 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
|
||||
EcoEnchants.values().forEach(enchant -> {
|
||||
if(enchant.isEnabled()) {
|
||||
this.getEventManager().registerEvents(enchant);
|
||||
this.getEventManager().registerListener(enchant);
|
||||
if(enchant instanceof EcoRunnable) {
|
||||
this.getScheduler().syncRepeating((EcoRunnable) enchant, 5, ((EcoRunnable) enchant).getTime());
|
||||
}
|
||||
@ -116,7 +116,7 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
HandlerList.unregisterAll(ecoEnchant);
|
||||
|
||||
this.getScheduler().runLater(() -> {
|
||||
if(ecoEnchant.isEnabled()) this.getEventManager().registerEvents(ecoEnchant);
|
||||
if(ecoEnchant.isEnabled()) this.getEventManager().registerListener(ecoEnchant);
|
||||
}, 1);
|
||||
}));
|
||||
}
|
||||
|
@ -11,32 +11,48 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ArrowDataListener extends PluginDependent implements Listener {
|
||||
public ArrowDataListener(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Listener to add metadata to arrows about the enchantments on the bow that shot them.
|
||||
*
|
||||
* @param plugin The {@link AbstractEcoPlugin} that registered the listener.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ArrowDataListener(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for arrows being shot by entities.
|
||||
*
|
||||
* @param event The {@link ProjectileLaunchEvent} passed by spigot.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onLaunch(ProjectileLaunchEvent event) {
|
||||
if (!(event.getEntity() instanceof Arrow))
|
||||
public void onLaunch(final ProjectileLaunchEvent event) {
|
||||
if (!(event.getEntity() instanceof Arrow)) {
|
||||
return;
|
||||
if (!(event.getEntity().getShooter() instanceof LivingEntity))
|
||||
}
|
||||
if (!(event.getEntity().getShooter() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Arrow arrow = (Arrow) event.getEntity();
|
||||
LivingEntity entity = (LivingEntity) arrow.getShooter();
|
||||
|
||||
if (entity.getEquipment() == null)
|
||||
if (entity.getEquipment() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = entity.getEquipment().getItemInMainHand();
|
||||
|
||||
if (item.getType().equals(Material.AIR)) return;
|
||||
if (!item.hasItemMeta()) return;
|
||||
if (item.getItemMeta() == null) return;
|
||||
if (item.getType().equals(Material.AIR) || !item.hasItemMeta() || item.getItemMeta() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchantments = item.getItemMeta().getEnchants();
|
||||
arrow.setMetadata("enchantments", this.getPlugin().getMetadataValueFactory().create(enchantments));
|
||||
|
@ -5,24 +5,47 @@ import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoEventManager extends PluginDependent implements EventManager {
|
||||
public EcoEventManager(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Manager class for event management.
|
||||
* <p>
|
||||
* Prevents calls to {@link AbstractEcoPlugin#getInstance()}.
|
||||
*
|
||||
* @param plugin The {@link AbstractEcoPlugin} that this manages the events of.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public EcoEventManager(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a listener with bukkit.
|
||||
*
|
||||
* @param listener The listener to register.
|
||||
*/
|
||||
@Override
|
||||
public void registerEvents(Listener listener) {
|
||||
public void registerListener(@NotNull final Listener listener) {
|
||||
Bukkit.getPluginManager().registerEvents(listener, this.getPlugin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a listener with bukkit.
|
||||
*
|
||||
* @param listener The listener to unregister.
|
||||
*/
|
||||
@Override
|
||||
public void unregisterEvents(Listener listener) {
|
||||
public void unregisterListener(@NotNull final Listener listener) {
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all listeners associated with the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void unregisterAllEvents() {
|
||||
public void unregisterAllListeners() {
|
||||
HandlerList.unregisterAll(this.getPlugin());
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,22 @@ package com.willfp.eco.util.bukkit.events;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public interface EventManager {
|
||||
void registerEvents(Listener listener);
|
||||
void unregisterEvents(Listener listener);
|
||||
void unregisterAllEvents();
|
||||
/**
|
||||
* Register a listener with bukkit.
|
||||
*
|
||||
* @param listener The listener to register.
|
||||
*/
|
||||
void registerListener(Listener listener);
|
||||
|
||||
/**
|
||||
* Unregister a listener with bukkit.
|
||||
*
|
||||
* @param listener The listener to unregister.
|
||||
*/
|
||||
void unregisterListener(Listener listener);
|
||||
|
||||
/**
|
||||
* Unregister all listeners associated with the plugin.
|
||||
*/
|
||||
void unregisterAllListeners();
|
||||
}
|
||||
|
@ -3,13 +3,25 @@ package com.willfp.eco.util.bukkit.keys;
|
||||
import com.willfp.eco.util.factory.PluginDependentFactory;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NamespacedKeyFactory extends PluginDependentFactory {
|
||||
public NamespacedKeyFactory(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Factory class to produce {@link NamespacedKey}s associated with an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin that this factory creates keys for.
|
||||
*/
|
||||
public NamespacedKeyFactory(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public NamespacedKey create(String key) {
|
||||
/**
|
||||
* Create an {@link NamespacedKey} associated with an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param key The key in the {@link NamespacedKey}.
|
||||
* @return The created {@link NamespacedKey}.
|
||||
*/
|
||||
public NamespacedKey create(@NotNull final String key) {
|
||||
return new NamespacedKey(this.getPlugin(), key);
|
||||
}
|
||||
}
|
||||
|
@ -3,24 +3,46 @@ package com.willfp.eco.util.bukkit.logging;
|
||||
import com.willfp.eco.util.StringUtils;
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoLogger extends PluginDependent implements Logger {
|
||||
public EcoLogger(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Implementation of {@link Logger}.
|
||||
* Manages logging for an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param plugin The {@link AbstractEcoPlugin} for the logger to manage.
|
||||
*/
|
||||
public EcoLogger(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an informative/neutral message to console.
|
||||
*
|
||||
* @param message The message to log.
|
||||
*/
|
||||
@Override
|
||||
public void info(String message) {
|
||||
public void info(@NotNull final String message) {
|
||||
this.getPlugin().getLogger().info(StringUtils.translate(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a warning to console.
|
||||
*
|
||||
* @param message The message to log.
|
||||
*/
|
||||
@Override
|
||||
public void warn(String message) {
|
||||
public void warn(@NotNull final String message) {
|
||||
this.getPlugin().getLogger().warning(StringUtils.translate(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error to console.
|
||||
*
|
||||
* @param message The message to log.
|
||||
*/
|
||||
@Override
|
||||
public void error(String message) {
|
||||
public void error(@NotNull final String message) {
|
||||
this.getPlugin().getLogger().severe(StringUtils.translate(message));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,24 @@
|
||||
package com.willfp.eco.util.bukkit.logging;
|
||||
|
||||
public interface Logger {
|
||||
/**
|
||||
* Log an informative/neutral message to console.
|
||||
*
|
||||
* @param message The message to log.
|
||||
*/
|
||||
void info(String message);
|
||||
|
||||
/**
|
||||
* Log a warning to console.
|
||||
*
|
||||
* @param message The message to log.
|
||||
*/
|
||||
void warn(String message);
|
||||
|
||||
/**
|
||||
* Log an error to console.
|
||||
*
|
||||
* @param message The message to log.
|
||||
*/
|
||||
void error(String message);
|
||||
}
|
||||
|
@ -3,13 +3,25 @@ package com.willfp.eco.util.bukkit.meta;
|
||||
import com.willfp.eco.util.factory.PluginDependentFactory;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MetadataValueFactory extends PluginDependentFactory {
|
||||
public MetadataValueFactory(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Factory class to produce {@link FixedMetadataValue}s associated with an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin that this factory creates values for.
|
||||
*/
|
||||
public MetadataValueFactory(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public FixedMetadataValue create(Object value) {
|
||||
/**
|
||||
* Create an {@link FixedMetadataValue} associated with an {@link AbstractEcoPlugin} with a specified value.
|
||||
*
|
||||
* @param value The value of meta key.
|
||||
* @return The created {@link FixedMetadataValue}.
|
||||
*/
|
||||
public FixedMetadataValue create(@NotNull final Object value) {
|
||||
return new FixedMetadataValue(this.getPlugin(), value);
|
||||
}
|
||||
}
|
||||
|
@ -3,46 +3,99 @@ package com.willfp.eco.util.bukkit.scheduling;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class EcoBukkitRunnable extends BukkitRunnable {
|
||||
/**
|
||||
* The linked {@link AbstractEcoPlugin} to associate runnables with.
|
||||
*/
|
||||
private final AbstractEcoPlugin plugin;
|
||||
|
||||
EcoBukkitRunnable(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Creates a new {@link EcoBukkitRunnable}.
|
||||
* <p>
|
||||
* Cannot be instantiated normally, use {@link RunnableFactory}.
|
||||
*
|
||||
* @param plugin The {@link AbstractEcoPlugin} to associate runnables with.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
EcoBukkitRunnable(@NotNull final AbstractEcoPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected AbstractEcoPlugin getPlugin() {
|
||||
/**
|
||||
* Get the {@link AbstractEcoPlugin} that created this runnable.
|
||||
*
|
||||
* @return The linked plugin.
|
||||
*/
|
||||
protected final AbstractEcoPlugin getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task.
|
||||
*
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@NotNull
|
||||
public synchronized BukkitTask runTask() {
|
||||
public final synchronized BukkitTask runTask() {
|
||||
return super.runTask(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task asynchronously.
|
||||
*
|
||||
* @return The created {@link BukkitTask}
|
||||
*/
|
||||
@NotNull
|
||||
public synchronized BukkitTask runTaskAsynchronously() {
|
||||
public final synchronized BukkitTask runTaskAsynchronously() {
|
||||
return super.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task after a specified number of ticks.
|
||||
*
|
||||
* @param delay The number of ticks to wait.
|
||||
* @return The created {@link BukkitTask}
|
||||
*/
|
||||
@NotNull
|
||||
public synchronized BukkitTask runTaskLater(long delay) {
|
||||
public final synchronized BukkitTask runTaskLater(final long delay) {
|
||||
return super.runTaskLater(plugin, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task asynchronously after a specified number of ticks.
|
||||
*
|
||||
* @param delay The number of ticks to wait.
|
||||
* @return The created {@link BukkitTask}
|
||||
*/
|
||||
@NotNull
|
||||
public synchronized BukkitTask runTaskLaterAsynchronously(long delay) {
|
||||
public final synchronized BukkitTask runTaskLaterAsynchronously(final long delay) {
|
||||
return super.runTaskLaterAsynchronously(plugin, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly on a timer.
|
||||
*
|
||||
* @param delay The delay before the task is first ran (in ticks).
|
||||
* @param period The ticks elapsed before the task is ran again.
|
||||
* @return The created {@link BukkitTask}
|
||||
*/
|
||||
@NotNull
|
||||
public synchronized BukkitTask runTaskTimer(long delay, long period) {
|
||||
public final synchronized BukkitTask runTaskTimer(final long delay, final long period) {
|
||||
return super.runTaskTimer(plugin, delay, period);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly on a timer asynchronously.
|
||||
*
|
||||
* @param delay The delay before the task is first ran (in ticks).
|
||||
* @param period The ticks elapsed before the task is ran again.
|
||||
* @return The created {@link BukkitTask}
|
||||
*/
|
||||
@NotNull
|
||||
public synchronized BukkitTask runTaskTimerAsynchronously(long delay, long period) {
|
||||
public final synchronized BukkitTask runTaskTimerAsynchronously(final long delay, final long period) {
|
||||
return super.runTaskTimerAsynchronously(plugin, delay, period);
|
||||
}
|
||||
}
|
||||
|
@ -5,42 +5,103 @@ import com.willfp.eco.util.lambda.Callable;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoScheduler extends PluginDependent implements Scheduler {
|
||||
public EcoScheduler(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Create a scheduler to manage the tasks of an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin to manage.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public EcoScheduler(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task after a specified tick delay.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @param ticksLater The amount of ticks to wait before execution.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runLater(Callable callable, long ticksLater) {
|
||||
public BukkitTask runLater(@NotNull final Callable callable,
|
||||
final long ticksLater) {
|
||||
return Bukkit.getScheduler().runTaskLater(this.getPlugin(), callable::call, ticksLater);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly on a timer.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runTimer(Callable callable, long delay, long repeat) {
|
||||
public BukkitTask runTimer(@NotNull final Callable callable,
|
||||
final long delay,
|
||||
final long repeat) {
|
||||
return Bukkit.getScheduler().runTaskTimer(this.getPlugin(), callable::call, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly and asynchronously on a timer.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runAsyncTimer(Callable callable, long delay, long repeat) {
|
||||
public BukkitTask runAsyncTimer(@NotNull final Callable callable,
|
||||
final long delay,
|
||||
final long repeat) {
|
||||
return Bukkit.getScheduler().runTaskTimerAsynchronously(this.getPlugin(), callable::call, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask run(Runnable runnable) {
|
||||
public BukkitTask run(@NotNull final Runnable runnable) {
|
||||
return Bukkit.getScheduler().runTask(this.getPlugin(), runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task asynchronously.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runAsync(Callable callable) {
|
||||
public BukkitTask runAsync(@NotNull final Callable callable) {
|
||||
return Bukkit.getScheduler().runTaskAsynchronously(this.getPlugin(), callable::call);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the task to be ran repeatedly on a timer.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The id of the task.
|
||||
*/
|
||||
@Override
|
||||
public int syncRepeating(Runnable runnable, long delay, long repeat) {
|
||||
public int syncRepeating(@NotNull final Runnable runnable,
|
||||
final long delay,
|
||||
final long repeat) {
|
||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(this.getPlugin(), runnable, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel all running tasks from the linked {@link AbstractEcoPlugin}.
|
||||
*/
|
||||
@Override
|
||||
public void cancelAll() {
|
||||
Bukkit.getScheduler().cancelTasks(this.getPlugin());
|
||||
|
@ -3,13 +3,25 @@ package com.willfp.eco.util.bukkit.scheduling;
|
||||
import com.willfp.eco.util.factory.PluginDependentFactory;
|
||||
import com.willfp.eco.util.lambda.InputCallable;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RunnableFactory extends PluginDependentFactory {
|
||||
public RunnableFactory(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Factory class to produce {@link EcoBukkitRunnable}s associated with an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin that this factory creates runnables for.
|
||||
*/
|
||||
public RunnableFactory(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public EcoBukkitRunnable create(InputCallable<EcoBukkitRunnable> callable) {
|
||||
/**
|
||||
* Create an {@link EcoBukkitRunnable}.
|
||||
*
|
||||
* @param callable Lambda of the code to run, where the parameter represents the instance of the runnable.
|
||||
* @return The created {@link EcoBukkitRunnable}.
|
||||
*/
|
||||
public EcoBukkitRunnable create(@NotNull final InputCallable<EcoBukkitRunnable> callable) {
|
||||
return new EcoBukkitRunnable(this.getPlugin()) {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1,14 +1,68 @@
|
||||
package com.willfp.eco.util.bukkit.scheduling;
|
||||
|
||||
import com.willfp.eco.util.lambda.Callable;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Scheduler {
|
||||
BukkitTask runLater(Callable callable, long ticksLater);
|
||||
BukkitTask runTimer(Callable callable, long delay, long repeat);
|
||||
BukkitTask runAsyncTimer(Callable callable, long delay, long repeat);
|
||||
BukkitTask run(Runnable runnable);
|
||||
BukkitTask runAsync(Callable callable);
|
||||
int syncRepeating(Runnable runnable, long delay, long repeat);
|
||||
/**
|
||||
* Run the task after a specified tick delay.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @param ticksLater The amount of ticks to wait before execution.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runLater(@NotNull Callable callable, long ticksLater);
|
||||
|
||||
/**
|
||||
* Run the task repeatedly on a timer.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runTimer(@NotNull Callable callable, long delay, long repeat);
|
||||
|
||||
/**
|
||||
* Run the task repeatedly and asynchronously on a timer.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runAsyncTimer(@NotNull Callable callable, long delay, long repeat);
|
||||
|
||||
/**
|
||||
* Run the task.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask run(@NotNull Runnable runnable);
|
||||
|
||||
/**
|
||||
* Run the task asynchronously.
|
||||
*
|
||||
* @param callable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runAsync(@NotNull Callable callable);
|
||||
|
||||
/**
|
||||
* Schedule the task to be ran repeatedly on a timer.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The id of the task.
|
||||
*/
|
||||
int syncRepeating(@NotNull Runnable runnable, long delay, long repeat);
|
||||
|
||||
/**
|
||||
* Cancel all running tasks from the linked {@link AbstractEcoPlugin}.
|
||||
*/
|
||||
void cancelAll();
|
||||
}
|
||||
|
@ -16,11 +16,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Wrapper for commands in {@link AbstractEcoPlugin}s
|
||||
* <p>
|
||||
* Reduces boilerplate and copying code between different commands.
|
||||
*/
|
||||
public abstract class AbstractCommand extends PluginDependent implements CommandExecutor, Registerable {
|
||||
/**
|
||||
* The name of the command
|
||||
|
@ -21,7 +21,7 @@ public class AnticheatManager {
|
||||
*/
|
||||
public static void register(AnticheatWrapper anticheat) {
|
||||
if (anticheat instanceof Listener) {
|
||||
plugin.getEventManager().registerEvents((Listener) anticheat);
|
||||
plugin.getEventManager().registerListener((Listener) anticheat);
|
||||
}
|
||||
anticheats.add(anticheat);
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
this.getLog().info("");
|
||||
this.getLog().info("==========================================");
|
||||
|
||||
this.getEventManager().registerEvents(new ArrowDataListener(this));
|
||||
this.getEventManager().registerEvents(new NaturalExpGainListeners());
|
||||
this.getEventManager().registerEvents(new ArmorListener());
|
||||
this.getEventManager().registerEvents(new DispenserArmorListener());
|
||||
this.getEventManager().registerEvents(new EntityDeathByEntityListeners(this));
|
||||
this.getEventManager().registerListener(new ArrowDataListener(this));
|
||||
this.getEventManager().registerListener(new NaturalExpGainListeners());
|
||||
this.getEventManager().registerListener(new ArmorListener());
|
||||
this.getEventManager().registerListener(new DispenserArmorListener());
|
||||
this.getEventManager().registerListener(new EntityDeathByEntityListeners(this));
|
||||
|
||||
new FastCollatedDropQueue.CollatedRunnable(this);
|
||||
|
||||
@ -149,7 +149,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
if(!abstractPacketAdapter.isPostLoad()) abstractPacketAdapter.register();
|
||||
});
|
||||
|
||||
this.getListeners().forEach(listener -> this.getEventManager().registerEvents(listener));
|
||||
this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener));
|
||||
|
||||
this.getCommands().forEach(AbstractCommand::register);
|
||||
|
||||
@ -162,7 +162,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
public final void onDisable() {
|
||||
super.onDisable();
|
||||
|
||||
this.getEventManager().unregisterAllEvents();
|
||||
this.getEventManager().unregisterAllListeners();
|
||||
this.getScheduler().cancelAll();
|
||||
|
||||
this.disable();
|
||||
|
Loading…
Reference in New Issue
Block a user