Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8a5fe0031 | ||
|
|
5603890663 | ||
|
|
1a86cc4dbd | ||
|
|
734add6dbc | ||
|
|
5641c0def3 | ||
|
|
b74ab5349a | ||
|
|
b0971e5124 | ||
|
|
02d8c8c6b6 | ||
|
|
d9bd5257e3 |
@@ -98,5 +98,5 @@ build.dependsOn publishToMavenLocal
|
||||
|
||||
group = 'com.willfp'
|
||||
archivesBaseName = project.name
|
||||
version = '1.2.0'
|
||||
version = '2.0.0'
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
7
src/main/java/com/willfp/eco/spigot/EcoSpigotMain.java
Normal file
7
src/main/java/com/willfp/eco/spigot/EcoSpigotMain.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.willfp.eco.spigot;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class EcoSpigotMain extends JavaPlugin {
|
||||
|
||||
}
|
||||
@@ -77,6 +77,8 @@ public final class TelekinesisUtils {
|
||||
try {
|
||||
testMethod1 = clazz.getDeclaredMethod("testPlayer", Player.class);
|
||||
registerMethod1 = clazz.getDeclaredMethod("registerTest", Function.class);
|
||||
testMethod1.setAccessible(true);
|
||||
registerMethod1.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
testMethod1 = null;
|
||||
|
||||
@@ -39,8 +39,8 @@ import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
|
||||
import com.willfp.eco.util.integrations.placeholder.plugins.PlaceholderIntegrationPAPI;
|
||||
import com.willfp.eco.util.optional.Prerequisite;
|
||||
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
|
||||
import com.willfp.eco.util.recipes.RecipeListener;
|
||||
import com.willfp.eco.util.recipes.RecipeManager;
|
||||
import com.willfp.eco.util.recipe.RecipeListener;
|
||||
import com.willfp.eco.util.recipe.RecipeManager;
|
||||
import com.willfp.eco.util.updater.UpdateChecker;
|
||||
import lombok.Getter;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.willfp.eco.util.recipes;
|
||||
package com.willfp.eco.util.recipe;
|
||||
|
||||
import com.willfp.eco.util.interfaces.Registerable;
|
||||
import com.willfp.eco.util.internal.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import com.willfp.eco.util.recipes.parts.EmptyRecipePart;
|
||||
import com.willfp.eco.util.recipes.parts.RecipePart;
|
||||
import com.willfp.eco.util.recipe.parts.EmptyRecipePart;
|
||||
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -184,9 +183,6 @@ public final class EcoShapedRecipe extends PluginDependent implements Registerab
|
||||
* @return The built recipe.
|
||||
*/
|
||||
public EcoShapedRecipe build() {
|
||||
Validate.notNull(output, "Output cannot be null!");
|
||||
Validate.isTrue(output.getType() != Material.AIR, "Output cannot be blank!");
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (recipeParts[i] == null) {
|
||||
recipeParts[i] = new EmptyRecipePart();
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.willfp.eco.util.recipes;
|
||||
package com.willfp.eco.util.recipe;
|
||||
|
||||
import com.willfp.eco.util.internal.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.willfp.eco.util.recipes;
|
||||
package com.willfp.eco.util.recipe;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.willfp.eco.util.recipe.lookup;
|
||||
|
||||
import com.willfp.eco.util.recipe.parts.EmptyRecipePart;
|
||||
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||
import com.willfp.eco.util.recipe.parts.SimpleRecipePart;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class EcoItemLookup implements ItemLookup {
|
||||
/**
|
||||
* Set of tests that return if the player is telekinetic.
|
||||
*/
|
||||
private final Map<String, Function<String, RecipePart>> tests = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerLookup(@NotNull final String key,
|
||||
@NotNull final Function<String, RecipePart> lookup) {
|
||||
tests.put(key, lookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipePart lookup(@NotNull final String key) {
|
||||
Function<String, RecipePart> lookup = tests.get(key);
|
||||
|
||||
if (lookup == null) {
|
||||
Material material = Material.getMaterial(key.toUpperCase());
|
||||
if (material == null || material == Material.AIR) {
|
||||
return new EmptyRecipePart();
|
||||
}
|
||||
return new SimpleRecipePart(material);
|
||||
}
|
||||
|
||||
return lookup.apply(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.willfp.eco.util.recipe.lookup;
|
||||
|
||||
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ItemLookup {
|
||||
/**
|
||||
* Register a new lookup.
|
||||
*
|
||||
* @param key The key of the lookup.
|
||||
* @param lookup The lookup to register, where the output is the recipe part generated.
|
||||
*/
|
||||
void registerLookup(@NotNull String key,
|
||||
@NotNull Function<String, RecipePart> lookup);
|
||||
|
||||
/**
|
||||
* Lookup recipe part from string.
|
||||
*
|
||||
* @param key The string to test.
|
||||
* @return The generated recipe part, or null if invalid.
|
||||
*/
|
||||
RecipePart lookup(@NotNull String key);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.willfp.eco.util.recipe.lookup;
|
||||
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@UtilityClass
|
||||
public final class RecipePartUtils {
|
||||
/**
|
||||
* Item lookup instance.
|
||||
*/
|
||||
private static final ItemLookup itemLookup;
|
||||
|
||||
/**
|
||||
* Lookup recipe part from string.
|
||||
*
|
||||
* @param key The string to test.
|
||||
* @return The generated recipe part, or null if invalid.
|
||||
*/
|
||||
public RecipePart lookup(@NotNull final String key) {
|
||||
return itemLookup.lookup(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new lookup.
|
||||
*
|
||||
* @param key The key of the lookup.
|
||||
* @param lookup The lookup to register, where the output is the recipe part generated.
|
||||
*/
|
||||
public void registerLookup(@NotNull final String key,
|
||||
@NotNull final Function<String, RecipePart> lookup) {
|
||||
itemLookup.registerLookup(key, lookup);
|
||||
}
|
||||
|
||||
static {
|
||||
if (!Bukkit.getServicesManager().isProvidedFor(ItemLookup.class)) {
|
||||
Bukkit.getServicesManager().register(ItemLookup.class, new EcoItemLookup(), AbstractEcoPlugin.getInstance(), ServicePriority.Normal);
|
||||
}
|
||||
|
||||
itemLookup = Bukkit.getServicesManager().load(ItemLookup.class);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.willfp.eco.util.recipes.parts;
|
||||
package com.willfp.eco.util.recipe.parts;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -10,6 +11,7 @@ public class ComplexRecipePart implements RecipePart {
|
||||
/**
|
||||
* The test for itemstacks to pass.
|
||||
*/
|
||||
@Getter
|
||||
private final Predicate<ItemStack> predicate;
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.willfp.eco.util.recipes.parts;
|
||||
package com.willfp.eco.util.recipe.parts;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.willfp.eco.util.recipes.parts;
|
||||
package com.willfp.eco.util.recipe.parts;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.willfp.eco.util.recipes.parts;
|
||||
package com.willfp.eco.util.recipe.parts;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -9,6 +10,7 @@ public class SimpleRecipePart implements RecipePart {
|
||||
/**
|
||||
* The material.
|
||||
*/
|
||||
@Getter
|
||||
private final Material material;
|
||||
|
||||
/**
|
||||
21
src/main/resources/plugin.yml
Normal file
21
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
name: eco
|
||||
version: 2.0.0
|
||||
main: com.willfp.eco.spigot.EcoSpigotMain
|
||||
api-version: 1.15
|
||||
authors: [Auxilor]
|
||||
website: willfp.com
|
||||
load: STARTUP
|
||||
depend:
|
||||
- ProtocolLib
|
||||
softdepend:
|
||||
- WorldGuard
|
||||
- GriefPrevention
|
||||
- Towny
|
||||
- FactionsUUID
|
||||
- Lands
|
||||
- Kingdoms
|
||||
- NoCheatPlus
|
||||
- AAC
|
||||
- Matrix
|
||||
- Spartan
|
||||
- PlaceholderAPI
|
||||
Reference in New Issue
Block a user