diff --git a/src/main/java/io/github/simplexdev/api/IPotionEffect.java b/src/main/java/io/github/simplexdev/api/ICompoundEffect.java similarity index 75% rename from src/main/java/io/github/simplexdev/api/IPotionEffect.java rename to src/main/java/io/github/simplexdev/api/ICompoundEffect.java index dd27cce..198e78d 100644 --- a/src/main/java/io/github/simplexdev/api/IPotionEffect.java +++ b/src/main/java/io/github/simplexdev/api/ICompoundEffect.java @@ -4,25 +4,23 @@ import org.bukkit.Color; import org.bukkit.NamespacedKey; import org.bukkit.Particle; import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; + /** * This interface is intended for creating custom potion effects. */ -public interface IPotionEffect { +public interface ICompoundEffect { @NotNull - PotionEffect getEffect(); - - @NotNull - PotionEffectType getType(); + List getEffects(); @NotNull String getName(); @NotNull - Long getDuration(); + Integer getDuration(); @Nullable Particle getParticleType(); diff --git a/src/main/java/io/github/simplexdev/api/IEnchant.java b/src/main/java/io/github/simplexdev/api/IEnchant.java deleted file mode 100644 index 88cb036..0000000 --- a/src/main/java/io/github/simplexdev/api/IEnchant.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.github.simplexdev.api; - -import org.bukkit.NamespacedKey; - -public interface IEnchant { - NamespacedKey getNamespacedKey(); - - String getName(); - - Integer getMaximumLevel(); - - Boolean isGlowing(); -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java b/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java index a408707..2096708 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java +++ b/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java @@ -5,11 +5,6 @@ import io.github.simplexdev.api.annotations.Requires; import io.github.simplexdev.simplexcore.command.defaults.Command_info; import io.github.simplexdev.simplexcore.config.Yaml; import io.github.simplexdev.simplexcore.config.YamlFactory; -import io.github.simplexdev.simplexcore.crafting.RecipeBuilder; -import io.github.simplexdev.simplexcore.module.DependencyManagement; -import io.github.simplexdev.simplexcore.task.Announcer; -import io.github.simplexdev.simplexcore.listener.DependencyListener; -import io.github.simplexdev.simplexcore.listener.SimplexListener; import io.github.simplexdev.simplexcore.module.SimplexModule; @Requires(ReqType.SPIGOT) @@ -17,7 +12,6 @@ public final class SimplexCorePlugin extends SimplexModule { private static boolean debug = false; private static boolean suspended = false; private static SimplexCorePlugin instance; - private DependencyManagement dpm; private Yaml config; private Yaml internals; @@ -33,7 +27,6 @@ public final class SimplexCorePlugin extends SimplexModule { @Override public void init() { SimplexCorePlugin.instance = this; - this.dpm = new DependencyManagement(); this.config = new YamlFactory(this).setDefaultPathways(); this.internals = new YamlFactory(this).from("internals.yml", getParentFolder(), "internals.yml"); } @@ -45,9 +38,6 @@ public final class SimplexCorePlugin extends SimplexModule { getCommandLoader().classpath(this, Command_info.class).load(); getYamlConfig().reload(); getInternals().reload(); - // - SimplexListener.register(new DependencyListener(), this); - new Announcer(this); } catch (Exception ex) { suspended = true; // TODO: Write an output to a file with why it suspended. @@ -74,13 +64,11 @@ public final class SimplexCorePlugin extends SimplexModule { return suspended; } - public DependencyManagement getDependencyManager() { - return dpm; - } - public Yaml getYamlConfig() { return config; } - public Yaml getInternals() { return internals; } + public Yaml getInternals() { + return internals; + } } \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/config/Json.java b/src/main/java/io/github/simplexdev/simplexcore/config/Json.java deleted file mode 100644 index c897be0..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/config/Json.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.simplexdev.simplexcore.config; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import io.github.simplexdev.api.IJson; -import io.github.simplexdev.api.func.Path; -import io.github.simplexdev.simplexcore.module.SimplexModule; -import org.json.simple.JSONObject; - -public final class Json implements IJson { - // TODO: Write actual JSON implementations. - // - private final Gson gson; - private final SimplexModule plugin; - - Json(SimplexModule plugin) { - this.gson = new GsonBuilder().setPrettyPrinting().create(); - this.plugin = plugin; - } - - final Gson getGson() { - return gson; - } - - public final SimplexModule getPlugin() { - return plugin; - } - - @Override - public JSONObject getJSONObject(Path path) { - return null; - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/config/JsonFactory.java b/src/main/java/io/github/simplexdev/simplexcore/config/JsonFactory.java deleted file mode 100644 index b32e621..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/config/JsonFactory.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.simplexdev.simplexcore.config; - -public final class JsonFactory { - // TODO: Write a JSON Object Factory. -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/config/Yaml.java b/src/main/java/io/github/simplexdev/simplexcore/config/Yaml.java index 5f423b7..e33d6a2 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/config/Yaml.java +++ b/src/main/java/io/github/simplexdev/simplexcore/config/Yaml.java @@ -151,13 +151,13 @@ public final class Yaml implements IConfig { * Called when a file is created. */ public void create() { - SimplexCorePlugin.getInstance().getLogger().info("File created!"); + plugin.getLogger().info("File created!"); } /** * Called when then file is reloaded */ public void onReload() { - SimplexCorePlugin.getInstance().getLogger().info("The plugin configuration has been reloaded!"); + plugin.getLogger().info("The plugin configuration has been reloaded!"); } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/crafting/ItemBuilder.java b/src/main/java/io/github/simplexdev/simplexcore/crafting/ItemBuilder.java index b717814..08d6a05 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/crafting/ItemBuilder.java +++ b/src/main/java/io/github/simplexdev/simplexcore/crafting/ItemBuilder.java @@ -196,14 +196,22 @@ public class ItemBuilder { public final Worker setUnbreakable(boolean unbreakable) { meta.setUnbreakable(unbreakable); + stack.setItemMeta(meta); return this; } /** * @return The final item. */ - public final ItemStack get() { + public final ItemStack getItem() { return stack; } + + /** + * @return The ItemMeta of the item. + */ + public final ItemMeta getItemMeta() { + return meta; + } } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/crafting/RBImpl.java b/src/main/java/io/github/simplexdev/simplexcore/crafting/RBImpl.java deleted file mode 100644 index 4919f53..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/crafting/RBImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.simplexdev.simplexcore.crafting; - -import io.github.simplexdev.simplexcore.module.SimplexModule; -import org.bukkit.Material; -import org.bukkit.attribute.Attribute; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; - -public class RBImpl { - private final RecipeBuilder builder; - private final SimplexModule plugin; - private final ItemBuilder bldr; - - public RBImpl(SimplexModule plugin) { - this.plugin = plugin; - this.builder = new RecipeBuilder(plugin); - this.bldr = new ItemBuilder(plugin); - - chainMailBoots(); - customWand(); - } - - public void chainMailBoots() { - ItemStack is = bldr.createNoBounds(Material.CHAINMAIL_BOOTS); - builder.of(is, "chainmail_boots", true) - .addIngredient('c', Material.CHAIN) - .addIngredient('a', Material.AIR) - .setShape("aaa", "cac", "cac") - .create(); - } - - public void customWand() { - ItemStack is = bldr.newItem(Material.BLAZE_ROD) - .setName("Magic Wand") - .addLore("This wand is magical.") - .addEnchant(Enchantment.KNOCKBACK, 10) - .addAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK, - bldr.multiply("generic_attack_knockback", 24.0)) - .get(); - builder.of(is, "magic_wand", true) - .addIngredient('b', Material.BLAZE_ROD) - .addIngredient('n', Material.NETHER_STAR) - .addIngredient('a', Material.AIR) - .setShape("aan", "aba", "baa") - .create(); - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/crafting/RecipeBuilder.java b/src/main/java/io/github/simplexdev/simplexcore/crafting/RecipeBuilder.java index 13f9638..f3bc05d 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/crafting/RecipeBuilder.java +++ b/src/main/java/io/github/simplexdev/simplexcore/crafting/RecipeBuilder.java @@ -4,7 +4,12 @@ import io.github.simplexdev.simplexcore.module.SimplexModule; import io.github.simplexdev.simplexcore.utils.Utilities; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; import org.jetbrains.annotations.NotNull; @@ -30,7 +35,7 @@ public final class RecipeBuilder { * @param isShaped Whether or not the recipe is shaped or shapeless. * @return A new appendable RecipeBuilder Worker instance based on the given parameters. */ - public final Worker of(ItemStack result, String recipeName, boolean isShaped) { + public final Worker newRecipe(ItemStack result, String recipeName, boolean isShaped) { return new Worker(result, recipeName, isShaped); } @@ -72,6 +77,9 @@ public final class RecipeBuilder { return recipe; } + /** + * Creates the recipe and registers it with Bukkit. + */ public void create() { plugin.getServer().addRecipe(shaped ? sha() : nosha()); } diff --git a/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java b/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java index 6c466a5..e66ff8f 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java +++ b/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java @@ -1,29 +1,6 @@ package io.github.simplexdev.simplexcore.enchanting; -import io.github.simplexdev.api.annotations.Enchant; -import io.github.simplexdev.simplexcore.utils.ReflectionTools; -import org.bukkit.enchantments.EnchantmentWrapper; - -import java.lang.reflect.Constructor; +import net.minecraft.server.v1_16_R3.Enchantment; public class EnchUtils { - public SimplexEnch enchantment; - - public void loadFrom(Class clz) { - Enchant info = clz.getDeclaredAnnotation(Enchant.class); - - if (info == null) { - // TODO - return; - } - - ReflectionTools.reflect(clz).getTypesAnnotatedWith(info).forEach(cls -> { - Constructor c = ReflectionTools.getDeclaredConstructor(cls); - if (c == null) return; - SimplexEnch ench = (SimplexEnch) ReflectionTools.initConstructor(c); - load(ench); - }); - } - - public void load(T enchantment) {} // TODO } diff --git a/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java b/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java index 72bdbc1..e2ec0e4 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java +++ b/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java @@ -1,23 +1,24 @@ package io.github.simplexdev.simplexcore.enchanting; -import io.github.simplexdev.api.IEnchant; import io.github.simplexdev.simplexcore.module.SimplexModule; import net.minecraft.server.v1_16_R3.EnchantmentSlotType; +import net.minecraft.server.v1_16_R3.EnumItemRarity; import net.minecraft.server.v1_16_R3.EnumItemSlot; import net.minecraft.server.v1_16_R3.Enchantment; import org.bukkit.NamespacedKey; -public abstract class SimplexEnch extends Enchantment implements IEnchant { - protected final SimplexModule plugin; +public abstract class SimplexEnch extends Enchantment { + private final SimplexModule plugin; + private final Rarity rarity; protected SimplexEnch(SimplexModule plugin, Rarity rarity, EnchantmentSlotType type, EnumItemSlot[] enumSlot) { super(rarity, type, enumSlot); + this.rarity = rarity; this.plugin = plugin; } public abstract String name(); - @Override public NamespacedKey getNamespacedKey() { return new NamespacedKey(plugin, name()); } diff --git a/src/main/java/io/github/simplexdev/simplexcore/listener/DependencyListener.java b/src/main/java/io/github/simplexdev/simplexcore/listener/DependencyListener.java deleted file mode 100644 index e59f65f..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/listener/DependencyListener.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.simplexdev.simplexcore.listener; - -import io.github.simplexdev.simplexcore.SimplexCorePlugin; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.server.PluginEnableEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.BooleanSupplier; - -public final class DependencyListener extends SimplexListener { - public List PAPI_NAMES = new ArrayList<>() {{ - add("PlaceholderAPI"); - add("PlaceHolderAPI"); - add("placeholderapi"); - add("PLACEHOLDERAPI"); - add("PAPI"); - add("papi"); - }}; - - public List PLIB_NAMES = new ArrayList<>() {{ - add("ProtocolLib"); - add("PLib"); - add("Protocollib"); - add("plib"); - add("protocollib"); - add("PROTOCOLLIB"); - }}; - - @EventHandler(priority = EventPriority.HIGHEST) - public void pluginRegister(PluginEnableEvent event) { - BooleanSupplier temp = () -> PLIB_NAMES.contains(event.getPlugin().getName()); - BooleanSupplier temp2 = () -> PAPI_NAMES.contains(event.getPlugin().getName()); - - if (temp.getAsBoolean()) { - SimplexCorePlugin.getInstance().getDependencyManager().registerProtocolLib(); - } - - if (temp2.getAsBoolean()) { - SimplexCorePlugin.getInstance().getDependencyManager().registerPAPI(); - } - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java b/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java deleted file mode 100644 index 3991174..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.github.simplexdev.simplexcore.math; - -import io.github.simplexdev.simplexcore.SimplexCorePlugin; -import io.github.simplexdev.simplexcore.utils.TickedTime; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.scheduler.BukkitTask; - -import java.util.function.Consumer; - -public final class Cuboid { - private final int x, y, z; - - public Cuboid() { - this(3, 3, 3); - } - - public Cuboid(int xSize, int ySize, int zSize) { - this.x = xSize; - this.y = ySize; - this.z = zSize; - } - - public Cuboid(Size size) { - this(size.getX(), size.getY(), size.getZ()); - } - - public void generate(Location location, Material material) { - Consumer task = bukkitTask -> { - int t1 = location.getBlockX(); - int t2 = location.getBlockY(); - int t3 = location.getBlockZ(); - - int a = t1 + x; - int b = t2 + y; - int c = t3 + z; - - for (int currentX = t1; currentX < a; currentX++) { - for (int currentY = t2; currentY < b; currentY++) { - for (int currentZ = t3; currentZ < c; currentZ++) { - location.getWorld().getBlockAt(currentX, currentY, currentZ).setType(material); - } - } - } - - }; - - SimplexCorePlugin.getInstance().getScheduler().runTaskLaterAsynchronously(SimplexCorePlugin.getInstance(), task, - TickedTime.SECOND); - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/math/Pyramid.java b/src/main/java/io/github/simplexdev/simplexcore/math/Pyramid.java deleted file mode 100644 index 24c2268..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/math/Pyramid.java +++ /dev/null @@ -1,149 +0,0 @@ -package io.github.simplexdev.simplexcore.math; - -import io.github.simplexdev.simplexcore.SimplexCorePlugin; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.scheduler.BukkitTask; - -import java.util.function.Consumer; - -public final class Pyramid { - - private final int height; - private Location location; - private Material material; - - public Pyramid(int height, Location location, Material material) { - - this.height = height; - this.location = location; - this.material = material; - } - - public Pyramid(Size size, Location location, Material material) { - - this.height = size.getY(); - this.location = location; - this.material = material; - } - - - public void setLocation(Location location) { - this.location = location; - } - - public void setMaterial(Material material) { - this.material = material; - } - - public void generate() { - - Consumer consumer = bukkitTask -> { - - System.out.println(height % 2 == 0); - - if (height % 2 == 0) - createEvenFull(); - - else - createOddFull(); - }; - - SimplexCorePlugin.getInstance().getScheduler().runTaskLater(SimplexCorePlugin.getInstance(), consumer, 20L); - } - - private void createOddFull() { - int locX = location.getBlockX(); - int locY = location.getBlockY(); - int locZ = location.getBlockZ(); - - int currentArea = 1; - - for (int y = height; y > 0; y--) { - for (int x = -(int) (Math.floor(currentArea / (double) 2)); x <= (int) Math.floor(currentArea / (double) 2); x++) { - for (int z = -(int) (Math.floor(currentArea / (double) 2)); z <= (int) Math.floor(currentArea / (double) 2); z++) { - - Block block = location.getWorld().getBlockAt(locX + x, locY + y, locZ + z); - - block.setType(material); - - } - } - currentArea += 2; - } - } - - private void createEvenFull() { - createEvenSide(1); - - location.setX(location.getBlockX() + 1); - createEvenSide(2); - - location.setZ(location.getBlockZ() + 1); - createEvenSide(3); - - location.setX(location.getBlockX() - 1); - createEvenSide(4); - } - - private void createEvenSide(int quadrant) { - int locX = location.getBlockX(); - int locY = location.getBlockY(); - int locZ = location.getBlockZ(); - - int currentArea = 1; - - int x = currentArea; - int z = currentArea; - - switch (quadrant) { - case 1: - x = +x; - z = +z; - - break; - case 2: - x = -x; - z = +z; - - break; - case 3: - - x = -x; - z = -z; - break; - case 4: - - x = +x; - z = -z; - - break; - } - - for (int y2 = locY + height; y2 > locY; y2--) { - - for (int x2 = x; x2 != 0; x2 = decreaseOrIncrease(x2)) { - - for (int z2 = z; z2 != 0; z2 = decreaseOrIncrease(z2)) { - - Block block = location.getWorld().getBlockAt(locX + x2, y2, locZ + z2); - block.setType(material); - } - - } - - x += x > 0 ? 1 : -1; - z += z > 0 ? 1 : -1; - } - } - - private int decreaseOrIncrease(int x) { - if (x > 0) - x--; - else if (x < 0) - x++; - - return x; - } -} \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/math/Size.java b/src/main/java/io/github/simplexdev/simplexcore/math/Size.java deleted file mode 100644 index 864f052..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/math/Size.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.simplexdev.simplexcore.math; - -public enum Size { - SMALL(1, 1, 1), - MEDIUM(3, 3, 3), - LARGE(5, 5, 5), - EXTRA_LARGE(10, 10, 10), - HUGE(20, 20, 20), - ENORMOUS(50, 50, 50); - - int x, y, z; - - Size(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public int getZ() { - return z; - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/module/DependencyManagement.java b/src/main/java/io/github/simplexdev/simplexcore/module/DependencyManagement.java deleted file mode 100644 index bed7c85..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/module/DependencyManagement.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.simplexdev.simplexcore.module; - -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; -import me.clip.placeholderapi.PlaceholderAPIPlugin; -import org.jetbrains.annotations.Nullable; - -public class DependencyManagement { - private ProtocolManager manager; - private PlaceholderAPIPlugin papi; - - public DependencyManagement() { - manager = null; - papi = null; - } - - public void registerProtocolLib() { - manager = ProtocolLibrary.getProtocolManager(); - } - - public void registerPAPI() { - papi = PlaceholderAPIPlugin.getInstance(); - } - - @Nullable - public PlaceholderAPIPlugin getPAPI() { - return papi; - } - - @Nullable - public ProtocolManager getProtocolManager() { - return manager; - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java b/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java index 3ee4f67..ce68129 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java +++ b/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java @@ -71,8 +71,4 @@ public abstract class SimplexModule> extends JavaPlug public CommandLoader getCommandLoader() { return CommandLoader.getInstance(); } - - public SimplexCorePlugin getProvider() { - return SimplexCorePlugin.getInstance(); - } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/particle/ParticleFactory.java b/src/main/java/io/github/simplexdev/simplexcore/particle/ParticleFactory.java index c4fd0a9..17986b6 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/particle/ParticleFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/particle/ParticleFactory.java @@ -85,9 +85,9 @@ public final class ParticleFactory { }; } - // TODO: Needs work :) public void spawnParticle(IParticleEffect effect, Location location) { World world = location.getWorld(); + if (world == null) return; effect.getParticles().forEach(particle -> { Color color = effect.getParticleColors().get(particle); world.spawnParticle(particle, location, 20); diff --git a/src/main/java/io/github/simplexdev/simplexcore/potion/PotionsFactory.java b/src/main/java/io/github/simplexdev/simplexcore/potion/PotionsFactory.java index 1e5afa5..e869708 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/potion/PotionsFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/potion/PotionsFactory.java @@ -1,22 +1,80 @@ package io.github.simplexdev.simplexcore.potion; -import io.github.simplexdev.api.IPotionEffect; +import io.github.simplexdev.api.ICompoundEffect; +import io.github.simplexdev.simplexcore.listener.SimplexListener; +import io.github.simplexdev.simplexcore.module.SimplexModule; import io.github.simplexdev.simplexcore.utils.Utilities; -import org.bukkit.entity.LivingEntity; +import org.bukkit.Color; +import org.bukkit.NamespacedKey; +import org.bukkit.Particle; +import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; public final class PotionsFactory { - private PotionsFactory() { - throw new AssertionError("This class should not be instantiated!"); + private final Player player; + private final Map map = new HashMap<>(); + + public PotionsFactory(Player player) { + this.player = player; } - public static void applyEffect(LivingEntity entity, PotionEffect... effect) { - entity.addPotionEffects(Utilities.stream(effect).collect(Collectors.toSet())); + public static ICompoundEffect compoundEffect(SimplexModule plugin, String name, int duration, int amplifier, PotionEffectType... effects) { + List list = new ArrayList<>(); + + Utilities.forEach(effects, effect -> { + list.add(effect.createEffect(duration, amplifier)); + }); + + return new ICompoundEffect() { + @Override + public @NotNull List getEffects() { + return list; + } + + @Override + public @NotNull String getName() { + return name; + } + + @Override + public @NotNull Integer getDuration() { + return duration; + } + + @Override + public @Nullable Particle getParticleType() { + return null; + } + + @Override + public @Nullable Color getParticleColor() { + return null; + } + + @Override + public @NotNull NamespacedKey getNamespacedKey() { + return new NamespacedKey(plugin, name); + } + }; } - public static void applyEffect(LivingEntity entity, IPotionEffect... effect) { - Utilities.forEach(effect, sim -> sim.getEffect().apply(entity)); // Interesting, not how it will be done in the end though. + public void applyCompoundEffect(ICompoundEffect effect) { + effect.getEffects().forEach(item -> { + item.apply(player); + }); + map.put(player, effect); + } + + public boolean hasPotionEffect(ICompoundEffect effect) { + return (map.containsKey(player) && map.get(player).equals(effect)); } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java b/src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java deleted file mode 100644 index 1ec4955..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.simplexdev.simplexcore.structures; - - -public enum PasteType { - BLOCKBYBLOCKASYNC, - INSTANTASYNC -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java deleted file mode 100644 index 5fc00ec..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java +++ /dev/null @@ -1,103 +0,0 @@ -package io.github.simplexdev.simplexcore.structures; - -import io.github.simplexdev.api.IStructure; -import io.github.simplexdev.simplexcore.math.Size; -import io.github.simplexdev.simplexcore.module.SimplexModule; -import io.github.simplexdev.simplexcore.structures.block.NBTBlock; -import io.github.simplexdev.simplexcore.structures.exception.InvalidSchematic; -import io.github.simplexdev.simplexcore.structures.exception.SchematicNotLoaded; -import org.bukkit.Location; -import org.bukkit.NamespacedKey; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.util.Vector; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -public class Structure implements IStructure { - private final SimplexModule plugin; - private File schematic; - private short width, height, length = 0; - private byte[] blockdatacontainer; - - private HashMap nbtBlocks = new HashMap<>(); - private HashMap blocks = new HashMap<>(); - - public Structure(SimplexModule plugin, File schematic) { - this.plugin = plugin; - this.schematic = schematic; - } - - public void load() throws InvalidSchematic { - - } - - public void paste(Location loc, PasteType pasteType) throws SchematicNotLoaded { - if (width == 0 || height == 0 || length == 0 || blocks.isEmpty()) { - throw new SchematicNotLoaded("Schematic not loaded please load schematic first..."); - } - } - - @Override - public NamespacedKey getNamespacedKey() { - return null; - } - - @Override - public String getName() { - return null; - } - - @Override - public Location getLocation() { - return null; - } - - @Override - public World getWorld() { - return null; - } - - @Override - public boolean shouldGenerateNaturally() { - return false; - } - - @Override - public void generate(Location location, World world) { - - } - - @Override - public void generate(Location location, World world, boolean generateNaturally) { - - } - - @Override - public Size getApproximateSize() { - return null; - } - - @Override - public Block[] getBlocks() { - return new Block[0]; - } - - @Override - public Map getBlockLocations() { - return null; - } - - @Override - public File getStructureFile() { - return null; - } - - public SimplexModule getPlugin() { - return plugin; - } - // TODO: Write this -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/block/NBTBlock.java b/src/main/java/io/github/simplexdev/simplexcore/structures/block/NBTBlock.java deleted file mode 100644 index 3e3e975..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/block/NBTBlock.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.github.simplexdev.simplexcore.structures.block; - -import io.github.simplexdev.simplexcore.structures.exception.InvalidSchematic; - -import java.util.Vector; - -public abstract class NBTBlock { - private Object nbttag; - - public Object getNbttag(){ - return nbttag; - } - - public abstract Vector getOffset() throws InvalidSchematic; - - public abstract boolean isEmpty(); - - -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/exception/InvalidSchematic.java b/src/main/java/io/github/simplexdev/simplexcore/structures/exception/InvalidSchematic.java deleted file mode 100644 index 8e6c6bd..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/exception/InvalidSchematic.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.simplexdev.simplexcore.structures.exception; - -public class InvalidSchematic extends Exception{ - - public InvalidSchematic(String msg) - { - super(msg); - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java b/src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java deleted file mode 100644 index 1612a28..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.simplexdev.simplexcore.structures.exception; - -public class SchematicNotLoaded extends Exception { - - public SchematicNotLoaded(String msg) { - super(msg); - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/task/Announcer.java b/src/main/java/io/github/simplexdev/simplexcore/task/Announcer.java deleted file mode 100644 index ea0a39f..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/task/Announcer.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.simplexdev.simplexcore.task; - -import io.github.simplexdev.simplexcore.SimplexCorePlugin; -import io.github.simplexdev.simplexcore.chat.Messages; -import io.github.simplexdev.simplexcore.module.SimplexModule; -import io.github.simplexdev.simplexcore.utils.TickedTime; -import org.apache.commons.lang.math.RandomUtils; -import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitTask; - -import java.util.ArrayList; -import java.util.List; - -public class Announcer extends SimplexTask { - private final List stringList = new ArrayList<>() {{ - add("Join our discord!" + Messages.DISCORD.getMessage()); - add("Thank you for using SimplexCore!"); - add("https://github.com/SimplexDevelopment/SimplexCore"); - }}; - - public Announcer(SimplexCorePlugin plugin) { - super(plugin, TickedTime.HOUR); - register(this, true, false); - } - - @Override - public void accept(BukkitTask bukkitTask) { - Bukkit.getServer().broadcastMessage(stringList.get(RandomUtils.nextInt(stringList.size()))); - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/utils/PlayerTools.java b/src/main/java/io/github/simplexdev/simplexcore/utils/PlayerTools.java index 585b6f0..3c6667c 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/utils/PlayerTools.java +++ b/src/main/java/io/github/simplexdev/simplexcore/utils/PlayerTools.java @@ -11,7 +11,7 @@ import java.util.UUID; public final class PlayerTools { @NotNull - public static String stringUUID(@NotNull Player player) { + public static String stringedUUID(@NotNull Player player) { return player.getUniqueId().toString(); }