diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d65aaf8..08aef93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: cache: 'maven' - name: build - run: mvn clean install + run: mvn clean package - name: Extract Maven project version run: echo "name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..39bb955 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + eu.mikart + AnimVanish + 1.1.0 + + + eu.mikart.animvanish + animvanish-common + 1.1.0 + + + 17 + 17 + UTF-8 + + + + + jitpack.io + https://jitpack.io + + + + + + + net.william278 + PagineDown + 1.1 + compile + + + + + net.william278 + DesertWell + 2.0.4 + compile + + + + + net.kyori + adventure-api + 4.14.0 + compile + + + + + net.kyori + adventure-platform-api + 4.3.2 + compile + + + + + de.exlll + configlib-yaml + 4.5.0 + + + + + com.google.guava + guava + 32.1.3-jre + compile + + + + + net.kyori + adventure-text-minimessage + 4.16.0 + + + + commons-lang + commons-lang + 2.6 + compile + + + \ No newline at end of file diff --git a/common/src/main/java/eu/mikart/animvanish/IAnimVanish.java b/common/src/main/java/eu/mikart/animvanish/IAnimVanish.java new file mode 100644 index 0000000..3f3eccd --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/IAnimVanish.java @@ -0,0 +1,48 @@ +package eu.mikart.animvanish; + +import eu.mikart.animvanish.config.ConfigProvider; +import eu.mikart.animvanish.effects.IEffectManager; +import eu.mikart.animvanish.hooks.Hook; +import eu.mikart.animvanish.user.ConsoleUser; +import eu.mikart.animvanish.util.Version; +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.platform.AudienceProvider; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; +import java.util.logging.Logger; + +public interface IAnimVanish extends ConfigProvider { + + String getPluginVersion(); + + IEffectManager getEffectManager(); + + @NotNull + AudienceProvider getAudiences(); + + @NotNull + default Version getVersion() { + return new Version(getPluginVersion()); + } + + Hook getCurrentHook(); + + Logger getLogger(); + + @NotNull + default Audience getAudience(@NotNull UUID user) { + return getAudiences().player(user); + } + + @NotNull + default ConsoleUser getConsole() { + return ConsoleUser.wrap(getAudiences().console()); + } + + default void reload() { + loadConfig(); + } + + default void loadExtra() {} +} \ No newline at end of file diff --git a/src/main/java/eu/mikart/animvanish/annonations/EffectAnnotation.java b/common/src/main/java/eu/mikart/animvanish/annotations/EffectAnnotation.java similarity index 77% rename from src/main/java/eu/mikart/animvanish/annonations/EffectAnnotation.java rename to common/src/main/java/eu/mikart/animvanish/annotations/EffectAnnotation.java index ea98501..10ae6a6 100644 --- a/src/main/java/eu/mikart/animvanish/annonations/EffectAnnotation.java +++ b/common/src/main/java/eu/mikart/animvanish/annotations/EffectAnnotation.java @@ -1,6 +1,4 @@ -package eu.mikart.animvanish.annonations; - -import org.bukkit.Material; +package eu.mikart.animvanish.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -12,5 +10,5 @@ public @interface EffectAnnotation { String name(); String description(); - Material item(); + String item(); } diff --git a/common/src/main/java/eu/mikart/animvanish/api/AnimVanishAPI.java b/common/src/main/java/eu/mikart/animvanish/api/AnimVanishAPI.java new file mode 100644 index 0000000..25b8079 --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/api/AnimVanishAPI.java @@ -0,0 +1,116 @@ +package eu.mikart.animvanish.api; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.effects.BareEffect; +import eu.mikart.animvanish.hooks.Hook; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public class AnimVanishAPI { + protected static AnimVanishAPI instance; + protected final IAnimVanish plugin; + + + /** + * Register an effect to the plugin + * @param effect the effect to register + * @since 1.1.0 + */ + public void registerEffect(BareEffect effect) { + plugin.getEffectManager().registerEffect(effect); + } + + /** + * Unregister an effect from the plugin + * + * @param effect the effect to unregister + * @since 1.1.0 + */ + public void unregisterEffect(BareEffect effect) { + plugin.getEffectManager().unregisterEffect(effect); + } + + /** + * Get the currentHook of the plugin. I have no idea why you would need this. But here it is. + * @return the currentHook of the plugin + * @since 1.1.0 + */ + public Hook getCurrentHook() { + return plugin.getCurrentHook(); + } + + /** + * Get a raw locale from the plugin locale file + * + * @param localeId the locale ID to get + * @param replacements the replacements to make in the locale + * @return the locale, with replacements made + * @since 1.1.0 + */ + public Optional getRawLocale(@NotNull String localeId, @NotNull String... replacements) { + return plugin.getLocales().getRawLocale(localeId, replacements); + } + + /** + * Get a locale from the plugin locale file + * + * @param localeId the locale ID to get + * @param replacements the replacements to make in the locale + * @return the locale as a formatted adventure {@link Component}, with replacements made + * @since 1.1.0 + */ + public Optional getLocale(@NotNull String localeId, @NotNull String... replacements) { + return plugin.getLocales().getLocale(localeId, replacements); + } + + /** + * Get an instance of the AnimVanish API. + * + * @return instance of the AnimVanish API + * @throws NotRegisteredException if the API has not yet been registered. + * @since 1.1.0 + */ + @NotNull + public static AnimVanishAPI getInstance() throws NotRegisteredException { + if (instance == null) { + throw new NotRegisteredException(); + } + return instance; + } + + /** + * (Internal use only) - Unregister the API instance. + * + * @since 1.1.0 + */ + @ApiStatus.Internal + public static void unregister() { + instance = null; + } + + /** + * An exception indicating the plugin has been accessed before it has been registered. + * + * @since 1.1.0 + */ + public static final class NotRegisteredException extends IllegalStateException { + + private static final String MESSAGE = """ + Could not access the AnimVanish API as it has not yet been registered. This could be because: + 1) AnimVanish has failed to enable successfully + 2) Your plugin isn't set to load after AnimVanish has + (Check if it set as a (soft)depend in plugin.yml or to load: BEFORE in paper-plugin.yml?) + 3) You are attempting to access AnimVanish on plugin construction/before your plugin has enabled."""; + + NotRegisteredException() { + super(MESSAGE); + } + + } +} diff --git a/common/src/main/java/eu/mikart/animvanish/config/ConfigProvider.java b/common/src/main/java/eu/mikart/animvanish/config/ConfigProvider.java new file mode 100644 index 0000000..4bbc0be --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/config/ConfigProvider.java @@ -0,0 +1,99 @@ +package eu.mikart.animvanish.config; + +import de.exlll.configlib.NameFormatters; +import de.exlll.configlib.YamlConfigurationProperties; +import de.exlll.configlib.YamlConfigurationStore; +import de.exlll.configlib.YamlConfigurations; +import eu.mikart.animvanish.IAnimVanish; +import org.jetbrains.annotations.NotNull; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.logging.Level; + +/** + * The configuration has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +public interface ConfigProvider { + + @NotNull + YamlConfigurationProperties.Builder YAML_CONFIGURATION_PROPERTIES = YamlConfigurationProperties.newBuilder() + .charset(StandardCharsets.UTF_8) + .setNameFormatter(NameFormatters.LOWER_UNDERSCORE); + + + default void loadConfig() { + loadSettings(); + loadLocales(); + } + + @NotNull + Settings getSettings(); + + void setSettings(@NotNull Settings settings); + + default void loadSettings() { + setSettings(YamlConfigurations.update( + getConfigDirectory().resolve("config.yml"), + Settings.class, + YAML_CONFIGURATION_PROPERTIES.header(Settings.CONFIG_HEADER).build() + )); + } + + @NotNull + Locales getLocales(); + + void setLocales(@NotNull Locales locales); + + /** + * Load the locales from the config file + * + * @since 1.1.0 + */ + default void loadLocales() { + final YamlConfigurationStore store = new YamlConfigurationStore<>( + Locales.class, YAML_CONFIGURATION_PROPERTIES.header(Locales.CONFIG_HEADER).build() + ); + // Read existing locales if present + final Path path = getConfigDirectory().resolve(String.format("messages-%s.yml", getSettings().getLanguage())); + if (Files.exists(path)) { + setLocales(store.load(path)); + return; + } + + // Otherwise, save and read the default locales + try (InputStream input = getResource(String.format("locales/%s.yml", getSettings().getLanguage()))) { + final Locales locales = store.read(input); + store.save(locales, path); + setLocales(locales); + } catch (Throwable e) { + getPlugin().getLogger().log(Level.SEVERE, "An error occurred loading the locales (invalid lang code?)", e); + } + } + + + /** + * Get a plugin resource + * + * @param name The name of the resource + * @return the resource, if found + * @since 1.1.0 + */ + InputStream getResource(@NotNull String name); + + /** + * Get the plugin config directory + * + * @return the plugin config directory + * @since 1.1.0 + */ + @NotNull + Path getConfigDirectory(); + + @NotNull + IAnimVanish getPlugin(); + +} diff --git a/common/src/main/java/eu/mikart/animvanish/config/Locales.java b/common/src/main/java/eu/mikart/animvanish/config/Locales.java new file mode 100644 index 0000000..f5955c1 --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/config/Locales.java @@ -0,0 +1,154 @@ +package eu.mikart.animvanish.config; + +import com.google.common.collect.Maps; +import de.exlll.configlib.Configuration; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import org.apache.commons.lang.StringEscapeUtils; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.Map; +import java.util.Optional; + +/** + * The configuration has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +@SuppressWarnings("FieldMayBeFinal") +@Configuration +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class Locales { + + static final String CONFIG_HEADER = """ + ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ + ┃ AnimVanish - Locales ┃ + ┃ Developed by ArikSquad ┃ + ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + ┣╸ Thanks for using AnimVanish. + ┗╸ Translate AnimVanish: https://github.com/ArikSquad/AnimVanish"""; + + protected static final String DEFAULT_LOCALE = "en-us"; + + // The raw set of locales loaded from yaml + Map locales = Maps.newTreeMap(); + + /** + * Returns a raw, unformatted locale loaded from the locales file + * + * @param localeId String identifier of the locale, corresponding to a key in the file + * @return An {@link Optional} containing the locale corresponding to the id, if it exists + */ + public Optional getRawLocale(@NotNull String localeId) { + return Optional.ofNullable(locales.get(localeId)).map(StringEscapeUtils::unescapeJava); + } + + /** + * Returns a raw, un-formatted locale loaded from the locales file, with replacements applied + *

