Removed more javadoc from internals
This commit is contained in:
@@ -5,11 +5,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
public class EcoJSONConfigSection extends EcoJSONConfigWrapper {
|
||||
/**
|
||||
* Config section.
|
||||
*
|
||||
* @param values The values.
|
||||
*/
|
||||
public EcoJSONConfigSection(@NotNull final Map<String, Object> values) {
|
||||
this.init(values);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.willfp.eco.core.config.interfaces.JSONConfig;
|
||||
import com.willfp.eco.util.StringUtils;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -21,27 +20,15 @@ import java.util.Set;
|
||||
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public class EcoJSONConfigWrapper implements JSONConfig {
|
||||
/**
|
||||
* The linked {@link ConfigurationSection} where values are physically stored.
|
||||
*/
|
||||
@Getter
|
||||
private final Gson handle = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
/**
|
||||
* All stored values.
|
||||
*/
|
||||
|
||||
@Getter
|
||||
private final Map<String, Object> values = new HashMap<>();
|
||||
|
||||
/**
|
||||
* All cached values.
|
||||
*/
|
||||
@Getter
|
||||
private final Map<String, Object> cache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Abstract config.
|
||||
*/
|
||||
|
||||
public EcoJSONConfigWrapper() {
|
||||
|
||||
}
|
||||
|
||||
@@ -19,44 +19,21 @@ import java.util.HashMap;
|
||||
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public class EcoLoadableJSONConfig extends EcoJSONConfigWrapper implements LoadableConfig {
|
||||
/**
|
||||
* The physical config file, as stored on disk.
|
||||
*/
|
||||
@Getter
|
||||
private final File configFile;
|
||||
|
||||
/**
|
||||
* Plugin handle.
|
||||
*/
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final EcoPlugin plugin;
|
||||
|
||||
/**
|
||||
* The full name of the config file (eg config.json).
|
||||
*/
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The subdirectory path.
|
||||
*/
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final String subDirectoryPath;
|
||||
|
||||
/**
|
||||
* The provider of the config.
|
||||
*/
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final Class<?> source;
|
||||
|
||||
/**
|
||||
* Abstract config.
|
||||
*
|
||||
* @param configName The name of the config
|
||||
* @param plugin The plugin.
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
*/
|
||||
public EcoLoadableJSONConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@@ -114,11 +91,7 @@ public class EcoLoadableJSONConfig extends EcoJSONConfigWrapper implements Loada
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource path as relative to base directory.
|
||||
*
|
||||
* @return The resource path.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String getResourcePath() {
|
||||
String resourcePath;
|
||||
@@ -132,23 +105,14 @@ public class EcoLoadableJSONConfig extends EcoJSONConfigWrapper implements Loada
|
||||
return "/" + resourcePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the config.
|
||||
*
|
||||
* @throws IOException If error in saving.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void save() throws IOException {
|
||||
configFile.delete();
|
||||
Files.write(configFile.toPath(), this.toPlaintext().getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the config.
|
||||
*
|
||||
* @param file The config file.
|
||||
* @throws FileNotFoundException If the file doesn't exist.
|
||||
*/
|
||||
|
||||
public void init(@NotNull final File file) throws FileNotFoundException {
|
||||
super.init(this.getHandle().fromJson(new FileReader(file), HashMap.class));
|
||||
}
|
||||
|
||||
@@ -3,15 +3,6 @@ package com.willfp.eco.internal.config.updating.exceptions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class InvalidUpdateMethodException extends RuntimeException {
|
||||
/**
|
||||
* Throws a new invalid update method exception.
|
||||
* <p>
|
||||
* Causes include:
|
||||
* Update method with parameters.
|
||||
* Update method is not static.
|
||||
*
|
||||
* @param message The error message to show.
|
||||
*/
|
||||
public InvalidUpdateMethodException(@NotNull final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@@ -15,44 +15,21 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class EcoLoadableYamlConfig extends EcoYamlConfigWrapper<YamlConfiguration> implements WrappedYamlConfiguration, LoadableConfig {
|
||||
/**
|
||||
* The physical config file, as stored on disk.
|
||||
*/
|
||||
@Getter
|
||||
private final File configFile;
|
||||
|
||||
/**
|
||||
* Plugin handle.
|
||||
*/
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final EcoPlugin plugin;
|
||||
|
||||
/**
|
||||
* The full name of the config file (eg config.yml).
|
||||
*/
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The subdirectory path.
|
||||
*/
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final String subDirectoryPath;
|
||||
|
||||
/**
|
||||
* The provider of the config.
|
||||
*/
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final Class<?> source;
|
||||
|
||||
/**
|
||||
* Abstract config.
|
||||
*
|
||||
* @param configName The name of the config
|
||||
* @param plugin The plugin.
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
*/
|
||||
public EcoLoadableYamlConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String subDirectoryPath,
|
||||
|
||||
@@ -15,26 +15,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class EcoUpdatableYamlConfig extends EcoLoadableYamlConfig {
|
||||
/**
|
||||
* Whether keys not in the base config should be removed on update.
|
||||
*/
|
||||
private final boolean removeUnused;
|
||||
|
||||
/**
|
||||
* List of blacklisted update keys.
|
||||
*/
|
||||
private final List<String> updateBlacklist;
|
||||
|
||||
/**
|
||||
* Updatable config.
|
||||
*
|
||||
* @param configName The name of the config
|
||||
* @param plugin The plugin.
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||
*/
|
||||
public EcoUpdatableYamlConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@@ -49,11 +33,6 @@ public class EcoUpdatableYamlConfig extends EcoLoadableYamlConfig {
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the config.
|
||||
* <p>
|
||||
* Writes missing values, however removes comments due to how configs are stored internally in bukkit.
|
||||
*/
|
||||
public void update() {
|
||||
super.clearCache();
|
||||
try {
|
||||
|
||||
@@ -4,11 +4,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoYamlConfigSection extends EcoYamlConfigWrapper<ConfigurationSection> {
|
||||
/**
|
||||
* Config section.
|
||||
*
|
||||
* @param section The section.
|
||||
*/
|
||||
public EcoYamlConfigSection(@NotNull final ConfigurationSection section) {
|
||||
this.init(section);
|
||||
}
|
||||
|
||||
@@ -18,20 +18,11 @@ import java.util.Objects;
|
||||
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public class EcoYamlConfigWrapper<T extends ConfigurationSection> implements Config {
|
||||
/**
|
||||
* The linked {@link ConfigurationSection} where values are physically stored.
|
||||
*/
|
||||
@Getter
|
||||
private T handle = null;
|
||||
|
||||
/**
|
||||
* Cached values for faster reading.
|
||||
*/
|
||||
|
||||
private final Map<String, Object> cache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Abstract config.
|
||||
*/
|
||||
|
||||
public EcoYamlConfigWrapper() {
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@UtilityClass
|
||||
public final class DropManager {
|
||||
/**
|
||||
* The currently used type, or implementation, of {@link com.willfp.eco.core.drops.DropQueue}.
|
||||
* <p>
|
||||
* Default is {@link DropQueueType#COLLATED}, however this can be changed.
|
||||
*/
|
||||
@Getter
|
||||
private DropQueueType type = DropQueueType.COLLATED;
|
||||
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
package com.willfp.eco.internal.drops;
|
||||
|
||||
public enum DropQueueType {
|
||||
/**
|
||||
* As drops are processed, push them to the world or to the player's inventory.
|
||||
*/
|
||||
STANDARD,
|
||||
|
||||
/**
|
||||
* As drops are processed, add them to a queue that are all collectively pushed at the end of a tick.
|
||||
* <p>
|
||||
* Generally better performance.
|
||||
*/
|
||||
COLLATED
|
||||
}
|
||||
|
||||
@@ -22,41 +22,21 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class EcoDropQueue extends DropQueue {
|
||||
/**
|
||||
* The items that the DropQueue stores.
|
||||
*/
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final List<ItemStack> items;
|
||||
|
||||
/**
|
||||
* The experience to give.
|
||||
*/
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private int xp;
|
||||
|
||||
/**
|
||||
* The owner of the queue.
|
||||
*/
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The location to drop the items and xp.
|
||||
*/
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private Location loc;
|
||||
|
||||
/**
|
||||
* If the queue should be processed telekinetically.
|
||||
*/
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private boolean hasTelekinesis = false;
|
||||
|
||||
/**
|
||||
* Create a DropQueue linked to player.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public EcoDropQueue(@NotNull final Player player) {
|
||||
super(player);
|
||||
this.items = new ArrayList<>();
|
||||
@@ -65,68 +45,36 @@ public class EcoDropQueue extends DropQueue {
|
||||
this.loc = player.getLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item to queue.
|
||||
*
|
||||
* @param item The item to add.
|
||||
* @return The DropQueue.
|
||||
*/
|
||||
@Override
|
||||
public DropQueue addItem(@NotNull final ItemStack item) {
|
||||
this.items.add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple items to queue.
|
||||
*
|
||||
* @param itemStacks The items to add.
|
||||
* @return The DropQueue.
|
||||
*/
|
||||
@Override
|
||||
public DropQueue addItems(@NotNull final Collection<ItemStack> itemStacks) {
|
||||
this.items.addAll(itemStacks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add xp to queue.
|
||||
*
|
||||
* @param amount The amount to add.
|
||||
* @return The DropQueue.
|
||||
*/
|
||||
@Override
|
||||
public DropQueue addXP(final int amount) {
|
||||
this.xp += amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set location of the origin of the drops.
|
||||
*
|
||||
* @param location The location.
|
||||
* @return The DropQueue.
|
||||
*/
|
||||
@Override
|
||||
public DropQueue setLocation(@NotNull final Location location) {
|
||||
this.loc = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the queue to act as if player has a telekinetic item.
|
||||
*
|
||||
* @return The DropQueue.
|
||||
*/
|
||||
@Override
|
||||
public DropQueue forceTelekinesis() {
|
||||
this.hasTelekinesis = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the queue.
|
||||
*/
|
||||
@Override
|
||||
public void push() {
|
||||
if (!hasTelekinesis) {
|
||||
|
||||
@@ -14,28 +14,12 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class EcoFastCollatedDropQueue extends EcoDropQueue {
|
||||
/**
|
||||
* The {@link CollatedDrops} linked to every player.
|
||||
* <p>
|
||||
* Cleared and updated every tick.
|
||||
*/
|
||||
public static final Map<Player, CollatedDrops> COLLATED_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Backend implementation of {@link com.willfp.eco.core.drops.DropQueue}
|
||||
* {@link this#push()} adds to a map that creates a new {@link EcoDropQueue} at the end of every tick
|
||||
* <p>
|
||||
* The drops are not instantly pushed when called, instead the map is iterated over at the end of every tick. This massively improves performance.
|
||||
*
|
||||
* @param player The player to link the queue with.
|
||||
*/
|
||||
public EcoFastCollatedDropQueue(@NotNull final Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues the drops to be managed by the runnable.
|
||||
*/
|
||||
@Override
|
||||
public void push() {
|
||||
CollatedDrops fetched = COLLATED_MAP.get(getPlayer());
|
||||
@@ -43,28 +27,16 @@ public class EcoFastCollatedDropQueue extends EcoDropQueue {
|
||||
COLLATED_MAP.put(this.getPlayer(), collatedDrops);
|
||||
}
|
||||
|
||||
/**
|
||||
* The items, location, and xp linked to a player's drops.
|
||||
*/
|
||||
@ToString
|
||||
public static final class CollatedDrops {
|
||||
/**
|
||||
* A collection of all ItemStacks to be dropped at the end of the tick.
|
||||
*/
|
||||
@Getter
|
||||
private final List<ItemStack> drops;
|
||||
|
||||
/**
|
||||
* The location to drop the items at.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
private Location location;
|
||||
|
||||
/**
|
||||
* The xp to give to the player.
|
||||
*/
|
||||
@Getter
|
||||
private int xp;
|
||||
|
||||
@@ -76,23 +48,11 @@ public class EcoFastCollatedDropQueue extends EcoDropQueue {
|
||||
this.xp = xp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add {@link ItemStack}s to the queue.
|
||||
*
|
||||
* @param toAdd The items to add.
|
||||
* @return The instance of the {@link CollatedDrops}.
|
||||
*/
|
||||
public CollatedDrops addDrops(@NotNull final List<ItemStack> toAdd) {
|
||||
drops.addAll(toAdd);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add xp to the queue.
|
||||
*
|
||||
* @param xp The amount of xp to add.
|
||||
* @return The instance of the {@link CollatedDrops}.
|
||||
*/
|
||||
public CollatedDrops addXp(final int xp) {
|
||||
this.xp += xp;
|
||||
return this;
|
||||
|
||||
@@ -10,39 +10,21 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoEventManager extends PluginDependent<EcoPlugin> implements EventManager {
|
||||
/**
|
||||
* Manager class for event management.
|
||||
*
|
||||
* @param plugin The {@link EcoPlugin} that this manages the events of.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public EcoEventManager(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a listener with bukkit.
|
||||
*
|
||||
* @param listener The listener to register.
|
||||
*/
|
||||
@Override
|
||||
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 unregisterListener(@NotNull final Listener listener) {
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all listeners associated with the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void unregisterAllListeners() {
|
||||
HandlerList.unregisterAll(this.getPlugin());
|
||||
|
||||
@@ -23,23 +23,12 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class EcoExtensionLoader extends PluginDependent<EcoPlugin> implements ExtensionLoader {
|
||||
/**
|
||||
* All currently loaded extensions.
|
||||
*/
|
||||
private final Set<Extension> extensions = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Create a new extension loader and link it to a specific {@link EcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin to manage
|
||||
*/
|
||||
public EcoExtensionLoader(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all present extensions.
|
||||
*/
|
||||
@Override
|
||||
public void loadExtensions() {
|
||||
File dir = new File(this.getPlugin().getDataFolder(), "/extensions");
|
||||
@@ -119,20 +108,12 @@ public class EcoExtensionLoader extends PluginDependent<EcoPlugin> implements Ex
|
||||
extensions.add(extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload all existing extensions.
|
||||
*/
|
||||
@Override
|
||||
public void unloadExtensions() {
|
||||
extensions.forEach(Extension::disable);
|
||||
extensions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all loaded extensions.
|
||||
*
|
||||
* @return A {@link Set} of all loaded extensions.
|
||||
*/
|
||||
@Override
|
||||
public Set<Extension> getLoadedExtensions() {
|
||||
return extensions;
|
||||
|
||||
@@ -7,21 +7,10 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoMetadataValueFactory extends PluginDependent<EcoPlugin> implements MetadataValueFactory {
|
||||
/**
|
||||
* Factory class to produce {@link FixedMetadataValue}s associated with an {@link EcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin that this factory creates values for.
|
||||
*/
|
||||
public EcoMetadataValueFactory(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link FixedMetadataValue} associated with an {@link EcoPlugin} with a specified value.
|
||||
*
|
||||
* @param value The value of meta key.
|
||||
* @return The created {@link FixedMetadataValue}.
|
||||
*/
|
||||
@Override
|
||||
public FixedMetadataValue create(@NotNull final Object value) {
|
||||
return new FixedMetadataValue(this.getPlugin(), value);
|
||||
|
||||
@@ -7,11 +7,6 @@ import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoNamespacedKeyFactory extends PluginDependent<EcoPlugin> implements NamespacedKeyFactory {
|
||||
/**
|
||||
* Factory class to produce {@link NamespacedKey}s associated with an {@link EcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin that this factory creates keys for.
|
||||
*/
|
||||
public EcoNamespacedKeyFactory(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EcoRunnableFactory extends PluginDependent<EcoPlugin> implements RunnableFactory {
|
||||
/**
|
||||
* Factory class to produce {@link RunnableTask}s associated with an {@link EcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin that this factory creates runnables for.
|
||||
*/
|
||||
public EcoRunnableFactory(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@@ -18,26 +18,14 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EcoMenu implements Menu {
|
||||
/**
|
||||
* The amount of rows.
|
||||
*/
|
||||
@Getter
|
||||
private final int rows;
|
||||
|
||||
/**
|
||||
* 2D list of slots.
|
||||
*/
|
||||
private final List<List<Slot>> slots;
|
||||
|
||||
/**
|
||||
* Menu title.
|
||||
*/
|
||||
@Getter
|
||||
private final String title;
|
||||
|
||||
/**
|
||||
* Handler on close.
|
||||
*/
|
||||
private final Consumer<InventoryCloseEvent> onClose;
|
||||
|
||||
public EcoMenu(final int rows,
|
||||
|
||||
@@ -16,30 +16,14 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EcoMenuBuilder implements MenuBuilder {
|
||||
|
||||
/**
|
||||
* The amount of rows.
|
||||
*/
|
||||
private final int rows;
|
||||
|
||||
/**
|
||||
* The title.
|
||||
*/
|
||||
private String title = "Menu";
|
||||
|
||||
/**
|
||||
* The mask slots.
|
||||
*/
|
||||
private List<List<Slot>> maskSlots;
|
||||
|
||||
/**
|
||||
* The slots.
|
||||
*/
|
||||
private final List<List<Slot>> slots;
|
||||
|
||||
/**
|
||||
* The close event handler.
|
||||
*/
|
||||
private Consumer<InventoryCloseEvent> onClose = (event) -> {
|
||||
};
|
||||
|
||||
|
||||
@@ -11,37 +11,17 @@ import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
public class MenuHandler {
|
||||
/**
|
||||
* All registered menus.
|
||||
*/
|
||||
private static final Map<Inventory, Menu> MENUS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Register a menu.
|
||||
*
|
||||
* @param inventory The inventory corresponding to the menu.
|
||||
* @param menu The menu.
|
||||
*/
|
||||
public void registerMenu(@NotNull final Inventory inventory,
|
||||
@NotNull final Menu menu) {
|
||||
MENUS.put(inventory, menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a menu.
|
||||
*
|
||||
* @param inventory The inventory for the menu.
|
||||
*/
|
||||
public void unregisterMenu(@NotNull final Inventory inventory) {
|
||||
MENUS.remove(inventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a menu from an inventory.
|
||||
*
|
||||
* @param inventory The inventory.
|
||||
* @return The menu, or null if not a menu.
|
||||
*/
|
||||
@Nullable
|
||||
public Menu getMenu(@NotNull final Inventory inventory) {
|
||||
return MENUS.get(inventory);
|
||||
|
||||
@@ -4,11 +4,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoFillerSlot extends EcoSlot {
|
||||
/**
|
||||
* Create new filler slot.
|
||||
*
|
||||
* @param itemStack The ItemStack.
|
||||
*/
|
||||
public EcoFillerSlot(@NotNull final ItemStack itemStack) {
|
||||
super((player) -> itemStack, null, null, null, null, null);
|
||||
}
|
||||
|
||||
@@ -12,35 +12,17 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class EcoSlot implements Slot {
|
||||
/**
|
||||
* The item provider.
|
||||
*/
|
||||
@Getter
|
||||
private final Function<Player, ItemStack> provider;
|
||||
|
||||
/**
|
||||
* Left click handler.
|
||||
*/
|
||||
private final BiConsumer<InventoryClickEvent, Slot> onLeftClick;
|
||||
|
||||
/**
|
||||
* Right click handler.
|
||||
*/
|
||||
private final BiConsumer<InventoryClickEvent, Slot> onRightClick;
|
||||
|
||||
/**
|
||||
* Shift-Left-Click handler.
|
||||
*/
|
||||
private final BiConsumer<InventoryClickEvent, Slot> onShiftLeftClick;
|
||||
|
||||
/**
|
||||
* Shift-Right-Click handler.
|
||||
*/
|
||||
private final BiConsumer<InventoryClickEvent, Slot> onShiftRightClick;
|
||||
|
||||
/**
|
||||
* Shift-Middle-Click handler.
|
||||
*/
|
||||
private final BiConsumer<InventoryClickEvent, Slot> onMiddleClick;
|
||||
|
||||
public EcoSlot(@NotNull final Function<Player, ItemStack> provider,
|
||||
|
||||
@@ -11,34 +11,16 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class EcoSlotBuilder implements SlotBuilder {
|
||||
/**
|
||||
* Provider.
|
||||
*/
|
||||
private final Function<Player, ItemStack> provider;
|
||||
|
||||
/**
|
||||
* Left click handler.
|
||||
*/
|
||||
private BiConsumer<InventoryClickEvent, Slot> onLeftClick = null;
|
||||
|
||||
/**
|
||||
* Right click handler.
|
||||
*/
|
||||
private BiConsumer<InventoryClickEvent, Slot> onRightClick = null;
|
||||
|
||||
/**
|
||||
* Shift-Left-Click handler.
|
||||
*/
|
||||
private BiConsumer<InventoryClickEvent, Slot> onShiftLeftClick = null;
|
||||
|
||||
/**
|
||||
* Shift-Right-Click handler.
|
||||
*/
|
||||
private BiConsumer<InventoryClickEvent, Slot> onShiftRightClick = null;
|
||||
|
||||
/**
|
||||
* Middle click handler.
|
||||
*/
|
||||
private BiConsumer<InventoryClickEvent, Slot> onMiddleClick = null;
|
||||
|
||||
public EcoSlotBuilder(@NotNull final Function<Player, ItemStack> provider) {
|
||||
|
||||
@@ -10,16 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements PlaceholderIntegration {
|
||||
/**
|
||||
* The linked plugin.
|
||||
*/
|
||||
private final EcoPlugin plugin;
|
||||
|
||||
/**
|
||||
* Create a new PlaceholderAPI integration.
|
||||
*
|
||||
* @param plugin The plugin to manage placeholders for.
|
||||
*/
|
||||
public PlaceholderIntegrationPAPI(@NotNull final EcoPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -19,29 +19,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EcoProxyFactory extends PluginDependent<EcoPlugin> implements ProxyFactory {
|
||||
/**
|
||||
* All supported NMS versions.
|
||||
*/
|
||||
private static final List<String> SUPPORTED_VERSIONS = Arrays.asList(
|
||||
"v1_16_R3",
|
||||
"v1_17_R1"
|
||||
);
|
||||
|
||||
/**
|
||||
* The proxy class loader.
|
||||
*/
|
||||
private final ClassLoader proxyClassLoader;
|
||||
|
||||
/**
|
||||
* Cached proxy implementations in order to not perform expensive reflective class-finding.
|
||||
*/
|
||||
private final Map<Class<? extends AbstractProxy>, AbstractProxy> cache = new IdentityHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a new Proxy Factory for a specific type.
|
||||
*
|
||||
* @param plugin The plugin to create proxies for.
|
||||
*/
|
||||
public EcoProxyFactory(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -53,13 +39,6 @@ public class EcoProxyFactory extends PluginDependent<EcoPlugin> implements Proxy
|
||||
this.proxyClassLoader = plugin.getClass().getClassLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the implementation of a proxy.
|
||||
*
|
||||
* @param <T> The proxy class.
|
||||
* @param proxyClass The proxy class.
|
||||
* @return The proxy implementation.
|
||||
*/
|
||||
@Override
|
||||
public <T extends AbstractProxy> @NotNull T getProxy(@NotNull final Class<T> proxyClass) {
|
||||
try {
|
||||
|
||||
@@ -9,28 +9,16 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class EcoRunnableTask extends BukkitRunnable implements RunnableTask {
|
||||
/**
|
||||
* The linked {@link EcoPlugin} to associate runnables with.
|
||||
*/
|
||||
|
||||
private final EcoPlugin plugin;
|
||||
|
||||
/**
|
||||
* Creates a new {@link EcoRunnableTask}.
|
||||
* <p>
|
||||
* Cannot be instantiated normally, use {@link EcoRunnableFactory}.
|
||||
*
|
||||
* @param plugin The {@link EcoPlugin} to associate runnables with.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EcoRunnableTask(@NotNull final EcoPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link EcoPlugin} that created this runnable.
|
||||
*
|
||||
* @return The linked plugin.
|
||||
*/
|
||||
|
||||
protected final EcoPlugin getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
@@ -9,37 +9,17 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EcoScheduler extends PluginDependent<EcoPlugin> implements Scheduler {
|
||||
/**
|
||||
* Create a scheduler to manage the tasks of an {@link EcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin to manage.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public EcoScheduler(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task after a specified tick delay.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @param ticksLater The amount of ticks to wait before execution.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runLater(@NotNull final Runnable runnable,
|
||||
final long ticksLater) {
|
||||
return Bukkit.getScheduler().runTaskLater(this.getPlugin(), runnable, ticksLater);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task 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 created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runTimer(@NotNull final Runnable runnable,
|
||||
final long delay,
|
||||
@@ -47,14 +27,6 @@ public class EcoScheduler extends PluginDependent<EcoPlugin> implements Schedule
|
||||
return Bukkit.getScheduler().runTaskTimer(this.getPlugin(), runnable, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly and asynchronously 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 created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runAsyncTimer(@NotNull final Runnable runnable,
|
||||
final long delay,
|
||||
@@ -62,36 +34,16 @@ public class EcoScheduler extends PluginDependent<EcoPlugin> implements Schedule
|
||||
return Bukkit.getScheduler().runTaskTimerAsynchronously(this.getPlugin(), runnable, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask run(@NotNull final Runnable runnable) {
|
||||
return Bukkit.getScheduler().runTask(this.getPlugin(), runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task asynchronously.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
@Override
|
||||
public BukkitTask runAsync(@NotNull final Runnable runnable) {
|
||||
return Bukkit.getScheduler().runTaskAsynchronously(this.getPlugin(), runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(@NotNull final Runnable runnable,
|
||||
final long delay,
|
||||
@@ -99,9 +51,6 @@ public class EcoScheduler extends PluginDependent<EcoPlugin> implements Schedule
|
||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(this.getPlugin(), runnable, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel all running tasks from the linked {@link EcoPlugin}.
|
||||
*/
|
||||
@Override
|
||||
public void cancelAll() {
|
||||
Bukkit.getScheduler().cancelTasks(this.getPlugin());
|
||||
|
||||
Reference in New Issue
Block a user