From 70a339a13055a41532d50830980fcb999649a9c7 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Sat, 1 May 2021 02:07:01 -0500 Subject: [PATCH] Alpha Release 1.0 --- gradle.properties | 4 +- .../simplexcore/ban/BanFactory.java | 2 +- .../simplexcore/block/InteractableBlock.java | 27 ---- .../simplexcore/block/SignFactory.java | 116 ------------------ .../simplexcore/chat/ChatUtils.java | 2 + .../simplexcore/enchanting/EnchUtils.java | 6 - .../simplexcore/enchanting/SimplexEnch.java | 25 ---- .../potion/PotionEffectFactory.java | 28 ++++- src/main/resources/plugin.yml | 5 +- 9 files changed, 31 insertions(+), 184 deletions(-) delete mode 100644 src/main/java/io/github/simplexdev/simplexcore/block/InteractableBlock.java delete mode 100644 src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java delete mode 100644 src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java diff --git a/gradle.properties b/gradle.properties index be93435..8c8d082 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ pluginMain=SimplexCorePlugin pluginMainPackage=io.github.simplexdev.simplexcore -pluginVersion=1.3_13 +pluginVersion=1.0.0 pluginName=SimplexCore -pluginJarClassifier=BLEEDING +pluginJarClassifier=Alpha diff --git a/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java b/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java index 3ee27fa..74aa487 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java @@ -112,7 +112,7 @@ public final class BanFactory { } public void deleteBan(IBan ban) { - + // TODO } public IBan getBan(String banId) { diff --git a/src/main/java/io/github/simplexdev/simplexcore/block/InteractableBlock.java b/src/main/java/io/github/simplexdev/simplexcore/block/InteractableBlock.java deleted file mode 100644 index dd4a366..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/block/InteractableBlock.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.simplexdev.simplexcore.block; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; - -public class InteractableBlock { - private final Block block; - private final Location location; - private final Material material; - - public InteractableBlock(Location location) { - this.block = location.getBlock(); - this.location = block.getLocation(); - this.material = block.getType(); - } - - public InteractableBlock(Block block) { - this.block = block; - this.location = block.getLocation(); - this.material = block.getType(); - } - - public void test() { - - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/block/SignFactory.java b/src/main/java/io/github/simplexdev/simplexcore/block/SignFactory.java index 5a5ab34..fc5f194 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/block/SignFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/block/SignFactory.java @@ -2,52 +2,13 @@ package io.github.simplexdev.simplexcore.block; import io.github.simplexdev.api.IUsableSign; import io.github.simplexdev.api.func.VoidSupplier; -import io.github.simplexdev.simplexcore.SimplexCorePlugin; -import io.github.simplexdev.simplexcore.listener.SimplexListener; -import io.github.simplexdev.simplexcore.module.SimplexModule; import org.bukkit.Material; import org.bukkit.block.Sign; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class SignFactory { - private static final List SIGN_TYPES = new ArrayList<>() {{ - add(Material.OAK_SIGN); - add(Material.OAK_WALL_SIGN); - add(Material.DARK_OAK_SIGN); - add(Material.DARK_OAK_WALL_SIGN); - add(Material.BIRCH_SIGN); - add(Material.BIRCH_WALL_SIGN); - add(Material.ACACIA_SIGN); - add(Material.ACACIA_WALL_SIGN); - add(Material.CRIMSON_SIGN); - add(Material.CRIMSON_WALL_SIGN); - add(Material.JUNGLE_SIGN); - add(Material.JUNGLE_WALL_SIGN); - add(Material.SPRUCE_SIGN); - add(Material.SPRUCE_WALL_SIGN); - add(Material.WARPED_SIGN); - add(Material.WARPED_WALL_SIGN); - }}; - - private SignData signData = null; - - public void activateBasicSignDataListener() { - signData = new SignData(SimplexCorePlugin.getInstance()); - } - - public SignData getSignData() { - return signData; - } - public IUsableSign create(Sign sign, boolean canInteract, String tag, VoidSupplier execute) { return new AbstractSign(sign) { @Override @@ -66,81 +27,4 @@ public class SignFactory { } }; } - - @Nullable - public IUsableSign addTagsToSign(Sign sign, Object... tags) { - if (getSignData() != null) { - if (!SignData.getUnlabeledSigns().containsKey(sign)) { - createNoTag(sign); - } - - AbstractSign abs = SignData.getUnlabeledSigns().get(sign); - for (Object tag : tags) { - if (tag instanceof VoidSupplier) { - abs.setExecuteScript((VoidSupplier) tag); - } - if (tag instanceof String) { - abs.setSignTag((String) tag); - } - if (tag instanceof Boolean) { - abs.setCanInteract((Boolean) tag); - } - } - return abs; - } else { - return null; - } - } - - private AbstractSign createNoTag(Sign sign) { - return new AbstractSign(sign) { - @Override - public boolean canInteract() { - return canInteract; - } - - @Override - public void execute() { - executeScript.get(); - } - }; - } - - private static class SignData extends SimplexListener { - public SignData(SimplexModule plugin) { - register(this, plugin); - } - - private static final Map signMap = new HashMap<>(); - - @EventHandler - public void blockPlaceEvent(BlockPlaceEvent event) { - if (SIGN_TYPES.contains(event.getBlockPlaced().getType()) - && (event.getBlockPlaced() instanceof Sign)) { - Sign sign = (Sign) event.getBlockPlaced(); - AbstractSign abs = new SignFactory().createNoTag(sign); - signMap.put(sign, abs); - } - } - - @EventHandler - public void blockInteractEvent(PlayerInteractEvent event) { - if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) - && event.getClickedBlock() != null - && SIGN_TYPES.contains(event.getClickedBlock().getType())) { - Sign sign = (Sign) event.getClickedBlock(); - if (signMap.containsKey(sign)) { - IUsableSign iSign = signMap.get(sign); - String tag = iSign.signTag(); - if (iSign.getLines().get(0).equals(tag)) { - iSign.execute(); - } - } - } - } - - public static Map getUnlabeledSigns() { - return signMap; - } - } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/chat/ChatUtils.java b/src/main/java/io/github/simplexdev/simplexcore/chat/ChatUtils.java index 61192dc..6792d16 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/chat/ChatUtils.java +++ b/src/main/java/io/github/simplexdev/simplexcore/chat/ChatUtils.java @@ -34,4 +34,6 @@ public final class ChatUtils { public void color(TextComponent component) { target.sendMessage(factory.colorize(component.getText())); } + + } diff --git a/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java b/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java deleted file mode 100644 index e66ff8f..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/enchanting/EnchUtils.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.github.simplexdev.simplexcore.enchanting; - -import net.minecraft.server.v1_16_R3.Enchantment; - -public class EnchUtils { -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java b/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java deleted file mode 100644 index e2ec0e4..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.simplexdev.simplexcore.enchanting; - -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 { - 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(); - - public NamespacedKey getNamespacedKey() { - return new NamespacedKey(plugin, name()); - } -} diff --git a/src/main/java/io/github/simplexdev/simplexcore/potion/PotionEffectFactory.java b/src/main/java/io/github/simplexdev/simplexcore/potion/PotionEffectFactory.java index 6ff731e..9e8a9b9 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/potion/PotionEffectFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/potion/PotionEffectFactory.java @@ -29,12 +29,12 @@ public final class PotionEffectFactory { /** * Creates a new compound effect with the specified parameters. - * @param plugin The plugin to use when registering a new NamespacedKey - * @param name - * @param duration - * @param amplifier - * @param effects - * @return + * @param plugin The plugin to use when registering a new NamespacedKey. + * @param name The effect name + * @param duration The duration of the effect + * @param amplifier the amplifier of the effect + * @param effects The {@link PotionEffectType}(s) you want to be included. + * @return A new compound effect. */ public static ICompoundEffect compoundEffect(SimplexModule plugin, String name, int duration, int amplifier, PotionEffectType... effects) { List list = new ArrayList<>(); @@ -76,15 +76,31 @@ public final class PotionEffectFactory { }; } + /** + * Creates a new {@link PotionEffect}. + * @param type The type of potion effect + * @param duration How long the effect should last + * @param amplifier How strong the potion is. + * @return A new {@link PotionEffect}. + */ public static PotionEffect potionEffect(PotionEffectType type, int duration, int amplifier) { return type.createEffect(duration, amplifier); } + /** + * Applies the compound effect to the defined player. + * @param effect The {@link ICompoundEffect} to apply. + */ public void applyCompoundEffect(ICompoundEffect effect) { effect.getEffects().forEach(player::addPotionEffect); map.put(player, effect); } + /** + * Checks if a player currently has a compound effect. + * @param effect The {@link ICompoundEffect} to look for + * @return Whether or not the player has the compound effect. + */ public boolean hasPotionEffect(ICompoundEffect effect) { return (map.containsKey(player) && map.get(player).equals(effect)); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9f01ec4..d9a66ff 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,10 @@ prefix: Simplex authors: - Paldiu - Conclure -description: Core for a group of plugins designed to enhance gameplay to the max + - Fleek + - abhi289 + - xDabDoub +description: A Spigot Library and API. softdepend: - PlaceholderAPI - ProtocolLib