+ * Note that replacements will not be MiniMessage-escaped; use {@link #escapeText(String)} to escape replacements + * + * @param localeId String identifier of the locale, corresponding to a key in the file + * @param replacements Ordered array of replacement strings to fill in placeholders with + * @return An {@link Optional} containing the replacement-applied locale corresponding to the id, if it exists + */ + public Optional getRawLocale(@NotNull String localeId, @NotNull String... replacements) { + return getRawLocale(localeId).map(locale -> applyReplacements(locale, replacements)); + } + + /** + * Returns a MiniMessage-formatted locale from the locales file + * + * @param localeId String identifier of the locale, corresponding to a key in the file + * @return An {@link Optional} containing the formatted locale corresponding to the id, if it exists + */ + public Optional getLocale(@NotNull String localeId) { + return getRawLocale(localeId).map(this::format); + } + + /** + * Returns a MiniMessage-formatted locale from the locales file, with replacements applied + * + * @param localeId String identifier of the locale, corresponding to a key in the file + * @param replacements Ordered array of replacement strings to fill in placeholders with + * @return An {@link Optional} containing the replacement-applied, formatted locale corresponding to the id, if it exists + */ + public Optional getLocale(@NotNull String localeId, @NotNull String... replacements) { + + return getRawLocale(localeId, Arrays.stream(replacements).map(Locales::escapeText) + .toArray(String[]::new)).map(this::format); + } + + /** + * Returns a MiniMessage-formatted string + * + * @param text The text to format + * @return A {@link Component} object containing the formatted text + */ + @NotNull + public Component format(@NotNull String text) { + return MiniMessage.miniMessage().deserialize(text, Placeholder.component("prefix", MiniMessage.miniMessage().deserialize(getRawLocale("prefix").orElse("[AnimVanish]")))); + } + + /** + * Apply placeholder replacements to a raw locale + * + * @param rawLocale The raw, unparsed locale + * @param replacements Ordered array of replacement strings to fill in placeholders with + * @return the raw locale, with inserted placeholders + */ + @NotNull + private String applyReplacements(@NotNull String rawLocale, @NotNull String... replacements) { + int replacementIndexer = 1; + for (String replacement : replacements) { + String replacementString = "%" + replacementIndexer + "%"; + rawLocale = rawLocale.replace(replacementString, replacement); + replacementIndexer += 1; + } + return rawLocale; + } + + /** + * Escape a string from {@link Component} formatting + * I don't know if I need this. + * + * @param string The string to escape + * @return The escaped string + */ + @NotNull + public static String escapeText(@NotNull String string) { + final StringBuilder value = new StringBuilder(); + for (int i = 0; i < string.length(); ++i) { + char c = string.charAt(i); + boolean isEscape = c == '\\'; + boolean isColorCode = i + 1 < string.length() && (c == 167 || c == '&'); + boolean isEvent = c == '[' || c == ']' || c == '(' || c == ')'; + if (isEscape || isColorCode || isEvent) { + value.append('\\'); + } + + value.append(c); + } + return value.toString().replace("__", "_\\_"); + } + + @NotNull + public String truncateText(@NotNull String string, int truncateAfter) { + if (string.isBlank()) { + return string; + } + return string.length() > truncateAfter ? string.substring(0, truncateAfter) + "…" : string; + } + + public enum Slot { + CHAT, + ACTION_BAR, + TITLE, + SUBTITLE, + NONE + } + +} diff --git a/common/src/main/java/eu/mikart/animvanish/config/Settings.java b/common/src/main/java/eu/mikart/animvanish/config/Settings.java new file mode 100644 index 0000000..654da8b --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/config/Settings.java @@ -0,0 +1,149 @@ +package eu.mikart.animvanish.config; + +import de.exlll.configlib.Comment; +import de.exlll.configlib.Configuration; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The configuration has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +@Getter +@Configuration +@SuppressWarnings("FieldMayBeFinal") +public class Settings { + + protected static final String CONFIG_HEADER = """ + ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ + ┃ AnimVanish Config ┃ + ┃ Developed by ArikSquad ┃ + ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + ┣╸ Information: https://github.com/ArikSquad/AnimVanish + ┣╸ Config Help: https://animvanish.mikart.eu/configuration/config.yml + ┗╸ Documentation: https://animvanish.mikart.eu/"""; + + @Comment("Locale of the default language file to use. Docs: https://animvanish.mikart.eu/configuration/language-files") + private String language = Locales.DEFAULT_LOCALE; + + @Comment("Whether to enable debug mode. This will print additional information to the console.") + private boolean debug = false; + + @Comment("Whether to enable the plugin's update checker.") + private boolean updateChecker = true; + + @Comment("All settings related to the effects.") + private EffectsSettings effects = new EffectsSettings(); + + @Getter + @Configuration + public static class EffectsSettings { + + private LightningSetting lightning = new LightningSetting(); + private ParticleSettings particle = new ParticleSettings(); + private SoundSettings sound = new SoundSettings(); + private BlindnessSettings blindness = new BlindnessSettings(); + private FireworkSettings firework = new FireworkSettings(); + private NPCSettings npc = new NPCSettings(); + private LaunchSettings launch = new LaunchSettings(); + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class LightningSetting { + + @Comment("Will the time set to night with the effect? Default: true") + private boolean night = true; + + } + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class ParticleSettings { + + @Comment("What particle will be used when using particle as the effect. Docs: https://animvanish.mikart.eu/configuration/config.yml#particle") + private String type = "DRAGON_BREATH"; + + @Comment("How many particles will be spawned. Default: 50") + private int amount = 50; + } + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class SoundSettings { + + @Comment("What sound the player will hear. Default: BLOCK_AMETHYST_BLOCK_HIT Docs: https://animvanish.mikart.eu/configuration/config.yml#sound") + private String type = "BLOCK_AMETHYST_BLOCK_HIT"; + + } + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class BlindnessSettings { + + @Comment("How many seconds the blindness effect will last. Default: 3") + private int duration = 3; + + @Comment("Radius of how many blocks the blindness effect will reach. Default: 10") + private int radius = 10; + + } + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class FireworkSettings { + + @Comment("What type of firework you want to have. Default: BURST Docs: https://animvanish.mikart.eu/configuration/config.yml#firework") + private String type = "BURST"; + + @Getter(AccessLevel.NONE) + @Comment("Colors of the firework. Default: ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF']") + private String[] colors = new String[] { + "#FF0000", + "#00FF00", + "#0000FF", + "#FFFF00", + "#00FFFF" + }; + + @NotNull + public List getColors() { + return Arrays.stream(colors) + .map(Color::decode) + .collect(Collectors.toList()); + } + } + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class NPCSettings { + + @Comment("How many seconds the NPC will be visible. Default: 3") + private int duration = 3; + + } + + @Getter + @Configuration + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class LaunchSettings { + + @Comment("Enable if launch effect Armor Stands should use the players' own armor. Default: true") + private boolean usePlayerArmor = true; + + } + + } +} diff --git a/common/src/main/java/eu/mikart/animvanish/effects/BareEffect.java b/common/src/main/java/eu/mikart/animvanish/effects/BareEffect.java new file mode 100644 index 0000000..d2f7f9b --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/effects/BareEffect.java @@ -0,0 +1,21 @@ +package eu.mikart.animvanish.effects; + +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.user.OnlineUser; +import lombok.Getter; + +public abstract class BareEffect implements IEffect { + + private final EffectAnnotation effectAnnotation = getClass().getAnnotation(EffectAnnotation.class); + @Getter + private final String name = effectAnnotation.name(), description = effectAnnotation.description(); + @Getter + private final String item = effectAnnotation.item(); + + public void runEffect(OnlineUser player) { + if(this.canRun()) { + this.start(player); + } + } + +} diff --git a/common/src/main/java/eu/mikart/animvanish/effects/IEffect.java b/common/src/main/java/eu/mikart/animvanish/effects/IEffect.java new file mode 100644 index 0000000..e4e023c --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/effects/IEffect.java @@ -0,0 +1,13 @@ +package eu.mikart.animvanish.effects; + +import eu.mikart.animvanish.user.OnlineUser; + +public interface IEffect { + + void start(OnlineUser player); + + default boolean canRun() { + return true; + } + +} diff --git a/common/src/main/java/eu/mikart/animvanish/effects/IEffectManager.java b/common/src/main/java/eu/mikart/animvanish/effects/IEffectManager.java new file mode 100644 index 0000000..79b89cf --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/effects/IEffectManager.java @@ -0,0 +1,13 @@ +package eu.mikart.animvanish.effects; + +import java.util.ArrayList; + +public interface IEffectManager { + BareEffect getEffect(String effectName); + + ArrayList getEffects(); + + void registerEffect(BareEffect effect); + + void unregisterEffect(BareEffect effect); +} diff --git a/common/src/main/java/eu/mikart/animvanish/effects/InternalEffect.java b/common/src/main/java/eu/mikart/animvanish/effects/InternalEffect.java new file mode 100644 index 0000000..c37fa06 --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/effects/InternalEffect.java @@ -0,0 +1,26 @@ +package eu.mikart.animvanish.effects; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.user.OnlineUser; +import net.kyori.adventure.audience.Audience; + +public abstract class InternalEffect extends BareEffect { + + public IAnimVanish plugin; + + public InternalEffect(IAnimVanish plugin) { + this.plugin = plugin; + } + + public void runEffect(OnlineUser player) { + if(this.canRun()) { + if(plugin.getSettings().isDebug()) plugin.getLogger().info("Running effect " + this.getName() + " for player " + player.getName()); + this.start(player); + } + } + + protected Audience getConsole() { + return plugin.getAudiences().console(); + } + +} diff --git a/src/main/java/eu/mikart/animvanish/hooks/Hook.java b/common/src/main/java/eu/mikart/animvanish/hooks/Hook.java similarity index 65% rename from src/main/java/eu/mikart/animvanish/hooks/Hook.java rename to common/src/main/java/eu/mikart/animvanish/hooks/Hook.java index a65ec7b..f274aee 100644 --- a/src/main/java/eu/mikart/animvanish/hooks/Hook.java +++ b/common/src/main/java/eu/mikart/animvanish/hooks/Hook.java @@ -1,14 +1,16 @@ package eu.mikart.animvanish.hooks; +import eu.mikart.animvanish.user.OnlineUser; import lombok.Getter; +@Getter public abstract class Hook implements HookInterface { - @Getter String name; public Hook(String name) { this.name = name; } + public abstract void vanish(OnlineUser p); } diff --git a/common/src/main/java/eu/mikart/animvanish/hooks/HookInterface.java b/common/src/main/java/eu/mikart/animvanish/hooks/HookInterface.java new file mode 100644 index 0000000..b92c662 --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/hooks/HookInterface.java @@ -0,0 +1,11 @@ +package eu.mikart.animvanish.hooks; + +import eu.mikart.animvanish.user.OnlineUser; + +public interface HookInterface { + + void vanish(OnlineUser p); + + boolean isVanished(OnlineUser p); + +} diff --git a/common/src/main/java/eu/mikart/animvanish/user/CommandUser.java b/common/src/main/java/eu/mikart/animvanish/user/CommandUser.java new file mode 100644 index 0000000..b878638 --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/user/CommandUser.java @@ -0,0 +1,22 @@ +package eu.mikart.animvanish.user; + +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.NotNull; + +/** + * The user system has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +public interface CommandUser { + + @NotNull + Audience getAudience(); + + boolean hasPermission(@NotNull String permission); + + default void sendMessage(@NotNull Component component) { + getAudience().sendMessage(component); + } + +} diff --git a/common/src/main/java/eu/mikart/animvanish/user/ConsoleUser.java b/common/src/main/java/eu/mikart/animvanish/user/ConsoleUser.java new file mode 100644 index 0000000..4d05f9c --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/user/ConsoleUser.java @@ -0,0 +1,35 @@ +package eu.mikart.animvanish.user; + +import net.kyori.adventure.audience.Audience; +import org.jetbrains.annotations.NotNull; + +/** + * The user system has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +public final class ConsoleUser implements CommandUser { + + @NotNull + private final Audience audience; + + private ConsoleUser(@NotNull Audience console) { + this.audience = console; + } + + @NotNull + public static ConsoleUser wrap(@NotNull Audience console) { + return new ConsoleUser(console); + } + + @Override + @NotNull + public Audience getAudience() { + return audience; + } + + @Override + public boolean hasPermission(@NotNull String permission) { + return true; + } + +} \ No newline at end of file diff --git a/common/src/main/java/eu/mikart/animvanish/user/OnlineUser.java b/common/src/main/java/eu/mikart/animvanish/user/OnlineUser.java new file mode 100644 index 0000000..1629d36 --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/user/OnlineUser.java @@ -0,0 +1,67 @@ +package eu.mikart.animvanish.user; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.config.Locales; +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.title.Title; +import org.intellij.lang.annotations.Subst; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +/** + * The user system has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +public abstract class OnlineUser extends User implements CommandUser { + + @NotNull + protected final IAnimVanish plugin; + + protected OnlineUser(@NotNull UUID uuid, @NotNull String username, @NotNull IAnimVanish plugin) { + super(uuid, username); + this.plugin = plugin; + } + + public final void sendActionBar(@NotNull Component component) { + getAudience().sendActionBar(component); + } + + public final void sendTitle(@NotNull Component title, @NotNull Component subtitle) { + getAudience().showTitle(Title.title(title, subtitle)); + } + + public final void sendMessage(@NotNull Locales.Slot slot, @NotNull Component message) { + switch (slot) { + case CHAT -> this.sendMessage(message); + case ACTION_BAR -> this.sendActionBar(message); + case TITLE -> this.sendTitle(message, Component.empty()); + case SUBTITLE -> this.sendTitle(Component.empty(), message); + } + } + + public final void playSound(@Subst("minecraft:block.note_block.banjo") @NotNull String sound) { + getAudience().playSound(Sound.sound(Key.key(sound), Sound.Source.PLAYER, 1.0f, 1.0f)); + } + + public abstract void addPotionEffect(@NotNull Key potionEffect, int duration, int amplifier); + + @NotNull + public Audience getAudience() { + return plugin.getAudience(getUuid()); + } + + public abstract boolean isSneaking(); + + /*not needed: public abstract void teleportTo(@NotNull Position position);*/ + + public abstract void giveExperiencePoints(int quantity); + + public abstract void giveExperienceLevels(int quantity); + + public abstract void giveItem(@NotNull Key material, int quantity); + +} \ No newline at end of file diff --git a/common/src/main/java/eu/mikart/animvanish/user/User.java b/common/src/main/java/eu/mikart/animvanish/user/User.java new file mode 100644 index 0000000..fb195aa --- /dev/null +++ b/common/src/main/java/eu/mikart/animvanish/user/User.java @@ -0,0 +1,56 @@ +package eu.mikart.animvanish.user; + +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +/** + * The user system has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +public class User implements Comparable { + private UUID uuid; + private String username; + + protected User(@NotNull UUID uuid, @NotNull String username) { + this.uuid = uuid; + this.username = username; + } + + @NotNull + public static User of(@NotNull UUID uuid, @NotNull String username) { + return new User(uuid, username); + } + + @SuppressWarnings("unused") + private User() { + } + + @NotNull + public UUID getUuid() { + return uuid; + } + + @NotNull + public String getName() { + return username; + } + + @NotNull + public String getUsername() { + return getName(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof User user)) { + return false; + } + return user.getUuid().equals(uuid); + } + + @Override + public int compareTo(@NotNull User o) { + return username.compareTo(o.getUsername()); + } +} diff --git a/src/main/java/eu/mikart/animvanish/util/Settings.java b/common/src/main/java/eu/mikart/animvanish/util/Utilities.java similarity index 53% rename from src/main/java/eu/mikart/animvanish/util/Settings.java rename to common/src/main/java/eu/mikart/animvanish/util/Utilities.java index f0372b7..7027d1c 100644 --- a/src/main/java/eu/mikart/animvanish/util/Settings.java +++ b/common/src/main/java/eu/mikart/animvanish/util/Utilities.java @@ -1,9 +1,8 @@ package eu.mikart.animvanish.util; -import eu.mikart.animvanish.Main; +public class Utilities { -public class Settings { public static final String PLUGIN_URL = "https://hangar.papermc.io/ArikSquad/AnimVanish"; - public static final boolean DEBUG = Main.getInstance().getConfig().getBoolean("debug"); public static boolean BETA = false; + } diff --git a/src/main/java/eu/mikart/animvanish/util/Version.java b/common/src/main/java/eu/mikart/animvanish/util/Version.java similarity index 100% rename from src/main/java/eu/mikart/animvanish/util/Version.java rename to common/src/main/java/eu/mikart/animvanish/util/Version.java diff --git a/common/src/main/resources/locales/en-us.yml b/common/src/main/resources/locales/en-us.yml new file mode 100644 index 0000000..95b302f --- /dev/null +++ b/common/src/main/resources/locales/en-us.yml @@ -0,0 +1,21 @@ +locales: + prefix: "[AnimVanish]" + invalid_args: " Invalid arguments." + not_player: " You must be a player." + reload: " Reloaded configs" + player_not_found: " Player not found." + no_permissions: " You don't have permissions to use this command. (%1%)" + only_to_vanish: " This effect only applies when going into vanish." + not_found: " Effect was not found." + particle_invalid_config: " Invalid particle configuration. Ask an administrator to check config file." + blindness_message: " You saw something and you now feel dizzy" + blindness_author: " You blinded all the players around you." + sound_invalid_config: " Invalid sound configuration. Ask an administrator to check config file." + turn_none: " Nobody was turned, because there is nobody close to you." + launch_no_space: " There is no space to launch an armor stand" + gui_title: "Select an effect" + gui_placeholder_name: "Select an effect" + gui_item_name: "%1%" + gui_item_lore: "%1%" + dependency_no_citizens: " You must have Citizens installed to use this effect." + dependency_no_vanish: " You must have a supported vanish plugin installed to use this command." diff --git a/common/src/main/resources/locales/fi-fi.yml b/common/src/main/resources/locales/fi-fi.yml new file mode 100644 index 0000000..5638a5c --- /dev/null +++ b/common/src/main/resources/locales/fi-fi.yml @@ -0,0 +1,23 @@ +locales: + prefix: "[AnimVanish]" + invalid_args: ' Virheelliset argumentit.' + not_player: ' Sinun pitää olla pelaaja.' + reload: ' Uudelleenladattu asetukset.' + player_not_found: ' Pelaajaa ei löydetty.' + no_permissions: " Sinulla ei ole lupaa käyttää tätä komentoa. (%1%>)" + only_to_vanish: ' Tätä efekti vaikuttaa vain, kun siirrytään vanishiin.' + not_found: ' Efektiä ei löydetty.' + particle_invalid_config: ' Virheellinen hiukkasten konfiguraatio. Pyydä järjestelmänvalvojaa tarkistamaan konfigurointitiedosto.' + invalid_particle: " Tuota hiukkasta ei ole olemassa tai sitä ei tueta." + blindness_message: ' Näit jotain, ja sinua huimaa nyt' + blindness_author: ' Sokaisit kaikki pelaajat ympärilläsi.' + sound_invalid_config: ' Virheellinen äänikonfiguraatio. Pyydä järjestelmänvalvojaa tarkistamaan konfigurointitiedosto.' + sound_invalid_sound: " Tätä ääntä ei ole olemassa tai sitä ei tueta." + turn_none: ' Ketään ei käännetty, koska kukaan ei ole lähelläsi.' + launch_no_space: ' Ei ole tilaa laukaista panssaritelinettä.' + gui_title: 'Valitse efekti' + gui_placeholder_name: 'Valitse efekti' + gui_item_name: '%1%' + gui_item_lore: '%1%' + dependency_no_citizens: ' Sinulla on oltava Citizens asennettuna, jotta voit käyttää tätä efektiä.' + dependency_no_vanish: ' Sinulla on oltava asennettuna jokin tuettu vanish-plugin, jotta voit käyttää tätä efektiä' diff --git a/paper/pom.xml b/paper/pom.xml new file mode 100644 index 0000000..dca6ff9 --- /dev/null +++ b/paper/pom.xml @@ -0,0 +1,120 @@ + + + 4.0.0 + + eu.mikart + AnimVanish + 1.1.0 + + + eu.mikart.animvanish + animvanish-paper + 1.1.0 + + + 17 + 17 + UTF-8 + AnimVanish-Paper-${project.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + 17 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.0 + + ../target/${jar.finalName}.jar + true + + + + org.bstats + eu.mikart.animvanish + + + + + co.aikar.commands + eu.mikart.animvanish.acf + + + + co.aikar.locales + eu.mikart.animvanish.locales + + + + + com.github.stefvanschie.inventoryframework + eu.mikart.animvanish.inventoryframework + + + + + + package + + shade + + + false + true + + + *:* + + META-INF/** + + + + + + + + + + + src/main/resources + true + + + + + + + + papermc + https://repo.papermc.io/repository/maven-public/ + + + + + + + io.papermc.paper + paper-api + 1.20.4-R0.1-SNAPSHOT + provided + + + + + eu.mikart.animvanish + animvanish-spigot + 1.1.0 + + + \ No newline at end of file diff --git a/paper/src/main/java/eu/mikart/animvanish/AnimVanishPaper.java b/paper/src/main/java/eu/mikart/animvanish/AnimVanishPaper.java new file mode 100644 index 0000000..c3fd173 --- /dev/null +++ b/paper/src/main/java/eu/mikart/animvanish/AnimVanishPaper.java @@ -0,0 +1,26 @@ +package eu.mikart.animvanish; + +import eu.mikart.animvanish.effects.impl.TntEffect; +import lombok.NoArgsConstructor; +import net.kyori.adventure.audience.Audience; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +@NoArgsConstructor +public class AnimVanishPaper extends AnimVanishBukkit { + + @Override + @NotNull + public Audience getAudience(@NotNull UUID user) { + final Player player = getServer().getPlayer(user); + return player == null || !player.isOnline() ? Audience.empty() : player; + } + + @Override + public void loadExtra() { + getEffectManager().registerEffect(new TntEffect(this)); + } + +} diff --git a/paper/src/main/java/eu/mikart/animvanish/effects/impl/TntEffect.java b/paper/src/main/java/eu/mikart/animvanish/effects/impl/TntEffect.java new file mode 100644 index 0000000..c857550 --- /dev/null +++ b/paper/src/main/java/eu/mikart/animvanish/effects/impl/TntEffect.java @@ -0,0 +1,24 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +@EffectAnnotation(name = "tnt", description = "Spawn a tnt", item = "TNT") +public class TntEffect extends InternalEffect { + + public TntEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + player.getWorld().spawn(player.getLocation(), TNTPrimed.class, tnt -> tnt.setYield(0)); + plugin.getCurrentHook().vanish(p); + } + +} diff --git a/paper/src/main/resources/paper-plugin.yml b/paper/src/main/resources/paper-plugin.yml new file mode 100644 index 0000000..b9a7b96 --- /dev/null +++ b/paper/src/main/resources/paper-plugin.yml @@ -0,0 +1,79 @@ +name: 'AnimVanish' +description: 'Beautiful library of pre-made effects to make vanishing look as cool as it can!' +version: '${project.version}' +main: 'eu.mikart.animvanish.AnimVanishPaper' +api-version: '1.19' +website: 'https://github.com/ArikSquad/AnimVanish' +author: 'ArikSquad' + +dependencies: + server: + SuperVanish: + load: BEFORE + required: false + join-classpath: true + PremiumVanish: + load: BEFORE + required: false + join-classpath: true + AdvancedVanish: + load: BEFORE + required: false + join-classpath: true + Citizens: + load: BEFORE + required: false + join-classpath: true + + +permissions: + animvanish.*: + children: + animvanish.invis.*: true + animvanish.reload: true + animvanish.help: true + description: All the permissions in AnimVanish + animvanish.reload: + description: Allows to reload the plugin + animvanish.help: + default: true + description: Allows to use the help command + animvanish.invis.*: + children: + animvanish.invis.other: true + animvanish.invis.lightning: true + animvanish.invis.particle: true + animvanish.invis.tnt: true + animvanish.invis.npc: true + animvanish.invis.blindness: true + animvanish.invis.sound: true + animvanish.invis.turn: true + animvanish.invis.firework: true + animvanish.invis.blood: true + animvanish.invis.gui: true + animvanish.invis.launch: true + description: All the invisibility effects + animvanish.invis.other: + description: Allows to use the invisibility effect on other players + animvanish.invis.gui: + description: Ability to open the invisibility selection menu + animvanish.invis.launch: + description: Ability to launch yourself to the sky + animvanish.invis.lightning: + description: Ability to vanish with an amazing lightning strike + animvanish.invis.particle: + description: Ability to use customizable particles effect + animvanish.invis.tnt: + description: Ability to vanish with a TNT explosion + animvanish.invis.npc: + description: Ability to vanish with a NPC taking your place for a moment + animvanish.invis.blindness: + description: Ability to vanish using the blindness effect + animvanish.invis.sound: + description: Ability to vanish using the sound effect + animvanish.invis.turn: + description: Ability to vanish using the turn effect + animvanish.invis.firework: + description: Ability to vanish using the firework effect + animvanish.invis.blood: + description: Ability to vanish using the blood effect diff --git a/pom.xml b/pom.xml index 7918807..45e992c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,16 +6,21 @@ eu.mikart AnimVanish - 1.0.8.2-BETA - jar + 1.1.0 + pom AnimVanish Plugin that provides large library of pre-made effects to your vanish + + common + spigot + paper + UTF-8 - https://youtube.com/c/ArikChannel + https://github.com/ArikSquad @@ -25,46 +30,11 @@ 3.8.1 17 + + -parameters + - - org.apache.maven.plugins - maven-shade-plugin - 3.3.0 - - - - - org.bstats - eu.mikart.animvanish - - - - - com.jeff_media.updatechecker - eu.mikart.animvanish.updatechecker - - - - - de.themoep.minedown - your.package.path.libraries.minedown - - - - - - - package - - shade - - - false - - - - @@ -75,137 +45,23 @@ - - - papermc - https://repo.papermc.io/repository/maven-public/ - - - - - everything - https://repo.citizensnpcs.co/ - - - sonatype - https://oss.sonatype.org/content/groups/public/ - - jitpack.io - https://jitpack.io - - - - - jeff-media-public - https://hub.jeff-media.com/nexus/repository/jeff-media-public/ - - - sonatype-oss-snapshots1 - https://s01.oss.sonatype.org/content/repositories/snapshots/ - - - Maven Central - https://repo1.maven.org/maven2/ - - - - - minebench-repo - https://repo.minebench.de/ - - - - - repsy - quantiom - https://repo.repsy.io/mvn/quantiom/minecraft + central + https://repo.maven.apache.org/maven2/ - - - io.papermc.paper - paper-api - 1.18.2-R0.1-SNAPSHOT - provided - - - - - org.bstats - bstats-bukkit - 3.0.1 - compile - - - - - com.github.LeonMangler - PremiumVanishAPI - 2.7.11 - provided - - - - - net.citizensnpcs - citizens-main - 2.0.30-SNAPSHOT - jar - provided - - - - - com.tchristofferson - ConfigUpdater - 2.1-SNAPSHOT - - - org.jetbrains annotations - 24.0.1 - - - - - net.william278 - PagineDown - 1.1 - compile + 24.1.0 - - - - net.william278 - DesertWell - 1.1 - compile - - - - - de.themoep - minedown-adventure - 1.7.1-SNAPSHOT - compile - - org.projectlombok lombok - 1.18.26 - compile - - - - me.quantiom - advancedvanish - 1.2.6 + 1.18.32 + provided diff --git a/readme.md b/readme.md index af09a8a..d4eac55 100644 --- a/readme.md +++ b/readme.md @@ -6,31 +6,33 @@ Plugin that provides large library of pre-made effects for vanishing - - paper-mc - - license - - Support AnimVanish on Patreon! + + Support AnimVanish on Patreon! - + + AnimVanish Wiki + -# YOU NEED PAPER TO RUN THIS PLUGIN + ## Overview -Animvanish makes your vanishing look great with a large library of pre-made effects for vanishing. +Elevate your vanishing to new heights with AnimVanish! AnimVanish makes your vanishing look great with a large library of pre-made effects for vanishing. You can use AnimVanish to vanish in front of your server community and make it look fantastic. +## Documentation +We have an extensive [wiki](https://animvanish.mikart.eu/) that covers all the features of the plugin. I highly suggest reading +it if you have time. + ### Current library of effects: - Lightning effect (Lightning strike and optional night) - Particle effect -- TNT effect +- TNT effect (paper only) - NPC effect (requires Citizens) - Zombie effect - Blindness effect @@ -40,14 +42,10 @@ You can use AnimVanish to vanish in front of your server community and make it l - Blood effect - Launch effect -## Configuration - -You can find all about the configuration in the [wiki](https://github.com/ArikSquad/AnimVanish/wiki/Configuration) - ## Permissions For more in-depth information about permissions, please visit -the [wiki](https://github.com/ArikSquad/AnimVanish/wiki/Permissions) +the [wiki](https://animvanish.mikart.eu/permissions) ```yml animvanish.* - All permissions in one @@ -60,7 +58,11 @@ animvanish.help - This permissions can see help for the plugin ``` ### Dependencies -AnimVanish depends on [SuperVanish](https://www.spigotmc.org/resources/supervanish-be-invisible.1331/) or [PremiumVanish](https://www.spigotmc.org/resources/premiumvanish-stay-hidden-bungee-support.14404/)! +List of supported vanish plugins in their preferred order (The plugin will use the first one it finds): +1. [PremiumVanish](https://www.spigotmc.org/resources/premiumvanish-stay-hidden-bungee-support.14404/) +2. [SuperVanish](https://www.spigotmc.org/resources/supervanish-be-invisible.1331/) +3. [AdvancedVanish](hhttps://www.spigotmc.org/resources/advancedvanish.86036/) + Additionally, you need to get [Citizens](https://www.spigotmc.org/resources/citizens.13811/) for the NPC effect. diff --git a/spigot/pom.xml b/spigot/pom.xml new file mode 100644 index 0000000..9deefc7 --- /dev/null +++ b/spigot/pom.xml @@ -0,0 +1,259 @@ + + + 4.0.0 + + eu.mikart + AnimVanish + 1.1.0 + + + eu.mikart.animvanish + animvanish-spigot + 1.1.0 + + + 17 + 17 + UTF-8 + AnimVanish-Spigot-${project.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + 17 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.0 + + ../target/${jar.finalName}.jar + + + + org.bstats + eu.mikart.animvanish + + + + + co.aikar.commands + eu.mikart.animvanish.acf + + + + co.aikar.locales + eu.mikart.animvanish.locales + + + + + com.github.stefvanschie.inventoryframework + eu.mikart.animvanish.inventoryframework + + + + + + package + + shade + + + false + true + + + *:* + + META-INF/** + + + + + + + + + + + src/main/resources + true + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + everything + https://repo.citizensnpcs.co/ + + + + + jitpack.io + https://jitpack.io + + + + + jeff-media-public + https://hub.jeff-media.com/nexus/repository/jeff-media-public/ + + + + + sonatype-oss-snapshots1 + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + Maven Central + https://repo1.maven.org/maven2/ + + + + + minebench-repo + https://repo.minebench.de/ + + + + + repsy + quantiom + https://repo.repsy.io/mvn/quantiom/minecraft + + + + + + + org.spigotmc + spigot-api + 1.19.4-R0.1-SNAPSHOT + provided + + + + + org.bstats + bstats-bukkit + 3.0.2 + compile + + + + + eu.mikart.animvanish + animvanish-common + 1.1.0 + + + + + com.github.LeonMangler + PremiumVanishAPI + 2.7.11-2 + provided + + + + + net.kyori + adventure-platform-bukkit + 4.3.2 + + + + + net.kyori + adventure-text-minimessage + 4.14.0 + + + + + net.citizensnpcs + citizens-main + 2.0.30-SNAPSHOT + jar + provided + + + + + com.tchristofferson + ConfigUpdater + 2.1-SNAPSHOT + + + + + net.william278 + PagineDown + 1.1 + compile + + + + + net.william278 + DesertWell + 2.0.4 + compile + + + + + net.kyori + adventure-key + 4.14.0 + compile + + + + + co.aikar + acf-paper + 0.5.1-SNAPSHOT + compile + + + + + me.quantiom + advancedvanish + 1.2.6 + provided + + + + + com.github.stefvanschie.inventoryframework + IF + 0.10.13 + + + diff --git a/spigot/src/main/java/eu/mikart/animvanish/AnimVanishBukkit.java b/spigot/src/main/java/eu/mikart/animvanish/AnimVanishBukkit.java new file mode 100644 index 0000000..4a52e3f --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/AnimVanishBukkit.java @@ -0,0 +1,176 @@ +package eu.mikart.animvanish; + +import co.aikar.commands.BukkitCommandExecutionContext; +import co.aikar.commands.PaperCommandManager; +import co.aikar.commands.contexts.ContextResolver; +import com.google.common.collect.Sets; +import eu.mikart.animvanish.api.AnimVanishBukkitAPI; +import eu.mikart.animvanish.commands.InvisibilityCommand; +import eu.mikart.animvanish.config.Locales; +import eu.mikart.animvanish.config.Settings; +import eu.mikart.animvanish.effects.BareEffect; +import eu.mikart.animvanish.effects.EffectManager; +import eu.mikart.animvanish.effects.impl.FireworkEffect; +import eu.mikart.animvanish.hooks.Hook; +import eu.mikart.animvanish.hooks.impl.AdvancedVanishHook; +import eu.mikart.animvanish.hooks.impl.PremiumVanishHook; +import eu.mikart.animvanish.hooks.impl.SuperVanishHook; +import eu.mikart.animvanish.util.UpdateChecker; +import eu.mikart.animvanish.util.Utilities; +import eu.mikart.animvanish.util.Version; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import net.kyori.adventure.platform.AudienceProvider; +import net.kyori.adventure.platform.bukkit.BukkitAudiences; +import org.bstats.bukkit.Metrics; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import eu.mikart.animvanish.commands.AnimVanishCommand; +import org.jetbrains.annotations.NotNull; + +import java.nio.file.Path; +import java.util.Set; +import java.util.logging.Logger; + +@Getter +@NoArgsConstructor +public class AnimVanishBukkit extends JavaPlugin implements IAnimVanish { + + private AudienceProvider audiences; + private PaperCommandManager commandManager; + private static AnimVanishBukkit instance; + private EffectManager effectManager; + + @Setter + private Set hooks = Sets.newHashSet(); + @Setter + private Hook currentHook; + @Setter + private Settings settings; + @Setter + private Locales locales; + + @Override + public void onEnable() { + audiences = BukkitAudiences.create(this); + effectManager = new EffectManager(this); + instance = this; + + new Metrics(this, 14993); + this.loadConfig(); + + getServer().getPluginManager().registerEvents(new FireworkEffect(this), this); + setupCommands(); + loadExtra(); + + Utilities.BETA = getDescription().getVersion().contains("BETA"); + updateCheck(); + + hooks.add(new AdvancedVanishHook()); + hooks.add(new SuperVanishHook()); + hooks.add(new PremiumVanishHook()); + + for (Hook hook : hooks) { + if (Bukkit.getPluginManager().isPluginEnabled(hook.getName())) { + currentHook = hook; + break; + } + } + + AnimVanishBukkitAPI.register(this); + } + + public void setupCommands() { + commandManager = new PaperCommandManager(this); + commandSetup(); + } + + public void commandSetup() { + commandManager.getCommandContexts().registerContext(BareEffect.class, getEffectContextResolver()); + commandManager.getCommandCompletions().registerAsyncCompletion("effects", c -> getEffectManager().getEffects().stream().map(BareEffect::getName).toList()); + + commandManager.registerCommand(new AnimVanishCommand(this)); + commandManager.registerCommand(new InvisibilityCommand(this)); + } + + @Override + public void onDisable() { + instance = null; + commandManager.unregisterCommands(); + } + + @Override + public String getPluginVersion() { + return getDescription().getVersion(); + } + + public static boolean isCitizens() { + return Bukkit.getPluginManager().isPluginEnabled("Citizens"); + } + + @Override + public @NotNull AudienceProvider getAudiences() { + return audiences; + } + + public void updateCheck() { + if (!getSettings().isUpdateChecker()) { + return; + } + + new UpdateChecker(this).getLatestVersion(version -> { + Version currentVersion = getVersion(); + Version latestVersion = new Version(version); + + String channel = Utilities.BETA ? "beta" : "main"; + + if (currentVersion.compareTo(latestVersion) < 0) { + getLogger().warning("New " + channel + " channel release is available (" + version + ")! Download it from here: " + Utilities.PLUGIN_URL); + } else { + getLogger().info("Running on the latest AnimVanish version"); + } + }); + } + + @Override + @NotNull + public Path getConfigDirectory() { + return getDataFolder().toPath(); + } + + @Override + @NotNull + public AnimVanishBukkit getPlugin() { + return this; + } + + public static ContextResolver getEffectContextResolver() { + return (context) -> { + String effectName = context.popFirstArg(); + if (effectName == null || effectName.isEmpty()) { + return null; // No effect name provided + } + + BareEffect effect = instance.getEffectManager().getEffect(effectName); + if (effect == null) { + instance.getLocales().getLocale("not_found").ifPresent(message -> { + if (context.getSender() instanceof Player player) { + instance.getAudience(player.getUniqueId()).sendMessage(message); + } else { + instance.getConsole().sendMessage(message); + } + }); + } + + return effect; + }; + } + + @Override + @NotNull + public Logger getLogger() { + return super.getLogger(); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/api/AnimVanishBukkitAPI.java b/spigot/src/main/java/eu/mikart/animvanish/api/AnimVanishBukkitAPI.java new file mode 100644 index 0000000..72e169b --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/api/AnimVanishBukkitAPI.java @@ -0,0 +1,47 @@ +package eu.mikart.animvanish.api; + +import eu.mikart.animvanish.AnimVanishBukkit; +import eu.mikart.animvanish.IAnimVanish; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * The Bukkit implementation of the AnimVanish API. Get the instance with {@link #getInstance()}. + * + * @since 1.1.0 + */ +public class AnimVanishBukkitAPI extends AnimVanishAPI { + + /** + * (Internal use only) - Constructor, instantiating the API. + * + * @param plugin The AnimVanish plugin instance + * @since 1.1.0 + */ + protected AnimVanishBukkitAPI(@NotNull IAnimVanish plugin) { + super(plugin); + } + + /** + * Get an instance of the AnimVanish API. + * + * @return instance of the AnimVanish API + * @throws NotRegisteredException if the API has not yet been registered. + * @since 1.1.0 + */ + @NotNull + public static AnimVanishBukkitAPI getInstance() throws NotRegisteredException { + return (AnimVanishBukkitAPI) AnimVanishAPI.getInstance(); + } + + /** + * (Internal use only) - Unregister the API instance. + * + * @since 1.1.0 + */ + @ApiStatus.Internal + public static void register(@NotNull AnimVanishBukkit plugin) { + instance = new AnimVanishBukkitAPI(plugin); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/api/Effect.java b/spigot/src/main/java/eu/mikart/animvanish/api/Effect.java new file mode 100644 index 0000000..51ef6c4 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/api/Effect.java @@ -0,0 +1,33 @@ +package eu.mikart.animvanish.api; + +import eu.mikart.animvanish.effects.BareEffect; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.entity.Player; + +/** + * Represents an effect that can be run on a player + * This should be used in the API, and not internally + * + *

This class should always be annotated with {@link eu.mikart.animvanish.annotations.EffectAnnotation}

+ * + * @see InternalEffect + */ +public abstract class Effect extends BareEffect { + + @Override + public void runEffect(OnlineUser player) { + if(this.canRun()) { + this.start(player); + } + } + + @Override + public void start(OnlineUser player) { + this.start(((BukkitUser) player).getPlayer()); + } + + public abstract void start(Player player); + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/commands/AnimVanishCommand.java b/spigot/src/main/java/eu/mikart/animvanish/commands/AnimVanishCommand.java new file mode 100644 index 0000000..3c1aaf2 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/commands/AnimVanishCommand.java @@ -0,0 +1,56 @@ +package eu.mikart.animvanish.commands; + +import co.aikar.commands.BaseCommand; +import co.aikar.commands.annotation.*; +import eu.mikart.animvanish.IAnimVanish; +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.TextColor; +import net.william278.desertwell.about.AboutMenu; +import net.william278.desertwell.util.Version; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandAlias("animvanish") +public class AnimVanishCommand extends BaseCommand { + private final IAnimVanish plugin; + + public AnimVanishCommand(IAnimVanish plugin) { + this.plugin = plugin; + } + + @Default + @Description("Command for information about the AnimVanish") + public void onDefault(CommandSender sender) { + if (sender instanceof Player player) { + Audience audience = plugin.getAudience(player.getUniqueId()); + final AboutMenu menu = AboutMenu.builder() + .title(Component.text("AnimVanish")) + .description(Component.text("Beautiful library of pre-made effects to make vanishing look as cool as it can!")) + .version(Version.fromString(plugin.getPluginVersion())) + .credits("Author", AboutMenu.Credit.of("ArikSquad").description("Click to visit website").url("https://github.com/ArikSquad")) + .buttons(AboutMenu.Link.of("https://www.mikart.eu/").text("Website").icon("⛏"), + AboutMenu.Link.of("https://discord.gg/xh9WAvGdVF").text("Discord").icon("⭐").color(TextColor.color(0x6773f5))) + .build(); + + audience.sendMessage(menu.toComponent()); + } else { + plugin.getConsole().sendMessage(Component.text("AnimVanish v" + plugin.getPluginVersion())); + } + } + @Subcommand("reload") + @CommandPermission("animvanish.reload") + @Description("Reloads the plugin config") + public void onReload(CommandSender sender) { + plugin.reload(); + + plugin.getLocales().getLocale("reload").ifPresent(message -> { + if (sender instanceof Player player) { + plugin.getAudience(player.getUniqueId()).sendMessage(message); + } else { + plugin.getConsole().sendMessage(message); + } + }); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/commands/InvisibilityCommand.java b/spigot/src/main/java/eu/mikart/animvanish/commands/InvisibilityCommand.java new file mode 100644 index 0000000..1e8169a --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/commands/InvisibilityCommand.java @@ -0,0 +1,163 @@ +package eu.mikart.animvanish.commands; + +import co.aikar.commands.BaseCommand; +import co.aikar.commands.annotation.*; +import co.aikar.commands.bukkit.contexts.OnlinePlayer; +import com.github.stefvanschie.inventoryframework.gui.GuiItem; +import com.github.stefvanschie.inventoryframework.gui.type.ChestGui; +import com.github.stefvanschie.inventoryframework.pane.OutlinePane; +import com.github.stefvanschie.inventoryframework.pane.PatternPane; +import com.github.stefvanschie.inventoryframework.pane.util.Pattern; +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.effects.BareEffect; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +@CommandAlias("invis") +public class InvisibilityCommand extends BaseCommand { + private final IAnimVanish plugin; + + public InvisibilityCommand(IAnimVanish plugin) { + this.plugin = plugin; + } + + @PreCommand + public boolean preCommand(CommandSender sender, String[] args) { + if (!(sender instanceof Player player)) { + return true; + } + + if (plugin.getCurrentHook() == null) { + Audience audience = plugin.getAudience(player.getUniqueId()); + plugin.getLocales().getLocale("dependency_no_vanish") + .ifPresent(audience::sendMessage); + return true; + } + + return false; + } + + // TODO: add back support for autocompletion to not show effects that you don't have permission to use + @Default + @CommandPermission("animvanish.invis") + @CommandCompletion("@effects @players") + public void onInvis(Player player, @Optional InternalEffect effect, @Optional OnlinePlayer target) { + Audience audience = plugin.getAudience(player.getUniqueId()); + if (effect == null) { + if (player.hasPermission("animvanish.invis.gui")) + openGui(player); + else + plugin.getLocales().getLocale("no_permissions", "animvanish.invis.gui") + .ifPresent(audience::sendMessage); + + return; + } + + if (target != null) { + if (!player.hasPermission("animvanish.invis.other")) + plugin.getLocales().getLocale("no_permissions", "animvanish.invis.other") + .ifPresent(audience::sendMessage); + else + effect.runEffect(BukkitUser.adapt(target.getPlayer(), plugin)); + + return; + } + + if (!player.hasPermission("animvanish.invis." + effect.getName())) + plugin.getLocales().getLocale("no_permissions", "animvanish.invis." + effect.getName()) + .ifPresent(audience::sendMessage); + else + effect.runEffect(BukkitUser.adapt(player, plugin)); + } + + private void openGui(Player player) { + ChestGui gui = new ChestGui(6, LegacyComponentSerializer.legacySection().serialize(plugin.getLocales().getLocale("gui_title").orElse(MiniMessage.miniMessage().deserialize("Select an effect")))); + gui.setOnGlobalClick(event -> event.setCancelled(true)); + + ItemStack border_item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE, 1); + ItemMeta border_meta = border_item.getItemMeta(); + Component border_name = plugin.getLocales().getLocale("gui_placeholder_name").orElse(MiniMessage.miniMessage().deserialize("Select an effect")); + border_meta.setDisplayName(LegacyComponentSerializer.legacySection().serialize(border_name)); + border_item.setItemMeta(border_meta); + + Pattern pattern = new Pattern( + "111111111", + "100000001", + "100000001", + "100000001", + "100000001", + "111111111" + ); + PatternPane background = new PatternPane(0, 0, 9, 6, pattern); + background.bindItem('1', new GuiItem(border_item)); + gui.addPane(background); + + OutlinePane effectPane = new OutlinePane(1, 1, 8, 5); + for (BareEffect effect : plugin.getEffectManager().getEffects()) { + if (effect.canRun()) { + effectPane.addItem(effectIcon(player, effect)); + } + } + gui.addPane(effectPane); + gui.show(player); + } + + private GuiItem effectIcon(Player player, BareEffect effect) { + ItemStack item = new ItemStack(Material.valueOf(effect.getItem())); + ItemMeta meta = item.getItemMeta(); + meta.getPersistentDataContainer().set(new NamespacedKey((Plugin) plugin, "identifier"), PersistentDataType.STRING, effect.getName()); + Component itemName = plugin.getLocales().getLocale("gui_item_name", effect.getName()).orElse(MiniMessage.miniMessage().deserialize("" + effect.getName() + "")); + meta.setDisplayName(LegacyComponentSerializer.legacySection().serialize(itemName)); + List lore = new ArrayList<>(); + Component loreName = plugin.getLocales().getLocale("gui_item_lore", effect.getDescription()).orElse(MiniMessage.miniMessage().deserialize("" + effect.getDescription() + "")); + lore.add(LegacyComponentSerializer.legacySection().serialize(loreName)); + meta.setLore(lore); + item.setItemMeta(meta); + + Audience audience = plugin.getAudience(player.getUniqueId()); + return new GuiItem(item, event -> { + if (plugin.getCurrentHook() == null) { + audience.sendMessage( + plugin.getLocales() + .getLocale("dependency_no_vanish") + .orElse(MiniMessage.miniMessage().deserialize("You must have a supported vanish plugin installed to use this command.")) + ); + return; + } + + ItemStack i = event.getCurrentItem(); + if (i == null || i.getType() == Material.AIR) { + return; + } + + @Nullable String effectName = i.getItemMeta().getPersistentDataContainer().get(new NamespacedKey((Plugin) plugin, "identifier"), PersistentDataType.STRING); + BareEffect selectedEffect = plugin.getEffectManager().getEffect(effectName); + + // Close the gui + event.getWhoClicked().closeInventory(); + if (!player.hasPermission("animvanish.invis." + selectedEffect.getName())) { + plugin.getLocales().getLocale("no_permissions", "animvanish.invis." + selectedEffect.getName()) + .ifPresent(audience::sendMessage); + return; + } + selectedEffect.runEffect(BukkitUser.adapt(player, plugin)); + }); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/EffectManager.java b/spigot/src/main/java/eu/mikart/animvanish/effects/EffectManager.java new file mode 100644 index 0000000..afec598 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/EffectManager.java @@ -0,0 +1,82 @@ +package eu.mikart.animvanish.effects; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.effects.impl.*; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; + +@Getter +public class EffectManager implements IEffectManager { + + @Getter + public final ArrayList effects = new ArrayList<>(); + private final IAnimVanish plugin; + + public EffectManager(@NotNull IAnimVanish plugin) { + this.plugin = plugin; + + // Lightning + effects.add(new LightningEffect(plugin)); + + // Particle + effects.add(new ParticleEffect(plugin)); + + // Npc + effects.add(new NpcEffect(plugin)); + + // Blood + effects.add(new BloodEffect(plugin)); + + // Blindness + effects.add(new BlindnessEffect(plugin)); + + // Turn + effects.add(new TurnEffect(plugin)); + + // Firework + effects.add(new FireworkEffect(plugin)); + + // Sound + effects.add(new SoundEffect(plugin)); + + // Launch + effects.add(new LaunchEffect(plugin)); + } + + public BareEffect getEffect(String name) { + for (BareEffect effect : effects) { + if (effect.getName().equalsIgnoreCase(name)) { + return effect; + } + } + return null; + } + + /** + * Internal use (shouldn't even work outside) + * @param effect InternalEffect + */ + public void registerEffect(InternalEffect effect) { + effects.add(effect); + } + + /** + * Internal use (shouldn't even work outside) + * @param effect InternalEffect + */ + public void unregisterEffect(InternalEffect effect) { + effects.remove(effect); + } + + public void registerEffect(BareEffect effect) { + effects.add(effect); + } + + public void unregisterEffect(BareEffect effect) { + effects.remove(effect); + } + + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/BlindnessEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/BlindnessEffect.java new file mode 100644 index 0000000..2165991 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/BlindnessEffect.java @@ -0,0 +1,45 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import net.kyori.adventure.audience.Audience; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +@EffectAnnotation(name = "blindness", description = "Makes players around you blind for a moment", item = "SPLASH_POTION") +public class BlindnessEffect extends InternalEffect { + + public BlindnessEffect(IAnimVanish plugin) { + super(plugin); + } + + /** + * We could use BukkitUser to add the potion effect to the player + * if we ever are going to move these to common + * @see BukkitUser#addPotionEffect + */ + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Audience sender = plugin.getAudience(player.getUniqueId()); + plugin.getLocales().getLocale("blindness_author") + .ifPresent(sender::sendMessage); + int duration = plugin.getSettings().getEffects().getBlindness().getDuration(); + int radius = plugin.getSettings().getEffects().getBlindness().getRadius(); + for (Entity ps : player.getNearbyEntities(radius, radius, radius)) { + if (ps instanceof Player rPlayer) { + Audience rAudience = plugin.getAudience(rPlayer.getUniqueId()); + rPlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * duration, 1)); + plugin.getLocales().getLocale("blindness_message") + .ifPresent(rAudience::sendMessage); + } + } + plugin.getCurrentHook().vanish(p); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/BloodEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/BloodEffect.java new file mode 100644 index 0000000..32b1d06 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/BloodEffect.java @@ -0,0 +1,32 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.concurrent.ThreadLocalRandom; + +@EffectAnnotation(name = "blood", description = "Makes some red particles around the player", item = "REDSTONE_BLOCK") +public class BloodEffect extends InternalEffect { + + public BloodEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Location location = player.getLocation(); + location.add(0, ThreadLocalRandom.current().nextFloat() * 1.75, 0); + player.getWorld().playEffect(location, org.bukkit.Effect.STEP_SOUND, Material.REDSTONE_BLOCK); + player.playEffect(EntityEffect.HURT); + plugin.getCurrentHook().vanish(p); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/FireworkEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/FireworkEffect.java new file mode 100644 index 0000000..28a5111 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/FireworkEffect.java @@ -0,0 +1,63 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.Color; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; + +@EffectAnnotation(name = "firework", description = "Spawns colorful fireworks", item = "FIREWORK_ROCKET") +public class FireworkEffect extends InternalEffect implements Listener { + + public FireworkEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Firework fw = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK); + fw.setVelocity(new Vector(0, 2, 0)); + fw.getPersistentDataContainer().set(new NamespacedKey((Plugin) plugin, "nodamage"), PersistentDataType.INTEGER, 1); + + FireworkMeta fwm = fw.getFireworkMeta(); + fwm.setPower(1); + for (java.awt.Color color : plugin.getSettings().getEffects().getFirework().getColors()) { + fwm.addEffect(org.bukkit.FireworkEffect.builder().with(org.bukkit.FireworkEffect.Type.valueOf(plugin.getSettings().getEffects().getFirework().getType().toUpperCase())).withColor(Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue())).build()); + } + + fw.setFireworkMeta(fwm); + + // This wasn't an intended feature, but it's so cool, the firework instantly explodes! + // It's not a bug, it's a feature + fw.detonate(); + plugin.getCurrentHook().vanish(p); + } + + @EventHandler + public void EntityDamageByEntityEvent(EntityDamageByEntityEvent e) { + // In some 1.20.4 builds, Firework damage won't be cancelled + // https://github.com/PaperMC/Paper/issues/10273 + // It has been fixed in Paper #10307 (paper build #453) + // > will probably do damage in spigot + + if (e.getDamager() instanceof Firework fw) { + if (fw.getPersistentDataContainer().get(new NamespacedKey((Plugin) plugin, "nodamage"), PersistentDataType.INTEGER) != null) { + e.setCancelled(true); + } + } + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/LaunchEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/LaunchEffect.java new file mode 100644 index 0000000..5144ac3 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/LaunchEffect.java @@ -0,0 +1,76 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import net.kyori.adventure.audience.Audience; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; + +@EffectAnnotation(name = "launch", description = "Launches you in the air!", item = "PISTON") +public class LaunchEffect extends InternalEffect { + + public LaunchEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Audience audience = plugin.getAudience(player.getUniqueId()); + // Check if there is only air above the player + for (int i = 0; i < 100; i++) { + Location location = player.getLocation().add(0, i, 0); + if (!location.getBlock().isPassable()) { + plugin.getLocales().getLocale("launch_no_spacer") + .ifPresent(audience::sendMessage); + return; + } + } + + // Vanish early if not vanished already + boolean vanished = plugin.getCurrentHook().isVanished(BukkitUser.adapt(player, plugin)); + if (!vanished) { + plugin.getCurrentHook().vanish(p); + } + + // Create and configure ArmorStand + ArmorStand armorStand = player.getWorld().spawn(player.getLocation().add(0, 1, 0).setDirection(player.getLocation().getDirection()), ArmorStand.class); + armorStand.setInvulnerable(true); + armorStand.setArms(true); + armorStand.setCustomNameVisible(true); + armorStand.setCustomNameVisible(true); + armorStand.setCustomName(player.getName()); + + // Copy player's armor to the ArmorStand if configured + if (plugin.getSettings().getEffects().getLaunch().isUsePlayerArmor()) { + EntityEquipment equipment = armorStand.getEquipment(); + equipment.setHelmet(player.getInventory().getHelmet()); + equipment.setChestplate(player.getInventory().getChestplate()); + equipment.setLeggings(player.getInventory().getLeggings()); + equipment.setBoots(player.getInventory().getBoots()); + equipment.setItemInMainHand(player.getInventory().getItemInMainHand()); + equipment.setItemInOffHand(player.getInventory().getItemInOffHand()); + } + + // Add the player as a passenger + armorStand.addPassenger(player); + + Vector launchDirection = new Vector(0, 1.5, 0); + armorStand.setVelocity(launchDirection); + + Bukkit.getScheduler().runTaskLater((Plugin) plugin, () -> { + if (vanished) { + plugin.getCurrentHook().vanish(p); + } + armorStand.remove(); + }, 20 * 2); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/LightningEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/LightningEffect.java new file mode 100644 index 0000000..fea7ce1 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/LightningEffect.java @@ -0,0 +1,32 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +@EffectAnnotation(name = "lightning", description = "Strike the player with a lightning", item = "LIGHTNING_ROD") +public class LightningEffect extends InternalEffect { + + public LightningEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + long timeBefore = player.getWorld().getTime(); + + player.getWorld().strikeLightningEffect(player.getLocation()); + if (plugin.getSettings().getEffects().getLightning().isNight()) { + player.getWorld().setTime(14000); + Bukkit.getScheduler().runTaskLater((Plugin) plugin, () -> player.getWorld().setTime(timeBefore), 20 * 5); + } + + plugin.getCurrentHook().vanish(p); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/NpcEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/NpcEffect.java new file mode 100644 index 0000000..60661ba --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/NpcEffect.java @@ -0,0 +1,51 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.AnimVanishBukkit; +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import net.citizensnpcs.api.CitizensAPI; +import net.citizensnpcs.api.npc.NPC; +import net.kyori.adventure.audience.Audience; +import org.bukkit.Bukkit; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +@EffectAnnotation(name = "npc", description = "Spawn a NPC", item = "SHEEP_SPAWN_EGG") +public class NpcEffect extends InternalEffect { + + public NpcEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public boolean canRun() { + return AnimVanishBukkit.isCitizens(); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Audience audience = plugin.getAudience(player.getUniqueId()); + if (!canRun()) { + plugin.getLocales().getLocale("dependency_no_citizens") + .ifPresent(audience::sendMessage); + return; + } + + NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, player.getName()); + npc.spawn(player.getLocation()); + + long duration = plugin.getSettings().getEffects().getNpc().getDuration(); + if (duration > 30) { + plugin.getLogger().warning("The duration of the NPC effect is too long, setting it to 3 seconds."); + duration = 3; + } + + Bukkit.getScheduler().runTaskLater((Plugin) plugin, () -> npc.destroy(), 20 * duration); + plugin.getCurrentHook().vanish(p); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/ParticleEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/ParticleEffect.java new file mode 100644 index 0000000..4972f40 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/ParticleEffect.java @@ -0,0 +1,37 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import net.kyori.adventure.audience.Audience; +import org.bukkit.Particle; +import org.bukkit.entity.Player; + +@EffectAnnotation(name = "particle", description = "Spawns particles", item = "AMETHYST_SHARD") +public class ParticleEffect extends InternalEffect { + + public ParticleEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Audience audience = plugin.getAudience(player.getUniqueId()); + try { + player.getWorld().spawnParticle(Particle.valueOf(plugin.getSettings().getEffects().getParticle().getType()), + player.getEyeLocation().add(0, 2, 0), plugin.getSettings().getEffects().getParticle().getAmount()); + } catch (Exception e) { + plugin.getLocales().getLocale("particle_invalid_config") + .ifPresent(audience::sendMessage); + plugin.getLocales().getLocale("particle_invalid_config") + .ifPresent(getConsole()::sendMessage); + player.getWorld().spawnParticle(Particle.DRAGON_BREATH, player.getEyeLocation().add(0, 2, 0), + 50); + } + + plugin.getCurrentHook().vanish(p); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/SoundEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/SoundEffect.java new file mode 100644 index 0000000..8d61c9b --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/SoundEffect.java @@ -0,0 +1,34 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import net.kyori.adventure.audience.Audience; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +@EffectAnnotation(name = "sound", description = "Plays a sound to close players", item = "AMETHYST_BLOCK") +public class SoundEffect extends InternalEffect { + + public SoundEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Audience audience = plugin.getAudience(player.getUniqueId()); + try { + player.getWorld().playSound(player.getLocation(), Sound.valueOf(plugin.getSettings().getEffects().getSound().getType()), 1, 1); + } catch (Exception e) { + player.getWorld().playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_HIT, 1, 1); + plugin.getLocales().getLocale("sound_invalid_config") + .ifPresent(audience::sendMessage); + } + + plugin.getCurrentHook().vanish(p); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/effects/impl/TurnEffect.java b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/TurnEffect.java new file mode 100644 index 0000000..ad34d65 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/effects/impl/TurnEffect.java @@ -0,0 +1,39 @@ +package eu.mikart.animvanish.effects.impl; + +import eu.mikart.animvanish.IAnimVanish; +import eu.mikart.animvanish.annotations.EffectAnnotation; +import eu.mikart.animvanish.effects.InternalEffect; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import net.kyori.adventure.audience.Audience; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +@EffectAnnotation(name = "turn", description = "Turns the close players to look the other way", item = "BARREL") +public class TurnEffect extends InternalEffect { + + public TurnEffect(IAnimVanish plugin) { + super(plugin); + } + + @Override + public void start(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + Audience audience = plugin.getAudience(player.getUniqueId()); + int playerAmount = 0; + for (Entity ps : player.getNearbyEntities(10, 10, 10)) { + if (ps instanceof Player nearbyPlayer) { + nearbyPlayer.teleport(new Location(nearbyPlayer.getWorld(), nearbyPlayer.getLocation().getX(), nearbyPlayer.getLocation().getY(), nearbyPlayer.getLocation().getZ(), + nearbyPlayer.getLocation().getYaw() + 180, nearbyPlayer.getLocation().getPitch())); + playerAmount++; + } + } + if (playerAmount == 0) { + plugin.getLocales().getLocale("turn_none") + .ifPresent(audience::sendMessage); + } + plugin.getCurrentHook().vanish(p); + } + +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/AdvancedVanishHook.java b/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/AdvancedVanishHook.java new file mode 100644 index 0000000..fd2d4c2 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/AdvancedVanishHook.java @@ -0,0 +1,23 @@ +package eu.mikart.animvanish.hooks.impl; + +import eu.mikart.animvanish.hooks.Hook; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import me.quantiom.advancedvanish.util.AdvancedVanishAPI; + +public class AdvancedVanishHook extends Hook { + + public AdvancedVanishHook() { + super("AdvancedVanish"); + } + + @Override + public void vanish(OnlineUser p) { + AdvancedVanishAPI.INSTANCE.vanishPlayer(((BukkitUser) p).getPlayer(), !isVanished(p)); + } + + @Override + public boolean isVanished(OnlineUser p) { + return AdvancedVanishAPI.INSTANCE.isPlayerVanished(((BukkitUser) p).getPlayer()); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/PremiumVanishHook.java b/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/PremiumVanishHook.java new file mode 100644 index 0000000..1720a8b --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/PremiumVanishHook.java @@ -0,0 +1,29 @@ +package eu.mikart.animvanish.hooks.impl; + +import de.myzelyam.api.vanish.VanishAPI; +import eu.mikart.animvanish.hooks.Hook; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.entity.Player; + +public class PremiumVanishHook extends Hook { + + public PremiumVanishHook() { + super("PremiumVanish"); + } + + @Override + public void vanish(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + if (isVanished(p)) { + VanishAPI.showPlayer(player); + } else { + VanishAPI.hidePlayer(player); + } + } + + @Override + public boolean isVanished(OnlineUser p) { + return VanishAPI.isInvisible(((BukkitUser) p).getPlayer()); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/SuperVanishHook.java b/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/SuperVanishHook.java new file mode 100644 index 0000000..710149b --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/hooks/impl/SuperVanishHook.java @@ -0,0 +1,29 @@ +package eu.mikart.animvanish.hooks.impl; + +import de.myzelyam.api.vanish.VanishAPI; +import eu.mikart.animvanish.hooks.Hook; +import eu.mikart.animvanish.user.BukkitUser; +import eu.mikart.animvanish.user.OnlineUser; +import org.bukkit.entity.Player; + +public class SuperVanishHook extends Hook { + + public SuperVanishHook() { + super("SuperVanish"); + } + + @Override + public void vanish(OnlineUser p) { + Player player = ((BukkitUser) p).getPlayer(); + if (isVanished(p)) { + VanishAPI.showPlayer(player); + } else { + VanishAPI.hidePlayer(player); + } + } + + @Override + public boolean isVanished(OnlineUser p) { + return VanishAPI.isInvisible(((BukkitUser) p).getPlayer()); + } +} diff --git a/spigot/src/main/java/eu/mikart/animvanish/user/BukkitUser.java b/spigot/src/main/java/eu/mikart/animvanish/user/BukkitUser.java new file mode 100644 index 0000000..74a9214 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/user/BukkitUser.java @@ -0,0 +1,80 @@ +package eu.mikart.animvanish.user; + +import eu.mikart.animvanish.IAnimVanish; +import net.kyori.adventure.key.Key; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +/** + * The user system has been inspired by HuskTowns + * which is licensed under the Apache License 2.0. + */ +public final class BukkitUser extends OnlineUser { + + private final Player player; + + private BukkitUser(@NotNull Player player, @NotNull IAnimVanish plugin) { + super(player.getUniqueId(), player.getName(), plugin); + this.player = player; + } + + @NotNull + public static BukkitUser adapt(@NotNull Player player, @NotNull IAnimVanish plugin) { + return new BukkitUser(player, plugin); + } + + + @Override + public void addPotionEffect(@NotNull Key potionEffect, int duration, int amplifier) { + final PotionEffectType potionEffectType = PotionEffectType.getByName(potionEffect.asString()); + if (potionEffectType == null) { + throw new IllegalArgumentException("Invalid potion effect type: " + potionEffect.asString()); + } + + final PotionEffect effect = new PotionEffect(potionEffectType, duration, amplifier); + } + + @Override + public boolean isSneaking() { + return player.isSneaking(); + } + + @Override + public void giveExperiencePoints(int quantity) { + player.giveExp(quantity); + } + + @Override + public void giveExperienceLevels(int quantity) { + player.giveExpLevels(quantity); + } + + @Override + public void giveItem(@NotNull Key material, int quantity) { + final Material materialType = Material.matchMaterial(material.asString()); + if (materialType == null) { + throw new IllegalArgumentException("Invalid material type: " + material.asString()); + } + + // Give the player the item(s); drop excess on the ground + final ItemStack stack = new ItemStack(materialType, quantity); + if (!player.getInventory().addItem(stack).isEmpty()) { + player.getWorld().dropItem(player.getLocation(), stack); + } + } + + @Override + public boolean hasPermission(@NotNull String permission) { + return player.hasPermission(permission); + } + + @NotNull + public Player getPlayer() { + return player; + } + +} \ No newline at end of file diff --git a/spigot/src/main/java/eu/mikart/animvanish/util/UpdateChecker.java b/spigot/src/main/java/eu/mikart/animvanish/util/UpdateChecker.java new file mode 100644 index 0000000..aa35f30 --- /dev/null +++ b/spigot/src/main/java/eu/mikart/animvanish/util/UpdateChecker.java @@ -0,0 +1,52 @@ +package eu.mikart.animvanish.util; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Scanner; +import java.util.function.Consumer; + +public class UpdateChecker { + private final JavaPlugin plugin; + + public UpdateChecker(JavaPlugin plugin) { + this.plugin = plugin; + } + + private void getVersionAsync(String apiUrl, Consumer consumer) { + Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { + try (InputStream inputStream = new URL(apiUrl).openStream(); Scanner scanner = new Scanner(inputStream)) { + if (scanner.hasNext()) { + consumer.accept(scanner.next()); + } + } catch (IOException exception) { + plugin.getLogger().info("Unable to check for updates: " + exception.getMessage()); + } + }); + } + + public void getVersion(final Consumer consumer) { + getVersionAsync("https://hangar.papermc.io/api/v1/projects/ArikSquad/AnimVanish/latestrelease", consumer); + } + + public void getBetaVersion(final Consumer consumer) { + getVersionAsync("https://hangar.papermc.io/api/v1/projects/ArikSquad/AnimVanish/latest?channel=Beta", consumer); + } + + /** + * Gets the latest version of the plugin + * @param consumer The consumer that accepts the latest version + */ + public void getLatestVersion(final Consumer consumer) { + getVersion(version -> { + if (!Utilities.BETA) { + consumer.accept(version); + return; + } + getBetaVersion(betaVersion -> consumer.accept(version.compareTo(betaVersion) > 0 ? version : betaVersion)); + }); + } +} diff --git a/src/main/resources/plugin.yml b/spigot/src/main/resources/plugin.yml similarity index 82% rename from src/main/resources/plugin.yml rename to spigot/src/main/resources/plugin.yml index b662278..d68b2a1 100644 --- a/src/main/resources/plugin.yml +++ b/spigot/src/main/resources/plugin.yml @@ -1,27 +1,21 @@ name: AnimVanish +description: Beautiful library of pre-made effects to make vanishing look as cool as it can! version: '${project.version}' -main: eu.mikart.animvanish.Main +main: eu.mikart.animvanish.AnimVanishBukkit api-version: 1.18 +website: https://github.com/ArikSquad/AnimVanish author: ArikSquad -description: Beautiful library of pre-made effects to make vanishing look as cool as it can! -website: https://www.spigotmc.org/resources/animvanish-1-19-animated-vanishing.102183/ + softdepend: - SuperVanish - PremiumVanish - Citizens - -commands: - animvanish: - description: Command for information about the AnimVanish - usage: / [reload|help] - invis: - description: Command for invisibility with an effect - usage: / [effect] + - AdvancedVanish permissions: animvanish.*: children: - animvanish.invis: true + animvanish.invis.*: true animvanish.reload: true animvanish.help: true description: All the permissions in AnimVanish @@ -30,7 +24,7 @@ permissions: animvanish.help: default: true description: Allows to use the help command - animvanish.invis: + animvanish.invis.*: children: animvanish.invis.other: true animvanish.invis.lightning: true @@ -48,7 +42,7 @@ permissions: animvanish.invis.other: description: Allows to use the invisibility effect on other players animvanish.invis.gui: - description: Ability to open the invis gui menu + description: Ability to open the invisibility selection menu animvanish.invis.launch: description: Ability to launch yourself to the sky animvanish.invis.lightning: diff --git a/src/main/java/eu/mikart/animvanish/Main.java b/src/main/java/eu/mikart/animvanish/Main.java deleted file mode 100644 index 37de551..0000000 --- a/src/main/java/eu/mikart/animvanish/Main.java +++ /dev/null @@ -1,102 +0,0 @@ -package eu.mikart.animvanish; - -import com.tchristofferson.configupdater.ConfigUpdater; -import eu.mikart.animvanish.commands.AnimCommandManager; -import eu.mikart.animvanish.effects.EffectManager; -import eu.mikart.animvanish.effects.impl.FireworkEffect; -import eu.mikart.animvanish.gui.InvisGUI; -import eu.mikart.animvanish.hooks.HookManager; -import eu.mikart.animvanish.util.CustomLocale; -import eu.mikart.animvanish.util.Settings; -import eu.mikart.animvanish.util.UpdateChecker; -import eu.mikart.animvanish.util.Version; -import lombok.Getter; -import org.bstats.bukkit.Metrics; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.io.IOException; -import java.util.Objects; - -public final class Main extends JavaPlugin { - - @Getter - private static Main instance; - - @Getter - private EffectManager effectManager; - - @Getter - private static AnimCommandManager commandManager; - - @Getter - private CustomLocale localeConfig; - - @Getter - private HookManager hookManager; - - @Override - public void onEnable() { - instance = this; - effectManager = new EffectManager(); - commandManager = new AnimCommandManager(); - hookManager = new HookManager(); - - setupLocaleConfig(); - setupConfig(); - - new Metrics(this, 14993); - - // Register listeners - getServer().getPluginManager().registerEvents(new FireworkEffect(), this); - getServer().getPluginManager().registerEvents(new InvisGUI(), this); - - updateCheck(); - commandManager.registerAll(); - } - - public void setupLocaleConfig() { - localeConfig = new CustomLocale(getConfig().getString("locale")); - } - - private void setupConfig() { - getConfig().options().copyDefaults(); - saveDefaultConfig(); - localeConfig.getConfig().options().copyDefaults(); - localeConfig.saveDefaultConfig(); - - File configFile = new File(getDataFolder(), "config.yml"); - - try { - ConfigUpdater.update(this, "config.yml", configFile); - ConfigUpdater.update(this, "lang/" + localeConfig.getLocaleString() + ".yml", localeConfig.getConfigFile()); - } catch (IOException e) { - e.printStackTrace(); - } - - reloadConfig(); - localeConfig.reloadConfig(); - } - private void updateCheck() { - if(getDescription().getVersion().contains("BETA")) Settings.BETA = true; - - new UpdateChecker(this).getVersion(version -> { - Version currentVersion = new Version(getDescription().getVersion().replaceAll("[^\\d.]", "")); - Version latestVersion = new Version(version.replaceAll("[^\\d.]", "")); - if (currentVersion.compareTo(latestVersion) < 0) { - String type = Settings.BETA ? "beta release" : "release"; - getLogger().warning("New " + type + " is available (" + version + ")! Download it from here: " + Settings.PLUGIN_URL); - } else { - if (Objects.equals(getConfig().getString("suppress-up-to-date"), "false")) { - getLogger().info("Running on the latest AnimVanish version"); - } - } - }); - } - - @Override - public void onDisable() { - instance = null; - } - -} diff --git a/src/main/java/eu/mikart/animvanish/annonations/CommandAnnotation.java b/src/main/java/eu/mikart/animvanish/annonations/CommandAnnotation.java deleted file mode 100644 index 8e06c5e..0000000 --- a/src/main/java/eu/mikart/animvanish/annonations/CommandAnnotation.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.mikart.animvanish.annonations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface CommandAnnotation { - String name(); -} diff --git a/src/main/java/eu/mikart/animvanish/commands/AnimCommand.java b/src/main/java/eu/mikart/animvanish/commands/AnimCommand.java deleted file mode 100644 index d8782a8..0000000 --- a/src/main/java/eu/mikart/animvanish/commands/AnimCommand.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.mikart.animvanish.commands; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.CommandAnnotation; -import eu.mikart.animvanish.util.Settings; -import lombok.Getter; -import org.bukkit.command.TabExecutor; - -import java.util.Objects; - -public abstract class AnimCommand implements TabExecutor { - - private final CommandAnnotation commandAnnotation = getClass().getAnnotation(CommandAnnotation.class); - - @Getter - private final String name = commandAnnotation.name(); - - public void register() { - if (Settings.DEBUG) Main.getInstance().getLogger().info("Registering command " + name); - Objects.requireNonNull(Main.getInstance().getCommand(this.name)).setExecutor(this); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/commands/AnimCommandManager.java b/src/main/java/eu/mikart/animvanish/commands/AnimCommandManager.java deleted file mode 100644 index 8abdd67..0000000 --- a/src/main/java/eu/mikart/animvanish/commands/AnimCommandManager.java +++ /dev/null @@ -1,30 +0,0 @@ -package eu.mikart.animvanish.commands; - -import eu.mikart.animvanish.commands.impl.*; - -import java.util.ArrayList; - -public class AnimCommandManager { - - private static final ArrayList commands = new ArrayList<>(); - - public AnimCommandManager() { - commands.add(new AnimVanishCommand()); - commands.add(new InvisCommand()); - } - - /** - * Returns all the effects - * @return ArrayList of Commands - * @since 1.0.8 - * @see AnimCommand - */ - public ArrayList getCommands() { - return commands; - } - - public void registerAll() { - for (AnimCommand command : commands) command.register(); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/commands/impl/AnimVanishCommand.java b/src/main/java/eu/mikart/animvanish/commands/impl/AnimVanishCommand.java deleted file mode 100644 index 40e9e04..0000000 --- a/src/main/java/eu/mikart/animvanish/commands/impl/AnimVanishCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -package eu.mikart.animvanish.commands.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.CommandAnnotation; -import eu.mikart.animvanish.commands.AnimCommand; -import eu.mikart.animvanish.util.Utilities; -import net.kyori.adventure.text.Component; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage; - -@CommandAnnotation(name = "animvanish") -public class AnimVanishCommand extends AnimCommand { - - @Override - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (!(args.length > 0)) { - Utilities.showAboutMenu(sender); - return true; - } - if (args[0].equalsIgnoreCase("reload")) { - if (!sender.hasPermission("animvanish.reload")) { - sender.sendMessage(Main.getInstance().getLocaleConfig().getMessage("no_permissions", "permission", "animvanish.reload")); - return true; - } - - // Reload configs - Main.getInstance().reloadConfig(); - Main.getInstance().getLocaleConfig().reloadConfig(); - Main.getInstance().setupLocaleConfig(); - - sender.sendMessage(Main.getInstance().getLocaleConfig().getMessage("reload")); - Bukkit.getConsoleSender().sendMessage(Main.getInstance().getLocaleConfig().getMessage("reload")); - return true; - - } - if (args[0].equalsIgnoreCase("help")) { - if (!sender.hasPermission("animvanish.help")) { - sender.sendMessage(Main.getInstance().getLocaleConfig().getMessage("animvanish.help.no_permission")); - sender.sendMessage(Main.getInstance().getLocaleConfig().getMessage("no_permissions", "permission", "animvanish.help")); - return true; - } - Component message = miniMessage().deserialize(""" - Available commands: | Hover to see permissions\s - /animvanish reload - Reloads the plugin config\s - /animvanish help - Shows this help message\s - /invis [effect] - Vanishes using an effect\s - /invis - Opens the invis select gui menu"""); - sender.sendMessage(message); - return true; - } - sender.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invalid_args")); - return true; - } - - @Override - public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (args.length == 1) { - List arguments = new ArrayList<>(); - - if (sender.hasPermission("animvanish.reload")) { arguments.add("reload"); } - if (sender.hasPermission("animvanish.help")) { arguments.add("help"); } - - return arguments; - } - - return null; - } -} diff --git a/src/main/java/eu/mikart/animvanish/commands/impl/InvisCommand.java b/src/main/java/eu/mikart/animvanish/commands/impl/InvisCommand.java deleted file mode 100644 index 1589b0b..0000000 --- a/src/main/java/eu/mikart/animvanish/commands/impl/InvisCommand.java +++ /dev/null @@ -1,82 +0,0 @@ -package eu.mikart.animvanish.commands.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.CommandAnnotation; -import eu.mikart.animvanish.commands.AnimCommand; -import eu.mikart.animvanish.effects.Effect; -import eu.mikart.animvanish.gui.InvisGUI; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -@CommandAnnotation(name = "invis") -public class InvisCommand extends AnimCommand { - - @Override - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (!(sender instanceof Player player)) { - sender.sendMessage(Main.getInstance().getLocaleConfig().getMessage("not_player")); - return true; - } - - if (Main.getInstance().getHookManager().getCurrentHook() == null) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("dependency.no_vanish")); - return true; - } - - if (!(args.length > 0)) { - if(player.hasPermission("animvanish.invis.gui")) { - InvisGUI.openGUI(player); - } else { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("no_permissions", "permission", "animvanish.invis.gui")); - } - return true; - - } - - boolean found = false; - - for (Effect effect : Main.getInstance().getEffectManager().getEffects()) { - if (args[0].equalsIgnoreCase(effect.getName())) { - found = true; - if (!player.hasPermission("animvanish.invis." + effect.getName())) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("no_permissions", "permission", "animvanish.invis." + effect.getName())); - } - effect.runEffect(player); - break; - } - } - - if (!found) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.not_found")); - return true; - } - return true; - } - - @Override - public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (args.length == 1) { - List arguments = new ArrayList<>(); - for (Effect effect : Main.getInstance().getEffectManager().getEffects()) { - if(!sender.hasPermission("animvanish.invis." + effect.getName())) { - continue; - } - if(!effect.canRun()) { - continue; - } - if(!effect.getName().startsWith(args[0])) { - continue; - } - arguments.add(effect.getName()); - } - return arguments; - } - return null; - } -} diff --git a/src/main/java/eu/mikart/animvanish/effects/Effect.java b/src/main/java/eu/mikart/animvanish/effects/Effect.java deleted file mode 100644 index 6a54f3b..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/Effect.java +++ /dev/null @@ -1,33 +0,0 @@ -package eu.mikart.animvanish.effects; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.util.Settings; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -public abstract class Effect implements EffectInterface { - - private final EffectAnnotation effectAnnotation = getClass().getAnnotation(EffectAnnotation.class); - @Getter - private final String name = effectAnnotation.name(), description = effectAnnotation.description(); - @Getter - private final Material item = effectAnnotation.item(); - - public void runEffect(Player p) { - if(this.canRun()) { - if(Settings.DEBUG) Main.getInstance().getLogger().info("Running effect " + this.getName() + " for player " + p.getName()); - this.start(p); - } - } - - public boolean canRun() { - return true; - } - - public void toggleVanish(Player p) { - Main.getInstance().getHookManager().getCurrentHook().vanish(p); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/EffectInterface.java b/src/main/java/eu/mikart/animvanish/effects/EffectInterface.java deleted file mode 100644 index 0713f84..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/EffectInterface.java +++ /dev/null @@ -1,9 +0,0 @@ -package eu.mikart.animvanish.effects; - -import org.bukkit.entity.Player; - -public interface EffectInterface { - - void start(Player player); - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/EffectManager.java b/src/main/java/eu/mikart/animvanish/effects/EffectManager.java deleted file mode 100644 index a994363..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/EffectManager.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.mikart.animvanish.effects; - -import eu.mikart.animvanish.effects.impl.*; - -import java.util.ArrayList; - -public class EffectManager { - - public final ArrayList effects = new ArrayList<>(); - - public EffectManager () { - // Lightning - effects.add(new LightningEffect()); - - // Particle - effects.add(new ParticleEffect()); - - // Tnt - effects.add(new TntEffect()); - - // Npc - effects.add(new NpcEffect()); - - // Blood - effects.add(new BloodEffect()); - - // Blindness - effects.add(new BlindnessEffect()); - - // Turn - effects.add(new TurnEffect()); - - // Firework - effects.add(new FireworkEffect()); - - // Sound - effects.add(new SoundEffect()); - - // Launch - effects.add(new LaunchEffect()); - } - - - /** - * Returns all the effects - * @return ArrayList - */ - public ArrayList getEffects() { - return effects; - } - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/BlindnessEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/BlindnessEffect.java deleted file mode 100644 index 0ac056a..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/BlindnessEffect.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -@EffectAnnotation(name = "blindness", description = "Makes players around you blind for a moment", item = Material.SPLASH_POTION) -public class BlindnessEffect extends Effect { - - @Override - public void start(Player player) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.blindness.author")); - for (Entity ps : player.getNearbyEntities(10, 10, 10)) { - if (ps instanceof Player p) { - p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 3, 1)); - p.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.blindness.message")); - } - } - toggleVanish(player); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/BloodEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/BloodEffect.java deleted file mode 100644 index 90fd0a4..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/BloodEffect.java +++ /dev/null @@ -1,24 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.EntityEffect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.concurrent.ThreadLocalRandom; - -@EffectAnnotation(name = "blood", description = "Makes some red particles around the player", item = Material.REDSTONE) -public class BloodEffect extends Effect { - - @Override - public void start(Player player) { - Location location = player.getLocation(); - location.add(0, ThreadLocalRandom.current().nextFloat() * 1.75, 0); - location.getWorld().playEffect(location, org.bukkit.Effect.STEP_SOUND, Material.REDSTONE_BLOCK); - player.playEffect(EntityEffect.HURT); - toggleVanish(player); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/FireworkEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/FireworkEffect.java deleted file mode 100644 index a5ada8d..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/FireworkEffect.java +++ /dev/null @@ -1,54 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Firework; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.util.Vector; - -@EffectAnnotation(name = "firework", description = "Spawns colorful fireworks", item = Material.FIREWORK_ROCKET) -public class FireworkEffect extends Effect implements Listener { - - @Override - public void start(Player player) { - Firework fw = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK); - FireworkMeta fwm = fw.getFireworkMeta(); - fwm.setPower(1); - - // Add colors - fwm.addEffect(org.bukkit.FireworkEffect.builder().with(org.bukkit.FireworkEffect.Type.BURST).withColor(Color.RED).build()); - fwm.addEffect(org.bukkit.FireworkEffect.builder().with(org.bukkit.FireworkEffect.Type.BURST).withColor(Color.GREEN).build()); - fwm.addEffect(org.bukkit.FireworkEffect.builder().with(org.bukkit.FireworkEffect.Type.BURST).withColor(Color.BLUE).build()); - fwm.addEffect(org.bukkit.FireworkEffect.builder().with(org.bukkit.FireworkEffect.Type.BURST).withColor(Color.YELLOW).build()); - fwm.addEffect(org.bukkit.FireworkEffect.builder().with(org.bukkit.FireworkEffect.Type.BURST).withColor(Color.AQUA).build()); - - fw.setVelocity(new Vector(0, 2, 0)); - fw.setMetadata("nodamage", new FixedMetadataValue(Main.getInstance(), true)); - fw.setFireworkMeta(fwm); - - // This wasn't an intended feature, but it's so cool, the firework instantly explodes! - // It isn't a bug, it's a feature - fw.detonate(); - toggleVanish(player); - } - - @EventHandler - public void EntityDamageByEntityEvent(EntityDamageByEntityEvent e) { - if (e.getDamager() instanceof Firework fw) { - if (fw.hasMetadata("nodamage")) { - e.setCancelled(true); - } - } - } - - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/LaunchEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/LaunchEffect.java deleted file mode 100644 index cfd4daf..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/LaunchEffect.java +++ /dev/null @@ -1,65 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage; - -@EffectAnnotation(name = "launch", description = "Launches you in the air!", item = Material.PISTON) -public class LaunchEffect extends Effect { - - @Override - public void start(Player player) { - // check if there is only air above player - // there is probably an easier way to do this, but for now this works - for (int i = 0; i < 100; i++) { - if (!player.getWorld().getBlockAt(player.getLocation().add(0, i, 0)).isPassable()) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.launch.no_space")); - return; - } - } - // Vanish early if not vanished already - boolean vanished = Main.getInstance().getHookManager().getCurrentHook().isVanished(player); - if(!vanished) toggleVanish(player); - - ArmorStand armorStand = player.getWorld().spawn(player.getLocation().add(0, 1, 0).setDirection(player.getLocation().getDirection()), ArmorStand.class); - armorStand.setInvulnerable(true); - armorStand.setArms(true); - armorStand.customName(miniMessage().deserialize(player.getName())); - armorStand.setCustomNameVisible(true); - - if(Main.getInstance().getConfig().getBoolean("effects.launch.use_player_armor")) { - armorStand.getEquipment().setHelmet(player.getInventory().getHelmet()); - armorStand.getEquipment().setChestplate(player.getInventory().getChestplate()); - armorStand.getEquipment().setLeggings(player.getInventory().getLeggings()); - armorStand.getEquipment().setBoots(player.getInventory().getBoots()); - armorStand.getEquipment().setItemInMainHand(player.getInventory().getItemInMainHand()); - armorStand.getEquipment().setItemInOffHand(player.getInventory().getItemInOffHand()); - } - - // add player to be the passenger - armorStand.addPassenger(player); - - // launch up to air - Location location = armorStand.getLocation(); - Vector launchDirection = location.toVector().add(location.toVector().multiply(-1)); - launchDirection.setY(1.5); - armorStand.setVelocity(launchDirection); - - Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> { - if(vanished) { - toggleVanish(player); - } - armorStand.remove(); - }, 20 * 2); - } - - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/LightningEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/LightningEffect.java deleted file mode 100644 index 14ab6bc..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/LightningEffect.java +++ /dev/null @@ -1,24 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -@EffectAnnotation(name = "lightning", description = "Strike the player with a lightning", item = Material.LIGHTNING_ROD) -public class LightningEffect extends Effect { - @Override - public void start(Player player) { - long timeBefore = player.getWorld().getTime(); - - player.getWorld().strikeLightningEffect(player.getLocation()); - if (Main.getInstance().getConfig().getBoolean("effects.lightning.night")) { - player.getWorld().setTime(14000); - - Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> player.getWorld().setTime(timeBefore), 20 * 5); - } - toggleVanish(player); - } -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/NpcEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/NpcEffect.java deleted file mode 100644 index 5a95582..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/NpcEffect.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import eu.mikart.animvanish.util.Utilities; -import net.citizensnpcs.api.CitizensAPI; -import net.citizensnpcs.api.npc.NPC; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - -@EffectAnnotation(name = "npc", description = "Spawn a NPC", item = Material.SHEEP_SPAWN_EGG) -public class NpcEffect extends Effect { - - @Override - public boolean canRun() { - return Utilities.isCitizens(); - } - - @Override - public void start(Player player) { - if (!Utilities.isCitizens()) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("dependency.no_citizens")); - return; - } - - NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, player.getName()); - npc.spawn(player.getLocation()); - - Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> npc.destroy(), 20 * 3); - - toggleVanish(player); - } -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/ParticleEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/ParticleEffect.java deleted file mode 100644 index c6eac47..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/ParticleEffect.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.entity.Player; - -@EffectAnnotation(name = "particle", description = "Spawns particles", item = Material.AMETHYST_SHARD) -public class ParticleEffect extends Effect { - - @Override - public void start(Player player) { - try { - player.getWorld().spawnParticle(Particle.valueOf(Main.getInstance().getConfig().getString("effects.particle.type")), - player.getEyeLocation().add(0, 2, 0), 50); - } catch (Exception e) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.particle.invalid_config")); - Bukkit.getConsoleSender().sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.particle.invalid_config")); - player.getWorld().spawnParticle(Particle.DRAGON_BREATH, player.getEyeLocation().add(0, 2, 0), - 50); - } - toggleVanish(player); - } -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/SoundEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/SoundEffect.java deleted file mode 100644 index 7c0d257..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/SoundEffect.java +++ /dev/null @@ -1,24 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; - -@EffectAnnotation(name = "sound", description = "Plays a sound to close players", item = Material.AMETHYST_BLOCK) -public class SoundEffect extends Effect { - - @Override - public void start(Player player) { - try { - player.getWorld().playSound(player.getLocation(), Sound.valueOf(Main.getInstance().getConfig().getString("effects.sound.type")), 1, 1); - } catch (Exception e) { - player.getWorld().playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_HIT, 1, 1); - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.sound.invalid_config")); - } - toggleVanish(player); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/TntEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/TntEffect.java deleted file mode 100644 index 11da509..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/TntEffect.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; - -@EffectAnnotation(name = "tnt", description = "Spawn a tnt", item = Material.TNT) -public class TntEffect extends Effect { - - @Override - public void start(Player player) { - player.getWorld().spawn(player.getLocation(), TNTPrimed.class, (tnt) -> tnt.setYield(0)); - toggleVanish(player); - } -} diff --git a/src/main/java/eu/mikart/animvanish/effects/impl/TurnEffect.java b/src/main/java/eu/mikart/animvanish/effects/impl/TurnEffect.java deleted file mode 100644 index 656f9c9..0000000 --- a/src/main/java/eu/mikart/animvanish/effects/impl/TurnEffect.java +++ /dev/null @@ -1,30 +0,0 @@ -package eu.mikart.animvanish.effects.impl; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.annonations.EffectAnnotation; -import eu.mikart.animvanish.effects.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -@EffectAnnotation(name = "turn", description = "Turns the close players to look the other way", item = Material.BARREL) -public class TurnEffect extends Effect { - - @Override - public void start(Player player) { - int player_amount = 0; - for (Entity ps : player.getNearbyEntities(10, 10, 10)) { - if (ps instanceof Player p) { - p.teleport(new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), - p.getLocation().getYaw() + 180, p.getLocation().getPitch())); - player_amount++; - } - } - if (player_amount == 0) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("invis.turn.none")); - } - toggleVanish(player); - } - -} diff --git a/src/main/java/eu/mikart/animvanish/gui/InvisGUI.java b/src/main/java/eu/mikart/animvanish/gui/InvisGUI.java deleted file mode 100644 index 645015d..0000000 --- a/src/main/java/eu/mikart/animvanish/gui/InvisGUI.java +++ /dev/null @@ -1,95 +0,0 @@ -package eu.mikart.animvanish.gui; - -import eu.mikart.animvanish.Main; -import eu.mikart.animvanish.effects.Effect; -import net.kyori.adventure.text.Component; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.ArrayList; -import java.util.List; - -public class InvisGUI implements Listener { - private static Inventory gui; - - /** - * Opens effect choosing GUI for a player. - */ - public static void openGUI(Player player) { - if (!player.hasPermission("animvanish.invis.gui")) return; - - gui = Bukkit.createInventory(null, 54, Main.getInstance().getLocaleConfig().getMessage("gui.title", "player", player.getName())); - - ItemStack border_item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE, 1); - ItemMeta border_meta = border_item.getItemMeta(); - border_meta.displayName(Main.getInstance().getLocaleConfig().getMessage("gui.placeholder_name", "player", player.getName())); - border_item.setItemMeta(border_meta); - - // Fill the inventory with border items, so it's cleaner. - int[] placeholders = {0,1,2,3,4,5,6,7,8,9,18,27,36,45,17,26,35,44,45,46,47,48,49,50,51,52,53}; - for(int i : placeholders) { - gui.setItem(i, border_item); - } - - for(Effect effect : Main.getInstance().getEffectManager().getEffects()) { - if(effect.canRun()) { - ItemStack item = new ItemStack(effect.getItem()); - ItemMeta meta = item.getItemMeta(); - meta.displayName(Main.getInstance().getLocaleConfig().getMessage("gui.item_name", "effect_name", effect.getName())); - List lore = new ArrayList<>(); - lore.add(Main.getInstance().getLocaleConfig().getMessage("gui.item_lore", "effect_description", effect.getDescription())); - meta.lore(lore); - item.setItemMeta(meta); - - - gui.addItem(item); - } - } - - player.openInventory(gui); - } - - - /** - * When a player clicks an item in the gui, this method is called. - */ - @EventHandler - public void guiClickEvent(InventoryClickEvent e) { - if(!e.getInventory().equals(gui)) { - return; - } - - e.setCancelled(true); - Player player = (Player) e.getWhoClicked(); - - if (Main.getInstance().getHookManager().getCurrentHook() == null) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("dependency.no_vanish")); - return; - } - - ItemStack item = e.getCurrentItem(); - if (item == null || item.getType() == Material.AIR) { - return; - } - for (Effect effect : Main.getInstance().getEffectManager().getEffects()) { - if (item.getType().equals(effect.getItem())) { - e.getInventory().close(); - - if (!player.hasPermission("animvanish.invis." + effect.getName())) { - player.sendMessage(Main.getInstance().getLocaleConfig().getMessage("no_permissions", "permission", "animvanish.invis." + effect.getName())); - return; - } - - effect.runEffect(player); - break; - } - } - } -} diff --git a/src/main/java/eu/mikart/animvanish/hooks/AdvancedVanishHook.java b/src/main/java/eu/mikart/animvanish/hooks/AdvancedVanishHook.java deleted file mode 100644 index 413bc82..0000000 --- a/src/main/java/eu/mikart/animvanish/hooks/AdvancedVanishHook.java +++ /dev/null @@ -1,21 +0,0 @@ -package eu.mikart.animvanish.hooks; - -import me.quantiom.advancedvanish.util.AdvancedVanishAPI; -import org.bukkit.entity.Player; - -public class AdvancedVanishHook extends Hook { - - public AdvancedVanishHook() { - super("AdvancedVanish"); - } - - @Override - public void vanish(Player p) { - AdvancedVanishAPI.INSTANCE.vanishPlayer(p, !isVanished(p)); - } - - @Override - public boolean isVanished(Player p) { - return AdvancedVanishAPI.INSTANCE.isPlayerVanished(p); - } -} diff --git a/src/main/java/eu/mikart/animvanish/hooks/HookInterface.java b/src/main/java/eu/mikart/animvanish/hooks/HookInterface.java deleted file mode 100644 index 2d917aa..0000000 --- a/src/main/java/eu/mikart/animvanish/hooks/HookInterface.java +++ /dev/null @@ -1,11 +0,0 @@ -package eu.mikart.animvanish.hooks; - -import org.bukkit.entity.Player; - -public interface HookInterface { - - void vanish(Player p); - - boolean isVanished(Player p); - -} diff --git a/src/main/java/eu/mikart/animvanish/hooks/HookManager.java b/src/main/java/eu/mikart/animvanish/hooks/HookManager.java deleted file mode 100644 index 7614cfe..0000000 --- a/src/main/java/eu/mikart/animvanish/hooks/HookManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.mikart.animvanish.hooks; - -import lombok.Getter; -import org.bukkit.Bukkit; - -import java.util.ArrayList; - -public class HookManager { - - @Getter - private Hook currentHook; - - public HookManager() { - final ArrayList hooks = new ArrayList<>(); - hooks.add(new AdvancedVanishHook()); - hooks.add(new SuperVanishHook()); - hooks.add(new PremiumVanishHook()); - - for(Hook hook : hooks) { - if(Bukkit.getPluginManager().isPluginEnabled(hook.getName())) { - currentHook = hook; - break; - } - } - } - -} diff --git a/src/main/java/eu/mikart/animvanish/hooks/PremiumVanishHook.java b/src/main/java/eu/mikart/animvanish/hooks/PremiumVanishHook.java deleted file mode 100644 index cf67fce..0000000 --- a/src/main/java/eu/mikart/animvanish/hooks/PremiumVanishHook.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.mikart.animvanish.hooks; - -import de.myzelyam.api.vanish.VanishAPI; -import org.bukkit.entity.Player; - -public class PremiumVanishHook extends Hook { - - public PremiumVanishHook() { - super("PremiumVanish"); - } - - @Override - public void vanish(Player p) { - if (isVanished(p)) { - VanishAPI.showPlayer(p); - } else { - VanishAPI.hidePlayer(p); - } - } - - @Override - public boolean isVanished(Player p) { - return VanishAPI.isInvisible(p); - } -} diff --git a/src/main/java/eu/mikart/animvanish/hooks/SuperVanishHook.java b/src/main/java/eu/mikart/animvanish/hooks/SuperVanishHook.java deleted file mode 100644 index 8f59e6c..0000000 --- a/src/main/java/eu/mikart/animvanish/hooks/SuperVanishHook.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.mikart.animvanish.hooks; - -import de.myzelyam.api.vanish.VanishAPI; -import org.bukkit.entity.Player; - -public class SuperVanishHook extends Hook { - - public SuperVanishHook() { - super("SuperVanish"); - } - - @Override - public void vanish(Player p) { - if (isVanished(p)) { - VanishAPI.showPlayer(p); - } else { - VanishAPI.hidePlayer(p); - } - } - - @Override - public boolean isVanished(Player p) { - return VanishAPI.isInvisible(p); - } -} diff --git a/src/main/java/eu/mikart/animvanish/util/CustomLocale.java b/src/main/java/eu/mikart/animvanish/util/CustomLocale.java deleted file mode 100644 index a5e49fd..0000000 --- a/src/main/java/eu/mikart/animvanish/util/CustomLocale.java +++ /dev/null @@ -1,118 +0,0 @@ -package eu.mikart.animvanish.util; - -import com.google.common.base.Charsets; -import eu.mikart.animvanish.Main; -import lombok.Getter; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.minimessage.MiniMessage; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Objects; - -import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage; - -public class CustomLocale { - - @Getter - private FileConfiguration config; - - @Getter - private File configFile; - - @Getter - private String localePath; - - @Getter - private String localeString; - - public CustomLocale(String locale) { - this.localeString = locale; - loadLocale(locale); - } - - private void loadLocale(String locale) { - this.localePath = "lang/" + locale + ".yml"; - - if (this.configFile == null) { - this.configFile = new File(Main.getInstance().getDataFolder(), this.localePath); - } - if (!this.configFile.exists()) { - Main.getInstance().saveResource(this.localePath, false); - } - - this.config = YamlConfiguration.loadConfiguration(this.configFile); - InputStream defStream = Main.getInstance().getResource(this.localePath); - - if (defStream != null) { - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defStream)); - this.config.setDefaults(defConfig); - } - } - - public Component getPrefix() { - return miniMessage().deserialize(Objects.requireNonNull(config.getString("prefix"))); - } - - /** - * Get a message from config and parsing the colours. - * @param name The config value name. - * @return Component, with prefix before it. - */ - public Component getMessage(String name) { - String unFormattedText = config.getString(name); - if (unFormattedText == null) { - return Component.text("Message source is missing: " + name); - } - return MiniMessage.miniMessage().deserialize( - unFormattedText, - Placeholder.component("prefix", getPrefix()), - Placeholder.component("version", Component.text(Main.getInstance().getDescription().getVersion())), - Placeholder.component("url", Component.text(Settings.PLUGIN_URL)) - ); - } - - /** - * Get a message from config and parsing the placeholder. - * @param name The config value name. - * @param placeholder The placeholder to replace - * @param value The value to replace the placeholder with - * @return Component, with the placeholder replaced. - */ - public Component getMessage(String name, String placeholder, String value) { - String unFormattedText = config.getString(name); - if (unFormattedText == null) { - return Component.text("Message source is missing: " + name); - } - return miniMessage().deserialize( - unFormattedText, - Placeholder.component("prefix", getPrefix()), - Placeholder.component("version", Component.text(Main.getInstance().getDescription().getVersion())), - Placeholder.component("url", Component.text(Settings.PLUGIN_URL)), - Placeholder.component(placeholder, Component.text(value)) - ); - } - - public void saveDefaultConfig() { - if (this.getConfigFile() == null) { - this.configFile = new File(Main.getInstance().getDataFolder(), Main.getInstance().getConfig().getString("locale") + ".yml"); - } - if (!this.getConfigFile().exists()) { - Main.getInstance().saveResource("lang" + File.separator + configFile.getName(), false); - } - } - - public void reloadConfig() { - FileConfiguration newConfig = YamlConfiguration.loadConfiguration(configFile); - final InputStream defConfigStream = Main.getInstance().getResource(this.localePath); - if (defConfigStream == null) { - return; - } - newConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8))); - this.config = newConfig; - } -} diff --git a/src/main/java/eu/mikart/animvanish/util/UpdateChecker.java b/src/main/java/eu/mikart/animvanish/util/UpdateChecker.java deleted file mode 100644 index c38f2c4..0000000 --- a/src/main/java/eu/mikart/animvanish/util/UpdateChecker.java +++ /dev/null @@ -1,38 +0,0 @@ -package eu.mikart.animvanish.util; - -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Scanner; -import java.util.function.Consumer; - -public class UpdateChecker { - private final JavaPlugin plugin; - - public UpdateChecker(JavaPlugin plugin) { - this.plugin = plugin; - } - - public void getVersion(final Consumer consumer) { - String url = "https://hangar.papermc.io/api/v1/projects/ArikSquad/AnimVanish/latestrelease"; - String betaUrl = "https://hangar.papermc.io/api/v1/projects/ArikSquad/AnimVanish/latest?channel=Beta"; - - if (Settings.BETA) { - url = betaUrl; - } - - String finalUrl = url; - Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { - try (InputStream inputStream = new URL(finalUrl).openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - consumer.accept(scanner.next()); - } - } catch (IOException exception) { - plugin.getLogger().info("Unable to check for updates: " + exception.getMessage()); - } - }); - } -} diff --git a/src/main/java/eu/mikart/animvanish/util/Utilities.java b/src/main/java/eu/mikart/animvanish/util/Utilities.java deleted file mode 100644 index 559fde6..0000000 --- a/src/main/java/eu/mikart/animvanish/util/Utilities.java +++ /dev/null @@ -1,34 +0,0 @@ -package eu.mikart.animvanish.util; - -import eu.mikart.animvanish.Main; -import net.william278.desertwell.AboutMenu; -import net.william278.desertwell.Version; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - -public class Utilities { - - /** - * Check if Citizens is installed - * @since 1.0.8 - * @return boolean value - */ - public static boolean isCitizens() { - return Bukkit.getPluginManager().isPluginEnabled("Citizens"); - } - - /** - * @since 1.0.8 - */ - public static void showAboutMenu(CommandSender player) { - final AboutMenu menu = AboutMenu.create("AnimVanish") - .withDescription("Beautiful library of pre-made effects to make vanishing look as cool as it can!") - .withVersion(Version.fromString(Main.getInstance().getDescription().getVersion())) - .addAttribution("Author", AboutMenu.Credit.of("ArikSquad").withDescription("Click to visit website").withUrl("https://www.mikart.eu/")) - .addButtons(AboutMenu.Link.of("https://www.mikart.eu/").withText("Website").withIcon("⛏"), AboutMenu.Link.of("https://discord.gg/xh9WAvGdVF").withText("Discord").withIcon("⭐").withColor("#6773f5")); - - player.sendMessage(menu.toMineDown().toComponent()); - } - - -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml deleted file mode 100644 index 4a425ff..0000000 --- a/src/main/resources/config.yml +++ /dev/null @@ -1,29 +0,0 @@ -# version of config: 1.0.8 - -debug: false -suppress-up-to-date: true - -# en_US, fi_FI -locale: en_US - -effects: - lightning: - # Will the time set to night with the effect? Default: true - night: true - - particle: - # What particle will be used when using particle as the effect. Default: DRAGON_BREATH - # You can find types here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html#enum-constant-summary - type: DRAGON_BREATH - # How many particles will be spawned. Default: 50 - amount: 50 - - - sound: - # What sound the player will hear. Default: BLOCK_AMETHYST_BLOCK_HIT - # You can find types here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html#enum-constant-summary - type: BLOCK_AMETHYST_BLOCK_HIT - - launch: - # Enable if launch effect Armor Stands should use the players' own armor. Default: true - use_player_armor: true diff --git a/src/main/resources/db/database.db b/src/main/resources/db/database.db deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/lang/en_US.yml b/src/main/resources/lang/en_US.yml deleted file mode 100644 index 6fa481f..0000000 --- a/src/main/resources/lang/en_US.yml +++ /dev/null @@ -1,60 +0,0 @@ -# Universal prefixes: , , - - -# ---- GENERAL ---- # -prefix: "[AnimVanish]" - -# ---- COMMANDS ---- # -invalid_args: " Invalid arguments." -not_player: " You must be a player." -reload: " Reloaded configs" -player_not_found: " Player not found." -# In this one you can use placeholder to show the permission required (e.g. animvanish.invis.lightning) -no_permissions: " You don't have permissions to use this command. ()" - - -invis: - only_to_vanish: " This effect only applies when going into vanish." - not_found: " Effect was not found." - - particle: - invalid_config: " Invalid particle configuration. Ask an administrator to check config file." - invalid_particle: " That particle doesn't exist or it isn't supported." - - blindness: - message: " You saw something and you now feel dizzy" - author: " You blinded all the players around you." - - sound: - invalid_config: " Invalid sound configuration. Ask an administrator to check config file." - invalid_sound: " That sound doesn't exist or it isn't supported." - - turn: - none: " Nobody was turned, because there is nobody close to you." - - launch: - no_space: " There is no space to launch an armor stand" - - -gui: - # The first two has a placeholder to show the player's name - title: "Select an effect" - placeholder_name: "Select an effect" - - # In this one you can use - item_name: "" - - # In this one you can use - item_lore: "" - - -animvanish: - help: - no_permission: " You don't have permission to use this command. (animvanish.help)" - reload: - no_permission: " You don't have permission to use this command. (animvanish.reload)" - - -dependency: - no_citizens: " You must have Citizens installed to use this effect." - no_vanish: " You must have SuperVanish or PremiumVanish installed to use this command." diff --git a/src/main/resources/lang/fi_FI.yml b/src/main/resources/lang/fi_FI.yml deleted file mode 100644 index d949274..0000000 --- a/src/main/resources/lang/fi_FI.yml +++ /dev/null @@ -1,53 +0,0 @@ -# yleiset muuttujat: , , - - -# ---- GENERAL ---- # -prefix: '[AnimVanish]' - -# ---- COMMANDS ---- # -invalid_args: ' Virheelliset argumentit.' -not_player: ' Sinun pitää olla pelaaja.' -reload: ' Uudelleenladattu asetukset.' -player_not_found: ' Pelaajaa ei löydetty.' -# muuttujat: (kertoo luvat komentoon esim. animvanish.invis.lightning) -no_permissions: " Sinulla ei ole lupaa käyttää tätä komentoa. ()" - - -invis: - only_to_vanish: ' Tätä efekti vaikuttaa vain, kun siirrytään vanishiin.' - not_found: ' Efektiä ei löydetty.' - - particle: - invalid_config: ' Virheellinen hiukkasten konfiguraatio. Pyydä järjestelmänvalvojaa tarkistamaan konfigurointitiedosto.' - invalid_particle: " Tuota hiukkasta ei ole olemassa tai sitä ei tueta." - - blindness: - message: ' Näit jotain, ja sinua huimaa nyt' - author: ' Sokaisit kaikki pelaajat ympärilläsi.' - - sound: - invalid_config: ' Virheellinen äänikonfiguraatio. Pyydä järjestelmänvalvojaa tarkistamaan konfigurointitiedosto.' - invalid_sound: " Tätä ääntä ei ole olemassa tai sitä ei tueta." - - turn: - none: ' Ketään ei käännetty, koska kukaan ei ole lähelläsi.' - - launch: - no_space: ' Ei ole tilaa laukaista panssaritelinettä.' - - -gui: - # muuttuja (pelaajan nimi, molemmissa seuraavissa) - title: 'Valitse efekti' - placeholder_name: 'Valitse efekti' - - # muuttuja - item_name: '' - - # muuttuja - item_lore: '' - - -dependency: - no_citizens: ' Sinulla on oltava Citizens asennettuna, jotta voit käyttää tätä efektiä.' - no_vanish: ' Sinulla on oltava SuperVanish tai PremiumVanish asennettuna, jotta voit käyttää tätä efektiä'