Compare commits

...

12 Commits
6.0.0 ... 6.0.4

Author SHA1 Message Date
Auxilor
d786014cbc Updated to 6.0.4 2021-07-22 18:40:17 +01:00
Auxilor
b62bb48bb6 Fixed loadable config reloading 2021-07-22 18:39:59 +01:00
Auxilor
b238a10209 Fixed EcoUpdatableYamlConfig not automatically registering itsefl 2021-07-22 18:34:00 +01:00
Auxilor
251049f1f1 Updated to 6.0.3 2021-07-22 16:42:00 +01:00
Auxilor
16d146dba0 Fixed ArrowUtils 2021-07-22 16:41:43 +01:00
Auxilor
214308da10 Updated to 6.0.2 2021-07-21 21:46:12 +01:00
Auxilor
2c12f78aa6 Fixed 'Menu not instance of EcoMenu!' bug 2021-07-21 21:45:59 +01:00
Auxilor
800e83d24b Merge remote-tracking branch 'origin/master' 2021-07-21 20:37:38 +01:00
Auxilor
0a1ee0679c Updated to 6.0.1 2021-07-21 20:37:20 +01:00
Auxilor
898230040a Fixed DropQueue Stack Overflow 2021-07-21 20:37:09 +01:00
Auxilor
6f01577165 Update README.md 2021-07-21 19:07:49 +01:00
Auxilor
1c8c95f292 Update README.md 2021-07-21 19:07:31 +01:00
13 changed files with 109 additions and 16 deletions

View File

@@ -15,6 +15,11 @@
# 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,
and specify it as a dependency in your plugin.yml:

View File

@@ -21,7 +21,7 @@ public class DropQueue {
/**
* The internally used {@link DropQueue}.
*/
private final DropQueue handle;
private final InternalDropQueue handle;
/**
* @param player The player.

View File

@@ -13,5 +13,5 @@ public interface DropQueueFactory {
* @param player The player.
* @return The Queue.
*/
DropQueue create(@NotNull Player player);
InternalDropQueue create(@NotNull Player player);
}

View File

@@ -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();
}

View File

@@ -29,10 +29,10 @@ public class ArrowUtils {
return null;
}
if (!(values.get(0) instanceof ItemStack)) {
if (!(values.get(0).value() instanceof ItemStack)) {
return null;
}
return (ItemStack) values.get(0);
return (ItemStack) values.get(0).value();
}
}

View File

@@ -63,6 +63,14 @@ public class EcoLoadableJSONConfig extends EcoJSONConfigWrapper implements Loada
plugin.getConfigHandler().addConfig(this);
}
public void reloadFromFile() {
try {
init(this.configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void createFile() {
String resourcePath = getResourcePath();

View File

@@ -5,7 +5,9 @@ import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import com.willfp.eco.core.config.updating.ConfigHandler;
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.yaml.EcoLoadableYamlConfig;
import com.willfp.eco.internal.config.yaml.EcoUpdatableYamlConfig;
import org.jetbrains.annotations.NotNull;
import org.reflections.Reflections;
@@ -76,6 +78,12 @@ public class EcoConfigHandler extends PluginDependent<EcoPlugin> implements Conf
if (config instanceof EcoUpdatableYamlConfig updatableYamlConfig) {
updatableYamlConfig.update();
}
if (config instanceof EcoLoadableYamlConfig ecoLoadableYamlConfig) {
ecoLoadableYamlConfig.reloadFromFile();
}
if (config instanceof EcoLoadableJSONConfig ecoLoadableJSONConfig) {
ecoLoadableJSONConfig.reloadFromFile();
}
}
}
}

View File

@@ -5,6 +5,7 @@ import com.willfp.eco.core.config.interfaces.LoadableConfig;
import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -49,9 +50,19 @@ public class EcoLoadableYamlConfig extends EcoYamlConfigWrapper<YamlConfiguratio
}
this.configFile = new File(directory, this.name);
this.getPlugin().getConfigHandler().addConfig(this);
init(YamlConfiguration.loadConfiguration(configFile));
}
public void reloadFromFile() {
try {
this.getHandle().load(this.getConfigFile());
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
@Override
public void createFile() {
String resourcePath = getResourcePath();

View File

@@ -30,6 +30,8 @@ public class EcoUpdatableYamlConfig extends EcoLoadableYamlConfig {
this.updateBlacklist = new ArrayList<>(Arrays.asList(updateBlacklist));
this.updateBlacklist.removeIf(String::isEmpty);
plugin.getConfigHandler().addConfig(this);
update();
}

View File

@@ -1,7 +1,7 @@
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.InternalDropQueue;
import com.willfp.eco.internal.drops.impl.EcoDropQueue;
import com.willfp.eco.internal.drops.impl.EcoFastCollatedDropQueue;
import org.bukkit.entity.Player;
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
public class EcoDropQueueFactory implements DropQueueFactory {
@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);
}
}

View File

@@ -1,6 +1,6 @@
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 lombok.AccessLevel;
import lombok.Getter;
@@ -21,7 +21,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
public class EcoDropQueue extends DropQueue {
public class EcoDropQueue implements InternalDropQueue {
@Getter(AccessLevel.PROTECTED)
private final List<ItemStack> items;
@@ -38,7 +38,6 @@ public class EcoDropQueue extends DropQueue {
private boolean hasTelekinesis = false;
public EcoDropQueue(@NotNull final Player player) {
super(player);
this.items = new ArrayList<>();
this.xp = 0;
this.player = player;
@@ -46,31 +45,31 @@ public class EcoDropQueue extends DropQueue {
}
@Override
public DropQueue addItem(@NotNull final ItemStack item) {
public InternalDropQueue addItem(@NotNull final ItemStack item) {
this.items.add(item);
return this;
}
@Override
public DropQueue addItems(@NotNull final Collection<ItemStack> itemStacks) {
public InternalDropQueue addItems(@NotNull final Collection<ItemStack> itemStacks) {
this.items.addAll(itemStacks);
return this;
}
@Override
public DropQueue addXP(final int amount) {
public InternalDropQueue addXP(final int amount) {
this.xp += amount;
return this;
}
@Override
public DropQueue setLocation(@NotNull final Location location) {
public InternalDropQueue setLocation(@NotNull final Location location) {
this.loc = location;
return this;
}
@Override
public DropQueue forceTelekinesis() {
public InternalDropQueue forceTelekinesis() {
this.hasTelekinesis = true;
return this;
}

View File

@@ -54,6 +54,10 @@ public class GUIListener extends PluginDependent<EcoPlugin> implements Listener
Menu menu = MenuHandler.getMenu(event.getInventory());
if (menu == null) {
return;
}
Validate.isTrue(menu instanceof EcoMenu, "Menu not instance of EcoMenu!");
EcoMenu ecoMenu = (EcoMenu) menu;

View File

@@ -1,2 +1,2 @@
version = 6.0.0
version = 6.0.4
plugin-name = eco