Compare commits

...

9 Commits
1.2.0 ... 2.0.0

Author SHA1 Message Date
Auxilor
b8a5fe0031 Fixed EcoShapedRecipe 2021-01-17 10:48:55 +00:00
Auxilor
5603890663 Reworked eco to be a spigot plugin 2021-01-17 10:48:34 +00:00
Auxilor
1a86cc4dbd Fixed shading errors. 2021-01-14 20:06:27 +00:00
Auxilor
734add6dbc Cleaned 2021-01-14 19:25:21 +00:00
Auxilor
5641c0def3 Updated to 1.3.1 2021-01-14 19:24:37 +00:00
Auxilor
b74ab5349a Fixed shading issues 2021-01-14 19:24:13 +00:00
Auxilor
b0971e5124 Renamed LookupUtils to RecipePartUtils 2021-01-14 14:06:50 +00:00
Auxilor
02d8c8c6b6 Updated to 1.3.0 2021-01-14 13:06:32 +00:00
Auxilor
d9bd5257e3 Added custom item registry 2021-01-14 13:06:03 +00:00
15 changed files with 158 additions and 17 deletions

View File

@@ -98,5 +98,5 @@ build.dependsOn publishToMavenLocal
group = 'com.willfp' group = 'com.willfp'
archivesBaseName = project.name archivesBaseName = project.name
version = '1.2.0' version = '2.0.0'
java.sourceCompatibility = JavaVersion.VERSION_1_8 java.sourceCompatibility = JavaVersion.VERSION_1_8

View File

@@ -0,0 +1,7 @@
package com.willfp.eco.spigot;
import org.bukkit.plugin.java.JavaPlugin;
public class EcoSpigotMain extends JavaPlugin {
}

View File

@@ -77,6 +77,8 @@ public final class TelekinesisUtils {
try { try {
testMethod1 = clazz.getDeclaredMethod("testPlayer", Player.class); testMethod1 = clazz.getDeclaredMethod("testPlayer", Player.class);
registerMethod1 = clazz.getDeclaredMethod("registerTest", Function.class); registerMethod1 = clazz.getDeclaredMethod("registerTest", Function.class);
testMethod1.setAccessible(true);
registerMethod1.setAccessible(true);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
e.printStackTrace(); e.printStackTrace();
testMethod1 = null; testMethod1 = null;

View File

@@ -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.integrations.placeholder.plugins.PlaceholderIntegrationPAPI;
import com.willfp.eco.util.optional.Prerequisite; import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.eco.util.protocollib.AbstractPacketAdapter; import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
import com.willfp.eco.util.recipes.RecipeListener; import com.willfp.eco.util.recipe.RecipeListener;
import com.willfp.eco.util.recipes.RecipeManager; import com.willfp.eco.util.recipe.RecipeManager;
import com.willfp.eco.util.updater.UpdateChecker; import com.willfp.eco.util.updater.UpdateChecker;
import lombok.Getter; import lombok.Getter;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;

View File

@@ -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.interfaces.Registerable;
import com.willfp.eco.util.internal.PluginDependent; import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin; import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.recipes.parts.EmptyRecipePart; import com.willfp.eco.util.recipe.parts.EmptyRecipePart;
import com.willfp.eco.util.recipes.parts.RecipePart; import com.willfp.eco.util.recipe.parts.RecipePart;
import lombok.Getter; import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -184,9 +183,6 @@ public final class EcoShapedRecipe extends PluginDependent implements Registerab
* @return The built recipe. * @return The built recipe.
*/ */
public EcoShapedRecipe build() { 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++) { for (int i = 0; i < 9; i++) {
if (recipeParts[i] == null) { if (recipeParts[i] == null) {
recipeParts[i] = new EmptyRecipePart(); recipeParts[i] = new EmptyRecipePart();

View File

@@ -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.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin; import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;

View File

@@ -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.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;

View File

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

View File

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

View File

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

View File

@@ -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.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -10,6 +11,7 @@ public class ComplexRecipePart implements RecipePart {
/** /**
* The test for itemstacks to pass. * The test for itemstacks to pass.
*/ */
@Getter
private final Predicate<ItemStack> predicate; private final Predicate<ItemStack> predicate;
/** /**

View File

@@ -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.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@@ -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.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@@ -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.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -9,6 +10,7 @@ public class SimpleRecipePart implements RecipePart {
/** /**
* The material. * The material.
*/ */
@Getter
private final Material material; private final Material material;
/** /**

View 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