Alpha Release 1.0

This commit is contained in:
Paldiu 2021-05-01 02:07:01 -05:00
parent d8829d4931
commit 70a339a130
9 changed files with 31 additions and 184 deletions

View File

@ -1,5 +1,5 @@
pluginMain=SimplexCorePlugin pluginMain=SimplexCorePlugin
pluginMainPackage=io.github.simplexdev.simplexcore pluginMainPackage=io.github.simplexdev.simplexcore
pluginVersion=1.3_13 pluginVersion=1.0.0
pluginName=SimplexCore pluginName=SimplexCore
pluginJarClassifier=BLEEDING pluginJarClassifier=Alpha

View File

@ -112,7 +112,7 @@ public final class BanFactory {
} }
public void deleteBan(IBan ban) { public void deleteBan(IBan ban) {
// TODO
} }
public IBan getBan(String banId) { public IBan getBan(String banId) {

View File

@ -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() {
}
}

View File

@ -2,52 +2,13 @@ package io.github.simplexdev.simplexcore.block;
import io.github.simplexdev.api.IUsableSign; import io.github.simplexdev.api.IUsableSign;
import io.github.simplexdev.api.func.VoidSupplier; 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.Material;
import org.bukkit.block.Sign; 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.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class SignFactory { public class SignFactory {
private static final List<Material> 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) { public IUsableSign create(Sign sign, boolean canInteract, String tag, VoidSupplier execute) {
return new AbstractSign(sign) { return new AbstractSign(sign) {
@Override @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<Sign, AbstractSign> 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<Sign, AbstractSign> getUnlabeledSigns() {
return signMap;
}
}
} }

View File

@ -34,4 +34,6 @@ public final class ChatUtils {
public void color(TextComponent component) { public void color(TextComponent component) {
target.sendMessage(factory.colorize(component.getText())); target.sendMessage(factory.colorize(component.getText()));
} }
} }

View File

@ -1,6 +0,0 @@
package io.github.simplexdev.simplexcore.enchanting;
import net.minecraft.server.v1_16_R3.Enchantment;
public class EnchUtils {
}

View File

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

View File

@ -29,12 +29,12 @@ public final class PotionEffectFactory {
/** /**
* Creates a new compound effect with the specified parameters. * Creates a new compound effect with the specified parameters.
* @param plugin The plugin to use when registering a new NamespacedKey * @param plugin The plugin to use when registering a new NamespacedKey.
* @param name * @param name The effect name
* @param duration * @param duration The duration of the effect
* @param amplifier * @param amplifier the amplifier of the effect
* @param effects * @param effects The {@link PotionEffectType}(s) you want to be included.
* @return * @return A new compound effect.
*/ */
public static ICompoundEffect compoundEffect(SimplexModule<?> plugin, String name, int duration, int amplifier, PotionEffectType... effects) { public static ICompoundEffect compoundEffect(SimplexModule<?> plugin, String name, int duration, int amplifier, PotionEffectType... effects) {
List<PotionEffect> list = new ArrayList<>(); List<PotionEffect> 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) { public static PotionEffect potionEffect(PotionEffectType type, int duration, int amplifier) {
return type.createEffect(duration, 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) { public void applyCompoundEffect(ICompoundEffect effect) {
effect.getEffects().forEach(player::addPotionEffect); effect.getEffects().forEach(player::addPotionEffect);
map.put(player, effect); 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) { public boolean hasPotionEffect(ICompoundEffect effect) {
return (map.containsKey(player) && map.get(player).equals(effect)); return (map.containsKey(player) && map.get(player).equals(effect));
} }

View File

@ -6,7 +6,10 @@ prefix: Simplex
authors: authors:
- Paldiu - Paldiu
- Conclure - 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: softdepend:
- PlaceholderAPI - PlaceholderAPI
- ProtocolLib - ProtocolLib