Finished moving ecoenchants to new structure

This commit is contained in:
Auxilor
2020-12-22 13:59:53 +00:00
parent 012f952c99
commit cea8e090bb
139 changed files with 269 additions and 277 deletions

View File

@@ -1,6 +1,6 @@
package com.willfp.eco.util.drops.internal;
import com.willfp.eco.util.drops.telekinesis.TelekineticTests;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -118,7 +118,7 @@ public class InternalDropQueue implements AbstractDropQueue {
* Push the queue
*/
public void push() {
if(!hasTelekinesis) hasTelekinesis = TelekineticTests.testPlayer(player);
if(!hasTelekinesis) hasTelekinesis = AbstractEcoPlugin.getInstance().getTelekineticTests().testPlayer(player);
World world = loc.getWorld();
assert world != null;

View File

@@ -1,19 +1,25 @@
package com.willfp.eco.util.drops.telekinesis;
import com.willfp.eco.util.injection.PluginDependent;
import com.willfp.eco.util.lambda.ObjectBiCallable;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.Set;
public class TelekineticTests {
private static final Set<ObjectBiCallable<Boolean, Player>> tests = new HashSet<>();
public class TelekineticTests extends PluginDependent {
private final Set<ObjectBiCallable<Boolean, Player>> tests = new HashSet<>();
public static void registerTest(ObjectBiCallable<Boolean, Player> test) {
public TelekineticTests(AbstractEcoPlugin plugin) {
super(plugin);
}
public void registerTest(ObjectBiCallable<Boolean, Player> test) {
tests.add(test);
}
public static boolean testPlayer(Player player) {
public boolean testPlayer(Player player) {
for (ObjectBiCallable<Boolean, Player> test : tests) {
if(test.call(player)) return true;
}

View File

@@ -1,5 +1,6 @@
package com.willfp.eco.util.extensions;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -9,6 +10,8 @@ import org.jetbrains.annotations.NotNull;
* Syntactically similar to Bukkit Plugins.
*/
public abstract class Extension {
protected final AbstractEcoPlugin plugin = AbstractEcoPlugin.getInstance();
/**
* Metadata containing version and name
*/

View File

@@ -13,6 +13,7 @@ import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.eco.util.config.Configs;
import com.willfp.eco.util.drops.internal.DropManager;
import com.willfp.eco.util.drops.internal.FastCollatedDropQueue;
import com.willfp.eco.util.drops.telekinesis.TelekineticTests;
import com.willfp.eco.util.events.armorequip.ArmorListener;
import com.willfp.eco.util.events.armorequip.DispenserArmorListener;
import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityListeners;
@@ -54,6 +55,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
private final NamespacedKeyFactory namespacedKeyFactory;
private final MetadataValueFactory metadataValueFactory;
private final ExtensionLoader extensionLoader;
private final TelekineticTests telekineticTests;
protected boolean outdated = false;
@@ -68,6 +70,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
this.namespacedKeyFactory = new NamespacedKeyFactory(this);
this.metadataValueFactory = new MetadataValueFactory(this);
this.extensionLoader = new EcoExtensionLoader(this);
this.telekineticTests = new TelekineticTests(this);
}
@Override
@@ -210,6 +213,10 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
public abstract List<Listener> getListeners();
public final TelekineticTests getTelekineticTests() {
return telekineticTests;
}
public final Logger getLog() {
return log;
}