Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26ab9a327d | ||
|
|
0676f5fa33 | ||
|
|
051b95ad88 | ||
|
|
d786014cbc | ||
|
|
b62bb48bb6 | ||
|
|
b238a10209 | ||
|
|
251049f1f1 | ||
|
|
16d146dba0 | ||
|
|
214308da10 | ||
|
|
2c12f78aa6 | ||
|
|
800e83d24b | ||
|
|
0a1ee0679c | ||
|
|
898230040a | ||
|
|
6f01577165 | ||
|
|
1c8c95f292 |
@@ -15,6 +15,11 @@
|
|||||||
|
|
||||||
# Information for development
|
# Information for development
|
||||||
|
|
||||||
|
## Javadoc
|
||||||
|
The 6.0.0 Javadoc can be found [here](https://javadoc.jitpack.io/com/willfp/eco/6.0.0/javadoc/)
|
||||||
|
|
||||||
|
## Plugin Information
|
||||||
|
|
||||||
eco is a standalone plugin, so you will need to install it on any servers that have plugins which depend on it,
|
eco is a standalone plugin, so you will need to install it on any servers that have plugins which depend on it,
|
||||||
and specify it as a dependency in your plugin.yml:
|
and specify it as a dependency in your plugin.yml:
|
||||||
|
|
||||||
@@ -157,4 +162,4 @@ Here's a list of some (not all) of the features of eco:
|
|||||||
<img src="https://i.imgur.com/zdDLhFA.png" alt="dedimc banner">
|
<img src="https://i.imgur.com/zdDLhFA.png" alt="dedimc banner">
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class DropQueue {
|
|||||||
/**
|
/**
|
||||||
* The internally used {@link DropQueue}.
|
* The internally used {@link DropQueue}.
|
||||||
*/
|
*/
|
||||||
private final DropQueue handle;
|
private final InternalDropQueue handle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ public interface DropQueueFactory {
|
|||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @return The Queue.
|
* @return The Queue.
|
||||||
*/
|
*/
|
||||||
DropQueue create(@NotNull Player player);
|
InternalDropQueue create(@NotNull Player player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.willfp.eco.core.drops;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal interface for backend DropQueue implementations.
|
||||||
|
*/
|
||||||
|
public interface InternalDropQueue {
|
||||||
|
/**
|
||||||
|
* Add item to queue.
|
||||||
|
*
|
||||||
|
* @param item The item to add.
|
||||||
|
* @return The DropQueue.
|
||||||
|
*/
|
||||||
|
InternalDropQueue addItem(@NotNull ItemStack item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add multiple items to queue.
|
||||||
|
*
|
||||||
|
* @param itemStacks The items to add.
|
||||||
|
* @return The DropQueue.
|
||||||
|
*/
|
||||||
|
InternalDropQueue addItems(@NotNull Collection<ItemStack> itemStacks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add xp to queue.
|
||||||
|
*
|
||||||
|
* @param amount The amount to add.
|
||||||
|
* @return The DropQueue.
|
||||||
|
*/
|
||||||
|
InternalDropQueue addXP(int amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set location of the origin of the drops.
|
||||||
|
*
|
||||||
|
* @param location The location.
|
||||||
|
* @return The DropQueue.
|
||||||
|
*/
|
||||||
|
InternalDropQueue setLocation(@NotNull Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force the queue to act as if player is telekinetic.
|
||||||
|
*
|
||||||
|
* @return The DropQueue.
|
||||||
|
*/
|
||||||
|
InternalDropQueue forceTelekinesis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push the queue.
|
||||||
|
*/
|
||||||
|
void push();
|
||||||
|
}
|
||||||
@@ -29,10 +29,10 @@ public class ArrowUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(values.get(0) instanceof ItemStack)) {
|
if (!(values.get(0).value() instanceof ItemStack)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ItemStack) values.get(0);
|
return (ItemStack) values.get(0).value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ public class EcoLoadableJSONConfig extends EcoJSONConfigWrapper implements Loada
|
|||||||
plugin.getConfigHandler().addConfig(this);
|
plugin.getConfigHandler().addConfig(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadFromFile() {
|
||||||
|
try {
|
||||||
|
init(this.configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createFile() {
|
public void createFile() {
|
||||||
String resourcePath = getResourcePath();
|
String resourcePath = getResourcePath();
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import com.willfp.eco.core.PluginDependent;
|
|||||||
import com.willfp.eco.core.config.interfaces.LoadableConfig;
|
import com.willfp.eco.core.config.interfaces.LoadableConfig;
|
||||||
import com.willfp.eco.core.config.updating.ConfigHandler;
|
import com.willfp.eco.core.config.updating.ConfigHandler;
|
||||||
import com.willfp.eco.core.config.updating.ConfigUpdater;
|
import com.willfp.eco.core.config.updating.ConfigUpdater;
|
||||||
|
import com.willfp.eco.internal.config.json.EcoLoadableJSONConfig;
|
||||||
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdateMethodException;
|
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdateMethodException;
|
||||||
|
import com.willfp.eco.internal.config.yaml.EcoLoadableYamlConfig;
|
||||||
import com.willfp.eco.internal.config.yaml.EcoUpdatableYamlConfig;
|
import com.willfp.eco.internal.config.yaml.EcoUpdatableYamlConfig;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
@@ -76,6 +78,12 @@ public class EcoConfigHandler extends PluginDependent<EcoPlugin> implements Conf
|
|||||||
if (config instanceof EcoUpdatableYamlConfig updatableYamlConfig) {
|
if (config instanceof EcoUpdatableYamlConfig updatableYamlConfig) {
|
||||||
updatableYamlConfig.update();
|
updatableYamlConfig.update();
|
||||||
}
|
}
|
||||||
|
if (config instanceof EcoLoadableYamlConfig ecoLoadableYamlConfig) {
|
||||||
|
ecoLoadableYamlConfig.reloadFromFile();
|
||||||
|
}
|
||||||
|
if (config instanceof EcoLoadableJSONConfig ecoLoadableJSONConfig) {
|
||||||
|
ecoLoadableJSONConfig.reloadFromFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.willfp.eco.core.config.interfaces.LoadableConfig;
|
|||||||
import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration;
|
import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -49,9 +50,19 @@ public class EcoLoadableYamlConfig extends EcoYamlConfigWrapper<YamlConfiguratio
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.configFile = new File(directory, this.name);
|
this.configFile = new File(directory, this.name);
|
||||||
|
|
||||||
|
this.getPlugin().getConfigHandler().addConfig(this);
|
||||||
init(YamlConfiguration.loadConfiguration(configFile));
|
init(YamlConfiguration.loadConfiguration(configFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadFromFile() {
|
||||||
|
try {
|
||||||
|
this.getHandle().load(this.getConfigFile());
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createFile() {
|
public void createFile() {
|
||||||
String resourcePath = getResourcePath();
|
String resourcePath = getResourcePath();
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public class EcoUpdatableYamlConfig extends EcoLoadableYamlConfig {
|
|||||||
this.updateBlacklist = new ArrayList<>(Arrays.asList(updateBlacklist));
|
this.updateBlacklist = new ArrayList<>(Arrays.asList(updateBlacklist));
|
||||||
this.updateBlacklist.removeIf(String::isEmpty);
|
this.updateBlacklist.removeIf(String::isEmpty);
|
||||||
|
|
||||||
|
plugin.getConfigHandler().addConfig(this);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.internal.drops;
|
package com.willfp.eco.internal.drops;
|
||||||
|
|
||||||
import com.willfp.eco.core.drops.DropQueue;
|
|
||||||
import com.willfp.eco.core.drops.DropQueueFactory;
|
import com.willfp.eco.core.drops.DropQueueFactory;
|
||||||
|
import com.willfp.eco.core.drops.InternalDropQueue;
|
||||||
import com.willfp.eco.internal.drops.impl.EcoDropQueue;
|
import com.willfp.eco.internal.drops.impl.EcoDropQueue;
|
||||||
import com.willfp.eco.internal.drops.impl.EcoFastCollatedDropQueue;
|
import com.willfp.eco.internal.drops.impl.EcoFastCollatedDropQueue;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class EcoDropQueueFactory implements DropQueueFactory {
|
public class EcoDropQueueFactory implements DropQueueFactory {
|
||||||
@Override
|
@Override
|
||||||
public DropQueue create(@NotNull final Player player) {
|
public InternalDropQueue create(@NotNull final Player player) {
|
||||||
return DropManager.getType() == DropQueueType.COLLATED ? new EcoFastCollatedDropQueue(player) : new EcoDropQueue(player);
|
return DropManager.getType() == DropQueueType.COLLATED ? new EcoFastCollatedDropQueue(player) : new EcoDropQueue(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.internal.drops.impl;
|
package com.willfp.eco.internal.drops.impl;
|
||||||
|
|
||||||
import com.willfp.eco.core.drops.DropQueue;
|
import com.willfp.eco.core.drops.InternalDropQueue;
|
||||||
import com.willfp.eco.util.TelekinesisUtils;
|
import com.willfp.eco.util.TelekinesisUtils;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -21,7 +21,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EcoDropQueue extends DropQueue {
|
public class EcoDropQueue implements InternalDropQueue {
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final List<ItemStack> items;
|
private final List<ItemStack> items;
|
||||||
|
|
||||||
@@ -38,7 +38,6 @@ public class EcoDropQueue extends DropQueue {
|
|||||||
private boolean hasTelekinesis = false;
|
private boolean hasTelekinesis = false;
|
||||||
|
|
||||||
public EcoDropQueue(@NotNull final Player player) {
|
public EcoDropQueue(@NotNull final Player player) {
|
||||||
super(player);
|
|
||||||
this.items = new ArrayList<>();
|
this.items = new ArrayList<>();
|
||||||
this.xp = 0;
|
this.xp = 0;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@@ -46,31 +45,31 @@ public class EcoDropQueue extends DropQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DropQueue addItem(@NotNull final ItemStack item) {
|
public InternalDropQueue addItem(@NotNull final ItemStack item) {
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DropQueue addItems(@NotNull final Collection<ItemStack> itemStacks) {
|
public InternalDropQueue addItems(@NotNull final Collection<ItemStack> itemStacks) {
|
||||||
this.items.addAll(itemStacks);
|
this.items.addAll(itemStacks);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DropQueue addXP(final int amount) {
|
public InternalDropQueue addXP(final int amount) {
|
||||||
this.xp += amount;
|
this.xp += amount;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DropQueue setLocation(@NotNull final Location location) {
|
public InternalDropQueue setLocation(@NotNull final Location location) {
|
||||||
this.loc = location;
|
this.loc = location;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DropQueue forceTelekinesis() {
|
public InternalDropQueue forceTelekinesis() {
|
||||||
this.hasTelekinesis = true;
|
this.hasTelekinesis = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ package com.willfp.eco.internal.extensions;
|
|||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
|
import com.willfp.eco.core.config.interfaces.Config;
|
||||||
|
import com.willfp.eco.core.config.yaml.YamlTransientConfig;
|
||||||
import com.willfp.eco.core.extensions.Extension;
|
import com.willfp.eco.core.extensions.Extension;
|
||||||
import com.willfp.eco.core.extensions.ExtensionLoader;
|
import com.willfp.eco.core.extensions.ExtensionLoader;
|
||||||
import com.willfp.eco.core.extensions.ExtensionMetadata;
|
import com.willfp.eco.core.extensions.ExtensionMetadata;
|
||||||
import com.willfp.eco.core.extensions.MalformedExtensionException;
|
import com.willfp.eco.core.extensions.MalformedExtensionException;
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -17,8 +18,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -50,12 +49,12 @@ public class EcoExtensionLoader extends PluginDependent<EcoPlugin> implements Ex
|
|||||||
try {
|
try {
|
||||||
loadExtension(extensionJar);
|
loadExtension(extensionJar);
|
||||||
} catch (MalformedExtensionException e) {
|
} catch (MalformedExtensionException e) {
|
||||||
this.getPlugin().getLogger().severe(extensionJar.getName() + " caused MalformedExtensionException: " + e.getMessage());
|
this.getPlugin().getLogger().warning(extensionJar.getName() + " caused an error!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadExtension(@NotNull final File extensionJar) {
|
private void loadExtension(@NotNull final File extensionJar) throws MalformedExtensionException {
|
||||||
URL url = null;
|
URL url = null;
|
||||||
try {
|
try {
|
||||||
url = extensionJar.toURI().toURL();
|
url = extensionJar.toURI().toURL();
|
||||||
@@ -71,22 +70,31 @@ public class EcoExtensionLoader extends PluginDependent<EcoPlugin> implements Ex
|
|||||||
throw new MalformedExtensionException("No extension.yml found in " + extensionJar.getName());
|
throw new MalformedExtensionException("No extension.yml found in " + extensionJar.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration extensionYml = YamlConfiguration.loadConfiguration(new InputStreamReader(ymlIn));
|
Config extensionYml = new YamlTransientConfig(YamlConfiguration.loadConfiguration(new InputStreamReader(ymlIn)));
|
||||||
|
|
||||||
Set<String> keys = extensionYml.getKeys(false);
|
String mainClass = extensionYml.getStringOrNull("main");
|
||||||
ArrayList<String> required = new ArrayList<>(Arrays.asList("main", "name", "version"));
|
String name = extensionYml.getStringOrNull("name");
|
||||||
required.removeAll(keys);
|
String version = extensionYml.getStringOrNull("version");
|
||||||
if (!required.isEmpty()) {
|
String author = extensionYml.getStringOrNull("author");
|
||||||
throw new MalformedExtensionException("Invalid extension.yml found in " + extensionJar.getName() + " - Missing: " + String.join(", ", required));
|
|
||||||
|
if (mainClass == null) {
|
||||||
|
throw new MalformedExtensionException("Invalid extension.yml found in " + extensionJar.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String mainClass = extensionYml.getString("main");
|
if (name == null) {
|
||||||
String name = extensionYml.getString("name");
|
this.getPlugin().getLogger().warning(extensionJar.getName() + " doesn't have a name!");
|
||||||
String version = extensionYml.getString("version");
|
name = "Unnamed Extension " + extensionJar.getName();
|
||||||
String author = extensionYml.getString("author");
|
}
|
||||||
Validate.notNull(name, "Name is missing!");
|
|
||||||
Validate.notNull(version, "Version is missing!");
|
if (version == null) {
|
||||||
Validate.notNull(author, "Author is missing!");
|
this.getPlugin().getLogger().warning(extensionJar.getName() + " doesn't have a version!");
|
||||||
|
version = "1.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (author == null) {
|
||||||
|
this.getPlugin().getLogger().warning(extensionJar.getName() + " doesn't have an author!");
|
||||||
|
author = "Unnamed Author";
|
||||||
|
}
|
||||||
|
|
||||||
ExtensionMetadata metadata = new ExtensionMetadata(version, name, author);
|
ExtensionMetadata metadata = new ExtensionMetadata(version, name, author);
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ public class GUIListener extends PluginDependent<EcoPlugin> implements Listener
|
|||||||
|
|
||||||
Menu menu = MenuHandler.getMenu(event.getInventory());
|
Menu menu = MenuHandler.getMenu(event.getInventory());
|
||||||
|
|
||||||
|
if (menu == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Validate.isTrue(menu instanceof EcoMenu, "Menu not instance of EcoMenu!");
|
Validate.isTrue(menu instanceof EcoMenu, "Menu not instance of EcoMenu!");
|
||||||
|
|
||||||
EcoMenu ecoMenu = (EcoMenu) menu;
|
EcoMenu ecoMenu = (EcoMenu) menu;
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 6.0.0
|
version = 6.0.5
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
Reference in New Issue
Block a user